Repository navigation
Route Direct knowledge by per-repo data and a per-request knowledge view - #203
Conversation
Direct routing named vllm-omni in code: the owner table, repo aliases, the default repo, the model directory, and a `!= "vllm-omni"` branch that sent every other repository down a different path. The knowledge root was also captured at import, so an activated knowledge snapshot would keep serving the old tree until the process restarted. - Move the owner table to knowledge/repos/vllm-omni/_routes.yaml (owners and models); aliases now come from each adapter's repo.full_name/aliases. - Pick the routing path by data: a repo with a non-empty _routes.yaml uses owner/model routing, else adapter changed-file routing, else unsupported. `repo` is required; path-like names are unsupported, not an escape. - Add KnowledgeView: KNOWLEDGE_ROOT resolves once per request; a snapshot with MANIFEST.json is verified on load and per read (fail closed on tampering). - DirectClient pins one view per plan and validates completion against the pinned tree (recomputed without the digest cache, so a file changed or deleted after planning still fails completion), so activating a snapshot mid-review does not reject it; plans report diagnostics.knowledge_snapshot. read_document() takes an optional review_context_id and then reads (every page) from that plan's snapshot. - The MCP document reader verifies every read and search against the snapshot manifest (KnowledgeDocs gains an optional per-file verify callback). A golden file records the old router's output for 150 merged vllm-omni PRs plus adapter-only and unsupported repos; the new router reproduces it exactly. The repo-neutrality ratchets drop direct_routing.py from 24 + 2 + 52 to zero. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
https://github.com/JiusiServe/InferMatrixCopilot/blob/7c877a2cb3009a5835d85ae5b90e2814690ac783/src/infermatrix_copilot/thin_mcp_server.py#L170-L171
Restore alias lookup in the Strict URL path
In the Strict MCP PR-URL path, whenever resolve_repo_alias returns None—including a default installation without repo_full_names or repo_paths, and any unsupported URL—this fallback evaluates _REPO_ALIASES, which this commit removed from the imports and from direct_routing.py. The request therefore raises an uncaught NameError instead of resolving a built-in adapter alias or returning the intended configuration error.
ℹ️ 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".
| @lru_cache(maxsize=64) | ||
| def _load_routes(view: KnowledgeView, repo: str) -> dict | None: |
There was a problem hiding this comment.
Avoid caching routes for mutable knowledge views
When KNOWLEDGE_ROOT points to the supported plain development tree, its KnowledgeView remains equal across requests, so this cache permanently retains the first parsed _routes.yaml; editing or deleting that file does not affect subsequent requests until a process restart or manual cache clear. The same cache also prevents a previously loaded manifest-backed route file from being rechecked after corruption, undermining the per-read fail-closed behavior.
Useful? React with 👍 / 👎.
| alias, changed_files = self._request_values(request) | ||
| expected_head = request.expected_head_sha.strip().casefold() | ||
| view = self._view() |
There was a problem hiding this comment.
Resolve the knowledge view before request validation
During DirectClient.plan, _request_values calls self.capabilities(), which resolves and hashes the currently active knowledge view, and only afterward does this code resolve another view for routing. If the activation symlink is swapped between those operations, repository support is validated against one snapshot while the plan is built from another, causing a newly supported repo to be rejected or a removed repo to receive an unsupported plan rather than preserving the advertised one-view-per-request invariant.
Useful? React with 👍 / 👎.
| raise ValueError(f"{relative}: owners[{index}] needs a unique owner") | ||
| if not isinstance(signals, list) or not isinstance(prefixes, list): | ||
| raise ValueError(f"{relative}: owners[{index}] signals/scope_prefixes must be lists") | ||
| view.path(path) # fail closed on a route to a missing page |
There was a problem hiding this comment.
Restrict owner routes to their repository slice
A repository's _routes.yaml can currently name any existing file in the knowledge tree, so, for example, repos/demo-repo/_routes.yaml can point an owner at repos/vllm-omni/... and Direct will serve another repository's rules. Validate that each owner path remains under repos/<repo>/ so a configuration mistake cannot cross owner/repository boundaries.
AGENTS.md reference: AGENTS.md:L12-L17
Useful? React with 👍 / 👎.
Model routes were sorted by name length only, so models with equal-length names (lingbot-world, minicpm-o-4-5, lingbot-video) kept filesystem order. When the three-route cap cut between them, two machines routed the same PR differently: the golden test passed locally and failed in CI for PRs 8175 and 7892. Break ties by name; the golden entry for 7892 records the new deterministic order. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
First PR of the knowledge-base redesign (Copilot owns the knowledge base; quality-gated auto-merge; release sweep). This one makes Direct routing repo-neutral and makes knowledge reads follow the active snapshot.
What changes
knowledge/repos/vllm-omni/_routes.yaml. Repo aliases come from each adapter'srepo.full_name/repo.aliases.direct_routing.pyno longer names any repository._routes.yamlgets owner and model routing. Otherwise, a repo with an adapter gets changed-file routing. Anything else is unsupported.repois now required.KnowledgeViewresolves per request. UnsetKNOWLEDGE_ROOTmeans the packaged tree, as today. When set, the path is resolved once per request. A snapshot withMANIFEST.jsonis verified when loaded and on every read, and a tampered, missing or unlisted file fails closed.DirectClientpins the snapshot each plan was issued from.read_document(..., review_context_id=...)reads from the pinned tree.diagnostics.knowledge_snapshotreports which snapshot was used.Test Plan
test/test_knowledge_view_routing.py:_routes.yaml;test_repo_vocabulary.py/test_v2_p0.py:direct_routing.pyleak ceilings go from 24 + 2 + 52 to 0.check_spec_freshness,check_doc_links.Test Result
PYTHONPATH=src python -m pytest -q).check_knowledge_tree.py: 0 errors.check_wiki_lint.py: 0 errors, 0 reminders.check_spec_freshness: 83/83 verified, 0 uncovered.check_doc_links: OK.🤖 Generated with Claude Code