Skip to content

Fix architecture context ranking and callpath language scope - #720

Merged
justrach merged 2 commits into
release/0.2.5845from
codex/fix-context-architecture-ranking
Aug 27, 2026
Merged

Fix architecture context ranking and callpath language scope#720
justrach merged 2 commits into
release/0.2.5845from
codex/fix-context-architecture-ranking

Conversation

@justrach

Copy link
Copy Markdown
Owner

Closes#718.

What changed

  • exclude .wrangler and .open-next generated caches from indexing/ANN corpus
  • add a narrowly gated architecture-overview prior after hybrid fusion
  • seed canonical architecture/codebase docs and shallow source entrypoints
  • demote experiments, e2e, generated, test, and benchmark paths for overview tasks
  • prefer package src/main.* definitions for generic codedb_explain main
  • resolve call-graph edges only within compatible language families

Regression coverage

  • architecture fixture requires all 5 gold files in top-5 and rejects e2e/generated files
  • generated cache walker coverage for Wrangler/OpenNext
  • generic main ordering test
  • cross-language synthetic callpath rejection

Verification

  • zig build test --summary all: 1033 passed, 4 skipped
  • MCP E2E: 76/76 passed
  • @hasmcp/mcp-spec-test 2026-07-28: 27 passed, 0 failed
  • live hybrid ANN: 8926 chunks, Qwen 512D, mmap=true; architecture docs/entrypoints retained after fusion

@chatgpt-codex-connectorchatgpt-codex-connectorBot 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: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".

Comment threadsrc/mcp.zig
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;

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 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 👍 / 👎.

Comment threadsrc/mcp.zig Outdated
}
return;
};
prioritizeGenericEntrypoint(name, fuzzy, results);

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 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 👍 / 👎.

@chatgpt-codex-connectorchatgpt-codex-connectorBot 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: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".

Comment threadsrc/mcp.zig
Comment on lines +3238 to +3243
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");

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 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 👍 / 👎.

Comment threadsrc/explore.zig
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;

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 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 👍 / 👎.

@justrach
justrach merged commit 71fc4f3 into release/0.2.5845Aug 27, 2026
2 checks passed
@justrach
justrach deleted the codex/fix-context-architecture-ranking branch August 27, 2026 19:19
@justrachjustrach mentioned this pull request Aug 27, 2026
Sign up for freeto 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

@justrach