Skip to content

Fix ambiguous symbol navigation and real-repo call graphs - #726

Merged
justrach merged 13 commits into
release/0.2.5847from
codex/fix-name-resolution-725
Aug 28, 2026
Merged

Fix ambiguous symbol navigation and real-repo call graphs#726
justrach merged 13 commits into
release/0.2.5847from
codex/fix-name-resolution-725

Conversation

@justrach

Copy link
Copy Markdown
Owner

Summary

  • make common-name navigation deterministic before truncation, with explicit path scoping and honest ambiguity instead of arbitrary callpaths
  • resolve exact same-file, imported receiver, Zig thread-callback, and nested Zig re-export edges without repository-wide guessing
  • preserve full Swift function bodies and filter caller results to real invocation syntax
  • make reindex atomically persist root and central snapshots so the next no-daemon query loads instead of rescanning
  • focus codedb_context on production definitions before imports/tests/generated collisions
  • update the vendored OpenPuffer backend through upstream PR O(n²) trigram dedup in readFromDiskInner #31 while retaining CodeDB's malformed-sidecar hardening and full-width recall
  • version the warm CLI proxy handshake so a newly installed binary replaces a stale daemon instead of silently serving old retrieval behavior

Fixes #725.

Validation

  • zig build test --summary all — 31/31 build steps; 1,454 passed, 4 skipped
  • python3 scripts/e2e_mcp_test.py --binary zig-out/bin/codedb --project /Users/blackfloofie/tmp/codedb-fix-name-resolution-725 — 76/76
  • python3 scripts/fd_regression_test.py --binary zig-out/bin/codedb — 45 descriptors at both 128 and 2,048 files (bounded, corpus-size independent)
  • ReleaseFast build succeeded
  • Zigrepper (945 files): main resolves exactly to zigrep/src/exec/search_engine.zig:run; warm snapshot load verified
  • OpenWispr (125 files): toggleDictation resolves directly to beginDictation; Swift bodies restored; start caller false positives reduced
  • CodeDB (660 files): production src/main.zig:main ranks first; scoped MCP/watcher callpaths resolve correctly; .env* and *.pem return no matches

No version bump, tag, or release is included in this PR.

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 9790be81d6

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/mcp.zig
Comment on lines +2982 to +2984
var cursor = after_name;
while (cursor < line.len and (line[cursor] == ' ' or line[cursor] == '\t')) cursor += 1;
if (cursor < line.len and line[cursor] == '(') return true;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Accept language-specific calls before filtering

This predicate only accepts an identifier followed directly by (, apart from the Swift and shell exceptions below. Consequently, valid calls such as Ruby's render user and generic invocations such as C++ foo<int>() are discarded by handleCallers, potentially reporting zero callers even though the content search found real call sites. Add the supported languages' non-parenthesized and generic-call forms before using this as a mandatory filter.

Useful? React with 👍 / 👎.

Comment thread src/explore.zig
outline.language == .go_lang or outline.language == .php or
outline.language == .dart or outline.language == .java or
outline.language == .kotlin or outline.language == .svelte or
outline.language == .kotlin or outline.language == .swift or

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Recognize Swift multiline strings when balancing bodies

Adding Swift to the generic brace scanner corrupts function ranges for valid multiline literals: findBraceEnd only recognizes Dart triple quotes, so Swift's opening """ is treated as three alternating ordinary quotes. An ordinary " inside that literal can therefore end the scanner's string state, after which a literal } is counted as code and may truncate the function body; later calls then disappear from symbol bodies and the call graph. Teach the scanner Swift multiline/raw-string rules before enabling brace balancing for Swift.

AGENTS.md reference: AGENTS.md:L21-L21

Useful? React with 👍 / 👎.

@justrach

Copy link
Copy Markdown
Owner Author

Follow-up review caught and fixed a Windows-specific stale-daemon handoff bug in 7ba719e: the named-pipe listener now honors the same retire/yield result as POSIX. Re-review found no remaining blocker. Native tests remain green (261/265, 4 skipped), and zig build -Dtarget=x86_64-windows cross-compiles successfully.

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 7ba719e7dd

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/main.zig Outdated
std.process.exit(1);
};
defer allocator.free(snapshot_path);
snapshot_mod.writeSnapshotDual(io, &explorer, abs_root, snapshot_path, allocator) catch |err| {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Keep reindex usable on read-only project roots

When the indexed project is readable but not writable, such as a read-only checkout or mounted dependency tree, this unconditional root snapshot write fails and exits 1. The paired bootstrap.zig change now skips writeProjectCacheSnapshot for reindex, so the command no longer leaves the fresh central snapshot that previously made this workflow succeed; retain the cache write or make the root copy best-effort.

Useful? React with 👍 / 👎.

Comment thread src/mcp.zig
}
return;
}
if (from_candidates.len > 1 or to_candidates.len > 1) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Support disambiguation within a single file

When a selected file contains multiple call-graph nodes with the same name—such as overloaded Java/C++ methods or identically named methods in multiple classes—from_path/to_path still leaves multiple candidates and this branch refuses the search. Because paths are the only disambiguators exposed by the MCP schema and CLI, the user cannot proceed even after following the diagnostic; add a line/symbol selector or allow the same-file candidates to participate as an endpoint set.

Useful? React with 👍 / 👎.

@justrach

Copy link
Copy Markdown
Owner Author

Final validation on f8d0cfa:

  • zig build test --summary all: green (262/266 in the uncached MCP shard, 4 platform skips; all 31 build steps succeeded)
  • zig build -Doptimize=ReleaseFast: green
  • zig build -Dtarget=x86_64-windows: green
  • MCP E2E: 76/76
  • macOS FD regression: 45 descriptors at both 128 and 2048 files (bounded)
  • paired benchmark (5 AB/BA pairs, frozen base corpus): provenance/parity pass; codedb_context +1.50% / +5.78 us, under the 10% / 50 us gate
  • Zigrepper: 945 files; scoped zigrep/src/main.zig:main -> zigrep/src/exec/search_engine.zig:run resolves in one hop
  • OpenWispr: 125 files; toggleDictation -> beginDictation resolves; callers are filtered correctly
  • CodeDB checkout: 1247 files; scoped src/main.zig:main -> src/mcp.zig:dispatch resolves in six hops; qualified watcher.incrementalLoop callbacks are retained
  • sensitive path smoke: *.pem and .env* return no indexed files

The ranking path keeps the established fast approximate graph; user-visible callpaths upgrade it to strict scoped/import-aware resolution. This preserves retrieval latency while fixing #725 correctness.

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f8d0cfa311

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/bootstrap.zig
defer allocator.free(snap_path);
if (std.Io.Dir.cwd().statFile(io, snap_path, .{})) |st| {
snap_stat = st;
if (!found or st.mtime.nanoseconds > snap_stat.mtime.nanoseconds) snap_stat = st;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Check freshness against the snapshot that actually loads

When the newer snapshot is corrupt, truncated, or has a mismatched Git HEAD, this uses that rejected file's mtime as the freshness baseline, while loadBestSnapshot subsequently falls back to the older valid copy. A worktree edit made after the older snapshot but before the rejected newer file will therefore not mark the index stale, so queries silently serve the older snapshot and miss the edit; select the baseline only after validating the snapshot, or propagate the mtime of the copy that was actually loaded.

Useful? React with 👍 / 👎.

@justrach
justrach merged commit 3e78c4c into release/0.2.5847 Aug 28, 2026
2 checks passed
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.

1 participant