Skip to content

chore(scripts): narrow email_domain backfill to nulls; flag M&A cases for review#4552

Merged
bokelley merged 1 commit into
mainfrom
bokelley/email-domain-null-backfill
May 15, 2026
Merged

chore(scripts): narrow email_domain backfill to nulls; flag M&A cases for review#4552
bokelley merged 1 commit into
mainfrom
bokelley/email-domain-null-backfill

Conversation

@bokelley

Copy link
Copy Markdown
Contributor

Summary

Follow-up to #4459. The original sync-email-domain-from-is-primary.ts flipped any organizations.email_domain that didn't match organization_domains.is_primary=true. Prod audit showed three distinct classes inside that broad definition; only one is safe to auto-fix.

This narrows the default behavior and flags M&A/subsidiary cases for human review instead of overwriting them.

Drift classes

class meaning example action
null never had a webhook fire / missed migration 468 Diageo: email_domain=null, canonical=diageo.com auto-fill (default)
www_drift email_domain vs canonical differs only by www Scope3: www.scope3.com vs scope3.com opt-in via --include-www-drift
mismatched completely different domains LinkedIn (Microsoft): linkedin.com vs microsoft.com NEVER auto-fix

Applied on prod 2026-05-12 12:02 UTC

7 null cases backfilled:

[null] Diageo                  → diageo.com
[null] digital opua GmbH (x2)  → digital-nalu.ch / digital-opua.ch
[null] harvingupta             → harvingupta.xyz
[null] Spectrum Reach          → spectrum.com
[null] TVIQ                    → tviq.io
[null] Willem LLC              → willemllc.com

5 mismatched cases NOT touched (filed as #4448 follow-up issue):

Cora AI               email_domain=noverift.ai     canonical=coraai.org
EdDomus               email_domain=quattroruote.it canonical=edidomus.it
LinkedIn (Microsoft)  email_domain=linkedin.com    canonical=microsoft.com
Omnicom Group         email_domain=omnicomgroup.com canonical=omc.com
Teal                  email_domain=tealplus.com    canonical=teal.works

Test plan

  • Dry-run on prod confirms classification
  • --apply (null only) writes 7 rows
  • CI green

🤖 Generated with Claude Code

The original script flipped any `organizations.email_domain` that didn't
match `organization_domains.is_primary=true`. Audit on prod revealed
three distinct classes inside that broad definition:

  1. `null`       — never had a webhook fire / missed migration 468.
                    Strictly safe to fill from canonical.
  2. `www_drift`  — Scope3 class. Webhook patched in #4459; opt-in via
                    `--include-www-drift` if another org regresses.
  3. `mismatched` — subsidiary/M&A (LinkedIn↔Microsoft,
                    EdDomus↔quattroruote.it, Omnicom↔omc.com, Teal↔teal.works,
                    Cora AI↔noverift.ai). NOT a drift bug. These are
                    structural modeling questions for `brands.house_domain`
                    + `brand_domain_aliases` and possibly separate org
                    records, not for an automated overwrite.

Default behavior now applies only class (1). Class (3) is reported and
never written. Class (2) requires explicit `--include-www-drift`.

Applied on prod 2026-05-12 12:02 UTC: 7 null cases backfilled (Diageo,
digital opua GmbH x2, harvingupta, Spectrum Reach, TVIQ, Willem LLC).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@bokelley
bokelley merged commit 0078057 into main May 15, 2026
13 checks passed
@bokelley
bokelley deleted the bokelley/email-domain-null-backfill branch May 15, 2026 01:03
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