Skip to content

[Task]: Import-edge resolver — C++ #359

Closed

Description

@sumithr

Part of #353. Foundation dependency #354 is complete.

Audit result

Valid, not duplicated, and partially implemented by open PR #468.

The resolver cannot work through scan_repo until #483 maps C/C++ extensions. Two original assumptions also need correction:

  • The C preprocessor searches the header spelling exactly; #include "foo" does not imply foo.h, so extension probing can fabricate edges.
  • Angle brackets do not mean “system-only.” Projects commonly resolve #include <project/foo.h> through configured include directories.

Fixed include/ and src/ guesses cannot reproduce compiler search order when multiple candidates exist.

Resolver scope

  • Register resolvers for the scanner's c and cpp language ids.
  • Extract both quoted and angle-bracket include directives from real tree-sitter output while preserving which form was used.
  • Resolve quoted includes against the including file's directory using the exact normalized spelling.
  • Resolve quoted and angle-bracket includes against configured include directories when repository context is available.
  • Emit an edge only for a repository-owned, unambiguous exact target.
  • Reject repository escapes, unresolved headers, macro-computed includes, and external/system headers.
  • Do not synthesize header extensions.
  • Reuse the shared registry, orchestrator, edge model, and optional dependency behavior.

Generated headers, compiler macros, conditional build variants, and full CMake/Bazel/MSBuild interpretation may remain documented non-goals.

Dependencies and boundaries

Until configured include paths are available, ambiguous conventional-root matches must under-edge rather than create a guessed high-confidence edge.

Acceptance criteria

