Mail readiness compares the DKIM key character-for-character; a mangled record is its own state #415

Closed
opened 2026-08-10 21:14:35 +00:00 by ben · 1 comment
Owner

internal/mailreadiness/net.go (matchToken) verifies a DKIM record by the substring v=dkim1 — it never looks at the p= key bytes. ADR 0115's mail-readiness contract says the records are verified, and CONTEXT.md's mail readiness promises the operator the same; the code checks presence of the record class, not its value.

Why this is live, not prospective: registrar zone-edit pipelines mangle values invisibly — the mauke fleet's cPanel registrar form-decoded + to space inside the published DKIM key (8 places), Gmail went dkim=neutral (invalid public key), and nothing bounced because SPF still aligned DMARC. Outbound reputation decayed silently for weeks while every presence check stayed green. An OurCloud operator publishing records by hand at such a registrar reproduces this exactly, and our readiness screen tells them it's fine. See docs/GOTCHAS.md #9.

Acceptance criteria

  • The DKIM check compares the published record's p= value against the key OurCloud generated, character-for-character (whitespace inside the served value is a mismatch, not noise).
  • A mismatch is its own readiness state — distinct from "not found yet", because the remedy differs (the record was mangled in transit, not missing); the state's operator copy says so in CONTEXT.md vocabulary.
  • SPF and DMARC get the same value comparison wherever OurCloud knows the expected record value (fall back to today's token match only where it doesn't).
  • Unit tests cover: intact key passes; +→space mangling detected as mangled (not missing); record absent still reports not-found.

Source: the clan-community (mauke reference fleet) lessons review, docs/research/2026-08-10-clan-community-lessons.md (lands on main this sitting), lesson 5.

`internal/mailreadiness/net.go` (`matchToken`) verifies a DKIM record by the substring `v=dkim1` — it never looks at the `p=` key bytes. ADR 0115's mail-readiness contract says the records are *verified*, and CONTEXT.md's **mail readiness** promises the operator the same; the code checks presence of the record *class*, not its value. Why this is live, not prospective: registrar zone-edit pipelines mangle values invisibly — the mauke fleet's cPanel registrar form-decoded `+` to space inside the published DKIM key (8 places), Gmail went `dkim=neutral (invalid public key)`, **and nothing bounced** because SPF still aligned DMARC. Outbound reputation decayed silently for weeks while every presence check stayed green. An OurCloud operator publishing records by hand at such a registrar reproduces this exactly, and our readiness screen tells them it's fine. See `docs/GOTCHAS.md` #9. **Acceptance criteria** - The DKIM check compares the published record's `p=` value against the key OurCloud generated, character-for-character (whitespace inside the served value is a mismatch, not noise). - A mismatch is its **own readiness state** — distinct from "not found yet", because the remedy differs (the record was mangled in transit, not missing); the state's operator copy says so in CONTEXT.md vocabulary. - SPF and DMARC get the same value comparison wherever OurCloud knows the expected record value (fall back to today's token match only where it doesn't). - Unit tests cover: intact key passes; `+`→space mangling detected as mangled (not missing); record absent still reports not-found. _Source: the clan-community (mauke reference fleet) lessons review, `docs/research/2026-08-10-clan-community-lessons.md` (lands on main this sitting), lesson 5._
Author
Owner

Landed on main in 551d78a.

Mail readiness no longer trusts record presence alone. internal/mailreadiness now runs a three-way per-record verdict (classifyTXT): found / absent / mangled.

  • DKIM p= compared character-for-character (dkimKey extracts the served key; whitespace inside it is a mismatch, not noise) — the exact +→space corruption of GOTCHAS #9 is caught.
  • SPF and DMARC get the same intact-value comparison wherever OurCloud knows the value, falling back to today's class-token match only where it doesn't (the production adapter's DKIM record still carries no p=, so it stays token-based until the generated public key is wired in — flagged as a follow-up in the commit body).
  • A mangled record is its own standing state records-mangled (StateRecordsMangled), distinct from records-not-verified because the remedy differs (re-publish the value verbatim, not add it); it takes precedence because a mangled record fails silently. recordMangledGuidance carries the re-publish remedy. Operator copy added to CONTEXT.md vocabulary, health.go/monitor.go summaries, and the dashboard MailReadinessState union.

Tests (internal/mailreadiness/net_test.go): intact key passes; +→space detected as mangled (not missing); record absent still reports not-found; DKIM token fallback when no expected p=; SPF/DMARC value compare; and the Assess fold to records-mangled with the named leg + remedy. All 15 package tests green; go build ./... clean; pre-push go-ci gate passed. GOTCHAS #9 already cited #415.

Landed on `main` in `551d78a`. Mail readiness no longer trusts record *presence* alone. `internal/mailreadiness` now runs a three-way per-record verdict (`classifyTXT`): found / absent / **mangled**. - **DKIM p= compared character-for-character** (`dkimKey` extracts the served key; whitespace inside it is a mismatch, not noise) — the exact `+`→space corruption of GOTCHAS #9 is caught. - **SPF and DMARC** get the same intact-value comparison wherever OurCloud knows the value, falling back to today's class-token match only where it doesn't (the production adapter's DKIM record still carries no `p=`, so it stays token-based until the generated public key is wired in — flagged as a follow-up in the commit body). - A **mangled** record is its own standing state `records-mangled` (`StateRecordsMangled`), distinct from `records-not-verified` because the remedy differs (re-publish the value verbatim, not add it); it takes precedence because a mangled record fails silently. `recordMangledGuidance` carries the re-publish remedy. Operator copy added to CONTEXT.md vocabulary, `health.go`/`monitor.go` summaries, and the dashboard `MailReadinessState` union. **Tests** (`internal/mailreadiness/net_test.go`): intact key passes; `+`→space detected as mangled (not missing); record absent still reports not-found; DKIM token fallback when no expected `p=`; SPF/DMARC value compare; and the `Assess` fold to `records-mangled` with the named leg + remedy. All 15 package tests green; `go build ./...` clean; pre-push go-ci gate passed. GOTCHAS #9 already cited #415.
ben closed this issue 2026-08-10 23:35:05 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Matou/idss#415
No description provided.