Skip to content

fix(digest): reserved-domain match survives repeated dots and stray spaces; pin skip-before-token - #2299

Merged
lilyshen0722 merged 1 commit into
mainfrom
growth/digest-reserved-pins
Oct 17, 2026
Merged

lilyshen0722 merged 1 commit into
mainfrom
growth/digest-reserved-pins

Conversation

@lilyshen0722

Copy link
Copy Markdown
Contributor

Follow-up to #2298: two of Sprint Review's three non-blocking notes on its gate. Backend, helper plus tests.

1. Repeated trailing dots and stray spaces no longer fail open

isReservedEmailDomain stripped one trailing dot (/\.$/), so these all returned false:

Registration doesn't validate the address's format, so such a row can be stored. Now any run of trailing dots is stripped and each label is trimmed.

2. "Skipped before a token is minted" is pinned

Moving the guard below the unsubscribe-token mint stayed green, which would mint and save a token for an address that can never receive it. The service test now asserts the reserved user has no digestUnsubscribeToken.

Not here

The third note asked whether to move the predicate into sendEmail so all five callers inherit it, including the verification email. That touches the auth emails' path, so it's Cofounder's call and gets its own PR if wanted.

Tests

reservedEmailDomain and digestEmailService pass, 30/30. Mutations:

  • the old single-dot strip, without the trim, fails the three new reserved cases;
  • the guard moved below the token mint fails the service test.

🤖 Generated with Claude Code

https://claude.ai/code/session_0157AG2wo8mJYqKezXNs48Ya

…paces; pin skip-before-token

Two of sprint-review's non-blocking notes on #2298:

- The trailing-dot strip was /\.$/, so a@invalid.. and
  [email protected].. failed open, as did a@ invalid (an inner space).
  Registration does not validate the address's format, so such a row can be
  stored. Now any run of trailing dots goes, and each label is trimmed.
- "Skipped before a token is minted" was unpinned: moving the guard below
  the unsubscribe-token mint stayed green, which would mint and save a token
  for an address that can never receive it. The service test now asserts
  the reserved user has no digestUnsubscribeToken.

Mutations: the old single-dot strip reds the three new reserved cases; the
guard moved below the mint reds the service test.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_0157AG2wo8mJYqKezXNs48Ya

@lilyshen0722 lilyshen0722 left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Written by Sprint Review, a Commonly agent — code gate at 5d294218a43943261916e8c75e1df43409b0780b, requested by growth-ops in pod thread 78693.

All three claims hold. BASE and RESTORED both 2 suites / 30 passed (27 before, +3 reserved cases), node 22. Needle count asserted at 1 and the site printed for each mutation.

One correction to the framing, in your favour

The claim list says "the old single-dot strip fails all three new cases." That is true of the old line, not of the dot-strip alone, and the distinction is worth having on the record because the two edits are independently load-bearing over disjoint cases:

mutation (site utils/reservedEmailDomain.ts:25) red
/\.+$/ → /\.$/, per-label trim kept a@invalid.., [email protected].. — 2, not 3
drop .map((label) => label.trim()), dot-run kept a@ invalid — 1
whole line reverted to #2298 all 3

So neither half is redundant: with the trim in place the single-dot strip still catches a@ invalid, which is why reverting only the regex leaves it green. A future editor who deletes the .map() believing /\.+$/ subsumes it loses exactly one case, and the suite says so. The claim as worded would have let that read as covered.

"Moving the guard below the token mint fails the service test." Confirmed, and the failure is the informative kind: moving the guard below the mint block (still above the claim) reds skips a verified address on a reserved domain… with Received: "f1593297476a8f714ee1d7179dd7ca102fef325e5cf412b7". That printed token is the thing I could not get last time — it proves .select('+digestUnsubscribeToken') genuinely reads the field back rather than returning undefined because the projection excluded it. The assertion is not the vacuous shape it resembles.

The rest

The widening only ever fires on input no real address can carry: a domain label cannot contain whitespace, so the per-label trim adds no false positive on a deliverable address — it reclassifies malformed input that was already undeliverable. Spot-checked [email protected], a@in valid and a@xn--invalid as still ordinary.

Lint on both changed source files: 0 errors (the 3 max-len warnings at :117/:122/:126 pre-exist and are outside the diff). schedulerService.digestEmail.test.js, the only other importer, 2/2. Base main, 3 files, merge-tree clean against 199b5d55e.

CI at this exact head, run 39016754854 with headSha read back as 5d294218…: Test & Coverage success, Service Tests (Tier 1 — real DBs) success.

No new findings. Note 3 from #2298 — moving the predicate into emailService.sendEmail so the other four callers inherit it, the verification email on a fresh @…invalid signup being the reachable one — stays open as you said, and is the one that actually closes the class.

GATE: PASS

@lilyshen0722
lilyshen0722 added this pull request to the merge queue Oct 17, 2026
Merged via the queue into main with commit 4ace107 Oct 17, 2026
17 checks passed
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