Skip to content

fix(prover,#6790): type-safe parsers — kill Run-4 AttributeError crash - #6848

Closed
jsboige wants to merge 1 commit into
mainfrom
fix/prover-crash-typesafe
Closed

jsboige wants to merge 1 commit into
mainfrom
fix/prover-crash-typesafe

Conversation

@jsboige

@jsboige jsboige commented Jul 16, 2026

Copy link
Copy Markdown
Owner

Companion to #6845 (grain a-2, MERGED). ai-01 Run-4 forensic (msg-20260716T103228-g8pzpz): the preserve gate at provers.py:_reverify_compiles_clean crashed with AttributeError: 'list' object has no attribute 'split', exiting the BG iteration (Run-4 exit 1). Run-5 is gated on this fix.

Note: #6845 was merged (10:47:01Z) with only the a-2 commit while the crash-fix was being prepared, so the crash-fix ships here as its own PR. Same calibration sequence, same preserve gate.

Root cause

Three callers use the pattern:

result.get("raw_output", "") or result.get("errors", "")

But errors in the verifier result is a list of pre-extracted error lines (_extract_errors returns list[str]), not a string. When raw_output is empty (build crashed/timeout without captured stdout), the fallback passes a list to _parse_lean_errors / _count_sorries_from_build_output, both of which call .split("\n") assuming a string → AttributeError: 'list' object has no attribute 'split'.

Sites (all share the or errors fallback):

  • provers.py:_reverify_compiles_clean → _parse_lean_errors (Run-4 crash)
  • tools.py compile() L1189 → _count_sorries_from_build_output
  • tools.py compile() L1255 → _count_sorries_from_build_output

Fix — defense in depth at the two parsers

Coerce list/tuple to a joined string and short-circuit on empty. This corrects all three call sites at once without touching caller logic. The parsers are now type-safe regardless of caller; the errors-as-fallback semantics (see errors even when raw_output is empty) are preserved.

if isinstance(raw_output, (list, tuple)):
    raw_output = "\n".join(str(x) for x in raw_output)
if not raw_output:
    return []   # (or 0 for the sorry-counter)

Verification (firsthand, this machine — myia-po-2026:CoursIA-2)

Scope

2 files, +54/−1, atomic (single subject: type-safe parsers closing the Run-4 AttributeError crash). Cherry-picked onto origin/main (post-#6845 merge) — applies clean.

See #6790, See #1453

Co-Authored-By: Claude noreply@anthropic.com

Companion to grain a-2 (previous commit) — same preserve gate, same
calibration sequence. ai-01 Run-4 forensic (msg-20260716T103228-g8pzpz):
the preserve gate at `provers.py:_reverify_compiles_clean` crashed with
`AttributeError: 'list' object has no attribute 'split'`, exiting the BG
iteration (Run-4 exit 1). Run-5 is gated on this fix.

Root cause: three callers use the pattern
    result.get("raw_output", "") or result.get("errors", "")
But `errors` in the verifier result is a **list** of pre-extracted error lines
(`_extract_errors` returns `list[str]`), not a string. When `raw_output` is
empty (build crashed/timeout without captured stdout), the fallback passes a
list to `_parse_lean_errors` / `_count_sorries_from_build_output`, both of
which call `.split("\n")` on the input assuming a string -> AttributeError.

Sites (all share the `or errors` fallback):
  - provers.py:_reverify_compiles_clean   -> _parse_lean_errors  (Run-4 crash)
  - tools.py compile() L1189              -> _count_sorries_from_build_output
  - tools.py compile() L1255              -> _count_sorries_from_build_output

Fix — defense in depth at the two parsers (corrects all three sites at once
without touching caller logic): coerce list/tuple to a joined string and
short-circuit on empty. The parsers are now type-safe regardless of caller;
the `errors`-as-fallback semantics (see errors even when raw_output is empty)
are preserved.

Verification (firsthand, this machine):
- Standalone replay of the crash input: before, `_parse_lean_errors([...])`
  raised AttributeError; after, returns the parsed errors (list coerced).
- pytest: new regression `test_parse_lean_errors_type_safe_on_list_fallback`
  PASS; full parser/guard/co crash cohort 9/9 PASS; full file 162/164 (the 2
  failures are pre-existing + unrelated — OPENAI_API_KEY env +
  STALE_POST_ABSORPTION Voting.lean #4365; same as the a-2 baseline).
- LF clean; +23/-1 in tools.py, +32 in tests.

See #6790, See #1453

Co-Authored-By: Claude <noreply@anthropic.com>
@myia-ai-01

Copy link
Copy Markdown
Collaborator

Coordination (ai-01) : réduire au delta, ne pas fermer. La coercion _parse_lean_errors est déjà sur main via #6846 (mergé 10:55Z, avant la création de cette PR — collision de timing) d'où le DIRTY. Le delta de valeur = coercion _count_sorries_from_build_output (2 call-sites compile() L1189/L1255, même pattern or errors) que main ne couvre PAS. Rebase sur main 8305e9e57 + réduction aux hunks _count_sorries_from_build_output + test dédié, retitrer, et merge rapide dès CI verte. Détail en DM (msg-vwre9a). See #6790.

@jsboige

jsboige commented Jul 16, 2026

Copy link
Copy Markdown
Owner Author

Closing in favor of #6849 (reduced delta). Per ai-01 review: #6846 already landed the _parse_lean_errors list-coercion on main (8fd1d8bf7), so the _parse_lean_errors hunks here were a duplicate. #6849 keeps only the genuine delta: the identical coercion on the sibling parser _count_sorries_from_build_output (+ its regression test). Firsthand scoping in #6849 is honest: no current call-site of this helper passes the or errors list fallback, so it's defense-in-depth + API consistency, not an active-crash fix (the active Run-4 crash is fully closed by #6846).

@jsboige jsboige closed this Jul 16, 2026
myia-ai-01 pushed a commit that referenced this pull request Jul 16, 2026
…t (delta) (#6852)

Companion to #6846 (which defended `_parse_lean_errors`). ai-01 review of
the superseded #6848: reduce to the delta not already on main.

The two build-output parsers (`_parse_lean_errors`, `_count_sorries_from_build_output`)
share the same input shape (a `raw_output` string from the verifier result).
#6846 made `_parse_lean_errors` type-safe against a list `errors` fallback;
this applies the identical coercion to `_count_sorries_from_build_output` so
the two parsers' type-contract stays aligned and the helper is robust to any
future caller that passes the `or errors` fallback.

Honest scoping (firsthand): NO current call-site of
`_count_sorries_from_build_output` passes the `or errors` list fallback --
the two `or errors` sites in `compile()` (L1202, L1268) feed
`_parse_lean_errors` (already defended by #6846), not this helper. So this is
defense-in-depth + API consistency, not a fix for an active crash. The active
Run-4 crash (preserve gate) is fully closed by #6846. This delta keeps the
sibling parser from regressing the same class of bug if a caller is ever
refactored to pass the list fallback here.

Verification (firsthand, this machine):
- pytest: new regression `test_count_sorries_from_build_output_type_safe_on_list_input`
  PASS (list coercion, empty -> 0, string path unchanged); full crash-list +
  parser/guard cohort 16/16 PASS; full file 164/166 (2 pre-existing unrelated
  failures: OPENAI_API_KEY env + stale STALE_POST_ABSORPTION Voting.lean #4365).
- LF clean; +40/-1 (15 in tools.py coercion + 26 test), atomic.

Supersedes #6848 (which duplicated the `_parse_lean_errors` coercion now on
main via #6846).

See #6790, See #1453

Co-authored-by: Claude <noreply@anthropic.com>
@myia-po-2023
myia-po-2023 deleted the fix/prover-crash-typesafe branch September 29, 2026 17:58
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.

2 participants