Skip to content

refactor(web): own the earliest birth date in the life date parser - #5395

Merged
tyler-dane merged 2 commits into
mainfrom
claude/kind-dirac-4vmazc
Nov 30, 2026
Merged

tyler-dane merged 2 commits into
mainfrom
claude/kind-dirac-4vmazc

Conversation

@tyler-dane

Copy link
Copy Markdown
Contributor

Tech-debt sweep for 2026-11-24 to 2026-11-30. No issue; the sweep is scheduled.

What and why

The earliest birth date Life accepts existed as four parallel 1900 literals,
and parseLifeBirthDateInput ignored its own minDate parameter.

The function takes minDate, but its year-only branch compared against a
hardcoded 1900 and both rejection messages named 1900 as a literal, while
each call site built the bound itself: LifeSidebarContent.tsx as
new Date(1900, 0, 1) and, new in #5391, LifeBirthDatePrompt.tsx as a second
copy of the same expression. The test file held a fifth copy and only ever
passed 1900, so nothing guarded the parameter.

The divergence this prevents. Reproduced before fixing: with
minDate = new Date(1950, 0, 1), the parser accepted a bare "1900" and
"1949" as valid year jumps, and rejected "1945-01-01" with
"Enter a date in 1900 or later", naming a bound that was not in force. So
raising the bound at either entry point would have left the year path on the
old rule while the full-date path moved, and the copy would have explained the
wrong year to the user: a validator desynced from the message beside it, with
no test failing. #5391 is what made this worth a PR. Before it there was one
caller and the hardcoding read as an unused parameter; with a second entry
point the rule had to be kept in step by hand across four sites.

The fix. parseLifeBirthDateInput.util.ts becomes the owning module. It
exports LIFE_BIRTH_DATE_MIN, the year branch and both messages derive from
options.minDate.getFullYear(), and both call sites plus the test import the
constant.

Behavior is identical: every caller passes 1900 today, so every accepted value
and every message is character-for-character what it was. The three new
assertions in the honours the caller's minDate block fail against the
previous implementation, so re-hardcoding either side now breaks the build.

Churn guard. parseLifeBirthDateInput.util.ts carries only #5093 (a fix)
in the last 30 days and LifeBirthDatePrompt.tsx is new in #5391.
LifeSidebarContent.tsx carries #5041, a prior sweep refactor inside 30 days,
so it is off limits for a rework; the change there is one line swapping a
literal for the imported constant.

Examined and deliberately left alone (recorded in full in
.agents/skills/tech-debt-sweep/judged-fine.md so the next sweep does not
redo it): the RANDOM_BIRTH_MIN_AGE/MAX_AGE pair and its * 365 span in
life-math.ts (off limits, #5389 was last sweep's own output, and the age-59
ceiling is pinned deliberately); the intro prompt's documented year-to-January
convention and its dropped usesMonthDayOrder disclosure (a product decision,
escalates rather than sweeps); renderWelcomeEmail's inline-link substitution
in #5394 (the HTML and text branches cannot disagree, since escapeHtml is a
character-wise map; two latent residuals noted); the heading removal in #5394
(complete, no reader left); LIFE_PREFERENCES_REQUEST_TIMEOUT_MS in #5392 (two
independent budgets that coincide at 30s); the lifeThisWeekEligible prop
chain in #5392 (complete, and it removed a duplicate preferences load); the
Alt+Arrow binding in #5391 (declared once, every consumer derives from it);
the confirmationSent plumbing in #5394 (insertMany is ordered: false and
swallows duplicate keys, so the new read-before-insert opens no race); the
hardcoded sender address in ReflectionEmailPreview.tsx (the real value is
deploy config, so closing it needs a new endpoint: a fix larger than the
problem); the three paraphrases of the weekly-review description (per-surface
copy, not a shared definition); and #5390 (lock and manifest only).

Verify

VERDICT: PASS

Checks run: test:web, type-check, lint, knip, test:a11y, test:e2e (baseline:
no new failures). Selected packages: web.

Baseline against origin/main:
FLAKY, passed on rerun (2):
- test:e2e: [chromium-desktop] › e2e/accessibility/focus-visible.spec.ts › the 'i' shortcut moves focus to a visibly-focused sidebar day
- test:e2e: [chromium-desktop] › e2e/accessibility/narrow-sidebar-layout.spec.ts › week sidebar fits a 360px viewport without horizontal overflow

Neither spec is reachable from this diff (no Life birth-date path, no sidebar
layout change). An earlier run of the same suite classified
narrow-sidebar-layout.spec.ts as PRE-EXISTING, failing on origin/main too.


Generated by Claude Code

`parseLifeBirthDateInput` took a `minDate` parameter but compared bare
years against a hardcoded 1900 and named 1900 as a literal in both
rejection messages, while each call site built the bound itself. #5391
added a second call site, so the rule sat in four parallel copies.

With a raised bound the parser accepted years below it and told the user
the wrong year, so moving the bound at either entry point would have
desynced the year path and the copy from the full-date path silently.

Export `LIFE_BIRTH_DATE_MIN` from the parse util, derive the year check
and both messages from `options.minDate`, and import the constant at both
call sites. Behavior is unchanged: every caller passes 1900 today.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HmwVQEPu2wGNzcsXb5TXTd
Biome's organizeImports wants the named import sorted ahead of the new
constant.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HmwVQEPu2wGNzcsXb5TXTd
@tyler-dane
tyler-dane enabled auto-merge November 30, 2026 11:47
@github-actions

Copy link
Copy Markdown
Contributor

Boot bundle: 606.1 KB gzip (+0.0 KB vs main)

@tyler-dane
tyler-dane added this pull request to the merge queue Nov 30, 2026
Merged via the queue into main with commit bb25d30 Nov 30, 2026
23 checks passed
@tyler-dane
tyler-dane deleted the claude/kind-dirac-4vmazc branch November 30, 2026 12:02

Copy link
Copy Markdown
Contributor Author

Promotion: deferred, to batch with the next release.

Per the release policy in AGENTS.md ("batch routine changes"), this one does not earn a production deploy of its own: it is behavior preserving (every caller passes 1900 today, so every accepted value and every message is unchanged), it is web-only, and the boot bundle came in at +0.0 KB. There is no user-visible change to verify in production and no urgency to trade against deploy risk.

  • Merged to main as bb25d30
  • Condition for promotion: rides along with the next release tag cut from main, no separate action needed
  • Rollback target if that release needs one: v1.4.194, the tag currently in production
  • Owner: whoever cuts the next release; nothing here blocks it

Generated by Claude Code

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.

2 participants