Repository navigation
Call graph: ownership and visibility — Rust impl owners, Go packages and receivers, C/C++ include closure, system headers, C variant edges, Rust module paths (Part of #8161) - #8186
Merged
Conversation
…s at its `;` (R1+R2, Part of #8161) `class_start` never matched `impl`, so no inherent or trait-impl method had an owner: `Type::f()` found nothing, a bare `f()` reached impl methods (Rust syntax never allows that) and `self.m()` reached any definition. The few owners that did exist were accidental: a tuple or unit struct's span ran to the NEXT `{` (usually an `impl`), so `pub struct Unit;` owned `impl b::Thing`'s methods. Now: - R1: the detector records each `impl [<..>] [Trait for] Type [where ..] {` span and gives the methods inside it `parent_class_name = Type` (`&'a mut a::Foo<T>` -> `Foo`; a blanket `impl<T: B> Tr for T`, or an unnamed `[T]` / tuple type, -> `Tr`). No class row is added. - R2: a Rust struct's span ends at a `;` that comes before its first `{` at bracket depth 0 (`struct X;`, `struct X([u8; 4]);`, `struct X<T>(T) where ..;`). Shipped together with R1 so the accidentally-right owners are not lost first. - A Rust path qualifier carries the `::` mark C++ already has (`::Other`, `::a.b`; `x.f()` stays `x`), so the resolver tells a path from a method call on a value: `Type::f()` is that in-repo type's method (`qualified`) or nothing in the repo (`Vec::new`, `String::from`); `m::f()` reaches a free function of a module the caller imports by that name, never a method (`walk::scan` is not `WorkerState::scan`, `std::mem::swap` is no repo `swap`); `self::f()`, `super::f()` (R3) and `Self::f()` as before. - `self.m()` walks the caller's own type, then the visible METHODS only (`_IMPL_SELF_LANGS`, the #3785 widening to any definition, is gone: a same-file test-module helper is never `self`'s). - The nested-unit rescan (`_drop_nested_unit_calls`) now marks scope paths as the first scan does; this also moves C++ (a nested unit's `ns::f()` kept its mark). Gates (call_graph_resolution, before -> after): - rust (serde-rs/json): confident precision 93.7 -> 98.3 (702 -> 858 judged), strict precision 88.6 -> 91.6, ambiguous precision 56.7 -> 69.3, recall 60.7 -> 77.8, resolution recall 61.2 -> 78.4 - cpp: recall 31.1 -> 31.2, resolution recall 54.1 -> 54.2 (1188 -> 1190 judged); precision unchanged Baselines regenerated; golden masters re-blessed (call edges, fan-in/out, PageRank and their downstream ranks move on the crucible's Rust repos). Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_018srRvhoWCV984xPpQKJHfF
… type (G1, Part of #8161) The import edge names one representative file per package (`go_modules._package_file`), and the resolver treated only that file as visible; a qualifier was never tested against the file's import names, so `errors.New` linked to any repo `New` in view; and Go methods had no owner, so every `Close` in one file collapsed onto the first. Now: - Package = directory. `extract_namespace_imports` records every Go import name (an alias, else the path's last element without a `/vN` or gopkg.in `.vN` suffix; `_` binds nothing), read from `import` declarations only. NetworkRiskSensor hands the resolver each name's package (`""` for one outside the scan). `pkg.F()` resolves among the package's non-test files only (several defining it: build-tag variants, a `tie`); `pkg.T.M()` to type T's method there; `errors.New` / `strings.NewReader` reach nothing in the repo. An import makes every non-test file of the package visible to the receiver ladder, not only the representative file. - Receivers. A method's `parent_class_name` is its receiver type (`func (s *S) f(`, `func (S) f(`, `func (t *T[K]) f(`), and its receiver variable is recorded as `self` in its call qualifiers, so `s.g()` is the `class` step on S, and two types' `Close` in one file are two classes (`x.Close()` stays the ambiguous `receiver`). A type's methods are looked up in its own package only. `_OWNERLESS_METHOD_LANGS` is gone. Gates (call_graph_resolution go, cobra + gin, before -> after): confident precision 98.9 -> 99.5 (3397 -> 3541 judged), strict precision 94.6 -> 96.4, recall 71.4 -> 74.8, resolution recall 80.0 -> 83.9; ambiguous precision 58.0 -> 48.4 (560 -> 473 judged: the rows the package and owner rules settle were the easy ambiguous ones). import_graph_accuracy unchanged. Baseline regenerated; golden masters re-blessed (Go call edges and `namespace_imports` move on the crucible's Go repos). Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_018srRvhoWCV984xPpQKJHfF
…static` stays in its own file (X4, Part of #8161) The resolver's `import` step looked only at a file's DIRECT includes (`_include_closure` was used for the C++ ctor-init check alone), a body in `foo.cc` was invisible to a caller that includes `foo.h`, and another translation unit's `static helper` counted as a candidate, so hiredis' `hi_malloc` (a static inline in alloc.h reached through hiredis.h) tied with alloc.c's Windows copy. Now, for C and C++ callers: - the visible set is the include closure, ranked by include depth (a direct include before one it reaches); a static inline reached through a header chain links `import`, and the header nobody includes no longer wins a `nearest` guess; - a header's paired source file is visible one hop past the header (`api.h` -> `api.c` beside it; in C++ also the repo's only source of the stem, `include/fmt/format.h` -> `src/format.cc`), which is how a declaration in a header reaches its out-of-line body. C pairs only beside the header: across directories, libuv's `include/uv/aix.h` exposed `src/unix/aix.c` to Windows callers (5 confident wrong links in a trial); - the detector marks a C/C++ `static` free function `def_shape = "static"` (internal linkage); the resolver drops another file's static from the candidates unless the caller #includes that file. A class's `static` method is unaffected (the mark is read on ownerless definitions only). Gates (call_graph_resolution, before -> after): - c (hiredis + libuv): confident judged 6653 -> 6724, precision 100.0 (unchanged), recall 50.1 -> 50.6, resolution recall 54.6 -> 55.2 - cpp (fmt): precision 86.7 -> 89.1 (1190 -> 1335 judged), strict 76.8 -> 79.1, ambiguous 32.4 -> 41.3, recall 31.2 -> 35.9, resolution recall 54.2 -> 60.9 (wrong-overload links 25 -> 40: more calls now reach the right file, where the overload choice is still by argument count) Baselines regenerated; golden masters re-blessed (C/C++ `fcall` file edges, fan-in/out and PageRank move on the crucible's C and C++ repos). Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_018srRvhoWCV984xPpQKJHfF
…th (Part of #8161) The include token keeps no quote/angle distinction, and the name search matched a bare `errno.h` to any repo file of that name: 61 libuv files drew an edge from `#include <errno.h>` to `include/uv/errno.h`, which libuv only ever reaches as `"uv/errno.h"`; `<poll.h>` reached hiredis' `adapters/poll.h` and `<mach/task.h>` reached `test/task.h` (directory part ignored). PR 1 (#8162) fixed the scorer; this fixes the engine. A C/C++ include naming a system header (`system_headers.is_system_header`, with an extension) now resolves only to a file beside the includer (the existing importer-directory step, what `-I.` gives) or to the one repo file at `<root>/<spelled path>` whose root is on the include path the repo shows: the repo root, an `include/` or `inc/` directory, or a directory one of the repo's multi-segment includes resolves through -- the scorer's rule. Never by bare name. Other includes are unchanged. import_graph_accuracy c (libuv + hiredis), before -> after: precision 92.8 -> 100.0 (false positives 63 -> 0), engine edges 871 -> 808, recall 100.0 (unchanged), hub overlap@10 0.90 -> 1.00, hub Spearman 0.886 -> 1.0. Other languages unchanged. call_graph_resolution c unchanged (precision 100.0, recall 50.6, resolution recall 55.2). Baseline regenerated; the golden masters do not move (no crucible C repo shadows a system header). Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_018srRvhoWCV984xPpQKJHfF
…te as a `variant` edge (C1, Part of #8161) The owner decision recorded in #8161 and docs/calls_out_rule_contract.md ("an open question becomes a labelled kind"): libuv defines `uv__io_poll` in linux.c, kqueue.c, sunos.c, ... and `uv_run` in src/unix/ and src/win/; a given build links one copy, so the resolver's `tie` (no edge) hid 71% of C's recall gap, and picking one copy would be a guess. - `resolve_calls`: a C `tie` row stays as it is (ambiguous, no function or file edge), and carries `variants`: every function definition of the tied name, one per file, each with the platform its path names (`platform_of`: the file name's `-`/`_`/`.` parts first, then its directories nearest first -- `windows`, `unix`, `linux`, `darwin`, `bsd` for kqueue, `sunos`, `aix`, `zos`, ...; None when the path names none). Platforms an `#ifdef` alone shows are not read (no preprocessor). - RecordKeeper stores them in a new `fcall_candidates` table (`src_file_id`, `src_func_id`, `callee`, `dst_file_id`, `dst_func_id`, `platform`; cascades off the calling file like fcall_data). Nothing reads them into PageRank, fan-in or the file graph: the confident graph is unchanged. Documented in docs/function_call_graph.md. - `call_graph_resolution.py` judges the variant edges and reports recall with and without them (report-only, not gated, not baselined). c gate (hiredis + libuv): gated metrics unchanged (precision 100.0, recall 50.6, resolution recall 55.2); variant edges 6073 judged, 72.3% agree with libclang's configuration, 71 unmapped; recall 50.6 without them -> 83.7 with them. No golden master moves. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_018srRvhoWCV984xPpQKJHfF
…lows a `pub use` re-export (R4, Part of #8161) `m::f()` / `crate::m::f()` resolved only when the caller's file already had an import edge whose stem matched, so a nested file's `crate::util::f()`, a `super::codec::encode()` and an integration test's `engine::compute()` found nothing. The resolver now walks the module tree the scan's paths show (`_RustTree`; `mod m;` is `m.rs` or `m/mod.rs` in the declaring module's directory): - `crate::a::b::f()` from the crate root (the nearest ancestor holding `lib.rs` / `main.rs`), `self::m::f()` from the caller's own module, `super::m::f()` from its parent, `m::f()` from a child module else the crate root, and `cratename::f()` from a workspace crate's `src/lib.rs` (its directory name, `-` read as `_`); `crate::f()` is the root file's; - the module file's free `f`, else the ONE file the module imports `f` from (a `pub use` re-export: a path call into a module that does not define `f` compiles only through one); - a segment that is no file module ends the walk: an inline `mod m {..}` and an external crate (`std::mem::swap`) are not resolved this way, and the import-stem rule (R1) still applies after it. Not done (a size-M follow-up): a BARE call to a name a prelude glob brings in (`use super::*` of a crate root that `pub(crate) use`s it; casey/just's 511 `unseen` rows) -- making a crate root a barrel would expose every `mod` it declares. Gate (call_graph_resolution rust, serde-rs/json, which seldom calls through paths): confident judged 858 -> 860, recall 77.8 -> 78.0, resolution recall 78.4 -> 78.6; precision 98.3, strict 91.6, ambiguous 69.3 unchanged. Baseline regenerated; the golden masters do not move. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_018srRvhoWCV984xPpQKJHfF
Contributor
Contributor
|
No description provided. |
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.
PR 3 of 4 for #8161. Six self-contained commits; each carries its engine change, regression tests, regenerated baselines and re-blessed golden masters.
implblocks own their methods, and a tuple or unit struct's span ends at its;(R1+R2).Type::f()reaches that type's methods, or nothing when the type is outside the repo (Vec::new).m::f()reaches free functions only;self.m()reaches methods only.pkg.F()resolves only in that package's non-test files, anderrors.Newreaches nothing in the repo). A method is owned by its receiver type (G1).staticfree functions stay in their own file and its includers (X4).<errno.h>) resolves only beside the includer or under an include root. The 63 false C import edges are gone.variantedges (owner decision, Epic: call-graph recall to comparator quality across C, C++, Java, Go, Python, TS/JS, Rust (four PRs; edge kinds for open questions) #8161):fcall_candidatestable, with the platform from the path.crate::,self::,super::m::, child modules, workspace crates) resolves through the crate's module tree and follows apub usere-export (R4).Gate numbers, main → this PR:
Checks:
--ci.crucible_check.pypasses on HEAD.test_committed_fidelity_table_is_fresh_against_the_corpus; it reads the box's stale keyword-rosetta checkout and fails identically on main.Follow-ups found, not fixed here:
def_shape(this predates the PR), so Gomember, TS shapes and the new Cstaticare lost on delta scans. Rust and Go owners without a class row in the same file are also lost; that needs an owner column.use super::*of a crate root that re-exports them) stayunseen.mod m {}paths don't resolve.variantedges:#ifdef-only platforms are not read, and C++ ties produce no variant edges.🤖 Generated with Claude Code
https://claude.ai/code/session_018srRvhoWCV984xPpQKJHfF