fix(registry): writer anchor-adopt promotes contributed rid to authoritative#3380
Merged
Merged
Conversation
…itative Found via escalation #287 (wheelrandom.com). Publisher's adagents.json was valid and anchored, but registry showed 0 authorizations. Root cause: when projectPropertyToCatalog adopts a foreign rid via the publisher-anchor path (Rule 4), the UPDATE refreshed adagents_url + property_id only — leaving source='contributed' and created_by='community:foo' (or whatever pipeline previously owned the rid). The auth projection's `WHERE created_by = 'adagents_json:<pub>' AND property_id = ANY(...)` then returned zero rows, and authorized_agents[] entries silently dropped. Fix: also set source='authoritative' and created_by=expectedCreatedBy on the adopt path. The publisher with a matching anchor is now the source-of-truth pipeline for this property; its created_by should reflect that. Idempotent for own re-crawls (the SET is a no-op when matchedCreatedBy already equals expectedCreatedBy). Test added (registry-catalog-agent-auth-writer.test.ts): pre-seed a 'contributed'/'community:<pub>' catalog row + identifier, then crawl an adagents.json that references the same domain. Asserts the rid is reused, source promoted to 'authoritative', created_by rebound, and the auth projection lands a CAA row referencing the promoted rid. Refs #3177.
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.
Summary
Found via escalation #287 (wheelrandom.com): the publisher's adagents.json is valid and anchored, but the registry resolves 0 authorizations.
Root cause
When
projectPropertyToCatalogadopts a foreign rid via Rule 4 (publisher anchors via a domain identifier under their own host), the UPDATE refreshesadagents_urlandproperty_idvia COALESCE — but leavessource='contributed'andcreated_by='community:<pub>'(or whatever pipeline previously owned the rid).The auth projection's slug-resolution query then looks up:
It returns zero rows for the just-adopted rid →
targets.length === 0→ no CAA insert → noauthorization.grantedevent. Theauthorized_agents[]entries silently drop.This is exactly what wheelrandom.com hit: a
contributedrow from earlier enrichment was sitting atdomain:wheelrandom.com, the manifest came in with a clean property + slug + auth, the property got the slug COALESCE'd in but the auth never landed.Fix
Two extra columns on the adopt-path UPDATE:
source = 'authoritative'created_by = expectedCreatedBy(='adagents_json:<pub>')Idempotent for own re-crawls (when
matchedCreatedBy === expectedCreatedByit's a no-op).Test
registry-catalog-agent-auth-writer.test.ts:source='contributed'andcreated_by='community:<pub>'domain:<pub>pointing at the rowsourcepromoted to'authoritative',created_byrebound, auth projection lands a CAA row referencing the promoted rid.61/61 tests pass across writer + reader baseline + reader cutover.
Test plan
POST /api/registry/crawl-request {domain: wheelrandom.com}/api/registry/feed?types=authorization.*for theauthorization.grantedeventresolve_propertyfordomain:wheelrandom.comreturns the property + the agentRefs #3177.
🤖 Generated with Claude Code