Repository navigation
Close #606: strict tests for python, fix a real comprehensions bug found along the way - #633
Merged
Merged
Conversation
…und along the way Full positive/negative/ambiguity/ReDoS coverage for all 44 checklisted structural signatures python defines (per epic #518's per-language scaffold), plus a systematic ambiguity sweep and ReDoS sweep across every non-None pattern in the language (both clean beyond what's already tested). One real, currently-shipping bug surfaced while writing the tests: `comprehensions` was `\.(?:map|filter|reduce|flatMap|...)\s*\(` -- JavaScript's Array-method idiom, copy-pasted in by mistake. Python has no builtin `.map(`/`.filter(` list methods; it has comprehension syntax (`[x for x in y]`, `{k: v for k, v in items}`, generator expressions). The old pattern never matched a single real Python comprehension and only fired incidentally on unrelated methods sharing a name (e.g. a Django queryset's `.filter(active=True)`). Confirmed via the golden-crucible corpus: real comprehension detection went from a flat 0 to 1-9 per file across the python corpus (previously always zero, now correctly nonzero). javascript/typescript's own copies of this pattern are correct as-is -- only python's was wrong -- confirmed by checking all 3 languages sharing the exact pattern text before touching anything. Fixed using the same (already ReDoS-bounded, from an earlier fix this session) pattern shape as `embedded_python`'s correct comprehensions rule. Golden master fixtures (both full-precision and zero-dependency) updated via the sanctioned tests/tools/update_golden_master.py and reviewed before blessing: all drift confined to python files, zero signal-count collapse. Full suite (1025 tests), ruff audit, mypy audit, and both golden-crucible modes pass. Closes #606. Co-Authored-By: Claude Sonnet 5 <[email protected]>
Contributor
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
Full positive/negative/ambiguity/ReDoS test coverage for all 44 checklisted structural signatures
pythondefines (per epic #518's per-language scaffold), plus a systematic literal-keyword ambiguity sweep and a generic ReDoS sweep across every non-None pattern in the language (both came back clean beyond what's already tested).Bug found and fixed
comprehensionswas matching JavaScript's idiom, not Python'sThat's JavaScript's Array-method chain (
.map(,.filter(, etc.) -- copy-pasted in by mistake. Python has no builtin.map(/.filter(list methods; it has comprehension syntax ([x for x in y],{k: v for k, v in items}, generator expressions). The old pattern never matched a single real Python comprehension and only fired incidentally on unrelated methods that happen to share a name (e.g. a Django queryset's.filter(active=True)).Confirmed via the golden-crucible corpus: real comprehension detection went from a flat
0to1-9per file across the python corpus (previously always zero, now correctly nonzero).Before touching anything, I checked whether
javascript/typescriptshare this exact pattern text too (they do) -- confirmed those two are correct as-is (.map(/.filter(really is their idiom), so only python's copy needed fixing. Fixed using the same pattern shape asembedded_python's already-correct (and already ReDoS-bounded, from an earlier fix this session) comprehensions rule.Sweeps run (both clean)
high_risk_execution/reflection_metaprogrammingsharing "call",exfiltration_camouflage/telemetrysharing "log") don't actually cross-fire.Golden master fixtures
Updated both fixtures via the sanctioned
tests/tools/update_golden_master.py, reviewed before blessing: all ~856 diffs confined to python files (confirmed by checking every mismatch path), zero signal-count collapse anywhere.Test plan
pytest tests/-- 1025 passedpython tests/ruff_audit.py --ci-- cleanpython tests/mypy_audit.py --ci-- cleanpytest -m golden_crucible-- passes in both full-precision and zero-dependency modes after fixture regenerationCloses #606.
🤖 Generated with Claude Code