Repository navigation
fix(cpp): resolve scoped aliases and inherited member receivers - #5118
xRedLeader wants to merge 9 commits into
Conversation
Persist lexical type declarations and include positions so ordinary aliases resolve only in their declaring scope and reachable headers. Preserve case, declaration order and alias shadowing, and leave unsupported or ambiguous targets unresolved. Keep direct namespace imports working without the previous corpus-wide simple-name fallback.
Use literal base declarations and member-name barriers to resolve inherited fields and methods only through one reachable path. Reject unknown bases, diamonds, virtual-base paths and inherited overload families; bound alias and inheritance work with cached lookups. Preserve lexical alias blockers, standard-pointer spelling and parked foreign-type behavior. Forward persisted C++ facts and include locations through CLI and watcher incremental updates, and retire older AST caches.
Keep field spellings and aliases bound to their declaration scope while allowing a unique exact type definition from the caller's explicit include set. Persist definition completeness to enforce same-file order, and keep base-type completeness declaration-scoped. Cover raw, reference, alias and smart-pointer fields, call-site alias shadowing, absent and ambiguous definitions, and incremental context.
Count visible complete declaration records before accepting a type target, so same-file duplicate bodies cannot become unique merely because their graph IDs coalesce.
Exclude namespace, class and function scoped includes from global type visibility while retaining whole-file guards and linkage wrappers. Complete aliases at their original use point so an earlier complete body can satisfy a base specifier without accepting a later caller-only definition. Retire cached extraction facts that included scoped imports.
Keep named namespace ancestry through an internal anonymous lookup scope without assigning identities to anonymous classes. Preserve anonymous declarations as unknown shadowing barriers, including their implicit parent visibility, and leave qualified parent access available. Apply the scope consistently to typed receiver bindings and scoped static calls.
|
Thanks for the pull request, @xRedLeader. A maintainer will review it soon. Want to talk it through while it is in review? Come join us on our Discord server. For longer-form discussion there is also GitHub Discussions. A couple of things that speed up review: make sure the test suite passes on Python 3.10 and 3.13, and that the change keeps extraction deterministic. |
There was a problem hiding this comment.
Graphify reviewed this change.
No issues found by static checks — no coupling regressions or blocking issues in the code graph. That is not the same as safe to merge: see what was not checked.
Not checked: tests were not run; formal verification proved 0 of 6 changed function(s) (6 not verified).
Formal verification. PR-changed functions: 0/6 verified (0 proven, 0 may-equivalent, 0 distinguished) · 6 not verified (3 vacuous, 3 unsupported).
Not verified on this run: dispatch\_command (vacuous: never exercised), \_resolve\_cpp\_member\_calls (vacuous: never exercised), \_cpp\_class\_fields (unsupported), \_cpp\_local\_binding\_ranges (vacuous: never exercised), \_extract\_generic (unsupported), \_rebuild\_code (unsupported).
Graphify review — findings
Extends C++ receiver-type resolution to follow using/typedef aliases (including raw-pointer and supported std smart-pointer aliases), namespace and using directives, and explicit preceding includes, all respecting lexical scope and declaration order. It also resolves inherited fields and methods through literal, reachable base types, with a derived class hiding same-named members in its bases. Anything ambiguous or unsupported (diamonds, virtual or dependent bases, alias templates, cyclic aliases, walks over 32 classes, unincluded definitions) stays unresolved rather than guessed. File and class nodes now persist lexical type/alias facts, include offsets and field declaration offsets, so an unchanged header supports incremental receiver resolution. The AST cache schema bumps to 50 to retire older entries, and existing graphs need graphify extract . --code-only --force to populate those facts before relying on changed-file-only updates. ARCHITECTURE.md documents the new lookup rules.
Review partial — this diff was larger than one review pass covers, so later files were not reviewed; some findings may be missing.
Analysis details — impact, health, verification
Impact & health
Graphify review
Impact — 5849 functions depend on the 1242 functions this change touches.
Health — this change adds coupling hotspots:
- worse:
extract()— 1186 callers, 71 callees - worse:
_extract_generic()— 20 callers, 55 callees - worse:
extract_cpp()— 41 callers, 5 callees - worse:
walk()— 1 callers, 86 callees - worse:
walk_calls()— 1 callers, 41 callees - worse:
_resolve_cpp_member_calls()— 2 callers, 10 callees
Verification — 5849 functions in the blast radius were not formally verified this run (proofs are advisory here).
Gate & verification
graphify gate
PASS — objectively clean (no health regressions, tests not run — proofs not run this pass (advisory)). Grounded, not self-assessed.
Advisory (not blocking):
- verification_scope: 5688 function(s) in the blast radius were not formally verified this run
Test selection
Test selection
546 of 546 test file(s) selected (100%) via static blast radius.
Escalated to a full run for safety (
noncode-change,uncovered-code) — the selection is not trustworthy on its own (see below). CI should run the whole suite.
tests/pi.test.ts— full-run-safetytests/test_4874_jvm_resolution.py— impact, full-run-safetytests/test_4909_reference_binding_scale.py— full-run-safetytests/test_4978_reconcile_cost.py— impact, full-run-safetytests/test_4992_ts_import_types.py— impact, full-run-safetytests/test_5072_splittable_under_cap_retry.py— full-run-safetytests/test_affected_cli.py— impact, full-run-safetytests/test_affected_defines.py— full-run-safetytests/test_affected_member_seed.py— full-run-safetytests/test_affected_overrides.py— impact, full-run-safetytests/test_affected_path_file_node.py— full-run-safetytests/test_affected_seed_reference_forms.py— impact, full-run-safetytests/test_agents_platform.py— impact, full-run-safetytests/test_alias_folding.py— impact, full-run-safetytests/test_analyze.py— impact, full-run-safetytests/test_anthropic_custom_endpoint.py— full-run-safetytests/test_antigravity_install.py— full-run-safetytests/test_apm_fallback_version.py— full-run-safetytests/test_architecture_doc.py— full-run-safetytests/test_astro_extraction.py— impact, full-run-safetytests/test_astro_import_ids.py— impact, full-run-safetytests/test_atomic_canvas_export.py— full-run-safetytests/test_atomic_version_stamp.py— full-run-safetytests/test_atomic_writes.py— full-run-safetytests/test_backend_env_isolation.py— full-run-safetytests/test_backend_extras.py— full-run-safetytests/test_backend_opt_in.py— full-run-safetytests/test_benchmark.py— full-run-safetytests/test_benchmark_raw_graph.py— full-run-safetytests/test_benchmark_real_query.py— full-run-safetytests/test_binary_media_words.py— impact, full-run-safetytests/test_blade_extractor.py— impact, full-run-safetytests/test_build.py— impact, full-run-safetytests/test_build_located_semantic_identity.py— impact, full-run-safetytests/test_build_merge_dedup_scope.py— impact, full-run-safetytests/test_build_merge_ghost_fold_4955.py— impact, full-run-safetytests/test_build_merge_hyperedges_and_prune.py— impact, full-run-safetytests/test_build_merge_shrink_guard.py— impact, full-run-safetytests/test_builtin_global_type_refs.py— impact, full-run-safetytests/test_c_include_resolution.py— impact, full-run-safetytests/test_cache.py— impact, full-run-safetytests/test_cache_long_paths.py— impact, full-run-safetytests/test_cache_stale_import_target.py— impact, full-run-safetytests/test_cache_windows_case_4925.py— impact, full-run-safetytests/test_callflow_html.py— full-run-safetytests/test_cargo_introspect.py— full-run-safetytests/test_cargo_missing_manifest.py— full-run-safetytests/test_carried_hyperedge_remap.py— impact, full-run-safetytests/test_case_only_decl_ids_4904.py— impact, full-run-safetytests/test_case_sensitive_resolution.py— impact, full-run-safety- … and 496 more
non-code file(s) changed (
ARCHITECTURE.md) → running the full suite for safety (a code graph can't see config/fixture/data deps)
changed code file(s) with no mapped test (
ARCHITECTURE.md) — a coverage gap or a missing link — running the full suite rather than only the selected tests
Selection is safe under the controlled-regression assumption; always-run tests + a periodic full run are the backstops. Advisory — it never changes the check verdict.
Docs that may be stale (advisory)
.github/PULL_REQUEST_TEMPLATE.md§ Graphify-specific checklist (lines 33-39): references changed symbolsrunBENCHMARKS.md§ Reproducing (lines 190-203): references changed symbolsrunCHANGELOG.md§ 0.9.101 (2026-11-02) (lines 113-136): references changed symbols__init__CHANGELOG.md§ 0.9.100 (2026-11-01) (lines 137-160): references changed symbolsresolveCHANGELOG.md§ 0.9.98 (2026-10-30) (lines 173-192): references changed symbolsresolveCHANGELOG.md§ 0.9.97 (2026-10-27) (lines 193-218): references changed symbolsrecord,resolve,runCHANGELOG.md§ 0.9.96 (2026-10-25) (lines 219-249): references changed symbolsrunCHANGELOG.md§ 0.9.94 (2026-10-22) (lines 276-297): references changed symbolsresolveCHANGELOG.md§ 0.9.90 (2026-10-13) (lines 364-382): references changed symbolsrunCHANGELOG.md§ 0.9.87 (2026-10-12) (lines 422-444): references changed symbolsresolve
…and 10 more.
Formal verification
Could not verify: Could not verify dispatch\_command.
The verifier did not have enough to check dispatch\_command, so it is saying so rather than guessing. No false assurance is the whole point.
Guarantee: No guarantee either way, this is an honest abstention, not a pass.
Note: Reason: no capturable inputs from the test suite; property tier: not verifiable: all 40 sampled inputs raised on both versions — the function never executed, so 'no divergence' would be vacuous (mostly SystemExit — names the real obstacle, not a sampling gap)
Could not verify: Could not verify \_resolve\_cpp\_member\_calls.
The verifier did not have enough to check \_resolve\_cpp\_member\_calls, so it is saying so rather than guessing. No false assurance is the whole point.
Guarantee: No guarantee either way, this is an honest abstention, not a pass.
Note: Reason: no capturable inputs from the test suite; property tier: non-vacuity: domain too small (only 1 distinct inputs exercised, need 3) — 'no divergence' would be near-vacuous
Could not verify: Could not verify \_cpp\_class\_fields.
The verifier did not have enough to check \_cpp\_class\_fields, so it is saying so rather than guessing. No false assurance is the whole point.
Guarantee: No guarantee either way, this is an honest abstention, not a pass.
Note: Reason: no capturable inputs from the test suite; property tier: signature changed: no shared positional arity
Could not verify: Could not verify \_cpp\_local\_binding\_ranges.
The verifier did not have enough to check \_cpp\_local\_binding\_ranges, so it is saying so rather than guessing. No false assurance is the whole point.
Guarantee: No guarantee either way, this is an honest abstention, not a pass.
Note: Reason: no capturable inputs from the test suite; property tier: not verifiable: all 230 sampled inputs raised on both versions — the function never executed, so 'no divergence' would be vacuous (mostly AttributeError — names the real obstacle, not a sampling gap)
Could not verify: Could not verify \_extract\_generic.
The verifier did not have enough to check \_extract\_generic, so it is saying so rather than guessing. No false assurance is the whole point.
Guarantee: No guarantee either way, this is an honest abstention, not a pass.
Note: Reason: no capturable inputs from the test suite; property tier: parameter `config` is annotated `LanguageConfig` — outside the synthesizable primitive/collection set
Could not verify: Could not verify \_rebuild\_code.
The verifier did not have enough to check \_rebuild\_code, so it is saying so rather than guessing. No false assurance is the whole point.
Guarantee: No guarantee either way, this is an honest abstention, not a pass.
Note: Reason: no capturable inputs from the test suite; property tier: nondeterministic output (both versions disagreed with themselves on the witness) — not a behaviour change; a function whose output is not a function of its inputs (random / time / uuid / os.urandom, or state carried across calls) cannot be soundly distinguished by execution, so this tier abstains for the whole function
· 6 more finding(s) on lines outside this diff (see the check run).
#5118 targeted an over-incremented schema (51) and its stale-cache test hardcoded >= 45 with 43 as the 'old' sentinel. The combined C++ batch bump is 43, so floor the assertion to >= 43 and use 42 as the genuinely-older sentinel. Co-Authored-By: Claude Opus 4.8 <[email protected]>
Co-landing the scoped-alias/inherited-receiver work (#5118) with the template/ guarded-initializer work (#5115) required merging their _cpp_local_binding_ranges tuple: #5118 appends the lexical lookup scope, #5115 appends the qualified name and a dependent-type flag. Carry all three (receiver_type, lookup_scope, qualified_name, dependent), widen the type annotations to the 6-tuple, and move the dependent-flag read in the member-defer predicate to its new index. Full C++ suite (443 tests incl. #5098/#4916/#4946) green. Co-Authored-By: Claude Opus 4.8 <[email protected]>
… trio #5113 (Python subscript generic-arg count) and #5117/#5118/#5115 (C++ decl/def reconcile, scoped aliases + inherited receivers, template ownership + guarded initializers) all change per-file extractor output and land in one window, so they share a single bump to 43 chained over prior (42). Co-Authored-By: Claude Opus 4.8 <[email protected]>
|
Landed on |
C++ member calls through ordinary aliases or inherited fields can lose their static receiver type, or fall through to an unrelated same-name method. This adds conservative scope- and include-aware lookup using persisted AST facts, shared by fresh extraction and incremental CLI/watch updates.
Resolve ordinary
using/typedefaliases in their declaration scope, including raw pointers and supportedstd::unique_ptr/std::shared_ptrforms. Unknown aliases still shadow outer declarations.Resolve inherited fields and methods only along an unambiguous static member path. Preserve name hiding and refuse ambiguous diamonds, unsupported bases and overload families.
Bind field spelling at its declaration, then require a unique complete type visible at the call site. This supports the normal forward-declared-pointee/header pattern without binding definitions from unrelated files or after the call.
Retain named enclosing lookup scopes inside anonymous namespaces for both receiver chains and scoped static calls. Keep anonymous type identities unknown and preserve shadowing barriers.
Bound alias and inheritance traversal, memoize repeated include/member lookup, and retain facts for changed-file CLI/watch updates.
Normalize C++ CRLF input to LF before parsing, so persisted lookup offsets and call sites use the same coordinates across Windows and Unix checkouts. Source files are not rewritten.
Verification
d84b82bd, including Python 3.10, 3.12, 3.13, and 3.14.f65022a7included the 32-extraction determinism matrix and combined testing with fix(cpp): preserve template ownership and guarded initializer calls #5115/fix(cpp): reconcile proven declarations and definitions #5117. Those broader experiments were not repeated for this follow-up. The existing touched-source Pyright baseline and previously reproduced Windows CLI exclusion failure remain as documented in the prior review.Focused PowerShell commands:
The local full suite was not run. GitHub's existing CI completed successfully on the updated PR.
Boundaries
This independently targets
v8at5eedffa8; it requires neither the template nor symbol-reconciliation PR. Shared-file overlaps and cache schema bumps need reconciliation when merging them together.AST cache schema 51 retires stale records; rebuild existing graphs with
graphify extract . --code-only --force.No compiler/build-configuration integration, arbitrary template instantiation, overload resolution, custom smart pointers or runtime virtual-dispatch inference is introduced. The new alias/inheritance paths decline dependent, cyclic, unknown or ambiguous targets. Alias and inheritance traversal are capped at 32. New guarantees apply to explicit receivers and field chains; unqualified bare calls retain the existing lexical resolver. Block-local class identity is not modeled; includes inside scopes are not used as global type-visibility proof.