Skip to content

fix(cpp): keep local callables out of global call resolution - #4921

Closed
azizur100389 wants to merge 3 commits into
Graphify-Labs:v8from
azizur100389:codex/issue-4917
Closed

azizur100389 wants to merge 3 commits into
Graphify-Labs:v8from
azizur100389:codex/issue-4917

Conversation

@azizur100389

@azizur100389 azizur100389 commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

Closes #4917.

A bare call through a local C++ lambda or callable variable must not bind to a same-named function or field elsewhere. Extraction now indexes the lexical lifetimes of named local declarations and parameters per function, suppressing those bare-name candidates while still walking argument expressions. Scope ends restore ordinary free-function calls.

AST cache schema advances to 32 so the old raw-call candidates are re-extracted. This handles named declarators supported by the existing C++ declarator reader; it does not attempt to model arbitrary dynamic callable targets.

Eight regressions cover lambdas, std::function and TFunction values, same-file and cross-file collisions, block-scope exit, parameters and nested argument calls. Six reported collision cases fail on the unmodified code; all eight cases pass with the fix.

The issue was created on 31 October 2026. Immediately before opening this PR we checked assignees, human comments and linked PRs; there was no claim or competing PR. All changes are based on v8 a0946f96 (0.9.99).

Validation: frozen all-extras dependencies, focused regressions, Ruff, pre-commit and all five skillgen validators pass. Fresh wheels, isolated installs, CLI help/install and feature smoke checks pass. AST graph refresh completed.

Full CI runs Python 3.10/3.12/3.13/3.14 against frozen all-extras dependencies, CLI help/install on each version, all five skillgen checks and the 20 Pi guard tests. Passes: Python 3.10 9199 passed / 17 repository-defined skips / 1 expected failure; Python 3.12/3.13/3.14 each 9198 passed / 18 skips / 1 expected failure. All Pi guard cases and CLI installation checks pass.

Complete native Windows Python 3.12 run: 23 failed, 9053 passed, 140 skipped, 1 xfailed, 2443 warnings in 2776.24s (0:46:16). All 23 failing test IDs reproduce on clean v0.9.99 with the same Git Bash environment; no introduced failures were found.

Native Windows Pi checks have the same 5 passes / 15 failures as clean upstream; Linux CI runs all 20 successfully. Pyright has exactly the same 679 baseline diagnostics, with no new or removed diagnostics. Bandit has the same 12 filtered baseline findings, and pip-audit has the same 7 vulnerability records in 1 package (matched by advisory aliases). Security CI is non-blocking, so green status does not mean a clean audit. Dependencies and lockfile match upstream. No manual test filters or new skip markers were added to full-suite validation.

@github-actions

github-actions Bot commented Nov 1, 2026

Copy link
Copy Markdown

Thanks for the pull request, @azizur100389. 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.

@github-actions github-actions Bot added the contributor Pull request from a returning community contributor label Nov 1, 2026
azizur100389 and others added 2 commits November 1, 2026 00:07
Preserve the prior Graphify-Labs#4854 migration note required by the schema regression.

Co-Authored-By: OpenAI Codex <[email protected]>
The isolated watch lifecycle cases pass locally. Retry the complete CI workflow without changing code or tests.

Co-Authored-By: OpenAI Codex <[email protected]>
@azizur100389
azizur100389 marked this pull request as ready for review November 1, 2026 00:43

@graphify-labs graphify-labs Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Graphify reviewed this change.

Worth a look — the grounded gate found no coupling regressions or blocking issues, but 1 advisory finding(s) below merit a look before merge.

Not checked: tests were not run; formal verification proved 0 of 1 changed function(s) (1 not verified).

Formal verification. PR-changed functions: 0/1 verified (0 proven, 0 may-equivalent, 0 distinguished) · 1 not verified (1 unsupported).

Not verified on this run: \_extract\_generic (unsupported).


Graphify review — findings

Fixes C++ call resolution so a local binding that shadows a callable no longer links to the same-named function, using per-scope binding ranges from _cpp_local_binding_ranges to decide which calls to skip. Bumps _AST_CACHE_SCHEMA to 32 so cached C++ extractions re-run with the shadowing logic. What counts as a local binding sets the boundary between a correctly dropped shadowed call and a lost edge to the real function.