Activity

  1. added
    enhancement
    on Jun 5, 2026
  2. added
    priority: later
    on Jun 6, 2026
  3. sumithr commented on Jul 13, 2026

    @sumithr
    OwnerAuthor

    Batch finish-pass (2026-07-13): full proof posted on the linked PR (per-file review, fix rounds where applicable, behavioral verification through the real entrypoints, integrated-tip check). Under this issue's audit-refreshed acceptance criteria the slice is PARTIAL; the proof's AC-ledger section names exactly what is delivered vs what remains (audit-gated items, mostly #483/#484-scoped). The merge-vs-park decision is pending in the batch go-ahead; if merged as a partial, the PR's Closes reference will be softened so this issue stays open for the remainder.

  4. sumithr commented on Jul 13, 2026

    @sumithr
    OwnerAuthor

    Drift reconciliation against live main (work-issue step 1, 2026-07-13):

    The audit note above says #468 merges "after exact-spelling and angle-bracket behavior are corrected". PR #468 is merged (commit 3034810), but the merged resolver still contains the two behaviors this issue's own audit rejects:

    Also reconciled: CPP_CONFIG.extensions omits .hh/.hxx even though the resolver probes them, the exact metadata mismatch #483 flags.

    Implementing against reality on the branch for #483 + this issue: correct the quoted-include semantics to exact-spelling, importer-relative resolution (no extension probing, no conventional-root guessing, under-edge direction), keep angle-bracket includes emitting no edge until proven include roots exist (#484), reconcile the extension metadata, and activate scan dispatch per #483.

  5. sumithr commented on Jul 14, 2026

    @sumithr
    OwnerAuthor

    AC ledger for #359, audited against PR #530 (branch feat/issue-483-scanner-activation) with fresh local evidence: full suite 3175 passed, 0 failed, 100% coverage with the treesitter extra; ruff/mypy/format clean.

    • feat(repo-map): add C/C++ include resolver to the import-edge layer (#359) #468 is merged after exact-spelling and angle-bracket behavior are corrected. Partially historical: feat(repo-map): add C/C++ include resolver to the import-edge layer (#359) #468 merged 2026-07-13 with header-extension probing and include/src root guessing still in place (see the drift comment above). PR feat(repo-map): activate C/C++, PHP, and C# resolver dispatch in scan_repo #530 completes the correction, so the corrected semantics are what lands on main. Angle-bracket behavior: extraction drops the bracket form, and with no proven include roots available before [Task]: add scan-local resolver preparation for repository-aware import edges #484 the correct resolution result is no edge either way.
    • [Bug]: activate C/C++, PHP, and C# resolver dispatch in scan_repo #483 activates the registered resolvers through scan_repo. PR feat(repo-map): activate C/C++, PHP, and C# resolver dispatch in scan_repo #530 maps the extensions and proves activation end to end in tests/test_repo_map_scan_activation.py (every test drives a real scan_repo).
    • Quoted relative includes resolve by exact path. test_cpp_resolver_resolve_relative_to_including_file (unit) and test_scan_cpp_quoted_relative_include_emits_exact_edges (scan level, exact edge set). Absolute (leading slash) and directory (trailing slash) spellings are additionally pinned as no-edge, since the preprocessor cannot resolve them importer-relative.
    • Project angle-bracket includes resolve only through proven include roots. No proven roots exist without [Task]: add scan-local resolver preparation for repository-aware import edges #484's repository context, so the correct current behavior is under-edge: zero angle-bracket edges, pinned by test_scan_angle_bracket_includes_emit_no_edge (bracket spelling with the same-named file present relative AND under include/) and the orchestrator dropme.h true negative.
    • Extensionless includes do not probe .h/.hpp variants. test_cpp_resolver_resolve_extensionless_does_not_probe_header_variants (unit true negative against config.h and config.hpp) and test_scan_extensionless_include_does_not_probe_header_variants (scan level).
    • Ambiguous, external, macro, and repository-escape includes emit no edge. Ambiguity source removed with the conventional roots (test_cpp_resolver_resolve_does_not_guess_include_root / _src_root); external: test_cpp_resolver_resolve_external_not_found_yields_nothing plus the no-dangling-edges rule; macro: test_cpp_resolver_extract_macro_include_dropped (real grammar: the argument parses as an identifier); escape: test_cpp_resolver_resolve_escaping_repo_root_yields_nothing.
    • C and C++ registration, extraction, resolution, and scanner integration use real fixtures. Real tree-sitter extract tests, the committed cpp_project mini-repo at orchestrator and scan level (now including a .hh producer header), and real-file tmp_path scans.
    • Existing Python behavior and no-extra degradation remain unchanged. Full suite green with all pre-existing Python resolver/orchestrator tests untouched; test_scan_without_extra_still_classifies_activated_languages pins the single-warning degradation, and the whole suite also passed in a venv without the extra.

    Boundary notes: quoted includes beyond the importer's own directory and angle-bracket resolution through configured include directories (compile_commands.json) stay under-edged until #484 supplies scan-local repository context, per this issue's own dependency section.

  6. sumithr commented on Jul 14, 2026

    @sumithr
    OwnerAuthor

    AC verification (pre-merge, PR #530)

    Per-AC evidence, checked against the branch (feat/issue-483-scanner-activation, head e8d5500) rather than the PR self-description, plus merge-boundary verification.

    Criterion Status Evidence (branch)
    #468 merged after exact-spelling and angle-bracket behavior corrected Met by #468 + this PR together #468 landed the resolver with probing/root-guessing still present; this PR removes both and lands the correction (drift recorded on #359)
    #483 activates the registered resolvers through scan_repo Met tests/test_repo_map_scan_activation.py (every test drives real scan_repo); live run emits C/C++/PHP/C# nodes and edges
    Quoted relative includes resolve by exact path Met test_cpp_resolver_resolve_relative_to_including_file, test_scan_cpp_quoted_relative_include_emits_exact_edges; live edge file:src/main.cpp -> file:src/util.h
    Project angle-bracket includes resolve only through proven include roots Met (under-edge) No proven roots without #484 context, so zero angle edges; test_scan_angle_bracket_includes_emit_no_edge; live <vector> produced no edge
    Extensionless includes do not probe .h/.hpp variants Met test_cpp_resolver_resolve_extensionless_does_not_probe_header_variants, test_scan_extensionless_include_does_not_probe_header_variants; live #include "config" produced no edge to config.h
    Ambiguous, external, macro, and repository-escape includes emit no edge Met test_cpp_resolver_resolve_does_not_guess_include_root, test_cpp_resolver_resolve_external_not_found_yields_nothing, test_cpp_resolver_extract_macro_include_dropped, test_cpp_resolver_resolve_escaping_repo_root_yields_nothing
    C and C++ registration, extraction, resolution, and scanner integration use real fixtures Met Real tree-sitter extract tests, committed cpp_project mini-repo, real-file tmp_path scans
    Existing Python behavior and no-extra degradation remain unchanged Met Full suite green (3175 passed / 100% coverage); test_scan_without_extra_still_classifies_activated_languages pins the single-warning degradation

    Merge-boundary verification

    • CI: all required checks green.
    • Behavioral (4.7): scan_repo from the branch reproduced the original zero-C/C++-nodes state on base 002da7b, then showed the fix on the branch (exact edge set, all true-negatives holding).
    • Per-file sumo-qa-reviewing-before-merge pass over all changed files: SAFE.
    • Mutation: no new survivors introduced (only the pre-existing knowledge_loaders set, already killed on main by merged test(mutation): kill the 47 knowledge_loaders survivors from PR #302 #522).
  7. added a commit that references this issue on Jul 14, 2026
    3d08487
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

    ai-taskenhancementpriority: latertooling

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions