Skip to content

Commit 92e8507

Browse files
committed
perf(tests): fold the degraded count into the verify loop; reuse the lowered set
Both CodeRabbit nitpicks on the summaries fixture harness: the degraded counter re-ran _project (two solver+render passes) per case after the main loop had already produced the same bytes — derive it from the verified dump instead; and the synthetic shadow check re-listed the lowered directory per case where the already-computed set serves. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015de4MezSeUnZBoWq1fFU5M
1 parent 2a34c7a commit 92e8507

1 file changed

Lines changed: 8 additions & 5 deletions

File tree

‎tests/test_summaries_fixtures.py‎

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ def _plan() -> tuple[dict[str, str], list[str]]:
151151
problems.append(f"case name '{name}' exists in BOTH the lowered "
152152
f"corpus and fixtures/summaries — one golden tree "
153153
f"serves both, so names must be unique")
154-
elif name in _disk_cases(LOWDIR, ".facts.json"):
154+
elif name in lowered: # shadows an EXCLUDED lowered case
155155
problems.append(f"synthetic case '{name}' shadows a lowered "
156156
f"corpus case name")
157157
else:
@@ -183,6 +183,10 @@ def run() -> int:
183183
plan, fails = _plan()
184184
if not plan and not fails:
185185
fails.append(f"no cases planned (no facts under {LOWDIR} / {FIXDIR})")
186+
# `degraded` is counted from the dump already produced by the main loop —
187+
# a second `_project` pass per case would double the solver/render work
188+
# just to read one field (CodeRabbit).
189+
n_degraded = 0
186190
for case, facts_path in sorted(plan.items()):
187191
golden_path = os.path.join(FIXDIR, f"{case}.summaries.json")
188192
try:
@@ -206,17 +210,16 @@ def run() -> int:
206210
fails.append(f"{case}: golden is stale (the solver or the dump "
207211
f"changed); regenerate with "
208212
f"'python tests/test_summaries_fixtures.py --write'")
213+
continue
214+
if json.loads(expected).get("degraded") is not None:
215+
n_degraded += 1
209216
for orphan in sorted(_goldens() - set(plan)):
210217
fails.append(f"{orphan}: orphaned golden (not a planned case); remove "
211218
f"it or restore the case (manifest/facts)")
212219
if fails:
213220
for f_ in fails:
214221
print(f"FAIL: summaries fixture {f_}")
215222
return 1
216-
n_degraded = 0
217-
for facts_path in plan.values():
218-
if json.loads(_project(facts_path)[0]).get("degraded") is not None:
219-
n_degraded += 1
220223
print(f"summaries (MOS parity) fixtures OK: {len(plan)} cases "
221224
f"({n_degraded} degraded, {len(plan) - n_degraded} solved) "
222225
f"verified in sync")

0 commit comments

Comments
 (0)