Repository navigation
fix(python): stop io/test rules double-counting globals/safety keywords (#2593) - #2626
Merged
Merged
Conversation
…ds (#2593) Two keyword-overlap bugs found while sweeping python's rosetta cross-language consistency deviations (#2593, epic #2560): - `io`'s `os\.`/`sys\.` matched ANY os./sys. attribute access, overlapping `globals`' own `os.environ`/`sys.argv`/`sys.path` -- a planted globals read was double-counted as io too. Negative lookaheads now carve out exactly those three tokens; os.path/os.remove/sys.stdin/etc. still count as io. - `test` included bare `\bassert\b`, already owned by `safety` -- a runtime invariant check in production code (no test framework involved) was miscounted as a testing signal. Removed; unittest/pytest/TestCase/fixture/ patch/def test_/Mock already cover real testing idioms without it. keyword-rosetta corpus measured: a.py io 3->1, test 3->2 (now matches planted intent exactly). Live deviation count: 5 red / 3 amber -> 4 red / 3 amber. Ledger entries os-sys-prefix-overlaps-io (resolved for python) and assert-overlaps-safety-and-test (python removed, still reproduces for c/perl) updated in keyword-rosetta#TBD. Golden masters re-blessed (test/io signal drift in python-classified files across the crucible corpus + downstream risk-percentage reflows, expected shape). tri-comparison --ci: no func/class precision regression. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Contributor
squid-protocol
added a commit
to squid-protocol/keyword-rosetta
that referenced
this pull request
Sep 1, 2026
Engine PR squid-protocol/gitgalaxy#2626 removes two keyword-overlap bugs in python's io/test rules (os./sys. no longer double-counts globals' os.environ/sys.argv; assert no longer double-counts safety). Re-baselining here per the rosetta-language-sweep skill's Phase 3-5: - data/python/expected_signals.json: a.py io 3->1, test 3->2, notes updated to point at the engine fix instead of baking in the old cross-contamination - deviation_ledger.json: os-sys-prefix-overlaps-io resolved for python (still_reproduces: false, languages_seen now empty); assert-overlaps- safety-and-test has python removed from languages_seen (still reproduces for c/perl, their own rule files untouched) - ENGINE_REF pinned to pull/2626/head until the engine PR merges - docs/bias_data.json, bias_report.md, bias_variance_chart.svg, findings_by_language.md regenerated via tools/bias_report.py -- only python's cells moved (io 6->4, keyword_hits 244->241); every other language's numbers are byte-identical to before Verified: tools/verify_language.py python -- PASS, 80 assertions. python: 5 red / 3 amber -> 4 red / 3 amber (tools/language_deviations.py). Cross-repo: companion engine PR squid-protocol/gitgalaxy#2626. Reset ENGINE_REF to main and merge this PR only after #2626 is approved, per docs/ecosystem.md's rosetta-sweep choreography (gitgalaxy PR merges last, bumping KEYWORD_ROSETTA_REF to this repo's post-merge commit). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This was referenced Sep 1, 2026
Closed
squid-protocol
added a commit
that referenced
this pull request
Sep 1, 2026
…sweep) (#2630) Third rosetta capstone after jcl.md/cobol.md §10 (numbered §11 here — this doc already uses §10 for its tri-comparison section). Records the #2593 sweep: #2626's io/test overlap fixes, the bucket-5 residuals pinned to #2546/#2535/#2625, and why the issue stays open. Claude-Session: https://claude.ai/code/session_01BsVATdyMPhUoAUNBKbMUVi Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
This was referenced Sep 7, 2026
squid-protocol
added a commit
that referenced
this pull request
Sep 7, 2026
… guard is safety's, a qualifier is not a second hit (#2852 contract, roadmap Phase 3) (#2854) Contract stated (docs/test_rule_contract.md, sheet row 6/68): one hit is a site that engages a testing framework -- a test-case or fixture declaration, a framework assertion or expectation call, or the framework itself named -- in a form an ordinary identifier cannot match; the language's own runtime guard is safety's hit, never test's. The three open-defect cells were two diseases: c and embedded_python counted safety's planted runtime assert (C1 -- the #2626 python resolution, never applied to c or the twin), and perl's Test::More::ok($kit) fired twice, module name + ok( call form (C2, (?!::) guard). Crucible-measured C3/C1 misfires fixed with no cell movement: lua's bare assert (3471->134, luassert chain assert.<chain> added), dart's bare test/group (predicate parameter, loop variable -- description-string anchor + corpus re-plant), php's bare test/mock (Twig ->test(, $mock -- call-form anchors), cobol's TEST-CASE inside hyphenated identifiers (#2622 shape, hyphen guards). Every corpus language reads test = 2; rosetta_audit 46/46 against the companion corpus branch. Bless scope: test + verification/safety_score formulas only; newly parsed/excluded none. Deferred residue filed as #2853. Closes #2852 Claude-Session: https://claude.ai/code/session_01VnsC1A6TUhGS5QcmM7fg8L Co-authored-by: Claude Opus 4.8 <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
io: negative-lookaheados\.(?!environ\b)/sys\.(?!argv\b|path\b)soos.environ/sys.argv/sys.path(owned byglobals) no longer double-count asio. Realos./sys.I/O calls (os.path,os.remove,sys.stdin, ...) still match.test: dropped\bassert\b(already owned bysafety) — a bareassertin production code is a validation signal, not a testing-framework signal.unittest/pytest/TestCase/fixture/patch/def test_/Mockare untouched.Found while sweeping python's rosetta cross-language-consistency issue (#2593, epic #2560), classified via the
rosetta-language-sweepskill's bucket taxonomy as real keyword-overlap bugs (not intended morphology) — both were already documented, unowned findings in keyword-rosetta'sdeviation_ledger.json(os-sys-prefix-overlaps-io,assert-overlaps-safety-and-test).Measured effect
keyword-rosetta
data/python/a.py:io3→1,test3→2 — both now match planted intent exactly (tools/verify_language.py python: PASS, 80 assertions). Live cross-language deviation count for python: 5 red / 3 amber → 4 red / 3 amber (tools/language_deviations.py python).safety/state_mutation/doc/comment_linesare untouched — classified as median-inflation-elsewhere or out of scope for this PR (see #2593 update comment).While triaging this, also found and filed a separate cross-cutting issue (#2625, not fixed here):
comment_linesconflates blank lines with real documentation lines engine-wide (total_locincludes blanks,coding_locdoesn't) — python's corpus files just have an unusually high blank-line ratio, which is why it surfaces loudest there.Also adds the keyword-rosetta capstone section (§11) to
docs/language_status/python.md.Cross-repo
ENGINE_REFpinned topull/2626/head.rosetta-auditon this PR fails, and that's expected — it checks out keyword-rosetta at the pinnedKEYWORD_ROSETTA_REF(stillmain, i.e. the pre-fix manifest) against this PR's engine build, so it correctly catches the io/test drift at the source (a.py: io expected 3, got 1,a.py: test expected 3, got 2). Resolves once keyword-rosetta#13 merges and this PR bumpsKEYWORD_ROSETTA_REFto that commit, perdocs/ecosystem.md's rosetta-sweep choreography. Do not merge this PR until then.Test plan
pytest tests/extraction/languages/test_python_strict.py tests/extraction/languages/test_python.py— 176 passed, new regression tests added (test_python_io_excludes_globals_overlap,test_python_test_excludes_bare_assert, plus 5 new parametrized cases)pytest tests/— 7169 passedruff_audit.py --ci/mypy_audit.py --ci— no new findingscrucible_check.py— PASS on both full_precision and zero_dependency after re-blessing (321 diffs, alltest/iosignal drops in python-classified files + downstream risk-percentage reflows — reviewed, expected shape, nothing outside python)tri_comparison_chart.py --all --ci— no func/class precision regressionkeyword-rosetta tools/verify_language.py python— PASSrosetta-audit(expected per above)🤖 Generated with Claude Code