Fix architecture context ranking and callpath language scope - #720
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit:0e634ccb42
ℹ️ 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".
| var outline_paths = explorer.outlines.keyIterator(); | ||
| while (outline_paths.next()) |path| { | ||
| if (architecturePathPriority(path.*) >= 700 and !known_paths.contains(path.*)) { | ||
| seed_paths.append(A, path.*) catch break; |
There was a problem hiding this comment.
Copy seeded paths before releasing the Explorer lock
When an architecture-context request runs concurrently with the watcher removing a seeded file, this stores a borrowed outlines map key and then releases the shared lock. Explorer.removeFile can subsequently free that key before seed_paths is sorted, previewed, and rendered, producing a use-after-free and potentially crashing the MCP process. Duplicate each selected path into the request arena while the lock is held, or retain the lock until all borrowed paths have been consumed.
Useful? React with 👍 / 👎.
| } | ||
| return; | ||
| }; | ||
| prioritizeGenericEntrypoint(name, fuzzy, results); |
There was a problem hiding this comment.
Apply entrypoint priority before truncating results
When codedb_symbol is called with a small max_results (or a repository has more than the default 50 main definitions), searchSymbols has already truncated exact matches using score/path ordering before this sort runs. For example, with max_results: 1, experiments/probe.py sorts before src/main.zig, so the canonical entrypoint is discarded and this new prioritization cannot recover it. The entrypoint path priority needs to participate in candidate selection before the limit is applied.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit:834b1e27e1
ℹ️ 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".
| return asciiContainsIgnoreCase(task, "overview") or | ||
| asciiContainsIgnoreCase(task, "entrypoint") or | ||
| asciiContainsIgnoreCase(task, "routing") or | ||
| asciiContainsIgnoreCase(task, "source layout") or | ||
| asciiContainsIgnoreCase(task, "how the") or | ||
| asciiContainsIgnoreCase(task, "map"); |
There was a problem hiding this comment.
Require overview intent before applying architecture priors
Implementation tasks such as fix routing in the architecture module satisfy this gate even though they are not overview requests, because architecture plus routing is sufficient; similarly, the substring check for map matches words such as roadmap. In that scenario handleContext filters test/fixture symbol evidence and sorts seeded architecture documents and every root src/ file ahead of the actual lexical results, potentially excluding the relevant implementation from the five-file context bundle. Require an explicit overview/map-style phrase rather than treating routing or entrypoint terms alone as overview intent.
Useful? React with 👍 / 👎.
| while (n2i.next()) |e| resolve.put(e.key_ptr.*, e.value_ptr.items) catch return; | ||
| var edges_tmp = codegraph.buildEdges(a, funcs.items, &resolve, false) catch return; | ||
| var edges_tmp = codegraph.buildEdgesWithinGroups(a, funcs.items, &resolve, node_language_group.items, false) catch return; |
There was a problem hiding this comment.
Invalidate persisted centrality after changing edge semantics
On an upgraded installation with an existing format-v4 snapshot, this new language-scoped graph is not used for ranking centrality: snapshot.zig restores the previously persisted CALL_CENTRALITY section, and ensureCallCentrality returns immediately whenever that map is non-null. Because this commit does not bump the snapshot format or otherwise discard/recompute that derived section, unchanged repositories retain centrality calculated from the old cross-language edges indefinitely, so ranked search and context results do not receive the advertised language-scope fix until some later index mutation invalidates the cache.
Useful? React with 👍 / 👎.
Closes#718.
What changed
.wranglerand.open-nextgenerated caches from indexing/ANN corpussrc/main.*definitions for genericcodedb_explain mainRegression coverage
Verification
zig build test --summary all: 1033 passed, 4 skipped@hasmcp/mcp-spec-test2026-07-28: 27 passed, 0 failed