Repository navigation
fix(core-engine): Rosetta sweep batch 2 — nine slicer/regex/DAG fixes (Gemini-implemented) - #2662
Merged
Merged
Conversation
Both languages have zero brace-delimited bodies (tab-indented recipes; procedure X is begin ... end X;) but were absent from the Mode_A_Labels tuple, silently falling through to Mode_B_Braces and dropping 100% of their real func_start matches from the function census (0/14 makefile, 0/13 ada on the rosetta corpus). Same defect class as the already-fixed jcl/m4/yacc/dockerfile/abap entries (#1975 lineage). Implemented by Gemini via the agy dispatch pattern; independently verified (259 passed). Co-Authored-By: Claude Fable 5 <[email protected]>
…#2649) _slice_by_indentation drops any sliced block under 2 lines unless the language is in a hardcoded exemption tuple. yaml was missing, so every single-line GitHub Actions step (- run: pytest) -- the dominant real-world form -- was silently dropped from the function census (rosetta corpus: functions_found 3 vs 13 func_start matches). Add yaml to the exemption tuple. Implemented by Gemini via the agy dispatch pattern (regex fix only); regression test added and independently verified here (265 passed; confirmed the new test fails 1/2 on pre-fix code). Co-Authored-By: Claude Sonnet 5 <[email protected]>
…ader (#2650) abap's doc rule matched a bare AUTHOR: alternative that ownership already owns exclusively, so one physical header line double-counted doc+ownership (rosetta corpus: doc=2 vs 1 planted). Remove AUTHOR from doc's alternation; DESCRIPTION/PURPOSE/REMARKS remain since they are genuine doc-idiom tags that don't collide with ownership. Implemented by Gemini via the agy dispatch pattern; independently verified here (131 passed). Co-Authored-By: Claude Sonnet 5 <[email protected]>
Both languages' globals rules anchored on ^[ \t]* -- any line-start indentation -- so function-local var/const declarations counted as globals (rosetta corpus zig: globals 5 vs 2 planted, +150%). Anchor changed to ^(?![ \t]) (true column-0) in both files. Implemented by Gemini via the agy dispatch pattern; independently verified here (328 passed, 2 skipped, 6 xfailed -- no regressions). Co-Authored-By: Claude Sonnet 5 <[email protected]>
…re-identifier match (#2656) The api rule's bare-identifier alternative lacked the keyword-exclusion negative lookahead that func_start/args already carry in this file, so param(/if (/switch (/etc. lines miscounted as API surface (rosetta corpus: risk_api_exposure +82%, raw signals otherwise in-band). Added the same exclusion set func_start/args already use. Implemented by Gemini via the agy dispatch pattern. Independently verified: fixed one bad test assertion (hyphenated 'Get-Foo (' was never matched by the bare-identifier alternative's [a-zA-Z_]\w* even pre-fix -- confirmed against the original regex -- so the test used a non-hyphenated identifier instead). 157 passed. Co-Authored-By: Claude Sonnet 5 <[email protected]>
…half) The bare 'return <ident>' alternative for lua's module-export idiom (return M at end of module) allowed any-indentation, so ordinary function-body returns false-positived as API surface (rosetta corpus: risk_api_exposure +110%, worst deviation in the sweep). Anchored to column 0. Scope note: the orphan-conversion/scoring half of #2657 is deliberately untouched here -- regex fix only. Implemented by Gemini via the agy dispatch pattern (source only); regression test added and independently verified here (120 passed; confirmed the new test fails on pre-fix code). Co-Authored-By: Claude Sonnet 5 <[email protected]>
…ng counts once (#2658) The doc rule matched opening and closing """/''' delimiters independently with no pairing, so one docstring counted doc=2 (rosetta corpus: doc=2 vs 1 planted, both languages). Match the full delimited span as a single bounded (0,15000 chars) non-greedy hit instead. Implemented by Gemini via the agy dispatch pattern; a later edit pass corrupted both files into a syntax error (an r-string literal embedded incorrectly) -- restored from the .orig backups Gemini's own editor left behind, which held the correct fix with its BUG FIX comment intact. Regression tests were also missing (only stray blank-line diffs); added here, including a ReDoS timing probe against an unterminated 200k-char delimiter (0.007s -- safe). Independently verified: 349 passed; confirmed both new tests fail on pre-fix code. Co-Authored-By: Claude Sonnet 5 <[email protected]>
scheme had no _dependency_capture at all -- its import regex fed only
the 'import' signal, never a DAG edge, so popularity stayed 0 for every
file and the orphan->api conversion could never fire (rosetta corpus:
dependency_links 0 vs 3 planted; risk_tech_debt +100% as a downstream
consequence). Added a capture for R7RS (import (scheme base)) /
Guile (use-modules (ice-9 x)) library-list forms.
Implemented by Gemini via the agy dispatch pattern; the original regex
only handled the parenthesized R7RS library-list form and did not
match the rosetta corpus's actual bare shell convention ((import a),
no inner parens) -- confirmed by testing it against the real corpus
files, all three came back with zero matches. Rewrote the capture
group to handle both forms with a bounded {0,6} component repeat
(no nested unbounded quantifiers); added the bare-form cases to the
test file; empirically verified the full main->a->b->c chain now
resolves against the real rosetta corpus. 120 passed.
Co-Authored-By: Claude Sonnet 5 <[email protected]>
…hip owns it exclusively (#2659) livecode's doc rule included a bare Author: tag that ownership already owns exclusively, so every header author line double-counted doc+ ownership (rosetta corpus: doc=2 vs 1 planted). Fixed livecode, then audited every language whose doc alternation contains Author/@author: agc_assembly and fortran share the identical bare-colon-tag collision (fixed); apex's @author and javadoc-family @author are genuine structured doc-comment tags with the @ prefix, left untouched. html: dropped bare 'author' from the meta name= doc alternative (same collision with html's own ownership rule, which already captures meta name=author). Scope note: cobol was found to share the same textual pattern but was DELIBERATELY EXCLUDED here -- its rosetta corpus shell (main.cbl) has no other doc-idiom content, so removing AUTHOR from doc would drop its doc signal to 0, not 1 (breaking a live corpus expectation rather than deduping one). That needs a corpus-side fix (plant a real doc-idiom line) before any engine change; filing separately rather than bundling an unverified consequence into this batch. Implemented by Gemini via the agy dispatch pattern (which also touched abap.py identically to the already-committed #2650 fix -- dropped here as a duplicate). Independently verified per language: read each touched language's ownership rule to confirm it still captures every real corpus Author/author line (agc_assembly, fortran, html, livecode all confirmed); empirically re-ran doc counts against the real rosetta corpus files (agc_assembly=1, fortran=1, matching planted intent; html/livecode drop from the old buggy 2 to the correct 1, both will need a rosetta corpus re-baseline in the follow-up PR). 711 passed. Co-Authored-By: Claude Sonnet 5 <[email protected]>
…gex line length) Co-Authored-By: Claude Sonnet 5 <[email protected]>
Regenerated both fixtures (crucible_check.py --update --yes) after the nine fixes in this branch. Verified every non-topological field-level diff (2831 total per fixture) traces cleanly to one of the nine changes by cross-checking file extension against leaf field: - ps1/psm1 (powershell, #2656) and lua (#2657): API Exposure, Public Exports, Structural Magnitude, Documentation Exposure - py/pyx/pxd (python, #2658), F (fortran, #2659), agc (agc_assembly, #2659), html (#2659): Structured Documentation Blocks, Documentation Exposure, downstream Cognitive Load / Error & Exception Exposure (doc_coverage feeds signal_processor.py's cog-load cooling factor, per docs/wiki/08-05) - zig/dart (#2651): Global State Dependencies (the globals count itself) - makefile (#2648): Makefile.pre.in in the c/cpython corpus jumps from 1 to 244 extracted functions -- the single most dramatic before/after in this regen, and exactly the severity #2648 predicted (a large real Makefile was previously ~100% invisible to the function census) - scheme (#2652): racket/cpnanopass.ss gains 6 real dependency edges The remaining 1942/2831 diffs (X/Y/Z topological coordinates) are the expected global ripple: spatial_mapper's graph embedding recomputes every node's layout position whenever any file's signal profile changes anywhere in the corpus, not just the changed files themselves. Both fixtures verified structurally identical in diff shape (2831 field diffs each, same distribution). No unexpected language/extension appeared in any non-coordinate field. Co-Authored-By: Claude Sonnet 5 <[email protected]>
--all --write regen per repo convention after an engine change. Chart SVG is byte-identical (zero badge/verdict changes); ledger diff is 211 last_reconciled_at timestamp bumps plus one unrelated ctags anonymous-class-naming noise diff on php (not one of this batch's languages). None of the nine fixed languages had an open ledger entry these changes touch. 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
Second Rosetta-corpus sweep batch, implemented via Gemini/agy dispatches (
gemini-analyzer/tree-sitter-accuracy-sweeppattern) and independently verified/committed here. Fixes nine engine issues surfaced by the #2560 classification sweep that followed #2641.Function-census / slicer bugs
detector.py'sMode_A_Labelstuple, silently falling through toMode_B_Bracesand dropping ~100% of real functions (rosetta corpus: 0/14 makefile, 0/13 ada). Added both to the tuple, matching the existing yacc/jcl/m4/dockerfile/abap precedent. On the real crucible corpus,c/cpython/Makefile.pre.ingoes from 1 to 244 extracted functions — the clearest evidence of severity in this batch._slice_by_indentation's 2-line function-body floor lacked a yaml exemption, dropping every single-line GitHub Actions- run:step — the dominant real-world form (rosetta corpus: functions_found 3 vs 13 func_start matches). Added yaml to the exemption tuple.doc/ownership double-counting
docrule included a bareAUTHOR/Author:alternative that theownershiprule already owns exclusively, so every header author line double-counted both signals. RemovedAUTHORfromdocin all four; verified each language'sownershiprule still captures every real corpus author line. cobol shares the identical pattern but is deliberately excluded — its rosetta shell has no other doc-idiom content, so the same fix would drop its doc signal to 0 (not dedupe it to 1); needs a corpus-side doc line planted first (filed as cobol: doc rule's AUTHOR-vs-ownership collision needs a corpus-side doc line planted before the engine fix (#2659 follow-up) #2661).<meta name="author">, which html's ownownershiprule already captures.docmatched opening and closing"""/'''delimiters independently with no pairing, so every docstring counted twice. Rewrote as a single bounded (0–15000 char) non-greedy span match; ReDoS-probed against a 200k-char unterminated delimiter (0.007s).api-exposure false positives
api's bare-identifier alternative lacked the keyword exclusionsfunc_start/argsalready carry in the same file, soparam(/if (/switch (miscounted as API surface (risk_api_exposure +82%). Added the same exclusion set.return <ident>alternative allowed any indentation, so ordinary function-body returns miscounted as module exports (risk_api_exposure +110%, worst deviation in the sweep). Anchored to column 0. Regex fix only — the scoring/orphan-conversion half stays out of scope.Other
globalsanchored on^[ \t]*(any indentation), so function-local declarations counted as globals (zig: +150%). Anchored to true column 0 in both. Follow-up audit found 11 more languages sharing the same shape, filed separately (globals rule audit: 11 more languages share zig/dart's ^[ \t]* any-indentation anchor (#2651 follow-up) #2660)._dependency_captureat all — the whole dependency DAG was invisible, and popularity staying 0 blocked the orphan→api conversion (risk_tech_debt +100% as a downstream consequence). Added a capture handling both the rosetta corpus's bare(import a)form and real R7RS/Guile library-list forms — the first Gemini draft only handled the latter and silently matched nothing on the actual corpus files, caught by testing against them directly. On the real crucible corpus,scheme/racket/cpnanopass.ssgains 6 real dependency edges.Verification
Every fix independently verified beyond the implementing model's own report, per the dispatch pattern's stated distrust of self-reported "all green":
.origbackup), a regex that didn't match the real corpus shape in scheme: no _dependency_capture — whole DAG missing, and orphan->api conversion can never fire (tech-debt systematically inflated) #2652 (rewritten and empirically verified against the actual files), a duplicate abap.py change from livecode (+~14 siblings): doc rule claims 'Author:' which ownership already owns — every header author line double-counts (ada has the correct pattern) #2659's cross-language audit (dropped — already landed via abap: doc regex's bare AUTHOR:/DESCRIPTION: alternative double-counts the ownership header line (doc 2x planted) #2650), and cobol excluded from livecode (+~14 siblings): doc rule claims 'Author:' which ownership already owns — every header author line double-counts (ada has the correct pattern) #2659 after its consequence (dropping doc to 0, not 1) was traced against the live corpus manifest.audit_check.py: ruff/mypy/dead-key/ast-accuracy all clean (two files neededruff formatafter merge — a ruff version mismatch first produced 67 spurious reformats; re-ran with the CI-pinnedruff==0.16.0and got the real 2).Golden masters
Re-blessed (
crucible_check.py --update --yes, both modes). Verified every non-topological field-level diff (2831 per fixture) by cross-referencing file extension against the changed field — all trace cleanly to the nine languages above (doc/api/globals/dependency fields on exactly ps1/psm1/lua/py/pyx/pxd/F/agc/html/zig/dart/makefile/ss files). The remaining 1942/2831 diffs are topological X/Y/Z coordinates —spatial_mapper's graph embedding recomputes every node's layout whenever any file's signal profile changes anywhere in the corpus, not evidence of unrelated drift. No unexpected language or extension appeared in any non-coordinate field. Tri-comparison chart also regenerated (--all --write); SVG is byte-identical, ledger diff is purelast_reconciled_attimestamps plus one unrelated PHP ctags anonymous-class-naming artifact.Notes for reviewers
Author-vs-doc scope decisions left for each language are all filed as explicit follow-ups rather than silently expanded into this PR.Fixes #2648
Fixes #2649
Fixes #2650
Fixes #2651
Fixes #2652
Fixes #2656
Fixes #2657
Fixes #2658
Fixes #2659
🤖 Generated with Claude Code