Client snowball projection duplicates server simulation (drift risk) #55

Closed
opened 2026-05-16 21:43:13 -05:00 by null · 1 comment
Owner

Severity: LOW 🔵

Affected Files

  • client/pages/SnowballPage.jsxcomputeLiveProjection() lines 37–122
  • services/snowballService.js — server-side projection

Problem

computeLiveProjection() in SnowballPage.jsx is a client-side reimplementation of the server-side snowball simulation in snowballService.js. A comment acknowledges this ("mirrors server snowballService") but there's no test or assertion to keep them in sync.

If rounding, interest handling, or the rolling-extra logic is fixed on the server, the client projection silently diverges.

Impact

  • Server and client projections can drift without anyone noticing
  • Bug fixes in one copy may not be applied to the other
  • No automated check catches divergence

Fix Options

  1. Preferred: Remove client-side projection entirely; fetch from server on every change (adds latency but guarantees consistency)
  2. Minimal: Add a snapshot test that runs both simulations with the same input and asserts identical output
  3. Compromise: Keep client projection but add a /api/snowball/projection validation endpoint that the client can periodically check against

Acceptance Criteria

  • Client and server projections produce identical results for the same input
  • There is a test or mechanism to detect drift
## Severity: LOW 🔵 ## Affected Files - `client/pages/SnowballPage.jsx` — `computeLiveProjection()` lines 37–122 - `services/snowballService.js` — server-side projection ## Problem `computeLiveProjection()` in `SnowballPage.jsx` is a client-side reimplementation of the server-side snowball simulation in `snowballService.js`. A comment acknowledges this ("mirrors server snowballService") but there's no test or assertion to keep them in sync. If rounding, interest handling, or the rolling-extra logic is fixed on the server, the client projection silently diverges. ## Impact - Server and client projections can drift without anyone noticing - Bug fixes in one copy may not be applied to the other - No automated check catches divergence ## Fix Options 1. **Preferred**: Remove client-side projection entirely; fetch from server on every change (adds latency but guarantees consistency) 2. **Minimal**: Add a snapshot test that runs both simulations with the same input and asserts identical output 3. **Compromise**: Keep client projection but add a `/api/snowball/projection` validation endpoint that the client can periodically check against ## Acceptance Criteria - [ ] Client and server projections produce identical results for the same input - [ ] There is a test or mechanism to detect drift
null added the
frontend
priority:nice-to-have
labels 2026-05-16 21:43:13 -05:00
Author
Owner

Fixed in c353dd9. Deleted computeLiveProjection() client duplicate. Server now accepts ?extra=N for unsaved amount preview. Drift is no longer possible.

Fixed in `c353dd9`. Deleted `computeLiveProjection()` client duplicate. Server now accepts `?extra=N` for unsaved amount preview. Drift is no longer possible.
null closed this issue 2026-06-03 21:50:37 -05:00
Sign in to join this conversation.
No Milestone
No project
No Assignees
1 Participants
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: null/BillTracker#55
No description provided.