Repository navigation
fix(registry-sync): origin-only agent URL matching in AuthorizationIndex - #9070
Conversation
Preview approval requiredThis pull request comes from a fork, so Mintlify won't build a preview until someone with write access approves commit |
There was a problem hiding this comment.
Ladon verdict: Approve
Approve — in-memory AuthorizationIndex replica aligned with server validator's origin-only agent URL matching (#9014, DR-0023).
What I checked:
- Keying by spec-exact canonical form, over-selecting two buckets (exact URL + canonical origin), and re-filtering candidates through
agentUrlAuthorizedByis the correct shape — the replica cannot disagree with the validator by construction. - Insertion-order sort preserves #9016 document-order union.
removeEntry/removeAgentcorrectly clean the reverse index by stored spellings.- No changeset needed: this is a
server/**app change, notstatic/schemas/source/**or other published protocol surface. - Shared fixture table (AUTHORIZED/UNAUTHORIZED/SIGNING_KEY_CASES) reused across the three surfaces, preventing drift.
Medium findings (non-blocking):
server/src/registry-sync/authorization-index.ts:283—check()/getSigningKeys()/getAuthorizedPlacements()rebuild the all-domains match map per call then discard all but one domain, a per-call recompute regression on the declared TMP hot path.
One medium finding, no critical/high. gated_paths is false; no high-risk, no team gate, no prior escalation. Falls through to row 9 (1–2 mediums, no trigger = approve).
Medium findings
- server/src/registry-sync/authorization-index.ts:283 — check() rebuilds all-domains match map on the hot path then discards all but one
…isher domain check() with a resolved publisher domain, getSigningKeys, and getAuthorizedPlacements now use matchingForDomain, which visits only the candidate buckets' entries for that domain, instead of matchingByDomain materializing and sorting the agent's entries for every publisher on the TMP hot path (Ladon Medium on adcontextprotocol#9070). Failure reasons are preserved via a scan-only hasAnyMatch check.
There was a problem hiding this comment.
Ladon verdict: Approve
Approve — performance refactor resolving the prior Medium, no new findings.
This PR touches only server/src/registry-sync/authorization-index.ts and its unit tests (non-protocol surface: no schema, docs, dist, or changeset-relevant files). The prior run flagged one Medium — check() rebuilding the all-domains match map on the hot path then discarding all but one entry. That finding is resolved: the known-domain hot path now calls the scoped matchingForDomain() instead of materializing/sorting every publisher's entries via matchingByDomain().
Reviewer verified behavioral equivalence — same candidateKeys/agentUrlAuthorizedBy filter and entryOrder sort, and the agent-not-found vs not-authorized-for-publisher reason split is preserved via hasAnyMatch() (equivalent to the old byDomain.size===0 check). matchingEntries() rerouting keeps getAuthorizedPlacements/getSigningKeys semantics.
No critical/high/medium findings in this run. high_risk false, gated_paths false, no author team gate. No escalation triggers (rows 1–8 do not fire; prior decision was approve, so sticky-escalation row 6 is inapplicable). Falls through to row 9.
bokelley
left a comment
There was a problem hiding this comment.
Thanks @sujanchalla0510, a clean fix for #9014. The replica now decides matches with agentUrlAuthorizedBy itself and visits only the exact-URL and origin buckets, so it can't drift from the validator. The shared fixture table, including the signing-key cases, covers it. The hot-path scoping in 91d8e78 addresses Ladon's note.
Pick up adcontextprotocol#8854 and adcontextprotocol#9070; resolve the test:schemas list conflict. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Fixes #9014.
Problem
The client-side registry-sync replica in
server/src/registry-sync/authorization-index.tsmatched agent URLs by exact string, while #9011 moved the server validator and the registry directory to origin-onlyauthorized_agents[].urlmatching (DR-0023, #8939). A TMP router using the replica denied an agent athttps://agent.example.com/mcpwhen the publisher authorized the origin-onlyhttps://agent.example.com, and differed on canonical equivalence (scheme/host case, default port, dot segments, percent-encoding, trailing root dot).Change
AuthorizationIndexnow decides matches with the same rule asagentUrlAuthorizedByinserver/src/db/registry-agent-url-key.ts:specExactAgentUrl— a non-root trailing slash stays significant; the identity keyregistryAgentUrlKey, which folds it, is deliberately not used).agentUrlAuthorizedBy, so the replica cannot disagree with the validator or the directory by construction.check(),getSigningKeys(),getSigningKeysForScope()andgetAuthorizedPlacements(). Entries gathered from both buckets are evaluated in insertion order, so the signing_keys when several authorized_agents entries match: pinned only if every matching entry pins; allowed keys are the union #9016 signing-key pin (pinned only if every matching entry pins, else the union) spans an origin-only entry and a full-URL entry in document order.removeEntry/removeAgentresolve through the same canonical key and clean the reverse index with the spellings actually stored, so a revocation spelled differently from the grant (case, default port) still revokes it; removing a path agent does not remove the origin-only entry for its origin.No changeset: this is a server/app change, not a protocol-package change (per
.agents/playbook.md).Tests
New tests in
server/tests/unit/registry-sync/authorization-index.test.tsrun the shared fixture table inserver/tests/fixtures/authorized-agent-url-matching.tsagainst the replica — allAUTHORIZED_CASES/UNAUTHORIZED_CASES, plus allSIGNING_KEY_CASESthroughcheck()/getSigningKeysForScope()— alongside origin-entry signing-key/placement lookups and spelling-variant removal.Locally:
vitest run tests/unit/registry-sync/authorization-index.test.ts— 114/114 passvitest run tests/unit/registry-sync/ tests/unit/authorized-agent-url-matching.test.ts tests/unit/matched-signing-keys.test.ts— 297/297 passtsc --project server/tsconfig.json --noEmit— clean🤖 This PR was written by an AI agent (Muse) on behalf of @sujanchalla0510.