Repository navigation
Description
Summary
StructuralExtractor._count_top_level_args (gitgalaxy/core/detector.py, around line 3770) has a guard meant to exempt Rust lifetimes ('_, 'static) and Scala symbols from its string-literal scanner:
elif ch == "'":
if getattr(self, "language", "") in ("rust", "scala") and re.match(
r"[a-zA-Z_]\w*\b(?!')", body[i + 1 :]
):
# It's a Rust lifetime or Scala symbol (e.g. `'a>`, `'_ `), not a string literal
pass
else:
in_string = True
quote_char = chself.language is never set anywhere in the class -- the actual attribute is self.primary_lang_id (set at line 497: self.primary_lang_id = lang_id.lower() if lang_id else "unknown"). Confirmed via grep: self.language has zero other references in the file. The getattr(self, "language", "") therefore always falls back to "", so "" in ("rust", "scala") is always False -- this exemption has never fired, for any language, since it was written.
Effect
Every lifetime mark in a Rust (or Scala) function signature gets misread as opening an unterminated string literal, which swallows every subsequent top-level comma until either a real closing quote appears later in the signature or the string never closes -- fusing 2+ real parameters into 1, or (with an odd number of lifetime marks in one signature) undercounting everything after the last one.
Confirmed repro
Found via tests/tools/tri_comparison_ledger.json's rust/function/args/agree[none]_vs[gitgalaxy,tree_sitter] shape (21 occurrences, tree-sitter and ctags both agree with the real signature, GitGalaxy alone is wrong every time) -- dispatched investigation + independent confirmation in the same session. Real signatures, language-crucible/data/rust/:
bevy/bevy_ecs_world.rs:1106spawn_at_with_caller:(&mut self, entity: Entity, bundle: MovingPtr<'_, B>, caller: MaybeLocation)-- real 4 args, GitGalaxy reports 3 (the'_swallows the comma beforecaller).bevy/bevy_ecs_world.rs:1270spawn_with_caller:(&mut self, bundle: MovingPtr<'_, B>, caller: MaybeLocation)-- real 3, GitGalaxy reports 2.serde/serde_core_de_mod.rs:1105deserialize_unit_struct:(self, name: &'static str, visitor: V)-- real 3, GitGalaxy reports 2.serde/serde_core_de_mod.rs:1152deserialize_struct:(self, name: &'static str, fields: &'static [&'static str], visitor: V)-- 3 lifetime marks (odd count, string mode never exits) -- real 4, GitGalaxy reports 2.
Suggested fix
getattr(self, "language", "") -> getattr(self, "primary_lang_id", "") (or just self.primary_lang_id, since it's always set in __init__). One-line fix; re-run tests/tools/tri_comparison_chart.py --languages rust,scala and the relevant test_rust_strict.py/test_scala_strict.py args cases afterward to confirm the args counts move.
Scope
This only affects args structural-signature accuracy for rust/scala specifically (epic #813's extraction-pillar naming accuracy), not risk-scoring or any other language. No other language's _count_top_level_args call path is affected -- the guard is scoped to exactly this condition.
🤖 Found via dispatched investigation, tri-comparison-ledger-sweep skill
Activity
squid-protocol commentedon Aug 19, 2026
Second, related manifestation found (same root cause, different function)
Follow-up dispatched investigation on a different ledger shape (
rust/function/args/agree[ctags,tree_sitter]_vs[gitgalaxy], extends the worked example already indocs/self_scan/how_to_investigate_a_discrepancy.md) found a second place a Rust lifetime tick gets misread as an unterminated string literal — independently confirmed against source, not just the dispatched agent's claim._matching_paren_end(gitgalaxy/core/detector.py, lines 3675-3703) has no lifetime guard at all (unlike_count_top_level_args's broken-but-present one this issue already covers):This function backs the self-containment check at ~line 4262 (
self._matching_paren_end(stripped, 0) == len(stripped) - 1) that decides whether a captured signature is a true self-contained(...)span. A Rust signature with any lifetime tick ('_,'a,'static) makes this check falsely fail (the phantom unclosed string swallows the real closing)), so control falls through to the comma/whitespace-split fallback meant for Lisp/Scheme/Shell (~line 4296). For a single-parameter signature with a lifetime and no comma, this produces an OVER-count instead of the other bug's under-count -- e.g.bevy_reflect_path.rs:43'snew(path: &'a str):"(path: &'a str)".split()= 3 tokens, GitGalaxy reports 3 args for a real 1-arg function.Both bugs share the identical underlying defect (a Rust/Scala lifetime tick never being recognized as non-string during bracket/quote scanning) and should almost certainly be fixed together --
_matching_paren_endneeds the same rust/scala lifetime exemption_count_top_level_argswas supposed to have (once itsself.language→self.primary_lang_idfix lands).Confirmed real signatures (
language-crucible/data/rust/):_count_top_level_argsbug):bevy/bevy_ecs_table.rs:171initialize(&mut self, row: TableRow, data: OwningPtr<'_>, tick: Tick, caller: MaybeLocation)— real 5, GitGalaxy reports 3._matching_paren_endbug):bevy/bevy_reflect_path.rs:43new(path: &'a str)— real 1, GitGalaxy reports 3.serde/serde_internals_ast.rs:119all_fields(&'a self) -> Box<dyn Iterator<...>>— real 1, GitGalaxy reports 2.Resolve all 6 rust tri-comparison ledger shapes (#1873)
Add docs/language_status/c.md -- full doc plus tri-comparison capstone
Resolve 8 of 11 c tri-comparison ledger shapes, 2 more tooling fixes (#…
squid-protocol commentedon Aug 20, 2026
Note: #1852 (filed 2026-08-18, before this issue) reported the identical bug independently -- closed as a duplicate of this one since this issue's diagnosis is fuller (confirmed root cause + repro cases + the follow-up
_matching_paren_endmanifestation). Should have searched before filing this -- noting for the record.Correct overclaim in c.md, cross-reference pre-existing args issues, …
Fix 1872 rust scala lifetime (#2137)