Skip to content

Explain a broken case directory in one line instead of a traceback (verify) - #21

Open
Birfy wants to merge 3 commits into
mainfrom
fix/verify-case-file-errors
Open

Birfy wants to merge 3 commits into
mainfrom
fix/verify-case-file-errors

Conversation

@Birfy

@Birfy Birfy commented Nov 5, 2026 •

Copy link
Copy Markdown
Owner

What

jitagent verify <case-dir> now answers an unusable case directory with one line on stderr, nothing on stdout, and exit code 2 — instead of raising out of Case.load. A valid case directory renders exactly as before.

Fixes #20.

Why

verify reads a hand-edited case.json and was the one command left that trusted it. Measured on main at 34b3d2f (CPython 3.12.16, PYTHONPATH=src, scratch JITAGENT_HOME, stdout empty every time):

case directory what verify did on 34b3d2f
does not exist / no case.json FileNotFoundError, 22 stderr lines, rc 1
case.json is invalid JSON json.decoder.JSONDecodeError, 24 lines
case.json holds an array AttributeError: 'list' object has no attribute 'get', 16 lines
case.json is UTF-16, not UTF-8 UnicodeDecodeError: 'utf-8' codec can't decode byte 0xff …, 23 lines
no "spec" key KeyError: 'spec', 16 lines
an example carries "notes" for "note" TypeError: Example.__init__() got an unexpected keyword argument 'notes', 16 lines
the spec carries "timeout" for "timeout_ms" TypeError: Spec.__init__() got an unexpected keyword argument 'timeout', 16 lines
the named impl file is missing FileNotFoundError, 22 lines

Exit code 1 made that worse than noise: cmd_verify already returns 1 for "the implementation failed verification", so a broken case file and a REJECTED verdict were indistinguishable to a script.

This is the half of #13 that was deliberately left out — its body says "verify has the same shape (Case.load on a bad directory raises FileNotFoundError) and is deliberately left out of this change". PR #14 fixed the compile door only, with the same exit code 2.

The contract now

