Skip to content

feat(server): drop primary_brand_domain column (#4159 Stage 2)#4313

Merged
bokelley merged 1 commit into
mainfrom
bokelley/4159-stage2-drop-column
May 10, 2026
Merged

feat(server): drop primary_brand_domain column (#4159 Stage 2)#4313
bokelley merged 1 commit into
mainfrom
bokelley/4159-stage2-drop-column

Conversation

@bokelley
Copy link
Copy Markdown
Contributor

Summary

Stage 2 of #4159 — drop member_profiles.primary_brand_domain entirely. After Stage 1 routed every read through getBrandPrimaryDomain (resolver-first, column-fallback), this PR cuts the column.

organization_domains.is_primary=true is now the single source of truth for both org-membership inference and brand identity. One row, one write, no more drift between the four overlapping domain columns that started this issue.

What's removed

  • member_profiles.primary_brand_domain column (migration 472)
  • resolver fallback to member_profilesgetBrandPrimaryDomain now reads only organization_domains.is_primary
  • WorkOS-webhook auto-populate that wrote member_profiles.primary_brand_domain on first verified domain (the auto-promote-to-is_primary on organization_domains covers the same ground in one row)
  • brand-identity service's dual-write to member_profiles
  • /api/me/agents POST backfill that set primary_brand_domain from agent hostnames
  • bootstrap endpoint's acceptance of primary_brand_domain in the request body (silently ignored — value derived from organization_domains.is_primary)
  • Stage 0 data-cleanup and backfill scripts (one-shot work complete)

What's added

  • 400 domain_not_workos_verified response on PUT /api/me/organization/domains/:domain/primary for non-WorkOS sources. With is_primary now driving brand identity too, an admin-imported "verified" row shouldn't be promotable via member self-service — that would let an admin escalate brand identity by importing a row.

API compat

The response field primary_brand_domain on GET /api/me/member-profile is preserved; its value is now derived from the resolver rather than stored on the profile. HTML clients (member-profile.html, dashboard-agents.html) keep working.

Test plan

  • Typecheck clean
  • Unit tests pass (member-profile-bootstrap-skip-rule, listing-autopublish updated for INSERT param shift)
  • Integration tests — brand-domain-resolver, workos-domain-auto-primary, me-organization-domains, brand-orphan-adoption, agent-visibility-e2e, member-agents-api, member-profile-bootstrap, registry-reader-baseline-public-endpoints all updated to seed organization_domains.is_primary=true instead of writing the dropped column
  • Migration 472 runs cleanly on prod
  • Smoke /api/me/member-profile returns primary_brand_domain derived from the resolver

🤖 Generated with Claude Code

Cuts the column entirely after Stage 1 routed reads through getBrandPrimaryDomain.
organization_domains.is_primary=true is now the single source of truth for both
org-membership inference and brand identity.

- migration 472 drops the column
- resolver now reads only org_domains.is_primary (fallback removed)
- WorkOS webhook auto-promote on org_domains covers what the auto-populate write did
- brand-identity, registry-api, member-agents, member-profiles writes removed
- PUT /api/me/organization/domains/:domain/primary refuses non-WorkOS sources
  (with is_primary now driving brand identity, admin-imported rows can't be
  promoted via member self-service)
- API response field preserved via resolver-derived value
- one-shot Stage 0 scripts and their tests deleted

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@bokelley bokelley merged commit 5163d21 into main May 10, 2026
15 checks passed
@bokelley bokelley deleted the bokelley/4159-stage2-drop-column branch May 10, 2026 10:11
bokelley pushed a commit that referenced this pull request May 11, 2026
Regenerated by build; reflects the primary_brand_domain → Linked Domains
UI description update committed in #4313 that was not yet reflected in dist.

https://claude.ai/code/session_01Qy5CniM5du4RLEDiTadFuJ
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.

1 participant