Skip to content

fix(core-engine): Rosetta sweep batch 2 — nine slicer/regex/DAG fixes (Gemini-implemented) - #2662

Merged
squid-protocol merged 21 commits into
mainfrom
fix/rosetta-batch-2648-2659
Sep 2, 2026
Merged

squid-protocol merged 21 commits into
mainfrom
fix/rosetta-batch-2648-2659

Conversation

@squid-protocol

Copy link
Copy Markdown
Owner

Summary

Second Rosetta-corpus sweep batch, implemented via Gemini/agy dispatches (gemini-analyzer/tree-sitter-accuracy-sweep pattern) and independently verified/committed here. Fixes nine engine issues surfaced by the #2560 classification sweep that followed #2641.

Function-census / slicer bugs

doc/ownership double-counting

api-exposure false positives

Other

Verification

Every fix independently verified beyond the implementing model's own report, per the dispatch pattern's stated distrust of self-reported "all green":

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 pure last_reconciled_at timestamps plus one unrelated PHP ctags anonymous-class-naming artifact.

Notes for reviewers

Fixes #2648
Fixes #2649
Fixes #2650
Fixes #2651
Fixes #2652
Fixes #2656
Fixes #2657
Fixes #2658
Fixes #2659

🤖 Generated with Claude Code

squid-protocol and others added 21 commits September 2, 2026 07:32
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]>
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]>
@squid-protocol squid-protocol added the core-engine Modifications to the central physics and parsing engine label Sep 2, 2026
@github-actions

github-actions Bot commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

🐦‍⬛ Muninn Security Scan

✅ No security issues found.

🐦‍⬛ Powered by Muninn · Skald Lab

@squid-protocol
squid-protocol merged commit 6feb8cb into main Sep 2, 2026
42 of 43 checks passed
@squid-protocol
squid-protocol deleted the fix/rosetta-batch-2648-2659 branch September 2, 2026 12:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment