Skip to content

fix(discovery): origin-only authorized_agents entries match any path under AdCP 3.3 - #3710

Merged
bokelley merged 3 commits into
mainfrom
fix/origin-only-authorized-agents-3695
Nov 14, 2026
Merged

bokelley merged 3 commits into
mainfrom
fix/origin-only-authorized-agents-3695

Conversation

@bokelley

@bokelley bokelley commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

Closes #3695

Needed for the AdCP 3.3 RC (Mon Nov 16). This is the SDK side of adcp#8943, with the server side in adcp#9011. It implements the rule adcp#8939 documents under DR-0023.

The rule

  • Origin-only entry. An authorized_agents[].url whose canonical form has the root path and no query (https://agent.example.com or https://agent.example.com/) matches any agent URL with the same canonical origin, including https://agent.example.com/mcp.
  • Entry with a path. It matches that canonical URL only, so path case, a trailing slash (/mcp vs /mcp/) and the query stay significant.
  • Which releases. The rule applies only at AdCP 3.3 or later. 3.2 and earlier keep exact canonical-URL matching, byte-identical to before.

Normalization

Both sides go through the existing canonicalizeAgentUrl first.

Input difference Effect
Scheme and host case Ignored
Default port (:443 for https, :80 for http) Dropped. Any other port must match
Root trailing slash (https://a.example vs https://a.example/) Ignored. Both are origin-only
Dot segments, unreserved percent-encoding, fragment Normalized away
One trailing root dot on a DNS host (https://a.example.) 3.3 only: removed on both sides. More than one dot matches nothing (spec step 2). At 3.2 the dot stays part of the exact URL, as before
Scheme, host, non-default port Always significant
A query on the entry, even an empty ? The entry is not origin-only
Userinfo, unparseable URL Matches nothing (canonicalizeAgentUrl returns null)

The root-dot rule lives inside the matcher, not in canonicalizeAgentUrl. That keeps the canonicalizer's other callers unchanged: format ids, supply-path agentIdentity and the v2 projections. 3.2 matching also stays byte-identical. The rules match adcp#9011.

Several matching entries: union (matches adcp#9011)

At 3.3 or later, every authorized_agents entry that matches an agent authorizes it, and the agent's scope is the union of theirs. Two examples:

  • an origin-only entry and an exact entry for the same agent;
  • two spellings of one origin.

What this means for the result:

  • properties, cross_publisher and cross_publisher_expanded combine, with duplicates removed. A narrower entry never removes scope that another matching entry grants.
  • unresolvable is set only when the union is empty. It then carries the first matching entry's reason.
  • matched_entries lists every matching entry in document order. matched_entry stays the first one.

Below 3.3 the resolver is byte-identical to before: only exact canonical matches count, and two of them still fail closed as ambiguous_agent_url. matched_entries is not set below 3.3.

signing_keys. The SDK resolver does not read or combine signing keys; it never did. Callers that need them read the entries from matched_entries. The server's getPublishersForAgentDetail reports signing_keys_pinned: true when any matching entry has a non-empty signing_keys (signingKeysPinnedByPublisher, using its agentUrlAuthorizedBy matcher). The matched_entries doc comment records that rule, so an SDK caller can reach the same answer. fetchAgentAuthorizationsFromDirectory already passes the server's flag through unchanged.

Version gate

The gate reuses the SDK's existing isAdcpVersionAtLeast(version, '3.3.0-beta.0'). The other 3.3 gates use the same threshold, so every 3.3 prerelease counts.

  • resolveAgentProperties(adAgents, agentUrl, { adcpVersion }). The new optional adcpVersion defaults to the SDK pin, ADCP_VERSION (3.3.0-beta.6), the same default the clients' adcpVersion option uses. A caller on a 3.2 session passes '3.2'. An unparseable version fails closed to exact matching.
  • PropertyCrawler. It matches each agent under the release that agent served for get_adcp_capabilities. When the agent reports none, it uses the new adcpVersion crawler option, which defaults to the SDK pin and is also passed to the agent's client.

Changes

File Change
src/lib/discovery/resolve-agent-properties.ts New agentUrlMatchesAuthorizedEntry(entryUrl, agentUrl, { adcpVersion }) and usesOriginOnlyAgentMatching(adcpVersion?). resolveAgentProperties takes { adcpVersion } and, at 3.3+, unions the scope of every matching entry (see below). New matched_entries on the result.
src/lib/discovery/property-crawler.ts Uses the served release, else the adcpVersion option.
src/lib/index.ts, src/lib/entrypoints/discovery.ts Export the helpers and AgentUrlMatchOptions from the root and from @adcp/sdk/discovery.
src/lib/supply-path/validation.ts, evaluate.ts Comments only. Supply-path semantics v1 keeps exact canonical-URL matching until a new semantics version (4.0), per adcp#8943.
src/lib/discovery/validate-adagents.ts JSDoc only. validateAdAgents locates and loads the file and does no agent matching, so the docs point at resolveAgentProperties.
docs/migration-16-to-17.md A note under "Protocol and discovery".
test/lib/authorized-agent-origin-only.test.js New tests.
.changeset/authorized-agents-origin-only.md minor: new exports and options.

verify_agent_authorization named in the issue is the Python SDK's function (adcp-client-python). This repo's equivalent is resolveAgentProperties. The Python SDK is not changed here.

Tests

test/lib/authorized-agent-origin-only.test.js has 53 cases:

  • an origin-only entry with an agent at a deeper path matches under 3.3 and does not match under 3.2;
  • a different host, subdomain, scheme or port never matches;
  • an entry with a path matches exactly only;
  • /?tenant=acme and an empty ? are not origin-only;
  • normalization: scheme and host case, default ports, dot segments, percent-encoding, fragments, IDN A-labels and IPv6;
  • trailing root dot: https://a.example. matches https://a.example/mcp at 3.3, https://a.example.. matches nothing, and a dotted entry against a dotted agent at 3.2 stays exact;
  • userinfo on either side matches nothing at 3.2 and 3.3;
  • union: exact plus origin-only, two origin-only spellings, mixed authorization types with cross-publisher selectors, an empty union's reason, and a broken entry that does not hide another's scope. At 3.2, two exact matches stay ambiguous;
  • the crawler gives the union at 3.3 and only the exact entry at 3.2;
  • the crawler follows the targeted release and the negotiated release;
  • the supply-path case-sensitive-agent-path vector still fails owner_agent_declared, with a passing control.

Verification

All of these pass locally:

  • npm run typecheck, npm run build:lib, npm run format:check, lint:boundaries and ci:docs-check.
  • npm run lint, with 0 errors.
  • The related suites: 406 tests.
  • A clean run of test:lib:fast: 22,562 tests, 0 failures.

🤖 Generated with Claude Code

…under AdCP 3.3

adcontextprotocol/adcp#8939 (adcp#8862, DR-0023) makes an origin-only
authorized_agents[].url authorize the agent at that origin whatever its
path; an entry with a path keeps exact canonical-URL matching.

resolveAgentProperties gains an adcpVersion option (default: the SDK pin)
and applies the rule at 3.3 or later, preferring an exact entry over an
origin-only one. New agentUrlMatchesAuthorizedEntry and
usesOriginOnlyAgentMatching expose the rule. PropertyCrawler matches under
each agent's served release, else its new adcpVersion option. Supply-path
verification stays exact under semantics v1 (adcp#8943).

Closes #3695

Co-Authored-By: Claude Opus 5.5 <[email protected]>
aao-secretariat[bot]
aao-secretariat Bot previously approved these changes Nov 14, 2026

@aao-secretariat aao-secretariat Bot 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.

Ladon verdict: Approve

Approve — AdCP 3.3 origin-only authorized_agents[].url matching (adcp#8943, DR-0023).

Checked:

  • Core matching in resolve-agent-properties.ts: exact preferred over origin (L298), origin matching gated on entry.origin === agent.origin (different port/scheme/subdomain/suffix fail per negative test matrix L494-510), duplicate-exact and duplicate-origin both fail closed as ambiguous_agent_url.
  • Version gate usesOriginOnlyAgentMatching fails closed to exact matching on unparseable/<3.3 versions; default follows SDK pin, documented in changeset + migration-16-to-17.md.
  • PropertyCrawler keys servedVersions by agent_url, populated in Step 1 before Step 3 matching, with crawler-pin fallback.
  • Supply-path legs stay exact (semantics v1); evaluate.ts/validation.ts changes are comment-only.
  • Changeset present and correctly typed minor (additive exports + optional param) — satisfies changeset-vs-wire-impact; minor-release backward pathway honored since prior minor falls closed to exact matching.
  • 378-line test file covers normalization, IDN, ambiguity, 3.2-vs-3.3 split, crawler negotiation, supply-path exactness.

Gates: gated_paths false; high_risk false; no no-auto-approve team match; no prior decision. Reviewer found no Critical/High/Medium findings. No decision-table row 1-8 fires → row 9 approve. (review_decision REVIEW_REQUIRED does not block since gated_paths is false.)

Aligns with the server PR adcontextprotocol/adcp#9011 and URL
canonicalization step 2: at AdCP 3.3 the authorized_agents[].url matcher
removes one trailing root-label dot from a DNS host on both the entry and
the agent, and a host ending in more than one dot matches nothing.
canonicalizeAgentUrl is unchanged, so 3.2 exact matching and its other
callers stay byte-identical. Adds userinfo-rejection tests.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
aao-secretariat[bot]
aao-secretariat Bot previously approved these changes Nov 14, 2026

@aao-secretariat aao-secretariat Bot 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.

Ladon verdict: Approve

Approve — subsequent pass, prior approve stands.

This is a follow-up pass on PR #3710. The delta adds trailing-root-dot normalization (stripRootDot) and locks in userinfo rejection across AdCP 3.2/3.3 with 48 test cases. The reviewer verified the IPv6 [-guard, url.slice(origin.length) prefix safety, port preservation, and the fail-closed (>1-dot / .-only → null) path feeding matchCanonicalAgentUrl. The 3.2 path remains byte-identical via the !originOnlyMatching short-circuit, and userinfo rejection pre-exists at parseAgentUrl.

Changeset is minor, correctly matching the new exports/options — changeset-vs-wire-impact is satisfied. No witness-not-translator concerns. No new findings.

Decision table: no critical/high/medium findings (row 1, 4, 5, 8 don't fire); gated_paths is false (row 2 n/a despite REVIEW_REQUIRED); high_risk is false (rows 3, 5 n/a); prior decision was approve, not escalate (row 6 n/a); no no-auto-approve team match (row 7 n/a). Falls through to row 9 → approve.

…ntry at 3.3

Matches the server (adcontextprotocol/adcp#9011): at AdCP 3.3 or later
every authorized_agents entry that matches an agent authorizes it, and the
agent's scope is the union of theirs. An exact entry and an origin-only
entry, or two origin-only spellings of one origin, now combine properties,
cross_publisher and cross_publisher_expanded instead of "exact wins" or
ambiguous_agent_url. New matched_entries lists every matching entry so
callers can read per-entry fields such as signing_keys. Below 3.3 the
resolver is byte-identical to before.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

@aao-secretariat aao-secretariat Bot 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.

Ladon verdict: Approve

Approve — clean pass, no blocking or medium findings.

This PR reverses prior fail-closed-on-ambiguous semantics to union-of-all-matching-entries at AdCP 3.3+, driven by spec adcontextprotocol/adcp#9011 (DR-0023). Verified:

  • Witness fidelity: 3.2-and-below unchanged (exact-match-only, ambiguous_agent_url), new behavior gated on usesOriginOnlyAgentMatching with a documented pathway back — satisfies the minor-release pathway-back requirement (DR-0033).
  • unionAgentScopes/uniqueByValue dedup correctly by reference and JSON value; empty-union reason, matched_entry (first-in-document-order), and matched_entries all match new tests.
  • Changeset present and correctly typed minor, matching the backward-compatible wire change — changeset-vs-wire-impact satisfied.
  • Migration doc updated; no stale doc links flagged.

No Critical/High/Medium findings. Prior decision was also approve on an earlier head. No author-team gate, gated_paths: false, high_risk: false. Decision table falls through to row 9.

@bokelley
bokelley merged commit 2849dd6 into main Nov 14, 2026
46 checks passed
@bokelley
bokelley deleted the fix/origin-only-authorized-agents-3695 branch November 14, 2026 15:37
bokelley added a commit that referenced this pull request Nov 14, 2026
…across matching entries

SDK side of adcontextprotocol/adcp#9016. When more than one
authorized_agents entry matches one agent under AdCP 3.3, the publisher
pins the agent only if every matching entry carries signing_keys (absent or
empty unpins), and the pin is then the union of their keys.

The SDK makes no pin decision from adagents.json itself: webhook
publisherPins are caller-supplied and supply-path verification only lists
signing_keys as an understood field. So this adds a helper and docs:

- resolvePublisherSigningKeyPin(scope | entries): undefined for no pin,
  never [], so it drops into PublisherSigningKeyPin.signingKeys. Uses
  matched_entries at 3.3+, matched_entry below 3.3. Exported from
  @adcp/sdk and @adcp/sdk/discovery.
- AuthorizedAgent gains optional signing_keys.
- matched_entries and AgentDirectoryPublisher.signing_keys_pinned docs
  state the rule; the pending #3710 changeset no longer says the registry
  pins on any matching entry.
- Migration docs (agent resolution 3.3, 16 to 17) point at the helper.

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.

validateAdAgents / verify_agent_authorization: origin-only authorized_agents entries match any path (DR-0023, adcp#8862)

1 participant