Repository navigation
Description
Symptom
After the Stage 2 column drop (#4313, 5163d21425), getBrandPrimaryDomain(orgId) reads only organization_domains.is_primary=true. For some orgs that previously curated brand.json content at www.<domain>, the resolver now returns <domain> (no www), so the publish path writes manifest updates to a different registry row than the user has been editing.
Repro (Affinity Answers, escalation #334)
organization_domainsrow:affinityanswers.com,is_primary: true,verified: true,source: workos(created 2026-03-10).brand_revisionsfor editor[email protected](admin endpoint/api/admin/accounts/{orgId}/registry-activity):- 2026-05-04 05:46 — "Published brand agent to brand.json" on
www.affinityanswers.com - 2026-05-04 12:39 — "Removed brand agent from brand.json" on
www.affinityanswers.com - 2026-05-05 05:09 — "Published brand agent to brand.json" on
www.affinityanswers.com
- 2026-05-04 05:46 — "Published brand agent to brand.json" on
- Their public website returns 404 at
https://www.affinityanswers.com/brand.json(WordPress, no self-hosted brand.json); the AAO registry hosts the manifest.https://affinityanswers.com/brand.jsonreturns 301 to www. - Current member-profile JSONB agent state:
visibility: members_only. Not published.
applyAgentVisibility (member-profiles.ts:1412-1444) now resolves the brand-primary to affinityanswers.com, then calls brandDb.getDiscoveredBrandByDomain('affinityanswers.com'). If no row exists at that exact domain, the post-commit brandDb.updateManifestAgents('affinityanswers.com', ...) will either create a new empty row at the root domain — orphaning the prior www.* manifest the user had been curating — or fail outright depending on the table's constraints.
Why pre-Stage 2 it worked
The dropped member_profiles.primary_brand_domain column on this org likely held www.affinityanswers.com (the domain the brand registry crawler had previously seeded). The publish path read that column directly, so all prior writes consistently landed on the same brand row. Post-#4313 the resolver authority shifted to organization_domains.is_primary, which was populated by WorkOS domain verification at the root domain — no www.
Impact
- Member publish flow appears to succeed but writes to a different brand row than the user previously curated, fracturing manifest state.
/api/me/agents/:index/checkwill reportnot_foundbecause the agent is no longer in the manifest at the resolved domain.- Almost certainly affects orgs beyond Affinity — any org whose previous
primary_brand_domainhad a www prefix and whose WorkOS-verified domain is the root.
Proposed fix
- Audit: SQL across
brand_revisionsjoined againstorganization_domainsto find orgs with prior revisions onwww.<domain>butorganization_domains.is_primary=trueon<domain>(or vice versa). - Backfill: for affected orgs, decide canonical domain (prefer the one with revision history when there's no conflict), and either flip
organization_domains.is_primaryor merge thewww.*brand row into the root row. - Forward fix: the brand-domain resolver could optionally canonicalize www-stripping when the root has no brand row but
www.<root>does — but the cleaner path is data-side reconciliation, not a runtime fallback.
References
- Stage 1.1 (publish gate uses resolver) — bb9ae6e (feat(member-profile): publish-agent gate uses resolver (#4159 Stage 1.1) #4300), 2026-05-09 13:04 EDT
- Stage 2 (column drop) — 5163d21 (feat(server): drop primary_brand_domain column (#4159 Stage 2) #4313), 2026-05-10 06:11 EDT
- Stage 3a (canonical writers) — da966f1 (feat(server): canonical organization_domains writers (#4159 Stage 3a) #4329), 2026-05-10 07:22 EDT
- Memory: "Four overlapping domain columns" /
project_domain_columns_mess.md - Escalation Fix allOf + additionalProperties validation and add oneOf titles #334 — Affinity Answers
- Copy-fix PR for the misleading tier message Addie quoted to this customer: fix(copy): clarify which tiers qualify for public agent listing #4447
🤖 Generated with Claude Code
Activity
chore(scripts): reconcile-brand-domain-www-mismatch (#4448 fix)
chore(scripts): audit + reconcile brand-domain www/no-www mismatch (#…