cannot read '/tmp/case/case.json': No such file or directory
cannot read '/tmp/case/case.json': not UTF-8 text ('utf-8' codec can't decode byte 0xff in position 0: invalid start byte)
'/tmp/case/case.json' is not valid JSON: Expecting property name enclosed in double quotes: line 1 column 16 (char 15)
'/tmp/case/case.json' must hold a JSON object with "spec", "examples" and "expect", not an array
'/tmp/case/case.json' is missing "spec"
'/tmp/case/case.json': "spec" has an unknown key "timeout"
'/tmp/case/case.json': example 0 has an unknown key "notes"
'/tmp/case/case.json': "examples" must be a list of examples
'/tmp/case/case.json': example 0 needs both "input" and "output" (missing 'output')
'/tmp/case/case.json' needs "expect" to be an object with a "level"
cannot read '/tmp/case/impl.py': No such file or directory

Paths are printed with repr, so a path containing a newline or a control character still produces a single line.

The unknown-key messages are not cosmetic: parsing with Example.from_dict / Spec(**…) while ignoring extra keys would have turned a typo into silence — the case would run with the intended value missing and the author would never be told.

How

  • src/jitagent/cases.py: CaseError(RuntimeError), and Case.load validates what it reads — file, JSON, top-level object, required keys, spec/examples/expect shapes, key names against the dataclass fields, impl file — raising one of the lines above.
  • src/jitagent/cli.py: cmd_verify turns CaseError into print(e, file=sys.stderr); return 2. No other line in cli.py changes.
  • CHANGELOG.md: [Unreleased] entry.
  • tests/test_verify_case_errors.py: 16 tests — 14 refusals (incl. the UTF-16 file, the deep-parse file and both unknown-key shapes) plus 2 pins that keep 0/1 meaning what they meant.

jitagent selftest shares Case.load through load_all. A broken corpus case now raises CaseError instead of KeyError there too, but selftest's own reporting is untouched and deliberately out of scope, the same way #13 scoped verify out.

Beyond the issue (found in review)

Security's pass found one more escape of the same class inside the same function: json.loads raises RecursionError — not JSONDecodeError — on a deeply nested case.json, so a 10,000-deep file still came back as rc 1 with a 25-line traceback, indistinguishable from a REJECTED verdict. That is a realistic input here, not a hypothetical: this repo's own #16 and #18 are deep-nesting reports, so anyone reproducing either of them writes a deep case file and meets this first.

Now caught in the same place, with the reason and no invented depth number (the threshold is stack-dependent): '<path>/case.json' nests too deeply to parse. One test builds the file as text ("[" * 50000 + "]" * 50000) rather than dumping a deep value, so the test itself does not depend on the writer.

Evidence

  • pytest -q on this branch → 118 passed (102 on 34b3d2f + 16 new), 0 failed.
  • The new file on unmodified 34b3d2f → 14 failed, 2 passed; the two passing are the pins (test_a_valid_case_still_verifies, test_a_wrong_implementation_is_still_rejected). Red is behavioural: each refusal test dies on the exception the old loader raised (the deep-parse one on RecursionError), not on a missing constant.
  • jitagent selftest → 6/6; python tools/audit_traps.py → 18/18.
  • Every repro dir behind the table above (nine of them, counting a missing directory and a missing case.json separately): rc 2, stdout 0 bytes, exactly 1 stderr line each, no Traceback.
  • Valid path unchanged, measured against 34b3d2f after normalising the took: Nms line: src/jitagent/corpus/01_correct → rc 0, 194 stdout bytes, 0 stderr; 02_wrong_no_clean → rc 1, 1687 stdout bytes, 0 stderr. Both diff-clean.
  • CI at a28347f: run 41946932814 — 4/4 success (test (3.11), test (3.12), test (3.13), package).

Known, not in this diff

Recorded from the review passes so the next change has them, not fixed here (all pre-existing or below the line for this job):

  • jitagent selftest shares Case.load through load_all, so a broken corpus case still tracebacks there. Scoped out deliberately, as jitagent compile answers a bad requirement file with a traceback, not an explanation #13 scoped verify out of Explain a bad requirement file in one line instead of a traceback #14.
  • An unknown key is echoed in full, so a 500,000-character key produces a single 500 KB stderr line — one line, but hard to read and easy to log-flood. Truncating to ~60 characters would fix it.
  • Strictness is asymmetric: unknown keys inside spec/examples are refused, unknown top-level keys are still ignored, so a top-level typo is silent.
  • _SPEC_KEYS/_EXAMPLE_KEYS are hand-kept copies of the dataclass fields; a future Spec/Example field would be rejected as "unknown" until they are updated.
  • _read is a plain read_text: a case.json symlinked to a FIFO or /dev/zero blocks until the caller gives up. Pre-existing.
  • expect.level is not validated against the three Level values: {"level": "BANANA"} loads and verify exits 0 (it does not consult expect at all). A typo in the expected verdict is silent.
  • A UTF-8-BOM case.json (Notepad's default save) is refused in the invalid-JSON branch with CPython's own hint, Unexpected UTF-8 BOM (decode using utf-8-sig) — correct, since RFC 8259 has no BOM, but it is Python-ese in a user-facing line. Reading with utf-8-sig would accept the file instead.
  • No test yet for a missing top-level expect, a non-string impl, or a case path that does not exist at all (the missing-file test creates the directory).
  • The 0/1/2 contract is stated only in the CHANGELOG: verify --help and the README still describe verify without it, which is where a caller looks.
  • impl is joined without confinement, so "impl": "../../x.py" reads a file outside the case directory. Pre-existing, read-only, and not introduced here.

Risk

Low. verify writes nothing; the change only runs on the path taken before a case is loaded, and every existing case-file shape that used to load still loads. Rollback is git revert of the two commits on the branch (three source files, one new test file).

Fledge · jitagent · Dev-1 · implemented

Status on current heads (2026-11-16)

No source or test change was needed on this branch. The 128-level example-depth refusal this
follow-up was opened for is not in main at all: MAX_VALUE_DEPTH, ExampleTooDeep and
nesting_depth are introduced by #17. Case.load here
builds examples with Example.from_dict, so that refusal could only reach verify while #17 carried
the cap inside from_dict. #17's head 5e8518d moved it to check_example_depth, which only
cmd_compile calls: the loader accepts any depth and verify renders its own verdict again.

Re-derived on the real heads (pytest -q tests, CPython 3.12.16, PYTHONPATH=src, scratch
JITAGENT_HOME):

tree result
main d4e7381 109 passed
main + this branch, head 75dd723 125 passed
main + #17 5e8518d 123 passed
main + #17 5e8518d + this branch 139 passed
#17's old head 0ce9324 + this branch 5 failed / 134 passed — this row only

The five failures in that last row are the four tests/test_detail_rendering.py tests merged by #19
plus test_the_verify_command_reports_a_deep_case; all five pass on every row above. The 139 row is a local trial merge of the two branches, not a CI run; this pull request's own CI runs the 125 row, and
tests/test_verify_case_errors.py (16 tests) passes on both main+#21 and main+#21+#17.

The only commit added since a28347f is a merge of main d4e7381 (tree 9f371e8, identical to a
local git merge of the same two commits), so this pull request's own CI now runs on the merged
tree: run 43842530962 — 4/4 success
(test (3.11), test (3.12), test (3.13), package).

Merge order: either order ends green (139 passed on the resolved combination), but the second pull
request needs a one-line union import in cli.py: this branch adds Case, CaseError, load_all to the
cases import, #17 adds check_example_depth to the types import, and the two lines are adjacent —
so whichever lands second needs that resolution and a fresh CI run. This branch itself is mergeable
as-is with main today (mergeable_state: clean, CI 4/4).

Fledge · jitagent · Lead · claimed

@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 a28347f — 93/100

Case.load now answers an unusable case directory in one sentence, and cmd_verify maps that to exit 2 while 1 keeps meaning "the implementation failed". I read 65aece2 and re-ran everything at this head; the delta since then is exactly the RecursionError branch and its test.

Verified by running (CPython 3.12.16, PYTHONPATH=src)

  • pytest -q → 118 passed. On unmodified 34b3d2f the same new file is 14 failed / 2 passed — the two pins (valid case rc 0, wrong impl rc 1) still pass there, so the rest are real coverage.
  • Deep case.json: 9 000 nested arrays parse and are refused as an array in one line; 12 000 / 20 000 / 50 000 → rc 2, exactly one stderr line nests too deeply to parse, empty stdout, no traceback. The escape I flagged on 65aece2 is closed.
  • Ordinary authoring mistakes — missing directory, missing case.json, invalid JSON, non-object top level, missing spec/examples/expect, unknown key in spec and in an example, examples not a list, example missing input/output, expect without a level, missing impl, UTF-16 — each give rc 2, one stderr line, 0 stdout, no traceback.
  • Valid output unchanged: 01_correct rc 0 and 02_wrong_no_clean rc 1, byte-identical to 34b3d2f after normalising took: (same md5).
  • selftest 6/6; audit_traps 18/18; CI 4/4 (41946932814); mergeable_state: clean; base 34b3d2f.

Blocking: none.

Non-blocking

  1. cases.py:114-116 and :128: expect is checked only for being an object with a level key, never for the value — {"level": "BANANA"} loads and verifies with rc 0. A typo in the expected verdict is silently accepted; validate against the three Level values.
  2. cases.py:69-70: a UTF-8-BOM case.json (Notepad's default) is refused as is not valid JSON: Unexpected UTF-8 BOM (decode using utf-8-sig), while the CHANGELOG says "a file that is not UTF-8" — a BOM'd file is UTF-8. Read with utf-8-sig, or name BOM in the changelog; there is no BOM test (the encoding test at tests/test_verify_case_errors.py:87 covers UTF-16 only).
  3. cases.py:15-17: _SPEC_KEYS/_EXAMPLE_KEYS repeat the dataclass fields by hand; when Spec/Example grows a field the message will call a valid key "unknown". Deriving them from dataclasses.fields(...) keeps the list honest and feeds _SPEC_REQUIRED from one place.
  4. Coverage gaps: no test for a missing top-level expect (the :86 loop covers it, but tests/test_verify_case_errors.py:125 parametrises only spec/examples), for a non-string impl (cases.py:118-120), or for a case path that does not exist at all (:81 creates the directory).
  5. cases.py:121: impl is joined without confinement — "impl": "../../x.py" reads a file outside the case dir. Pre-existing, not introduced here, and only read as source, but the PR now prints that path.
  6. The 0/1/2 contract lives only in the CHANGELOG; verify --help (cli.py:309) and the README do not state it, and callers are exactly who must tell rc 2 from rc 1.

Merge note: this branch adds ## [Unreleased] at the same CHANGELOG line as #7/#8/#10 — those four have to merge in sequence.

93/100. COMMENT: right layer, one-line diagnostics, tests genuinely red on base, valid cases byte-identical, and the decode-recursion escape is now fixed with a test that writes text rather than relying on the JSON writer. The remaining points are type validation, message wording and docs — none block. Not approved, not merged.

Ran vs read: ran — tarball at a28347f, diff against 65aece2 (only cases.py:71-72 + one test + one CHANGELOG line), full pytest -q (118 passed), new file on base 34b3d2f (14 failed / 2 passed), deep-JSON sweep 9k/12k/20k/50k, ~10 broken-dir/edge CLI probes (BOM, expect.level, traversal), corpus render comparison vs base, selftest, audit_traps, CI/mergeable via API; read — cases.py/cli.py at line level, the 16 tests, issue #20. Not run: 3.11 (not on this machine). I posted nothing to GitHub.

Posted by the Lead on the Reviewer's behalf: the Reviewer wrote and ran this review and has no write credential for this repository.

Fledge · jitagent · Reviewer · reviewed

@Birfy

Birfy commented Nov 5, 2026

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

Automated run: Lead wrote · Product claimed · Dev-1 implemented · Test tested · Reviewer reviewed.

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

jitagent Dev-1 added 2 commits November 5, 2026 01:30
`jitagent verify` read case.json and trusted it: a missing file, invalid JSON,
a missing key or a typo key each came out as the standard-library exception that
happened to be raised inside Case.load (16-25 stderr lines, exit code 1 - the same
code that means "the implementation failed verification").

Case.load now raises CaseError naming the file and the reason, and cmd_verify turns
it into one line on stderr and exit code 2. Valid case directories render exactly as
before.
json.loads raises RecursionError, not JSONDecodeError, on a deeply nested
case.json, so a 10,000-deep file still came back as rc 1 with a traceback -
indistinguishable from a REJECTED verdict. Caught in the same place as the other
unreadable-file branches, with no invented depth number: the threshold is
stack-dependent.

Found in Security's review of this branch; this repo's #16/#18 are deep-nesting
reports, so a deep case file is a realistic input.

@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 a28347f — 93/100

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

Verified by running (CPython 3.12.16, PYTHONPATH=src)

  • pytest -q → 118 passed; on unmodified 34b3d2f the same new test file is 14 failed / 2 passed (the two pins), re-checked today; selftest 6/6; audit_traps 18/18; CI run 41946932814 success (3.11/3.12/3.13/package); mergeable_state: clean; base 34b3d2f.
  • Deep case.json: 9 000 nested arrays → rc 2, one line refusing a non-object; 12 000 / 20 000 / 50 000 → rc 2, exactly one stderr line nests too deeply to parse, empty stdout, no traceback.
  • A valid case still renders unchanged (same bytes as base after normalising took:).

Blocking: none.

Non-blocking

  1. cases.py:114-116, :128: expect is checked for having a level key, never for its value — {"level": "BANANA"} loads and verifies rc 0.
  2. cases.py:69-70: a UTF-8-BOM case.json is refused as "not valid JSON" while the CHANGELOG says "not UTF-8"; there is no BOM test (the encoding test covers UTF-16 only).
  3. cases.py:15-17: _SPEC_KEYS/_EXAMPLE_KEYS duplicate the dataclass fields by hand.
  4. Coverage gaps: missing top-level expect, non-string impl, a nonexistent case path (:81 creates the directory).
  5. cases.py:121: impl is joined without confinement — "impl": "../../x.py" reads outside the case dir (pre-existing).
  6. The 0/1/2 contract lives only in the CHANGELOG, not in verify --help (cli.py:309) or the README.
  7. Merge note: this branch inserts ## [Unreleased] at the same CHANGELOG line as #7/#8/#10.

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 a28347f — 93/100

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

Verified by running (CPython 3.12.16, PYTHONPATH=src)

  • pytest -q → 118 passed; on unmodified 34b3d2f the same new test file is 14 failed / 2 passed; selftest 6/6; audit_traps 18/18; CI 4/4 success (3.11/3.12/3.13/package); mergeable_state: clean; base 34b3d2f.
  • Deep case.json: 12 000 and 50 000 nested arrays → rc 2, exactly one stderr line nests too deeply to parse, empty stdout, no traceback.
  • A valid case still renders byte-identically to base after normalising took:.

Blocking: none.

Non-blocking (unchanged)

  1. cases.py:114-116, :128: expect.level is checked for presence, not value — {"level": "BANANA"} verifies rc 0.
  2. cases.py:69-70: a UTF-8-BOM case.json is refused as invalid JSON while the CHANGELOG says "not UTF-8"; no BOM test.
  3. cases.py:15-17: _SPEC_KEYS/_EXAMPLE_KEYS duplicate the dataclass fields by hand.
  4. Coverage gaps: missing top-level expect, non-string impl, nonexistent case path.
  5. cases.py:121: impl is joined without confinement (pre-existing).
  6. The 0/1/2 contract lives only in the CHANGELOG, not in verify --help (cli.py:309) or the README.

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 a28347f — 93/100 (against current main d4e7381)

Head unchanged since review 5794409059; 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 → 125 passed; on the original base 34b3d2f the new test file is still 14 failed / 2 passed.
  • A 50 000-deep case.json → rc 2, exactly one stderr line nests too deeply to parse, empty stdout, no traceback.
  • CI at this head: 4/4 success; mergeable: clean, rebaseable: true.

Blocking: none.

Non-blocking (unchanged)

  1. cases.py:114-116, :128: expect.level is checked for presence, not value — {"level": "BANANA"} verifies rc 0.
  2. cases.py:69-70: a UTF-8-BOM case.json is refused as invalid JSON while the CHANGELOG says "not UTF-8"; no BOM test.
  3. cases.py:15-17: _SPEC_KEYS/_EXAMPLE_KEYS duplicate the dataclass fields by hand.
  4. Coverage gaps: missing top-level expect, non-string impl, nonexistent case path; impl joined without confinement (:121, pre-existing).
  5. The 0/1/2 contract lives only in the CHANGELOG, not in verify --help (cli.py:309) or the README.

Merge note: after #7 merges, this branch conflicts only in CHANGELOG.md — merge #7/#8/#10/#21 in sequence.

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 a28347f — 93/100 (against current main d4e7381)

Head and base are unchanged since review 5854249505; this pass re-ran the merged tree, the case-file probe (now at 50 000 levels) and the red-on-base check.

Verified by running (CPython 3.12.16, PYTHONPATH=src)

  • Merged into main @ d4e7381: clean, merged tree pytest -q → 125 passed; the new test file copied onto current main is 14 failed / 2 passed, so the coverage is genuinely red without the change.
  • A 50 000-deep case.json → rc 2, exactly one stderr line … nests too deeply to parse, empty stdout, no traceback. Same for a missing case directory (one line naming case.json).
  • Ordinary authoring mistakes: missing top-level expect → rc 2 one line; non-string impl → rc 2 one line; invalid JSON/non-object/BOM → rc 2 one line. Valid case still rc 0.
  • CI at this head: 4/4 check runs green; mergeable: clean, rebaseable: true.

Blocking: none.

Non-blocking (unchanged unless noted)

  1. cases.py:113/:128: expect is checked for being an object with a level key, never for the value — {"level": "BANANA"} verifies with rc 0 (re-measured).
  2. cases.py read path: a UTF-8-BOM case.json (Notepad's default) is refused as invalid JSON while the CHANGELOG says "not UTF-8"; read with utf-8-sig or name BOM in the changelog.
  3. cases.py:15-16: _SPEC_KEYS/_EXAMPLE_KEYS repeat the dataclass fields by hand; deriving them from dataclasses.fields(...) keeps them honest.
  4. Coverage gaps: no test for a missing top-level expect (it works — measured), for a non-string impl (works), or for a case path that does not exist (works).
  5. cases.py:123: name is the only field taken from the file without a type check (meta.get("name", d.name)); an integer name loads and verifies fine. Cosmetic, but it is the one untyped field left.
  6. cases.py:118-120: impl is joined without confinement — "impl": "../../x.py" resolves outside the case directory (pre-existing; the read fails with a plain rc 2 line when absent, and the PR now prints that path).
  7. The 0/1/2 contract lives only in the CHANGELOG; verify --help and the README do not state it.

Merge note: after #7 merges, this branch conflicts only in CHANGELOG.md — merge #7/#8/#10/#21 in sequence.

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 a28347f — 93/100 (against current main d4e7381)

Head and base are unchanged since review 5862902582; the case-file probe and the red-on-base check were re-run on a fresh merge.

Verified by running (CPython 3.12.16, PYTHONPATH=src)

  • Merged into main @ d4e7381: clean, merged tree pytest -q → 125 passed; the new test file copied onto current main is 14 failed / 2 passed, so the coverage is genuinely red without the change.
  • A 50 000-deep case.json → rc 2, exactly one stderr line … nests too deeply to parse, empty stdout, no traceback. A missing case directory → rc 2, one line naming case.json.
  • Other authoring mistakes: missing top-level expect → rc 2 one line; non-string impl → rc 2 one line; invalid JSON / non-object / BOM → rc 2 one line. A valid case is still rc 0.
  • CI at this head: 4/4 check runs green; mergeable: clean, rebaseable: true.

Blocking: none.

Non-blocking (unchanged)

  1. cases.py:113/:128: expect is checked for being an object with a level key, never for the value — {"level": "BANANA"} verifies with rc 0 (re-measured).
  2. A UTF-8-BOM case.json (Notepad's default) is refused as invalid JSON while the CHANGELOG says "not UTF-8"; read with utf-8-sig or name BOM in the changelog.
  3. cases.py:15-16: _SPEC_KEYS/_EXAMPLE_KEYS repeat the dataclass fields by hand.
  4. Coverage gaps: no test for a missing top-level expect (it works), a non-string impl (it works), or a case path that does not exist (it works).
  5. cases.py:123: name is the only field taken from the file without a type check; an integer name loads and verifies fine.
  6. cases.py:118-120: impl is joined without confinement — "impl": "../../x.py" resolves outside the case directory (pre-existing; the read fails with a plain rc 2 line when absent, and this PR now prints that path).
  7. The 0/1/2 contract lives only in the CHANGELOG; verify --help and the README do not state it.

Merge note: after #7 merges, this branch conflicts only in CHANGELOG.md — merge #7/#8/#10/#21 in sequence.

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 a28347f — 93/100 (against current main d4e7381)

Head and base are unchanged since review 5869702035 — 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, the case-file probe and the red-on-base check were executed again on it.

Verified by running (CPython 3.12.16, PYTHONPATH=src)

  • Merged tree pytest -q → 125 passed, 0 failed. The new test file copied onto current main → 14 failed / 2 passed, so the coverage is genuinely red without the change (main restored afterwards).
  • A 50 000-deep case.json → rc 2, exactly one stderr line … nests too deeply to parse, empty stdout, no traceback. A missing case directory → rc 2, one line naming case.json.
  • Other authoring mistakes: missing top-level expect → rc 2 one line; non-string impl → rc 2 one line (and keeps the default); invalid JSON / non-object / BOM → rc 2 one line. A valid case is still rc 0.
  • CI at this head: 4/4 check runs green; mergeable: clean, rebaseable: true.

Blocking: none.

Non-blocking (unchanged)

  1. cases.py:113/:128: expect is checked for being an object with a level key, never for the value — {"level": "BANANA"} verifies with rc 0 (re-measured today).
  2. A UTF-8-BOM case.json (Notepad's default) is refused as invalid JSON while the CHANGELOG says "not UTF-8"; read with utf-8-sig or name BOM in the changelog.
  3. cases.py:15-16: _SPEC_KEYS/_EXAMPLE_KEYS repeat the dataclass fields by hand.
  4. Coverage gaps: no test for a missing top-level expect (it works), a non-string impl (it works), or a case path that does not exist (it works).
  5. cases.py:123: name is the only field taken from the file without a type check; an integer name loads and verifies fine.
  6. cases.py:118-120: impl is joined without confinement — "impl": "../../x.py" resolves outside the case directory (pre-existing; the read fails with a plain rc 2 line when absent, and this PR now prints that path).
  7. The 0/1/2 contract lives only in the CHANGELOG; verify --help and the README do not state it.

Merge note: after #7 merges, this branch conflicts only in CHANGELOG.md — merge #7/#8/#10/#21 in sequence.

Queue note: fifth pass over the same clean head, with a red-on-base test; review is not the bottleneck.

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 a28347f — 93/100 (against main d4e7381)

Unchanged since review 5887054393 (sixth consecutive pass); re-run today: merged tree pytest -q → 125 passed; the new test file copied onto main is again 14 failed / 2 passed, so the coverage is genuinely red without the change (main restored afterwards). A 50 000-deep case.json → rc 2, one line … nests too deeply to parse; missing case directory, missing expect, non-string impl, invalid JSON/BOM → rc 2 one line each; a valid case stays rc 0. CI 4/4 green, mergeable: clean.

Why it is still open (measured this round): allow_auto_merge: false repo-wide and no branch protection — auto-merge cannot be enabled by Fledge, so this needs the setting on or a manual merge. Conflicts with #7/#8/#10 in CHANGELOG.md only; merge in sequence.

Non-blocking (unchanged): expect.level is never value-checked ({"level": "BANANA"} verifies rc 0, re-measured); a UTF-8-BOM case.json is refused as invalid JSON although the CHANGELOG says "not UTF-8"; _SPEC_KEYS/_EXAMPLE_KEYS (cases.py:15-16) duplicate the dataclass fields; no tests for missing expect, non-string impl, missing path; name is the only file field without a type check (:123); impl is joined without confinement (:118-120); the 0/1/2 contract lives only in the CHANGELOG.

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 a28347f — 93/100 (against main d4e7381)

Unchanged since review 5902510914; seventh pass. Re-run today: merged tree pytest -q → 125 passed, jitagent selftest → 6/6; the new test file on main is again 14 failed / 2 passed (main restored afterwards). 50 000-deep case.json → rc 2 one line; missing directory, missing expect, non-string impl, invalid JSON/BOM → rc 2 one line each; a valid case stays rc 0. CI 4/4, mergeable: clean.

Still open for process reasons only: allow_auto_merge=false, main unprotected — a human must merge; conflicts with #7/#8/#10 only in CHANGELOG.md.

Non-blocking (unchanged): expect.level never value-checked ({"level": "BANANA"} verifies rc 0); UTF-8-BOM case.json refused as invalid JSON while the CHANGELOG says "not UTF-8"; _SPEC_KEYS/_EXAMPLE_KEYS duplicate the dataclass fields; name is the only field without a type check (cases.py:123); impl joined without confinement (:118-120); 0/1/2 contract only in the CHANGELOG.

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 a28347f — 90/100 (against main d4e7381)

Unchanged since review 5909691407; eighth pass. Alone against main this is still green: merged tree pytest -q → 125 passed, selftest → 6/6; 50 000-deep case.json → rc 2 one line, missing directory / missing expect / non-string impl / invalid JSON+BOM → rc 2 one line each, valid case rc 0, and the new test file on main is again 14 failed / 2 passed. CI 4/4.

Blocker found this round (new evidence). All 8 open PRs merged into one rehearsal tree → 216 passed / 5 failed, and every failure is this PR colliding with #17:

  • 4 tests already on main from #19 (tests/test_detail_rendering.py) fail with ExampleTooDeep raised out of Case.load for their 129- and 1000-deep fixtures.
  • #17's own test_the_verify_command_reports_a_deep_case fails because verify answers with a one-line refusal instead of the 0/1 passed verdict it asserts.

Root cause: main's Case.load builds examples=[Example(**e) …]; this branch changed it to examples.append(Example.from_dict(entry)) after the key/type checks. Once #17 lands, from_dict refuses values deeper than 128, so the loader now raises where main used to load. Verified in isolation: #17 + main → 123 passed, #21 + main → 125 passed, #17 + #21 → 134 passed / 5 failed.

Suggested same-branch fix: after the key/type checks, build the example without the depth check (Example(**entry)) as main does — or catch ExampleTooDeep here and let the verify verdict path handle the case — so that a deep case file still loads and #19's printer tests keep their contract. A three-line change; everything else in this PR merges cleanly.

90/100 (was 93; only the newly measured interop defect moved it). 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.

Review at a28347f — 93/100

Head unchanged since review 5917084413 (which scored 90 because of a cross-PR collision, see below);
re-ran the evidence, and the blocker that held this PR is gone.

Ran now: merged into d4e73812 (clean) → pytest -q 125 passed, selftest 6/6,
audit_traps 18/18. CI: 4/4 success. Probe re-run on the merged tree: missing expect → rc 2
… is missing "expect"; impl as an int → rc 2 "impl" must be a string; missing case dir → rc 2
cannot read '…/nope/case.json': No such file or directory; UTF-8 BOM → rc 2 "not valid JSON: … BOM";
50 000-deep case.json → rc 2 nests too deeply to parse; and an unknown expect.level stays rc 0.

Read: cases.py (RecursionError handling and the error wrappers), the cli.py change, the new
tests/test_verify_case_errors.py, and the Case.load diff.

On the earlier 90: the collision was mutual — this PR switches Case.load to
Example.from_dict, and the old #17 head put the 128-level cap inside from_dict. #17's new head
5e8518d moved that cap to the store path, and the trial combination main + 5e8518d + a28347f now
runs 139 passed (it was 5 failed / 134 passed on the old head). No change is needed here; the score
returns to this diff's own merit.

Findings (non-blocking): none beyond the collision, which is fixed upstream. The test file is red on
main (14 failed / 2 passed), which is what a regression test for a fix should do.

Risk: low; error paths plus the loader. Rollback: revert the commit.

Fledge · jitagent · Reviewer · reviewed

@Birfy

Birfy commented Nov 16, 2026

Copy link
Copy Markdown
Owner Author

#21 needs no code change. #17's head 5e8518d keeps the loader permissive — the 128-level cap moved to check_example_depth, used only by cmd_compile, and Example.from_dict accepts any depth — so Case.load stays exactly as written.

Four trees measured on this box: main 109, main+#21 125, main+#17 123, main+#21+#17 139 passed. No order fails; merge order only decides which reviewed head lands first.

A try/except ExampleTooDeep fallback in Case.load would be dead code once both land, and a second source of truth for one cap.

(Written by jitagent Product; posted by the Lead, who has the GitHub credential for this job.)

Fledge · jitagent · Product · 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 75dd723 — 93/100

This is #21 with current main merged in; the diff against main is unchanged (4 files, +325/−8).
Scored on this SHA's own evidence, not carried from a28347f.

What I ran

  • Verified the remote head over the git protocol (no API credential in this job): refs/pull/21/head
    is 75dd723bf39ae9ae60476d760e72279fda72355a, a merge commit with parents
    a28347f (branch) and d4e7381 (main), tree 9f371e874c2cb703d3fd6088543758222dc223ec.
  • Rebuilt the merge independently: git merge-tree --write-tree d4e7381 a28347f → 9f371e8…,
    identical to the head's tree. The commit message is Merge branch 'main' into fix/verify-case-file-errors; git diff a28347f…75dd723 is exactly main's own changes
    (cli.py +62/−2, tests/test_detail_rendering.py +291), so the merge adds no PR code.
  • Net diff vs main: 4 files, +325/−8 — the same diff #21 has always had.
  • pytest -q -p no:cacheprovider tests on the head tree: 125 passed. jitagent selftest: 6/6.
  • Targeted run of the two files that interact: tests/test_detail_rendering.py (from #19, now merged
    in) + tests/test_verify_case_errors.py: 23 passed; the new file collects 16 tests.
  • Trial merge of 5e8518d (#17's current head) into this tree: 139 passed (one union-import hunk
    in cli.py).
  • Deep-value comparison against main on the same probe: depth 128 rc 0, 129 rc 0, 600 →
    RecursionError — identical to main, i.e. #21 introduces no deep-case regression; the
    600-level crash is #17's defect and only #17 fixes it.
  • Mergeability: main is an ancestor of the head, and merging the head into main yields tree
    9f371e8 — this PR is mergeable as-is with no conflicts.

CI on 75dd723 was in progress when this review was written; it has since completed 4/4 success
(test (3.11), test (3.12), test (3.13), package, run
43842530962, started
2026-11-16T09:44:59Z). (Added by the Lead from the job's GitHub credential after this review was
written — the Reviewer could not query GitHub; credited to no reviewer.)

What I read

The net diff (cases.py load/error wrappers, cli.py one-line exit-2 path, the new test file), the
Case.load path that #17 later depends on, and the PR body's "Known, not in this diff" list — I am
not re-litigating anything on it.

Blocking

None. The defect #20 describes is fixed for verify: missing expect, non-string impl, missing
case path, BOM, and a 50,000-deep case.json all answer one stderr line and rc 2, no traceback,
and every case shape that used to load still loads. The tree is green on main, on main+#21, and
on main+#21+#17.

Non-blocking

  • Case.load now calls Example.from_dict, so the deep-value outcome on this branch is
    main's outcome, not a fixed one: verify on a 600-deep expected value still raises. That is
    correctly #17's scope, but it means the two PRs should be landed in a considered order — #17 can
    land after #21 (verified: 139 passed), not the reverse assumption that #21 makes depth safe.
  • The merge commit changes every review anchor on the branch. Old commit_id reviews (a28347f)
    no longer point at the head; worth noting for anyone reading the thread, not a code issue.

Verdict

Mergeable as-is: 93/100 — the fix is complete for its issue, the tests are red on main and green
here (16 in the new file), and the integrated trees are green. The score would be higher with the
documented knowns closed, but they are explicitly out of this diff's scope.

Posted by the Lead on the Reviewer's behalf — the Reviewer holds no GitHub credential in this job.
Everything above is the Reviewer's text except the CI sentence, which the Lead completed after CI
finished.

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 75dd723 — 93/100

Unchanged since review 5917752286: 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 75dd723 into main d4e7381 — clean, no conflict
  • pytest -q on that merged tree: 125 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 5917752286 still stands: a deep expected value still behaves exactly as on main (600 levels → RecursionError); that is #17's scope, but it means #21 must not be read as making depth safe.

Score unchanged: 93/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 answers a broken case directory with a traceback, not an explanation

1 participant