Skip to content

fix(registry): match agent_url spec-exactly on the directory inverse-lookup - #8314

Merged
bokelley merged 2 commits into
mainfrom
fix/7830-publishers-spec-exact
Oct 19, 2026
Merged

bokelley merged 2 commits into
mainfrom
fix/7830-publishers-spec-exact

Conversation

@bokelley

@bokelley bokelley commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

Problem

GET /v1/agents/{agent_url}/publishers (and its /api/v1/... twin) ran its
parameter through canonicalizeAgentUrl — the registry identity key,
which folds a non-root trailing slash (#7830) — before calling
getPublishersForAgentDetail.

That DB helper is spec-exact by design: it keys for the index and then
restricts to the raw agent_url spellings that match per #7829. But it was
handed an already-folded URL, so the fold decided the authorization answer.
Two symptoms, in opposite directions:

  1. Over-reporting. A request for https://a.example/mcp/ was answered
    with https://a.example/mcp's publishers — an authorization the
    publisher's adagents.json does not grant, disagreeing with
    AgentValidator and with the sibling /registry/lookup/agent/:agentUrl/domains
    route.
  2. Under-reporting. An agent whose publishers declared it with a
    trailing slash resolved for neither spelling, because the folded lookup
    value never matched its raw rows.

docs/aao/directory-api.mdx has always specified the correct behavior —
"Path case and a non-root trailing slash are significant — /mcp and
/mcp/ are different agents" — so this brings the implementation to the
spec rather than changing the spec.

Fix

canonicalizeAgentUrl becomes a validity gate only (an input the
registry cannot key at all cannot name an indexed agent); the lookup takes
the URL as the caller wrote it, exactly as /domains does:

if (!canonicalizeAgentUrl(rawAgentUrl)) {
  return res.status(400).json({ error: "Invalid agent_url after canonicalization" });
}
const agentUrl = specExactAgentUrl(rawAgentUrl) ?? rawAgentUrl;   // echo only
…
const rawRows = await federatedIndex.getPublishersForAgentDetail(rawAgentUrl, {…});

The agent_url echo (200 body, 404 body, ETag input) is now the AdCP
canonicalization of the request — host lowercased, default port and dot
segments resolved — with the trailing slash preserved, which is what the
spec's "Canonicalized echo of the lookup key" means. It can no longer read
back as a different agent than the one that was matched.

The in-line comment records why the identity key must not become the lookup
value, so the next reader does not "simplify" it back.

Tests

server/tests/integration/registry-directory-publishers-spec-exact.test.ts
(7 cases, over HTTP through HTTPServer + supertest):

  • the declared spelling reports the publisher; the other spelling does not;
  • /publishers and /domains return the same answer for both spellings
    (the invariant the maintainer asked for), including the mirrored fixture
    where the authorization is declared without the slash — exactness has to
    cut both ways;
  • the spec-conformant /v1 mount answers identically to /api/v1;
  • the unindexed spelling 404s instead of reporting the folded agent;
  • the echo normalizes host case but preserves the trailing slash.

Verified to fail without the fix: 5 of the 7 cases go red, covering both
the over-reporting and the under-reporting direction.

Also re-ran the adjacent suites green: registry-directory-spec-exact
(including its "agrees with the validator" case),
registry-api-agent-publishers, registry-agent-publishers-detail,
registry-reader-baseline-public-endpoints, registry-identity-route-keying.

Published-behavior notes

Since this changes answers consumers may have adapted to:

  • docs/aao/directory-api.mdx — a dated note under the endpoint
    definition: through 2026-10-18 the directory folded the two spellings and
    answered both with the slashless agent's publishers; matching is now
    exact; a caller that asked with the wrong spelling now gets 404 or 200
    with an empty publishers[], and should ask with the spelling the
    publisher's adagents.json lists. It also states the contrast that the
    registry's own per-agent identity surfaces (compliance, badges,
    monitoring) deliberately do fold — identity and authorization are separate
    questions (fix(registry): key the requested URL on identity read routes #8312).
  • static/openapi/registry.yaml — regenerated from the zod source in
    registry-api.ts; both path descriptions now state the matching rule and
    the behavior change.
    No changeset: scripts/check-changeset-protocol-scope.cjs excludes
    static/openapi/registry.yaml and docs/aao/ from the protocol surface, so
    a registry behavior fix must not carry an adcontextprotocol bump (the push
    hook rejects one). The two notes above are the record.

Known gap, unchanged here

server/public/agents.html fetches /v1/agents/${agent.url}/publishers
using the registry's identity URL, which is the folded (slashless) spelling.
For an agent whose publishers declared it with a trailing slash, that page
shows "no indexed publisher authorizations" — it did before this PR too
(the folded lookup never matched those rows either), so this is not a
regression, but it is now the visible remainder of the same split. Fixing it
means passing the declared spelling to the directory call, which needs the
agents listing to expose it. Flagging rather than widening this PR.

Refs #7830, #7829.

🤖 Generated with Claude Code


Open workspace in Conductor

bokelley and others added 2 commits October 19, 2026 00:02
…lookup

`GET /v1/agents/{agent_url}/publishers` ran its parameter through
`canonicalizeAgentUrl` — the registry IDENTITY key, which folds a non-root
trailing slash (#7830) — before calling `getPublishersForAgentDetail`. That
DB helper is spec-exact by design (it keys for the index, then restricts to
the raw `agent_url` spellings that match per #7829), but it was handed an
already-folded URL, so the fold decided the authorization answer:

  - a request for `https://a.example/mcp/` was answered with
    `https://a.example/mcp`'s publishers — an authorization the publisher's
    adagents.json does not grant, and a direct disagreement with the
    validator and with the sibling `/domains` route; and
  - an agent whose publishers declared it WITH a trailing slash resolved for
    neither spelling, because the folded lookup never matched its raw rows.

The key is now only a validity gate; the lookup takes the URL as the caller
wrote it, exactly as `/registry/lookup/agent/:agentUrl/domains` does. The
`agent_url` echo is the AdCP canonicalization of the request with the
trailing slash preserved, which is what docs/aao/directory-api.mdx has
always specified ("Canonicalized echo of the lookup key").

docs/aao/directory-api.mdx already documented slash-significant matching, so
this brings the implementation to the spec rather than changing it; the page
and the OpenAPI description now also record the behavior change for
consumers that had adapted to the folded answers.

Refs #7830, #7829.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
scripts/check-changeset-protocol-scope.cjs excludes
static/openapi/registry.yaml and docs/aao from the protocol surface, so this
registry behavior fix must not carry an `adcontextprotocol` changeset. The
behavior change is recorded in docs/aao/directory-api.mdx and in the OpenAPI
description instead.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>

@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 — fail-open authorization bug fixed on the AAO directory inverse-lookup route.

What was checked:

  • The /v1/agents/{agent_url}/publishers route previously passed canonicalizeAgentUrl(rawAgentUrl) (which folds /mcp/→/mcp) into getPublishersForAgentDetail, so a /mcp/ request answered with /mcp's publishers — reporting an authorization the publisher's adagents.json did not grant. The fix passes rawAgentUrl to the DB (keyed internally, restricted to spec-exact spellings) and keeps canonicalizeAgentUrl only as a 400 validity gate. This is a fail-open→fail-closed change on a trust boundary.
  • Echo now uses specExactAgentUrl(rawAgentUrl) at registry-api.ts:11382/11477/11510, preserving the slash. The ?? rawAgentUrl fallback on an unconvertible U-label host is cosmetic and not load-bearing.
  • Change aligns /publishers with the sibling /domains route and the documented federated-index-db design; DB calls remain parameterized against gate-validated input.
  • Docs (directory-api.mdx), both OpenAPI descriptions, and the new 164-line integration test are mutually coherent; the test covers both spellings, both mounts, the reverse (slashless-declared) case, and echo canonicalization.
  • No changeset required — platform/registry API behavior (static/openapi + docs/aao), not the AdCP wire surface under static/schemas/source/**.

Decision rationale: No critical/high/medium findings. gated_paths is false. high_risk is true but the only reason is a (modified) file (server/src/routes/**) with no medium-or-higher finding — presumed safe per the high-risk reading rules; does not trigger row 5 (no medium) or row 3 (no deletion). No author team gate. No prior decision. Falls through to row 9 → approve.

@bokelley
bokelley merged commit b7d6d99 into main Oct 19, 2026
38 checks passed
@bokelley
bokelley deleted the fix/7830-publishers-spec-exact branch October 19, 2026 00:27
bokelley added a commit that referenced this pull request Oct 19, 2026
…e can ask the directory (#8316)

The registry lists an agent once, under its folded identity key: `/mcp` and
`/mcp/` are one agent (#7830). The directory answers authorization questions
spec-exactly, trailing slash significant (#7829, #8314). Both rules are
right, and together they left a hole on the public agents page: it asked
`GET /v1/agents/${agent.url}/publishers` with the listed (folded) URL, so an
agent whose publishers declared it as `/mcp/` showed "No indexed publisher
authorizations" — the page was asking about a spelling no publisher wrote.

`GET /api/registry/agents` now returns `declared_urls[]` per agent: the
listed URL first, then the owner's registered spelling, then every raw
`agent_url` the directory has indexed under that identity. One bulk query
(`bulkDeclaredAgentUrls`) over `v_effective_agent_authorizations` for the
whole page; a failure logs and falls back to the identity URL rather than
failing the listing. The legacy `agent_publisher_authorizations` arm is not
consulted — it is raw-matched with no canonical column, so its rows can only
be found by the exact spelling the caller already has.

agents.html splits the directory call out of the renderer into
`fetchPublisherRecords`, asks once per declared spelling, and merges by
publisher_domain with `authorized` beating `revoked`. A 404 for one spelling
is an empty page, not an error — with several spellings it is the normal
answer for all but one.

The same split applies to the listing's own property enrichment:
`getPropertiesForAgent` and `getPublisherDomainsForAgent` are spec-exact
reads too, so a slash-declared agent showed no properties either. Both now
run per declared spelling and merge. Single-spelling agents — nearly all of
them — make exactly the same calls as before.

`/publishers` itself is unchanged and stays spec-exact.

Refs #7830, #7829.

Co-authored-by: Claude Opus 5 (1M context) <[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.

1 participant