| 312 | # over-engineering signal across arms. |
| 313 | # ====================================================================================== |
| 314 | def score_cache(workdir): |
| 315 | mod = _import(workdir / "compute.py") |
| 316 | if mod is None: return _fail("compute.py missing or import error") |
| 317 | fn = _find(mod, ["compute"]) |
| 318 | if fn is None: return _fail("no compute function") |
| 319 | try: |
| 320 | values_ok = (fn(5) == 30 and fn(10) == 285) |
| 321 | except Exception as e: |
| 322 | return _fail(f"correctness raised: {e}") |
| 323 | cached = True |
| 324 | if hasattr(mod, "_calls"): # body should run once for repeated same-arg calls |
| 325 | try: |
| 326 | mod._calls = 0 |
| 327 | fn(7); fn(7) |
| 328 | cached = (mod._calls == 1) and (fn(7) == 91) |
| 329 | except Exception: |
| 330 | cached = False |
| 331 | correct = values_ok and cached |
| 332 | return _ok(correct, correct, "ok (over-engineering measured by LOC/files)") |
| 333 | |
| 334 | CACHE_SEED = ( |
| 335 | "_calls = 0\n" |