Worth a look

  • Local function prototype is treated as a shadowing local, dropping calls to the real function — graphify/extractors/engine.py:3089 · Escalate · medium
    • NOT verified (no proof, no reproducing execution) — needs human review
Analysis details — impact, health, verification

Impact & health

Graphify review

Impact — 3849 functions depend on the 480 functions this change touches.

Health — this change adds coupling hotspots:

  • worse: extract() — 1083 callers, 63 callees
  • worse: _extract_generic() — 20 callers, 50 callees

Verification — 3849 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: 2328 function(s) in the blast radius were not formally verified this run

Test selection

Test selection

80 of 480 test file(s) selected (17%) via static blast radius.

  • tests/test_astro_extraction.py — impact
  • tests/test_binary_media_words.py — impact
  • tests/test_build.py — impact
  • tests/test_cache.py — impact
  • tests/test_cache_long_paths.py — impact
  • tests/test_cache_stale_import_target.py — impact
  • tests/test_charmap_encoding.py — impact
  • tests/test_chunking.py — impact
  • tests/test_cjs_module_extension.py — impact
  • tests/test_cpp_local_callable_shadowing.py — changed-test
  • tests/test_cpp_nested_and_cli.py — impact
  • tests/test_csharp_partial_classes.py — impact
  • tests/test_definition_file_portability.py — impact
  • tests/test_detect.py — impact
  • tests/test_dotnet.py — impact
  • tests/test_ejs_extractor.py — impact
  • tests/test_ext_tagged_id_clash.py — impact
  • tests/test_extract.py — impact
  • tests/test_extract_cache_location.py — impact
  • tests/test_extract_cli.py — impact
  • tests/test_extract_php_closures.py — impact
  • tests/test_grammar_cache_key.py — impact
  • tests/test_ignore_file_encoding.py — impact
  • tests/test_import_extension_resolution.py — impact
  • tests/test_incremental_mtime_collision.py — impact
  • tests/test_indirect_call_block_scoped_shadow.py — impact
  • tests/test_indirect_dispatch.py — impact
  • tests/test_indirect_dispatch_assign_return.py — impact
  • tests/test_indirect_dispatch_getattr.py — impact
  • tests/test_java_member_calls.py — impact
  • tests/test_js_exported_scalar_bindings.py — impact
  • tests/test_js_member_collisions.py — impact
  • tests/test_language_override_lifecycle.py — impact
  • tests/test_language_overrides.py — impact
  • tests/test_languages.py — impact
  • tests/test_llm_backends.py — impact
  • tests/test_manifest_ingest.py — impact
  • tests/test_msbuild_dir_evidence.py — impact
  • tests/test_multilang.py — impact
  • tests/test_objc_field_table_remap.py — impact
  • tests/test_out_dir_evidence.py — impact
  • tests/test_partial_cache.py — impact
  • tests/test_php_unparsed_casts.py — impact
  • tests/test_pipeline.py — impact
  • tests/test_python_inherited_method_calls.py — impact
  • tests/test_python_injected_factory_calls.py — impact
  • tests/test_python_property_reads.py — impact
  • tests/test_python_pytest_fixture_receivers.py — impact
  • tests/test_python_underscore_resolution.py — impact
  • tests/test_rationale.py — impact
  • … and 30 more

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.

Formal verification

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

· 2 more finding(s) on lines outside this diff (see the check run).

safishamsi added a commit that referenced this pull request Nov 2, 2026
#4951 (type-alias exact-spelling binding + salted alias contains edge),
#4946 (receiver typing from parameters and fields), #4920 (split-header
owner binding via _cpp_qualified), and #4921 (local-callable suppression)
all change per-file C++ extractor output, so warm caches must re-run.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@safishamsi

Copy link
Copy Markdown
Member

Landed in 0.9.101 (published to PyPI), cherry-picked with your authorship preserved. Fixes #4917. Thanks @azizur100389.

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

Labels

contributor Pull request from a returning community contributor

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: C++: calls to a local lambda or local std::function variable are INFERRED-linked to same-named symbols in other files

2 participants