Repository navigation
fix(registry): return a domain as canonical_domain for House Portfolio brands - #9035
Conversation
…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]>
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
Closes #9034
Problem
For a House Portfolio brand.json,
GET /api/brands/resolvereturned the brand'sidascanonical_domain. For example,?domain=wonderstruck.orggavecanonical_domain: "wonderstruck". The API typescanonical_domainas a domain, and callers join on it, so they missed every brand published as a House Portfolio.Change
canonical_domainis now always a domain.canonical_idis unchanged (brand.id, orparent#id).server/src/brand-manager.tscanonical_domainbeforebrand.idmasterBrand.idresolveBrandReflookup bybrand_idbrand.idprimaryowned website, else its first owned website, else the house domainFor the
brand_idlookup, preferring the brand's own website means a lookup bybrand_idreturns the samecanonical_domainas a lookup of that website that reaches the same portfolio.resolveBrandRefmatchedbrand_idagainstcanonical_idorcanonical_domain. It now compares the final segment ofcanonical_idonly, soparent#idsub-brands still return early without a second fetch. Abrand_idthat equals the domain no longer matches.Cache comparison
retainCachedMutualRelationshipcomparescanonical_domainbetween the cached and fresh results. House Portfolio results never reach that comparison: they areinline, notmutual, and the fresh side is always a Brand Canonical Document result, whosecanonical_domainwas 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:
selectResolvedBrandResponseand the bulk route pass the value through.registryRequestsDb.markResolvedwrites it toregistry_requests.resolved_to_domain, which now gets a domain instead of an id.resolve_brand: builds abrand://<canonical_domain>URI, which now carries a domain.brand-tools: passes the value through.canonical_domainonly fromresolveHouseBrandReference, which goes through the Brand Canonical Document path and was already a domain.canonical_id, notcanonical_domain.resolveBrandRefand reads onlybrand_manifest.brand-builder.html: checks only thatcanonical_domainis 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 toserver/tests/unit/brand-manager-cache.test.ts:authoritative_location(the wonderstruck case), and a sub-brand through a House Redirect;brand_idlookup 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;brand_idreturning early oncanonical_id, and abrand_idthat matches onlycanonical_domainno longer matching;Each case checks
canonical_domainandcanonical_id. Nine of the new tests fail onmain. The Brand Canonical Document test passes both before and after.npx vitest run --config server/vitest.config.tson the brand, registry, crawler, trust-lookup, sandbox, governance, mcp-tools and resolve-brand unit files: 84 files and 1091 tests passed.npm run typecheckpassed.BrandManagerresolution, so none were run.No changeset: this changes server behavior only, not the protocol.
🤖 Generated with Claude Code