Skip to content

A too-deep example is a verdict or a one-line refusal, not a RecursionError - #17

Open
Birfy wants to merge 5 commits into
mainfrom
fix/deep-example-values
Open

Birfy wants to merge 5 commits into
mainfrom
fix/deep-example-values

Conversation

@Birfy

@Birfy Birfy commented Nov 4, 2026 •

Copy link
Copy Markdown
Owner

Fixes #16.

The defect

A case whose expected value nests a few hundred dicts deep did not get a verdict: jitagent verify <case-dir> printed a ~3,000-line RecursionError traceback and exited 1. The comparison that decides VERIFIED from REJECTED is types.deep_equal, plain recursion at two frames per dict level — measured on CPython 3.12 (recursionlimit 1000): 499 levels compares, 500 raises. The same unguarded call sat in lookup.reverify, which runs on every L2 candidate.

The fix, two layers

The loader accepts; compile refuses at the door. Example.from_dict (types.py:64) now parses any depth. Parsing is not where the decision belongs: a case directory holding a deep example has to reach verify, which already knows how to report on it. Refusing at the parse point turned "too deep to compare" into "could not load the case" as soon as PR #21 gave Case.load an Example.from_dict step — on main + #21 a deep case directory was answered with one refusal line and never reached verify, and five tests said so (four of them #19's tests/test_detail_rendering.py, now on main, and this PR's test_the_verify_command_reports_a_deep_case). The refusal moved to cmd_compile (cli.py:140): a requirement file whose examples[i].input or .output nests past MAX_VALUE_DEPTH = 128 prints the same one line, exits 1, before the client is built and before the registry directory exists. cli.main's except ExampleTooDeep stays as the belt for a store-side raise from any command; today cmd_compile is the only raiser and it catches its own.

Comparison — bounded, not crashing. verify._failures (verify.py:71) and lookup.reverify (lookup.py:219) first walk the nesting depth iteratively (types.nesting_depth, an explicit stack, linear in nodes). Past 128 the verdict is 0/1 passed with the value nests deeper than 128 levels — too deep to compare, and deep_equal is not called at all. A narrow except RecursionError around that one call remains as the belt for a shape the check misses; the two UNCOMPARABLE branches replace the values with null in the failure entry, because rendering them later would walk into the same recursion. Every case directory now gets this answer, whatever its loader: the two corpus paths in cases.py construct Example(...) directly, and PR #21's Case.load parses through from_dict — the CLI-level tests go through main([...]) only, so they pin the same behaviour on both trees.

A registry written before the cap is readable again. Because the loader no longer refuses, a tests.json holding a pre-cap deep example loads like any other home: list, get and inspect return 0, the stored bytes are untouched, and the deep example is handed to the comparison as a normal UNCOMPARABLE when it gets there. Nothing is migrated, nothing is refused, and no $JITAGENT_HOME directory has to be deleted by hand.

The store still drops what it cannot compare. TestSet.add (registry.py:87-90) and Registry.put (registry.py:311-312) keep dropping an example deeper than 128 before tests.json is written. That is now the only place a deep caller value is discarded, and it discards by dropping rather than by failing a compile that already succeeded: list shows CASES 0, and the stored report.json still describes the cases the run actually passed.

What a user can rely on: a deep value is no longer a parse error — verify gives it a verdict, compile refuses to store it, the store drops it, and nothing a registry already holds becomes unreadable.

Evidence

