Server-side calculations are computed in the container timezone, shifting all TOU windows #22
Labels
No labels
bug
decision
docs
enhancement
integration
ops
security
tech-debt
testing
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
rbrooks/BatteryStorageCalculator#22
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
The shared calculation runtime derives season, weekday, holiday, and TOU hour from local-time
Datemethods (src/lib/simulation.js:316,src/lib/rates.js:135-141). Usage timestamps travel to the backend as UTC instants (src/lib/homePersistence.js:210,timestamptzcolumn in001_initial.sql:87), and the backend re-runs the same runtime (backend/src/calculationRunner.js:30) in whatever timezone the container has — which is UTC for node:20-alpine, and nothing in the repo (Dockerfile,backend/Dockerfile, either compose file,.env.example) setsTZ.Result: server-side calculations — the authoritative path since the server-calculation milestone — bucket every hour 5–6 hours off for a Missouri home. On-peak/off-peak assignment, weekend/holiday detection, month grouping, and season edges are all wrong, and server results silently diverge from the in-browser fallback. Backend tests can't see it because expected values are computed in the same (shifted) process.
Fix in two steps:
TZ=America/Chicagoto the backend image/compose environment.Intl.DateTimeFormatagainst a per-home IANA zone (defaultAmerica/Chicagoon the home profile) instead ofDate#getHours()etc. Add a regression test that runs the simulation withprocess.env.TZ='UTC'and asserts identical output to a Central-time run.After deploying either step, force-recompute stored calculation results and re-generate report snapshots — existing cached outputs were computed with shifted buckets.
Acceptance criteria
Relations: relates to #8 (deployment config), #16 (cached results may need invalidation after fix)
(Audit finding F-01, 2026-07-16 — Severity: Critical, Confidence: High)
Sequencing (from the 2026-07-16 audit roadmap assessment): this issue leads the v1.1.1 Calculation Correctness slice, which should land before or alongside the remaining v1.1.0 items (#7, #8, #9).
Recommended order:
TZ=America/Chicagostopgap) — ship immediately, ahead of everything else.Rationale: every other number in the app depends on the authoritative engine bucketing hours correctly; fixing anything downstream first means re-verifying it later.