fix(registry): canonicalize agent_url before registered/discovered collapse (closes #3573)#3773
Closed
EmmaLouise2018 wants to merge 1 commit into
Closed
fix(registry): canonicalize agent_url before registered/discovered collapse (closes #3573)#3773EmmaLouise2018 wants to merge 1 commit into
EmmaLouise2018 wants to merge 1 commit into
Conversation
…llapse (closes #3573) The merge in `listAllAgents` and `lookupDomain` keyed on raw `agent_url` strings, so a registered `https://agent.example/` and discovered `https://agent.example` surfaced as two separate entries instead of collapsing to the registered row. Read-side: map keys + lookups in `server/src/federated-index.ts` now go through the existing `canonicalizeAgentUrl` helper (lowercase, trailing slash stripped) so case- and slash-only differences collapse. Write-side: `recordAgentFromAdagentsJson`, `recordPublisherFromAgent`, and `updateAgentMetadata` canonicalize before persisting so legacy `discovered_agents` and `agent_publisher_authorizations` rows match the shape the catalog-side already enforces. Forward-only — existing rows are not migrated, per the issue's out-of-scope note. Tests pin slash collapse, host-case collapse, and that scheme mismatch (http vs https) intentionally does NOT collapse — different security posture.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #3573. Refs #3565 (the blocker, now merged).
The registered-vs-discovered collapse in
FederatedIndexService.listAllAgentsandlookupDomainkeyed onagent_urlas a raw string. A registeredhttps://agent.example/and a discoveredhttps://agent.examplewould surface as two separate entries instead of collapsing to the registered row.Read-side and write-side are now consistent with the catalog-side, which already uses
canonicalizeAgentUrl(server/src/db/publisher-db.ts:96).What changed
server/src/federated-index.tscollapseKey()helper wraps the existingcanonicalizeAgentUrlfor in-memory map keys (lowercase, trailing slash stripped; raw fallback so we never silently drop a row).listAllAgents:registeredAgentsMap keyed on canonical form;discovered.agent_urlcanonicalized for the lookup.lookupDomain: same treatment forregisteredAgentUrlsMap and the auth/claim member-resolution lookups.recordAgentFromAdagentsJson/recordPublisherFromAgent/updateAgentMetadata: canonicalize once at the entry point so legacydiscovered_agentsandagent_publisher_authorizationsrows store the same shape the catalog-side already enforces. Forward-only — existing rows are not migrated, per the issue's out-of-scope note.server/tests/unit/registry-discovered-endorsement.test.ts— three new pins:https://shared.agent.example.com/collapses with discoveredhttps://shared.agent.example.com.Shared.Agent.Example.comvs lowercase).httpvshttps) intentionally does NOT collapse — different security posture..changeset/canonicalize-agent-url-collapse.md— empty changeset (server-only fix, no protocol bump).Test plan
npx vitest run server/tests/unit/registry-discovered-endorsement.test.ts— 9/9 pass (6 existing + 3 new).npm run typecheck— clean.Out of scope
discovered_agents/agent_publisher_authorizations— issue explicitly defers; the canonicalization is forward-only. Could be a one-off cleanup PR if a sweep finds collisions.routes/member-profiles.ts): registered agent URLs still flow in verbatim from user input. Read-side canonicalization handles the collapse, so the user-visible bug is fixed without changing the user-facing contract on what gets stored.example.comvswww.example.com) — separate identity question.