Skip to content

Detector extracts only the first function on a line: several definitions packed on one line lose all but the first #7504

Closed

Description

@squid-protocol

What happens

The detector finds a function only where a definition starts a line. When several definitions share one physical line, only the first is recorded. The others are lost from function_data, and with them their calls, complexity and signals.

#7503 (Fixes #7501) made dense hand-written files reach the detector instead of being excluded as minified. That made this limit visible on real code. Three Codex-written programs from the agent-habits study, scanned with #7503's engine, each compared with a formatter-wrapped copy of the same source (where GitGalaxy and ctags agree):

file lines GG functions, as written GG = ctags, wrapped copy
chess engine, Rust (2nd run), src/main.rs 36 21 30
chess engine, C, engine.c 55 22 23
chess engine, Rust, src/main.rs 34 19 20

The same limit appears in Java: methods written on one line inside a class body (class M { int f(){…} int g(){…} }) are missed. That was seen as 4 functions across the study's Java runs, 3 of them by Sonnet, so it isn't one author's style only.

Why it matters

  • Per-function metrics are wrong for dense code: function counts, complexity per function, fan-out and the call graph.
  • The loss isn't neutral between authors. In the agent-habits study, one agent writes much denser code than the others. Any per-function comparison is biased against it, even after Scan dense hand-written source instead of excluding it as minified (Fixes #7501) #7503.
  • AI-written code is a growing share of what gets scanned.

Scope and constraints

  • This is a detector-wide change (Mode A slicing / function-start detection), so expect golden drift. Bless via crucible_check.py --update --yes with the drift attributed.
  • It must stay ReDoS-safe on long lines. Scan dense hand-written source instead of excluding it as minified (Fixes #7501) #7503's gitgalaxy/core/dense_source.py already has a bounded, linear inline-definition scan that may be reusable.
  • Ordinary one-function-per-line code must stay byte-identical. Prove this with golden masters on the crucible.
  • Sweep the class: which languages allow several definitions per line (C/C++, Rust, Go, Java, C#, Kotlin, Swift, Scala, JS/TS), and which slicing modes (_cobol_*, brace languages, Python).

Acceptance

  • Synthetic fixtures with 2-10 definitions per line in at least C, Rust and Java. GG matches tree-sitter and ctags on name and parameter count.
  • Each function's span is correct (start/end on the shared line; the next function's span does not swallow the previous one).
  • Goldens re-blessed with the drift attributed; ordinary files unchanged.
  • The agent-habits Codex programs above reach the wrapped-copy counts (30, 23, 20) as written.

Related: #7501, #7503.

Activity

  1. added
    bug
    core-engine
    on Nov 2, 2026
  2. squid-protocol commented on Nov 3, 2026

    @squid-protocol
    OwnerAuthor

    Claimed by promoter-bot host melek, lease renewed 2026-11-03T14:01Z. It lapses after 6 h without a renewal. To take it back, assign someone or remove the claim:melek label.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugclaim:melekcore-engine

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions