Skip to content

test(server): seed the metrics simulation from a fixed until - #168

Merged
sanchitrk merged 1 commit into
canaryfrom
fix/seed-repeatable
Nov 14, 2026
Merged

sanchitrk merged 1 commit into
canaryfrom
fix/seed-repeatable

Conversation

@sanchitrk

@sanchitrk sanchitrk commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

metrics.simulation.json changed between runs even when nothing else did, because apps/server/test/machines/seed.ts read the wall clock in three places:

  • until defaulted to Date.now().
  • startDay() weighted weekends by the weekday of until - ago * DAY, so the result followed the run date.
  • if (at > UNTIL) at = UNTIL - int(...) drew an extra random number only when a turn's work hour fell after the current time. That shifted the rest of the mulberry32 stream depending on the hour of the run.

Changes:

  • The suite passes a fixed past until (2026-11-14T12:00Z). It is in the past, so until() (now + 2 days) and the since 1970 reads still cover every seeded row. Live turns under CODEWORK_FIXTURE_NOW still land today.
  • seed.ts now requires <until ms>.
  • The clamp draws its number whether or not the turn needs it.
  • metrics.simulation.json is regenerated.

Verified on OrbStack cw-a and cw-b, one suite at a time: run 1 (-u, 12:40 UTC) and run 3 (no -u, 12:44 UTC) both passed and wrote byte-identical artifacts. Run 2 matched run 1 through the restored case. It then failed in readded, where truth(cwB) got an empty result from sqlite3 over orb for an aggregate SELECT. That looks like an existing transport flake, not something the seed causes. vp check and vp run typecheck pass.

Rebased onto #166 and regenerated the artifact at 17:18 UTC. Its seeded and first-connect totals match the 12:40 UTC run exactly, and a second run with no -u passed all 9 tests with a byte-identical artifact.

🤖 Generated with Claude Code


Autofix with [code]smith
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

The seed read the wall clock: `until` defaulted to now, weekend weighting
followed the run date, and the clamp for turns past `until` drew an extra
random number only when a turn fell after the current time, shifting the
rest of the stream with the hour. The suite now passes a fixed past
`until`, the seed requires it, and the clamp draws either way, so
metrics.simulation.json repeats across runs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@sanchitrk
sanchitrk merged commit b9173fe into canary Nov 14, 2026
1 check passed
@sanchitrk
sanchitrk deleted the fix/seed-repeatable branch November 14, 2026 17:22
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