Skip to content

Graph comparison: reconcile calls like the tri-comparison — ledger, validated numbers, C8 (#3641) - #3647

Merged
squid-protocol merged 4 commits into
mainfrom
claude/festive-fermat-kojuy7
Sep 25, 2026
Merged

squid-protocol merged 4 commits into
mainfrom
claude/festive-fermat-kojuy7

Conversation

@squid-protocol

@squid-protocol squid-protocol commented Sep 25, 2026 •

Copy link
Copy Markdown
Owner

Part of #3641, which is now scoped to calls and imports only. This implements the decisions recorded on the epic.

Why

The call comparison graded GitGalaxy against tree-sitter as ground truth. The structural comparisons stopped doing that, because tree-sitter and our own harness have faults of their own. This PR moves calls onto the same process as the structural tri-comparison. Imports follow in the next PR.

What changes

  1. Contract (docs/calls_out_rule_contract.md):

  2. Harness fixes (mechanical, so fixed in code):

    • An anonymous function no longer claims its calls and then silently drops them. This was the biggest artifact: 213 JavaScript and 505 TypeScript "GitGalaxy false positives" were the harness's own bug.
    • Go type_conversion_expression counts as a call (C3).
    • A generic call is named by its function, not its type argument (collect::<Vec<_>>() is collect).
  3. --buckets labels every disagreement with a syntactic cause.

  4. --ledger merges each cause shape into docs/self_scan/graph_comparison_ledger.json.

    • It goes through tri_comparison_ledger.py: same schema, lifecycle and credit_tools geometry, separate file. The structural ledger and chart are untouched.
    • Every run prints raw and validated precision/recall. Validated moves only on a recorded verdict, and * marks a language with open shapes.
    • The --ci gate stays on raw.
    • The ledger stays in this repo: an engine fix and the verdicts it retires land in one PR.
  5. Post-merge refresh: .github/workflows/graph-comparison-history.yml, the twin of tri-comparison-history.yml.

    • On a main push that can move a call, it re-runs --ledger and auto-merges the refreshed counts, examples and still_reproduces.
    • PRs only add verdicts; the bot commits the churn.
    • It never touches a verdict or the raw baseline.
    • It uses the same AUTOMATION_PAT merge path as its twin.
  6. Five examples per shape (LEDGER_EXAMPLES): enough to read a verdict from. Ledger size is 240 KB.

  7. Ledger seeded: 162 shapes, 23 validated by reading their recorded examples. All 23 confirm GitGalaxy faults, now filed:

    So validated still equals raw everywhere. The shapes where tree-sitter may be the one that's wrong are in the smaller, mixed buckets still open, such as calls inside Rust macro token trees and C++ member initializers.

Raw baseline changes (all from the harness fixes)

precision recall
javascript 79.5 → 87.6 97.6
typescript 86.2 → 94.0 95.8 → 95.2
php 96.7 → 99.7 98.9 → 98.8
go 99.6 → 99.9 96.5 → 96.4
csharp 93.9 97.2 → 97.6
rust 87.4 90.4 → 90.3

The small recall drops come from newly counted calls: anonymous-callback calls and Go conversions add both matches and misses.

Verification

  • tests/tools/test_call_graph_accuracy.py: 12 tests. They cover C8 in both directions, Go conversions, generic naming in three languages, and the cause labels.
  • call_graph_accuracy --ci against the regenerated baseline, on the pinned corpus (v1.5.0).
  • ruff, format and dead-key audits clean. The workflow YAML parses.
  • No engine code changes, so there's no golden or rosetta impact.

🤖 Generated with Claude Code

https://claude.ai/code/session_01YAtpBfGGyBGGovitSVaM5Q

…ot callee name (#3641)

`--samples` lists the most frequent FP/FN callee names (`add`, `get`, `then`),
which say nothing about why the two sides disagree. `--buckets N` labels every
FP/FN with a syntactic cause, with N examples each:

  fp:inner-{named,anonymous}-<node>  tree-sitter gives the call to an inner
                                     function; the engine also counts it
  fp:not-a-call-in-ts:<parent<grand> the name is there, but not as a call
  fp:outside-ts-function             the engine attributes a call from beyond
                                     tree-sitter's function (span overrun)
  fn:<call node>/<callee node>[+generic][+bang]  the shape the engine missed
  fn:engine-attributes-to-another-function

Labels are leads for the verification step, not verdicts. The default run and
the --ci gate are unchanged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01YAtpBfGGyBGGovitSVaM5Q
…validated numbers, C8 (#3641)

Decided 2026-09-25: the call/import comparisons follow the structural
tri-comparison process instead of grading GitGalaxy against tree-sitter.

- Contract (docs/calls_out_rule_contract.md): C8 -- a call belongs to the
  innermost NAMED unit (nested named function: that unit only; anonymous
  function: the enclosing unit). C3 amended: a pattern (`Ok(t) =>`,
  `if let Some(x) =`) is not a call. Conversions stay calls (C3 as decided).
- Harness fixes (mechanical, so code): an anonymous function no longer owns
  and silently drops its calls (C8) -- that bug read as 213 JS / 505 TS
  GitGalaxy "false positives"; go `type_conversion_expression` counts (C3);
  a generic call is named by its function, not its type argument
  (`collect::<Vec<_>>()` is `collect`, `OfType<T>()` is `OfType`).
- `--ledger` merges each cause shape into docs/self_scan/graph_comparison_ledger.json
  through tri_comparison_ledger.py (same schema/lifecycle, separate file);
  every run prints raw and validated precision/recall. Validated moves only
  on a recorded verdict (credit geometry in graph_comparison_README.md); the
  --ci gate stays on raw.
- Ledger seeded: 162 shapes, 23 validated by reading their examples -- all
  confirm GitGalaxy faults, filed as #3642 (C8 nested units), #3643 (rust
  macros/turbofish/patterns), #3644 (cpp/ts generics, cpp own header and
  `Type var(`), #3645 (go throw, conversions), #3646 (ruby span).

Raw baseline, from the harness fixes: javascript precision 79.5 -> 87.6,
typescript 86.2 -> 94.0, php 96.7 -> 99.7, go 99.6 -> 99.9.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01YAtpBfGGyBGGovitSVaM5Q
The ledger holds hand-recorded verdicts, so it is committed like its
tri-comparison twin; *.json under docs/ is otherwise ignored scan output.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01YAtpBfGGyBGGovitSVaM5Q
- .github/workflows/graph-comparison-history.yml, twin of
  tri-comparison-history.yml: on a main push that can move a call, re-run
  `call_graph_accuracy.py --ledger` and auto-merge the refreshed ledger.
  PRs then add verdicts only; the bot commits the count churn. Never
  touches a verdict or the raw baseline.
- LEDGER_EXAMPLES = 5 (was 10): enough to read a verdict from; the full
  list is one `--buckets N` away. Ledger 316 KB -> 240 KB; all 23 verdicts
  preserved through the merge.
- README: who writes what, and why the ledger stays in this repo.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01YAtpBfGGyBGGovitSVaM5Q
@github-actions

Copy link
Copy Markdown
Contributor

🐦‍⬛ Muninn Security Scan

✅ No security issues found.

🐦‍⬛ Powered by Muninn · Skald Lab

@squid-protocol
squid-protocol merged commit 0b3fdf1 into main Sep 25, 2026
30 checks passed
@squid-protocol
squid-protocol deleted the claude/festive-fermat-kojuy7 branch September 25, 2026 18:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants