Skip to content

fix(registry): return a domain as canonical_domain for House Portfolio brands - #9035

Merged
bokelley merged 2 commits into
mainfrom
fix/9034-portfolio-canonical-domain
Nov 15, 2026
Merged

bokelley merged 2 commits into
mainfrom
fix/9034-portfolio-canonical-domain

Conversation

@bokelley

Copy link
Copy Markdown
Contributor

Closes #9034

Problem

For a House Portfolio brand.json, GET /api/brands/resolve returned the brand's id as canonical_domain. For example, ?domain=wonderstruck.org gave canonical_domain: "wonderstruck". The API types canonical_domain as a domain, and callers join on it, so they missed every brand published as a House Portfolio.

Change

canonical_domain is now always a domain. canonical_id is unchanged (brand.id, or parent#id).

Branch in server/src/brand-manager.ts canonical_domain before after
Brand found by its website property brand.id the requested domain (normalized)
Master-brand fallback masterBrand.id the house domain (lowercased)
resolveBrandRef lookup by brand_id brand.id the requested domain if the brand owns it, else the brand's primary owned website, else its first owned website, else the house domain

For the brand_id lookup, preferring the brand's own website means a lookup by brand_id returns the same canonical_domain as a lookup of that website that reaches the same portfolio.

resolveBrandRef matched brand_id against canonical_id or canonical_domain. It now compares the final segment of canonical_id only, so parent#id sub-brands still return early without a second fetch. A brand_id that equals the domain no longer matches.

Cache comparison

retainCachedMutualRelationship compares canonical_domain between the cached and fresh results. House Portfolio results never reach that comparison: they are inline, not mutual, and the fresh side is always a Brand Canonical Document result, whose canonical_domain was already a domain. The resolution cache is in memory, so a deploy clears entries written before the fix. A comment at the comparison records this.

Other consumers

None needed a code change. I checked:

  • Registry routes: selectResolvedBrandResponse and the bulk route pass the value through. registryRequestsDb.markResolved writes it to registry_requests.resolved_to_domain, which now gets a domain instead of an id.
  • MCP resolve_brand: builds a brand://<canonical_domain> URI, which now carries a domain.
  • Addie brand-tools: passes the value through.
  • Crawler: persists canonical_domain only from resolveHouseBrandReference, which goes through the Brand Canonical Document path and was already a domain.
  • Trust lookup: reads canonical_id, not canonical_domain.
  • Training-agent governance: calls resolveBrandRef and reads only brand_manifest.
  • brand-builder.html: checks only that canonical_domain is truthy.

#9024, the enrichment junk records, is in the enrichment routes, not in this resolver. The two don't touch the same code.

Tests

Added a House Portfolio canonical_domain (#9034) block to server/tests/unit/brand-manager-cache.test.ts:

  • a brand found by its website through authoritative_location (the wonderstruck case), and a sub-brand through a House Redirect;
  • the master-brand fallback;
  • brand_id lookup when the brand has a primary website, owns the requested domain, or names no website, plus a check that it agrees with the by-website lookup;
  • a sub-brand brand_id returning early on canonical_id, and a brand_id that matches only canonical_domain no longer matching;
  • the Brand Canonical Document path is unchanged.

Each case checks canonical_domain and canonical_id. Nine of the new tests fail on main. The Brand Canonical Document test passes both before and after.

  • npx vitest run --config server/vitest.config.ts on the brand, registry, crawler, trust-lookup, sandbox, governance, mcp-tools and resolve-brand unit files: 84 files and 1091 tests passed.
  • npm run typecheck passed.
  • No integration tests exercise BrandManager resolution, so none were run.

No changeset: this changes server behavior only, not the protocol.

🤖 Generated with Claude Code

…o brands

GET /api/brands/resolve put the brand id in canonical_domain for every
House Portfolio branch (wonderstruck.org gave canonical_domain
"wonderstruck"). canonical_domain is now always a domain:

- brand found by its website property: the requested domain
- master-brand fallback: the house domain
- resolveBrandRef brand_id lookup: the requested domain if the brand owns
  it, else the brand's primary (or first) owned website, else the house
  domain

canonical_id is unchanged (id, or parent#id). resolveBrandRef now matches
brand_id against canonical_id's final segment only, not canonical_domain.

Closes #9034

Co-Authored-By: Claude Opus 5.5 <[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 — clean fix with no blocking findings.

The diff is confined to server/** (brand-manager.ts + its unit test). The change normalizes canonical_domain to always be a domain across all three House Portfolio branches and introduces a portfolioBrandDomain helper (most-specific-first selection) backed by new tests. The resolveBrandRef early-return change is a deliberate, documented, tested behavior change. No changeset is required — no protocol surface (static/schemas/source/**, docs/reference/**, dist/**) is touched. resolved_to_domain is write-only with no join consumer, so no durable-state staleness. No new external I/O. Nine of ten new tests fail on main; branch coverage is complete.

Gate checks: no no-auto-approve team match; gated_paths is false (so the REVIEW_REQUIRED status does not trigger row 2); high_risk is false; no prior decision. Reviewer surfaced zero Critical/High/Medium findings, so rows 1–8 do not fire — falls through to row 9.

@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 — clean pass, no blocking or medium findings.

PR #9035 fixes canonical_domain resolution in server/src/brand-manager.ts to always return a domain (never a brand id) for House Portfolio brands across three resolution paths: by-website (normalizedDomain), master-brand fallback (house domain), and resolveBrandRef by brand_id (new portfolioBrandDomain helper). The helper's precedence (requested domain if owned → primary owned website → first owned website → house domain) is consistent with the by-website path, and the new test confirms the two agree. The early-return rewrite correctly compares only the final # segment of canonical_id and intentionally drops the canonical_domain === brand_id branch (brand_id is never a domain); covered by tests. Cache-comparison reasoning is sound (House Portfolio results are inline, never hit the mutual comparison; in-memory cache clears on deploy). No changeset needed — this is server resolver behavior, not static/schemas/source/**. No external I/O or operational hazards; 190 lines of targeted tests cover every branch.

Decision table: no critical/high/medium findings; gated_paths false (review_decision APPROVED regardless); high_risk false; no author team gate. Falls through to row 9 → approve. Prior decision was also approve.

@bokelley
bokelley merged commit 115adda into main Nov 15, 2026
31 checks passed
@bokelley
bokelley deleted the fix/9034-portfolio-canonical-domain branch November 15, 2026 17:01
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 resolve: canonical_domain is the brand id, not a domain, for House Portfolio brand.json

1 participant