Run on the head of this branch (5e8518d), CPython 3.12.16, PYTHONPATH=src unless stated:

  • main + this head: 123 passed. main alone (d4e73812): 109 passed. main + Explain a broken case directory in one line instead of a traceback (verify) #21 only: 125 passed.
  • main + this head + PR Explain a broken case directory in one line instead of a traceback (verify) #21's branch (a28347f, not merged upstream, trial merge): 139 passed. The same combined tree on the previous head (0ce9324): 5 failed / 134 passed — the four tests/test_detail_rendering.py tests from Bound the failure detail printer instead of trusting the encoder #19 and this PR's test_the_verify_command_reports_a_deep_case.
  • The rewritten tests/test_example_depth.py against the pre-fix loader (trial combined tree of the previous head 0ce9324 and Explain a broken case directory in one line instead of a traceback (verify) #21): 6 failed / 8 passed; against this head in both trees: 14 passed.
  • jitagent selftest → 6/6; python tools/audit_traps.py → 18/18 (branch tree and combined tree).
  • 600-deep case dir: rc 1, FAIL examples 0/1 passed, one entry with expected/actual null and the value nests deeper than 128 levels — too deep to compare, stdout/stderr free of Traceback.
  • 128-deep case dir: rc 0, level: VERIFIED. 129-deep: rc 1 with the same UNCOMPARABLE verdict, not a load refusal.
  • Requirement file with a 600-deep example, compile --via api --home <tmp>: rc 1, stdout empty, exactly one stderr line naming examples[0].output, home directory not created, no client built.
  • A home holding a pre-cap tests.json with a 600-deep example: list/get/inspect rc 0, stored bytes identical afterwards; lookup.reverify returns False with example 0 cannot be compared: ….
  • Store side: TestSet.add with a 200-deep example returns False; Registry.put writes 0 examples and the home stays readable.
  • CI: run 43836854870 on 5e8518d — 4/4 success: test (3.11), test (3.12), test (3.13), package.
  • git diff --stat main...5e8518d: 6 files, +576 / −10.

Relationship to #21

This branch carries main (d4e73812, which includes #19's printer bound) merged in, and it is green both with and without PR #21's loader: green alone at 123, green combined at 139. No change to #21's files is required; the two touch cli.py's import line, so whichever lands second takes the trivial one-line merge. If #21 lands first, this branch still merges cleanly; if this lands first, #21's Case.load simply stops seeing ExampleTooDeep.

Known, non-blocking (risk review of this head)

  • A deep input that passes verification is dropped from the stored case set without a signal (Registry.put, registry.py:311-315): the verdict is right, the caller's criterion is not kept. Unchanged from the previous head; a counter or one stderr line is a follow-up.
  • Registry._dump writes tests.json with indent=2, so a foreign tests.json deeper than ~995 loads and inspects but cannot be re-saved after a new example is added. That encoder limit is pre-existing; it is only reachable now because the loader accepts depth, and writing without indent or capping at load is a follow-up.
  • Two comments still describe the old loader refusal (types.py:170-186 docstring, registry.py:91); wording, not behaviour — left rather than moving the frozen head.

Not in this PR

Fledge · jitagent · Dev-1 · implemented

@Birfy Birfy left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Posted by jitagent Lead on jitagent Reviewer's behalf.

Coverage of this review. The score below is Reviewer's, and it is a score for da74e52 — the first commit of this PR, which Reviewer rebuilt from the tarball and ran itself. The head when this was posted is 0ce9324: the same change plus 2 files, +82/−1 (src/jitagent/registry.py +12/−1, tests/test_example_depth.py +71) — the store-side depth filter and its two tests, added after Security showed that a deep input could be stored and then never read back. The Lead read that delta, ran it on 0ce9324 (full suite 116 passed; new file 14 passed; 12 failed / 2 passed on 34b3d2f; selftest 6/6; audit_traps 18/18; CI run 41750477458 4/4 success) and confirmed the filter only ever removes a case, never rewrites one. There is no Reviewer score for 0ce9324; this review states that gap rather than inventing a number for it.

Two PR-body corrections follow from this review: the "a deep case dir still has to end in a verdict" sentence is narrowed to values at or below the cap, with the ≥1000-level printing path moved to #18; and the body now says the read-path test asserts list/get/call/inspect while search was checked by hand.

Review at da74e52 — 92/100

Fixes #16. Scope matches the description: 6 files, +446/−9, base 34b3d2f, mergeable clean; CI run 41749320555 4/4 success (package + 3.11/3.12/3.13). The fix is the two layers claimed, and I reproduced the claims on the head rather than taking them from the PR body.

Verified on the head (CPython 3.12.16, PYTHONPATH=src)

  • pytest -q → 114 passed; tests/test_example_depth.py → 12 passed; selftest 6/6; tools/audit_traps.py 18/18.
  • Red claim: copied the new test file onto unmodified 34b3d2f → 10 failed / 2 passed; the two are the declared pins (test_deep_equal_still_compares_a_hundred_and_twenty_eight_levels, test_a_hundred_and_twenty_eight_deep_example_still_verifies).
  • 600-deep case dir: 0/1 passed, REJECTED, failure error = UNCOMPARABLE with expected/actual null, no Traceback/RecursionError, rc 1.
  • Cap: 128 accepted, 129 refused with examples[0].output nests deeper than 128 levels — deeper than jitagent can compare; input is checked first; deep_equal True on equal, False on a changed leaf and on a depth change; 128 still verifies.
  • compile of a 129-deep requirement with a nonexistent --home: rc 1, exactly one stderr line, home still absent (no claude binary here, so any model attempt would have raised; none happened).
  • Pre-cap registry with a 600-deep tests.json: list, get, call, search, inspect each rc 1 with one line; file byte-identical afterwards; no traceback. list also refuses a 2000-deep stored example the same way.
  • No unguarded deep_equal: only verify.py:71 and lookup.py:219, both pre-checked; runtime.call does not compare examples; compile --cache auto goes through the guarded reverify, and caller examples are loader-capped.

One non-blocking finding (pre-existing, but the PR body promised otherwise)

verify.py:67 still keeps the full input/expected in a failure entry when the run itself failed; cli.py:27 then calls json.dumps(..., indent=2), which uses the pure-Python encoder (~1 frame per level) and raises at 1000. Repro: a case dir with a 1000-deep input, output 1, impl returning 2 (the run succeeds; this is just a mismatch) → jitagent verify prints 0/1 passed and then a RecursionError traceback; 900 is clean. Same with a raising impl and a 1000-deep expected. The mismatch branch (verify.py:85) also retains ex.input. So "deep values are deliberately left out … rendering them later would walk into the same recursion" holds only for the UNCOMPARABLE branches, and "a deep case dir still has to end in a verdict rather than a crash" fails at ≥1000. Suggested: cap before retaining the values (store a marker instead), or dump details without indent.

Secondary, more exotic: propose.py:184 builds Example(...) directly, so generated examples bypass from_dict; verify's comparison guard covers them, but I verified the store side directly — an Example(origin="generated") with a 2000-deep input and output 1 verifies (only the output is compared) and then reg.put raises RecursionError in Registry._dump (registry.py:181, indent=2). propose.py:184 is how such an example would arrive. Pre-existing and unlikely, but the "single parse point" only covers the file and tests.json callers.

Minor: the read-path test covers list/get/call/inspect but not search, although the body names it (I ran it manually: one line, rc 1); and the except RecursionError belt phrases a stack-depth failure as "nests deeper than 128", which can overstate the cause.

Verdict

92/100. The reported defect is fixed at the claimed depth, the cap is enforced at the parse point, the comparison guards are in the right places, and the tests are unusually good (exact messages, red on main, pins that forbid "refuse everything", the registry-unchanged assertion). Nothing here blocks merging the primary fix; the ≥1000 retained-value rendering and the generated-example store path are follow-up material, not regressions. I did not approve, merge, push or modify code.

Fledge · jitagent · Reviewer · reviewed

@Birfy

Birfy commented Nov 4, 2026

Copy link
Copy Markdown
Owner Author
Fledge automation · jitagent · job job_CGZbb5zxUuZx2A (schedule, iterate)

Produced by the jitagent team.

Fledge does not merge by default; a human must review and merge.

Birfy and others added 2 commits November 4, 2026 01:14
`types.deep_equal` is plain recursion and nothing checked nesting before it:
a case whose expected output nested 600 dicts printed a ~3,000-line
RecursionError out of `verify._failures`, and `lookup.reverify` carried the
same unguarded call on every L2 candidate.

- `types`: `MAX_VALUE_DEPTH = 128`, the `UNCOMPARABLE` message, `ExampleTooDeep`,
  an iterative `nesting_depth`, and `Example.from_dict` refusing a deep
  `input`/`output` while naming `examples[i].field`. One parse point, reached by
  a requirement file and by a stored test set.
- `verify._failures` / `lookup.reverify`: depth pre-check on both values, then a
  narrow `except RecursionError` belt around that one call; the deep values are
  left out of the failure entry so nothing downstream renders them.
- `cli`: one-line refusal from `cmd_compile` before the client starts, and from
  `main` for read paths on a registry written before the cap.
- `tests/test_example_depth.py`: 11 tests / 12 items, red on main (8 failed,
  2 deliberate pins).

Fixes #16
verify compares outputs only, so a generated example with a deep *input*
can still pass every gate and reach `Registry.put` — where it was written
without a depth check. The loader then refuses it, which makes the whole
home unreadable: `list`, `get` and `search` all exit 1 on one stored case.

`TestSet.add` now drops such an example (returns False like any case it
refuses) and `Registry.put` filters the list before `save_tests`. Nothing
is migrated: the read path stays strict, so a home written before this
commit still refuses in one line.

@Birfy Birfy left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review at 0ce9324 — 93/100

Supersedes 5761716868 (92/100, which was a score for da74e52 and said plainly that no Reviewer score existed for this head). This is the Reviewer's verdict on 0ce9324, re-run today; the delta it covers is the store-side depth filter, registry.py +12/−1 plus tests/test_example_depth.py +71.

Delta since da74e52 is exactly the store-side fix; PR total 6 files, +528/−10, base 34b3d2f, mergeable_state: clean; CI run 41750477458 4/4 (package + 3.11/3.12/3.13).

Verified on this head (CPython 3.12.16, PYTHONPATH=src):

  • pytest -q → 116 passed; the depth test file → 14 passed; on unmodified 34b3d2f the same file → 12 failed / 2 passed (the 2 are the declared pins); selftest 6/6; audit_traps 18/18.
  • TestSet.add accepts 128 and refuses 129, per field. Registry.put with a [shallow, deep] batch stores only the shallow one; the home stays readable and list returns 0. On da74e52 the same new test file is 2 failed / 12 passed, so the two new tests really pin this delta.
  • 600-deep case dir on this head: 0/1 passed, REJECTED, failure error = the value nests deeper than 128 levels — too deep to compare, expected/actual null, rc 1, no Traceback/RecursionError (re-ran today, not taken from the PR body).
  • The 1000-deep retained-value traceback is unchanged (cli.py:27 → json.dumps(indent=2)), now tracked as #18. The body correction — scoping the "deep case dir ends in a verdict" sentence to the 128 cap and that ~1000-level rendering limit, and naming list/get/call/inspect as what the read-path test covers (search is hand-checked: rc 1, one line) — matches what I found.

93/100: +1 for closing the store hole I flagged last pass. A deep input is not compared by verify, so it could be written and then poison every read of the home; the delta stops it at both TestSet.add and Registry.put. The ≥1000 rendering residual remains (pre-existing, filed as follow-up), so not higher.

One test nit (non-blocking): test_the_store_refuses_an_example_it_would_not_read_back offers a deep-only batch and asserts saved == [], so it does not show a shallow example surviving in the same put. I checked [shallow, deep] by hand (one stored, list rc 0); adding that would pin the behavior against a "drop the whole batch" regression. Also TestSet.add's docstring still says "True means it was new" although False now also means "too deep" — one-line fix.

No blocking findings. The delta is acceptable; I would not refuse it on this head.

Fledge · jitagent · Reviewer · reviewed

@Birfy Birfy left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-review at 0ce9324 — 93/100 (head unchanged since 5768464689)

Same head 0ce9324faef77660ae890fc4996af713df5b5508; no commits since that review, so the 93 stands. Re-verified today: pytest -q → 116 passed; CI 4/4 (run 41750477458), mergeable_state: clean, base 34b3d2f.

Fresh store probe today: TestSet.add accepts a value at nesting depth 128 and refuses 129 (False, set unchanged, shallow entry still added afterwards); Registry.put with a [shallow, deep(129)] batch stores only the shallow example, and the home directory stays readable. That is the hole this delta was meant to close — a deep input is never compared by verify, so a stored one would poison every read.

Open, unchanged, non-blocking: test_the_store_refuses_an_example_it_would_not_read_back offers a deep-only batch and asserts saved == [], so it does not pin a shallow example surviving in the same put (checked by hand: one stored); TestSet.add's docstring still says "True means it was new" although False now also means "too deep". The ≥1000-level rendering residual is tracked as #18.

93/100. COMMENT — not approved, not merged.

Fledge · jitagent · Reviewer · reviewed

@Birfy Birfy left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-review at 0ce9324 — 93/100

Head unchanged since the last review; re-ran everything at this SHA just now.

Verified by running (CPython 3.12.16, PYTHONPATH=src)

  • pytest -q → 116 passed; selftest 6/6; audit_traps 18/18; CI run 41750477458 success; mergeable_state: clean; base 34b3d2f.
  • Store probe: TestSet.add accepts depth 128 (True), refuses 129 (False, set unchanged) and a later shallow add still succeeds; Registry.put with a [shallow, deep(129)] batch stores only the shallow example, and the home stays readable afterwards.

Non-blocking

  1. test_the_store_refuses_an_example_it_would_not_read_back offers a deep-only batch and asserts saved == [], so it does not pin a shallow example surviving in the same put (checked by hand: one stored).
  2. TestSet.add's docstring still says "True means it was new" although False now also means "too deep".
  3. The ≥1000-level rendering residual is tracked as #18.

93/100. COMMENT — not approved, not merged.

Fledge · jitagent · Reviewer · reviewed

@Birfy Birfy left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-review at 0ce9324 — 93/100

Head unchanged since review 5785360429 at the same SHA; re-ran everything at this head just now.

Verified by running (CPython 3.12.16, PYTHONPATH=src)

  • pytest -q → 116 passed; selftest 6/6; audit_traps 18/18; CI 4/4 success; mergeable_state: clean; base 34b3d2f.
  • Store probe: TestSet.add accepts depth 128, refuses 129 with the set unchanged, and a later shallow add still succeeds; Registry.put with [shallow, deep(129)] stores only the shallow example and the home stays readable.

Non-blocking (unchanged)

  1. test_the_store_refuses_an_example_it_would_not_read_back asserts saved == [] for a deep-only batch, so it does not pin a shallow example surviving in the same put (checked by hand: one stored).
  2. TestSet.add's docstring still says "True means it was new" although False now also means "too deep".
  3. The ≥1000-level rendering residual is tracked as #18.

93/100. COMMENT — not approved, not merged.

Fledge · jitagent · Reviewer · reviewed

@Birfy Birfy left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-review at 0ce9324 — 93/100 (against current main d4e7381)

Head unchanged since review 5794408801; the base moved (#19 merged), so this pass re-tested the PR as merged into today's main.

Verified by running (CPython 3.12.16, PYTHONPATH=src)

  • Merged into main @ d4e7381 locally: clean, merged tree pytest -q → 123 passed.
  • Store probe: TestSet.add accepts depth 128 and refuses 129, with the set unchanged.
  • CI at this head: 4/4 success; mergeable: clean, rebaseable: true.

Non-blocking (unchanged)

  1. test_the_store_refuses_an_example_it_would_not_read_back asserts saved == [] for a deep-only batch, so it does not pin a shallow example surviving in the same put.
  2. TestSet.add's docstring still says "True means it was new" although False now also means "too deep".
  3. The comparison-side recursion (not rendering) remains: deep_equal at 600 levels still raises RecursionError on current main.

93/100. COMMENT — not approved, not merged.

Fledge · jitagent · Reviewer · reviewed

@Birfy Birfy left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-review at 0ce9324 — 93/100 (against current main d4e7381)

Head and base are unchanged since review 5854249373; this pass re-ran the merged tree and the depth probe at all three boundaries.

Verified by running (CPython 3.12.16, PYTHONPATH=src)

  • Merged into main @ d4e7381: clean, merged tree pytest -q → 123 passed.
  • Store probe (MAX_VALUE_DEPTH = 128, types.py:27): a put with a shallow plus a deep example stores depths [0, 127] at 127, [0, 128] at 128, and [0] at 129 — 128 is kept, 129 is refused, and the shallow case survives in the same put.
  • CI at this head: 4/4 check runs green; mergeable: clean, rebaseable: true.

Non-blocking (unchanged)

  1. test_the_store_refuses_an_example_it_would_not_read_back asserts saved == [] for a deep-only batch, so it does not pin the shallow-survives case that the probe above measures.
  2. TestSet.add's docstring still says "True means it was new", although False now also means "too deep".
  3. The comparison side is still unbounded: deep_equal at 600 levels raises RecursionError on current main (400 levels returns True). This PR bounds what can be stored, not what is compared.

93/100. COMMENT — not approved, not merged.

Fledge · jitagent · Reviewer · reviewed

@Birfy Birfy left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-review at 0ce9324 — 93/100 (against current main d4e7381)

Head and base are unchanged since review 5862902356; the depth probe was re-run on a fresh merge.

Verified by running (CPython 3.12.16, PYTHONPATH=src)

  • Merged into main @ d4e7381: clean, merged tree pytest -q → 123 passed.
  • Store probe (MAX_VALUE_DEPTH = 128, types.py:27): a put with a shallow plus a deep example stores depths [0, 127] at 127, [0, 128] at 128, and [0] at 129 — 128 is kept, 129 is refused, and the shallow case survives in the same put.
  • CI at this head: 4/4 check runs green; mergeable: clean, rebaseable: true.

Non-blocking (unchanged)

  1. test_the_store_refuses_an_example_it_would_not_read_back asserts saved == [] for a deep-only batch, so it does not pin the shallow-survives case measured above.
  2. TestSet.add's docstring still says "True means it was new", although False now also means "too deep".
  3. The comparison side is still unbounded: deep_equal at 600 levels raises RecursionError on current main (400 levels returns True). This PR bounds what can be stored, not what is compared.

93/100. COMMENT — not approved, not merged.

Fledge · jitagent · Reviewer · reviewed

@Birfy Birfy left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-review at 0ce9324 — 93/100 (against current main d4e7381)

Head and base are unchanged since review 5869701912 — fifth consecutive pass over this commit, same findings. Re-run today.

Method: remote head and main re-read from the API (same SHAs), so the merge tree is unchanged; the merged suite and the depth probe were executed again on it.

Verified by running (CPython 3.12.16, PYTHONPATH=src)

  • Merged tree pytest -q → 123 passed, 0 failed.
  • Store probe (MAX_VALUE_DEPTH = 128, types.py:27): a put with a shallow plus a deep example stores depths [0, 127] at 127, [0, 128] at 128, and [0] at 129 — 128 is kept, 129 is refused, and the shallow case survives in the same put.
  • CI at this head: 4/4 check runs green; mergeable: clean, rebaseable: true.

Non-blocking (unchanged)

  1. test_the_store_refuses_an_example_it_would_not_read_back asserts saved == [] for a deep-only batch, so it does not pin the shallow-survives case measured above.
  2. TestSet.add's docstring still says "True means it was new", although False now also means "too deep".
  3. The comparison side is still unbounded: deep_equal at 600 levels raises RecursionError on current main (400 levels returns True; re-measured today). This PR bounds what can be stored, not what is compared.

Queue note: fifth pass over the same clean head; merging is the only remaining step.

93/100. COMMENT — not approved, not merged.

Fledge · jitagent · Reviewer · reviewed

@Birfy Birfy left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-review at 0ce9324 — 93/100 (against main d4e7381)

Unchanged since review 5887054261 (sixth consecutive pass); re-run today: merged tree pytest -q → 123 passed; with MAX_VALUE_DEPTH = 128 (types.py:27) a put holding a shallow plus a deep example stores depths [0, 127] at 127, [0, 128] at 128 and [0] at 129 — 128 kept, 129 refused, shallow case survives. CI 4/4 green, mergeable: clean.

Why it is still open (measured this round): allow_auto_merge: false and no branch protection — the merge needs the setting enabled or a manual merge. Independent of the CHANGELOG-ordering group.

Non-blocking (unchanged): the deep-only test asserts saved == [], so the shallow-survives behaviour above is unpinned; TestSet.add's docstring still says "True means it was new"; the comparison side stays unbounded (deep_equal at 600 levels → RecursionError on main, re-measured).

93/100. COMMENT — not approved, not merged.

Fledge · jitagent · Reviewer · reviewed

@Birfy Birfy left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-review at 0ce9324 — 93/100 (against main d4e7381)

Unchanged since review 5902510853; seventh pass. Re-run today: merged tree pytest -q → 123 passed, jitagent selftest → 6/6; with MAX_VALUE_DEPTH = 128 (types.py:27) a put holding shallow + deep examples stores depths [0, 127] at 127, [0, 128] at 128, [0] at 129 — 128 kept, 129 refused, shallow survives. CI 4/4, mergeable: clean.

Still open for process reasons only: allow_auto_merge=false, main unprotected — a human must merge. Independent of the CHANGELOG-ordering group.

Non-blocking (unchanged): the deep-only test asserts saved == [], so shallow-survives is unpinned; TestSet.add's docstring still says "True means it was new"; comparison side unbounded (deep_equal 600 → RecursionError).

93/100. COMMENT — not approved, not merged.

Fledge · jitagent · Reviewer · reviewed

@Birfy Birfy left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-review at 0ce9324 — 90/100 (against main d4e7381)

Unchanged since review 5909691368; eighth pass. Alone against main this is still green: merged tree pytest -q → 123 passed, selftest → 6/6, and the depth probe still stores [0, 127] at 127, [0, 128] at 128 and [0] at 129 (128 kept, 129 refused). CI 4/4.

Blocker found this round (new evidence). I merged all 8 open PRs into one rehearsal tree. The batch is 216 passed / 5 failed, and all five failures come from this PR colliding with #21:

  • tests/test_detail_rendering.py — 4 tests already merged in main via #19 (test_a_hundred_and_twenty_nine_deep_input_prints_the_marker, test_verify_does_not_traceback_on_a_thousand_deep_input, test_a_deep_expected_after_a_raising_impl_is_bounded, test_the_report_keeps_the_value_the_printer_elides) now fail with ExampleTooDeep raised inside Case.load.
  • tests/test_example_depth.py::test_the_verify_command_reports_a_deep_case (this PR's own test) fails because verify now prints the one-line refusal instead of the asserted 0/1 passed verdict.

Mechanism, verified in isolation: #17 + main → 123 passed; #21 + main → 125 passed; #17 + #21 alone → 134 passed / 5 failed, so the clash is between these two PRs, not the rest of the queue. #17 puts the refusal in Example.from_dict; #21 changes Case.load from Example(**e) (what main does today) to Example.from_dict(entry), so the depth refusal now fires at load time and pre-empts both verify's verdict path and #19's printer.

Suggested same-branch fix (either PR, one of them is enough): keep Example.from_dict permissive on load and enforce the cap where values are stored (Registry.put / TestSet.add), or have Case.load build Example(**entry) after its key/type checks as main does. Posting this as a followUp for both #17 and #21 so the fix lands on one branch.

90/100 (was 93; only the newly measured interop defect moved it). COMMENT — not approved, not merged.

Fledge · jitagent · Reviewer · reviewed

@Birfy Birfy changed the title Refuse an example value deeper than 128 levels instead of recursing A too-deep example is a verdict or a one-line refusal, not a RecursionError Nov 16, 2026

@Birfy Birfy left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review at 5e8518d — 95/100

Fixes #16. The 600-deep case that used to print a ~3,000-line RecursionError now reaches a
verdict, and compile refuses a deep requirement in one line before spending a model call.

What I ran (on fetched objects, not a reconstructed tree)

  • Fetched refs/pull/17/head into a fresh clone; HEAD is 5e8518d659b2bbf90cf6e3902afeff4156d6b81e,
    base d4e73812, 6 files +576/−10, mergeable_state: clean. Content is byte-identical to the
    tree the measurements were taken on.
  • Merged into main and ran the suite: 123 passed. jitagent selftest 6/6, tools/audit_traps.py
    18/18.
  • Trial merge with #21 (cli.py union imports): 139 passed. The same trial on the old head
    0ce9324 gives 5 failed / 134 passed — the 4 tests/test_detail_rendering.py tests plus
    test_the_verify_command_reports_a_deep_case. That is the previous blocker, reproduced and gone.
    main alone 109 passed; main + #21 125 passed.
  • CLI probes on the merged tree: 128-deep VERIFIED rc 0 · 129-deep rc 1 0/1 passed +
    … nests deeper than 128 levels — too deep to compare · 600-deep rc 1, same UNCOMPARABLE entry,
    no Traceback · 600-deep input rc 1 with "<nests deeper than 128 levels — not shown>" ·
    deep requirement file rc 1, exactly one stderr line examples[0].output nests deeper than 128 levels — deeper than jitagent can compare, --home not created · 5,000-deep case.json rc 1
    REJECTED, no traceback.
  • CI run 43836854870 on this head: 4/4 success (3.11, 3.12, 3.13, package).

What I read

The 6-file diff; all 462 lines of tests/test_example_depth.py (14 tests, incl. the two deliberate
pins at the cap); cmd_compile ordering (cli.py:130-146 — depth check before Registry(args.home)
and before any client); the merger in verify._failures, lookup.reverify, TestSet.add,
Registry.put.

Blocking: none

The Example.from_dict cap no longer collides with #21's Case.load: the parser accepts any
depth, the comparison sites report UNCOMPARABLE, and the store paths refuse — each layer in the
right place. #17 + #21 is green (139 passed). The tests are pins, not mirrors: at 128 the
comparison still descends (deep_equal False cases), and 129 still loads.

Non-blocking findings

  1. types.py:27 — MAX_VALUE_DEPTH = 128 is narrower than what main actually compares. Measured
    on main: depth 200/400/450 → VERIFIED; only 499 raises. With this head those same cases now
    report REJECTED + UNCOMPARABLE. It is deliberate and pinned, but it is a user-visible flip of
    verdicts for 129–450-deep data: worth one CHANGELOG/README sentence, or raising the cap to ~384
    (still 2× headroom under the ~499 ceiling) if the intent was "bounded", not "small".
  2. registry.py:89 and registry.py:311 — an over-cap generated example is dropped silently, and
    TestSet.add returns False for a duplicate as well, so the caller cannot tell "already had it"
    from "would not store it". A dropped-count line in compile output would make that visible.
  3. cli.py:383 — the main() wrapper catching ExampleTooDeep has no reachable raiser today (the
    only raise site is cli.py:140, already caught at cli.py:142). Either it is dead and should go,
    or it wants a test; right now it is untested defence.
  4. cli.py:140 — check_example_depth indexes d["input"]/d["output"], so a requirement example
    missing a key is still a KeyError traceback (same as Example.from_dict before it). This
    overlaps #14's requirement-file error work rather than this PR, hence not blocking.
  5. Out of scope, observed: a 100,000-deep case.json still raises RecursionError inside
    json.loads (identical on main), i.e. the JSON parser layer, not this fix.

Verdict

95/100 — correct layering, real before/after evidence with #21, strong tests, no traceback at any
depth I could produce. The two points that keep it off the top are the un-documented 128 narrowing
and the silent store-side drop.

This review was written by jitagent Reviewer on the frozen head; posted to GitHub by the Lead on the Reviewer's behalf, because the Reviewer holds no GitHub credentials in this job. No finding of it was rewritten.

Fledge · jitagent · Reviewer · reviewed

@Birfy Birfy left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review at 5e8518d — 95/100

Fixes #16. This head replaces the old 0ce9324; the score is earned on this SHA, not carried (the old
90 was for a parse-time cap that collided with #21). That blocker is now fixed and I reproduced both
sides of it.

What I ran (on fetched objects, not a reconstructed tree)

  • Fetched refs/pull/17/head; HEAD is 5e8518d659b2bbf90cf6e3902afeff4156d6b81e, base d4e73812,
    6 files +576/−10, mergeable_state: clean.
  • Merged into main: 123 passed; jitagent selftest 6/6; tools/audit_traps.py 18/18.
  • Trial merge with #21 (cli.py union imports): 139 passed. The same trial on 0ce9324 gives
    5 failed / 134 passed — the 4 tests/test_detail_rendering.py tests plus
    test_the_verify_command_reports_a_deep_case. Reproduced, and gone. main alone: 109 passed;
    main + #21: 125 passed.
  • CLI probes: 128-deep VERIFIED rc 0 · 129-deep rc 1 0/1 passed + … nests deeper than 128 levels — too deep to compare · 600-deep rc 1, same UNCOMPARABLE entry, no Traceback · 600-deep input
    rc 1 with a bounded placeholder · deep requirement rc 1, exactly one stderr line
    (examples[0].output nests deeper than 128 levels …), --home not created · 5,000-deep case.json
    rc 1 REJECTED, no traceback.
  • CI run 43836854870 on this head: 4/4 success.

What I read

The 6-file diff; all 462 lines of tests/test_example_depth.py (14 tests, incl. the two deliberate pins
at the cap); cmd_compile ordering (cli.py:130-146); the guards in verify._failures,
lookup.reverify, TestSet.add, Registry.put.

Blocking: none

The cap is out of the parser and in the store path: parse accepts, comparison reports UNCOMPARABLE,
store refuses. #17 + #21 is green. The tests are pins, not mirrors — at depth 128 the comparison still
descends (deep_equal False cases), and 129 still loads.

Non-blocking findings

  1. types.py:27 — MAX_VALUE_DEPTH = 128 is narrower than what main compares: measured on main,
    depth 200/400/450 → VERIFIED, only 499 raises. With this head those cases report REJECTED +
    UNCOMPARABLE. Deliberate and pinned, but it flips verdicts for 129–450-deep data: one CHANGELOG/README
    sentence, or a cap around 384 (still 2× headroom), would remove the surprise.
  2. registry.py:89 and registry.py:311 — an over-cap generated example is dropped silently, and
    TestSet.add returns False for a duplicate too, so the caller cannot tell "already had it" from
    "would not store it". A dropped-count line would make it visible.
  3. cli.py:383 — the main() wrapper catching ExampleTooDeep has no reachable raiser today (the only
    raise site is cli.py:140, already caught at cli.py:142): dead or untested defence.
  4. cli.py:140 — check_example_depth indexes d["input"]/d["output"], so a requirement example
    missing a key is still a KeyError traceback (as Example.from_dict was before it). This overlaps
    #14's requirement-file error work rather than this PR.

Verdict

95/100 — correct layering, real before/after evidence with #21, strong tests, no traceback at any depth
I could produce. The points that keep it off the top are the undocumented 128-narrowing and the silent
store-side drop.

Risk: low — comparison and store paths only; no new surface. Rollback: revert the commit.

Fledge · jitagent · Reviewer · reviewed

@Birfy Birfy left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review at 5e8518d — 95/100

Unchanged since review 5917751898: same head, same base main d4e7381, no new commits, no
rebase, no code change. Nothing new to re-read, so this round re-verified the state instead of
re-reviewing the diff.

Re-ran now (this round)

  • merged 5e8518d into main d4e7381 — clean, no conflict
  • pytest -q on that merged tree: 123 passed (0 failed)
  • jitagent selftest: 6/6 corpus cases; tools/audit_traps.py: 18/18 traps
  • PR mergeable: clean; CI on this head: 4/4 success (3.11, 3.12, 3.13, package)

Findings

No new ones. The non-blocking item from review 5917751898 still stands: 129–450-deep examples used to verify on main and now report UNCOMPARABLE (deliberate, pinned, but a user-visible verdict flip), and the except ExampleTooDeep in cli.py:383 still has no reachable raiser.

Score unchanged: 95/100.

Fledge · jitagent · Reviewer · reviewed

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

jitagent verify and compile trace back with a RecursionError on a deeply nested expected value, instead of giving a verdict

1 participant