Skip to content

refactor(core): derive the average life variation from the shared lifespan - #5389

Merged
tyler-dane merged 1 commit into
mainfrom
claude/kind-dirac-5te3pk
Nov 29, 2026
Merged

tyler-dane merged 1 commit into
mainfrom
claude/kind-dirac-5te3pk

Conversation

@tyler-dane

Copy link
Copy Markdown
Contributor

No issue: scheduled tech-debt sweep. This is the finding the 2026-11-28 sweep
recorded as "deferred by budget, still a real finding" and handed to this one.

What and why

DEFAULT_LIFESPAN = 79 in packages/core/src/life/life-math.ts is the owning
definition of the default lifespan, but LIFE_VARIATIONS.average re-stated it
as the literal 79 while its sibling random entry correctly referenced
RANDOM_LIFESPAN_MAX. The two defaults in
apps/calendar-web/src/views/Life/life-preferences.storage.ts then read from
opposite sides of that split: line 22 defaults the Zod schema from
DEFAULT_LIFESPAN, line 34 defaults DEFAULT_LIFE_PREFERENCES.lifespan from
LIFE_VARIATIONS.average.defaultLifespan. Raising the shared constant would
have moved the schema default, the reflection email's "N-year average" caption
(reflection-life-progress.ts:14) and the life grid's row count
(reflection-life-image.ts:46) while leaving the stored default and the
sidebar's "Average" button (LifeView.tsx:236, life-search.ts:60) on 79, so
the grid would desync from its own caption silently. That is the same shape as
the WEEKS_PER_ROW finding in #5187. Nothing guarded the pair.

This points the entry at the constant and pins the invariant in
life.utils.test.ts, including clampLifespan's own DEFAULT_LIFESPAN
fallback, so re-hardcoding either side now fails a test. Behavior is
identical:
the constant is 79 today, so every call site resolves to the same
number it did before.

long: { defaultLifespan: 100 } is deliberately left as a literal even though
it equals RANDOM_LIFESPAN_MAX: the longest lifespan a user may pick and the
ceiling the random roll draws from are two product decisions that happen to
share a number today, and binding them would couple them.

The sweep's ledger entry in .agents/skills/tech-debt-sweep/judged-fine.md
records what else was examined and deliberately left alone (the PAYING set in
#5383's new billing-confirmation module, the five-PR life week sidebar cluster,
and formatLifeWeekRange.ts), so the next sweep does not redo it.

Verify

VERDICT: FAIL

Checks run: test:web, type-check, lint, knip, test:e2e, test:a11y (baseline: no
new failures). bun knip, bun lint and bun type-check all pass.

The verdict is FAIL on one failure that verify's baseline block did not
classify, and it is pre-existing and environmental, not caused by this diff:

PRE-EXISTING (1):

  • test:core: configureHttpServer > does not reject a request that exceeds maxHeadersCount (packages/core/src/server/http-server.test.ts:199), expected HTTP/1.1 200 OK, received HTTP/1.1 431 Request Header Fields Too Large

Reproduced on unmodified origin/main (1a7ab75) in a clean detached
worktree: same test, same assertion, same 431. This runner has bun 1.4.4 while
the repo pins bun@1.3.14 (bun test prints the mismatch warning), and 1.4.x
enforces header limits differently. The rest of test:core is green: 1093 pass,
1 fail across 1094 tests. Nothing in this diff touches packages/core/src/server.

FLAKY, passed on rerun (2):

  • test:a11y: [chromium-desktop] › e2e/accessibility/focus-visible.spec.ts › the 'i' shortcut moves focus to a visibly-focused sidebar day
  • test:a11y: [chromium-desktop] › e2e/accessibility/narrow-sidebar-layout.spec.ts › week sidebar fits a 360px viewport without horizontal overflow

The changed test file passes on its own: bun test apps/calendar-web/src/views/Life/life.utils.test.ts, 10 pass, 0 fail.


Generated by Claude Code

…espan

`DEFAULT_LIFESPAN` is the owning constant for the 79-year default, but
`LIFE_VARIATIONS.average` re-stated it as a literal while its sibling
`random` referenced `RANDOM_LIFESPAN_MAX`. The two defaults in
`life-preferences.storage.ts` read from opposite sides of that split: the
Zod schema default from the constant, `DEFAULT_LIFE_PREFERENCES` from the
variation table. Raising the constant would have moved the schema default,
the reflection email's "N-year average" caption and the life grid's rows
while leaving the stored default and the sidebar's "Average" button on 79.

Point the entry at the constant and pin the invariant so re-hardcoding
either side fails. Behavior is identical: the constant is 79 today.

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

Copy link
Copy Markdown
Contributor

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

@tyler-dane
tyler-dane added this pull request to the merge queue Nov 29, 2026
Merged via the queue into main with commit 54719c6 Nov 29, 2026
23 checks passed
@tyler-dane
tyler-dane deleted the claude/kind-dirac-5te3pk branch November 29, 2026 11:36
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