Repository navigation
fix: compile-gate mutated children and guard invalid OR patterns - #892
Merged
Merged
Conversation
Health analysis of a session run (~/runs/jit_run12) showed 37.5% of
ignored_crash events (2,150 of 5,738) were children that failed at
compile() in the executor and never ran — 0 coverage, 0 JIT trace, pure
wasted executions that also counted toward sterility.
The mutation pipeline validated children only via ast.parse/ast.unparse
round-trips, which do NOT catch match-statement semantic errors — only
compile() does. Two dominant offenders:
- "alternative patterns bind different names" (1,880): from
PatternMatchingChaosMutator._add_pattern_complexity wrapping a
name-binding pattern in `case P | [_]:`.
- "mapping pattern checks duplicate key" (252): from a constant mutator
flipping a key in `case {'x': _, 'y': _}:`.
Two fixes:
1. prepare_child_script now compile()s the generated core and skips the
mutation on SyntaxError (logging a core_code_syntax_error health
event), killing the entire class cheaply — compile() is far cheaper
than the wasted subprocess run it prevents. SyntaxWarnings are
suppressed during this side-effect-free validation.
2. _add_pattern_complexity now skips patterns that capture any name,
since the alternatives it adds bind none.
Adds TestCompileGate and _add_pattern_complexity/_pattern_binds_names
tests. Full suite: 2182 passed; mypy clean.
Closes #891
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
~/runs/jit_run12(session-fuzz) found 37.5% ofignored_crashevents (2,150 of 5,738) were children that fail atcompile()in the executor and never run — 0 coverage, 0 JIT trace, pure wasted executions that also count toward sterility/coldness.ast.parse/ast.unparseround-trips, which do not catch match-statement semantic errors — onlycompile()does. Dominated byalternative patterns bind different names(from_add_pattern_complexitywrapping a name-binding pattern incase P | [_]:) andmapping pattern checks duplicate key(from a constant mutator flipping a key incase {'x': _, 'y': _}:).prepare_child_scriptnowcompile()s the generated core and skips the mutation onSyntaxError, logging acore_code_syntax_errorhealth event.compile()is far cheaper than the wasted subprocess run it prevents, and it kills the entire class (both variants + any future semantic-SyntaxError generator). SyntaxWarnings are suppressed during this side-effect-free validation._add_pattern_complexitynow skips patterns that capture any name, since the alternatives it adds bind none.Test plan
TestCompileGate: a child that round-trips throughast.parsebut failscompile()is rejected (returnsNone, records the health event); a valid child passes and the assembled child compiles._pattern_binds_namesdetection (capture / star / mapping-rest);_add_pattern_complexityskips name-binding patterns and still wraps non-binding ones — both outputs compile.mypy lafleurclean (38 files);ruff check/ruff formatclean.Closes #891
🤖 Generated with Claude Code