Skip to content

fix(registry-sync): origin-only agent URL matching in AuthorizationIndex - #9070

Merged
bokelley merged 2 commits into
adcontextprotocol:mainfrom
sujanchalla0510:fix-9014-registry-sync-origin-matching
Nov 18, 2026
Merged

bokelley merged 2 commits into
adcontextprotocol:mainfrom
sujanchalla0510:fix-9014-registry-sync-origin-matching

Conversation

@sujanchalla0510

Copy link
Copy Markdown
Contributor

Fixes #9014.

Problem

The client-side registry-sync replica in server/src/registry-sync/authorization-index.ts matched agent URLs by exact string, while #9011 moved the server validator and the registry directory to origin-only authorized_agents[].url matching (DR-0023, #8939). A TMP router using the replica denied an agent at https://agent.example.com/mcp when the publisher authorized the origin-only https://agent.example.com, and differed on canonical equivalence (scheme/host case, default port, dot segments, percent-encoding, trailing root dot).

Change

AuthorizationIndex now decides matches with the same rule as agentUrlAuthorizedBy in server/src/db/registry-agent-url-key.ts:

  • The primary index is keyed by the spec-exact canonical form of the entry's URL (specExactAgentUrl — a non-root trailing slash stays significant; the identity key registryAgentUrlKey, which folds it, is deliberately not used).
  • A lookup visits only the two buckets that can authorize the agent — its canonical URL and its canonical origin — and every candidate entry is still passed through agentUrlAuthorizedBy, so the replica cannot disagree with the validator or the directory by construction.
  • The rule applies to every lookup surface: check(), getSigningKeys(), getSigningKeysForScope() and getAuthorizedPlacements(). 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 / removeAgent resolve 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.ts run the shared fixture table in server/tests/fixtures/authorized-agent-url-matching.ts against the replica — all AUTHORIZED_CASES / UNAUTHORIZED_CASES, plus all SIGNING_KEY_CASES through check() / 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 pass
  • vitest run tests/unit/registry-sync/ tests/unit/authorized-agent-url-matching.test.ts tests/unit/matched-signing-keys.test.ts — 297/297 pass
  • tsc --project server/tsconfig.json --noEmit — clean

🤖 This PR was written by an AI agent (Muse) on behalf of @sujanchalla0510.

@mintlify

mintlify Bot commented Nov 17, 2026 •

Copy link
Copy Markdown

Preview approval required

This pull request comes from a fork, so Mintlify won't build a preview until someone with write access approves commit 91d8e78.

Approve preview

aao-secretariat[bot]
aao-secretariat Bot previously approved these changes Nov 17, 2026

@aao-secretariat aao-secretariat Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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 agentUrlAuthorizedBy is the correct shape — the replica cannot disagree with the validator by construction.
  • Insertion-order sort preserves #9016 document-order union.
  • removeEntry/removeAgent correctly clean the reverse index by stored spellings.
  • No changeset needed: this is a server/** app change, not static/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.

@aao-secretariat aao-secretariat Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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 bokelley left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

@bokelley
bokelley merged commit 05ce3a4 into adcontextprotocol:main Nov 18, 2026
29 checks passed
bokelley added a commit to aymeric45/adcp that referenced this pull request Nov 18, 2026
Pick up adcontextprotocol#8854 and adcontextprotocol#9070; resolve the test:schemas list conflict.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
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.

registry-sync AuthorizationIndex.check() uses exact-string agent_url matching, not origin-only matching

2 participants