Repository navigation
Commit 744b73f
test(verify): the dashboard-window runs freeze Date at noon UTC, pinned from a wall clock 100 ms before midnight (#23583)
Fixes #23351
Clause-②: no
## What changed
`packages/verify/src/dashboard-window.test.ts` only. The probe
(`packages/verify/src/dashboard-window.ts`) is not edited: its day-turn
`not-run` is a correct answer and stays as it is. No case is skipped.
- **The freeze.** One helper, `onFrozenClock(run)`, fakes `Date` only
(`vi.useFakeTimers({ toFake: ['Date'] })`; every timer stays real) at
noon UTC of the day the run starts on, and gives the real clock back in
`finally`. Every `runDashboardWindowProofs` call in the file goes
through it.
- **The pin.** `wallClockAtMidnight()` sets the wall clock to
23:59:59.900Z of today, still moving at its real pace
(`shouldAdvanceTime: true`, `Date` only). The positive fixture run and
both NEGATIVE CONTROL runs start from it, then go through
`onFrozenClock`. With the freeze they pass. Without it they cross
midnight in their first measure and fail with the day-turn reason on any
day, not only on a day whose run crosses 00:00Z (ablation below). The
pin is in the file, so it stays, and it costs no extra boot.
- **One spelling.** THE DAY TURN block now uses the same helper instead
of its own copy of the fake-`Date` setup. It still moves the clock one
day on the run's first door call. It now starts from noon of the start
day instead of the real instant.
## Inventory, on `origin/main` 252775d
Every case that runs the family and asserts a verdict or reason other
than the day turn:
| block | cases | real clock before this PR | what a day turn changes |
|---|---|---|---|
| `runDashboardWindowProofs — the fixture app` | 4, one shared
`beforeAll` run | yes | "proves every bound count widget…" asserts
`proven`; "counts every dashboard…" asserts `proven: 10`, `notRun: 0` |
| NEGATIVE CONTROL (drop) | 2 | yes | `contradicted`, the `logged_at`
rewrite reason, the `audited_at` unconfirmed reason |
| NEGATIVE CONTROL (zero) | 2 | yes | the same; these two went red in
merge-queue run 38486827994 |
| THE DAY TURN | 1 | no, already faked `Date` | asserts the day turn
itself |
| `deriveDashboardWindowCases` | 2 | no clock read | none |
The freeze sits in each run's `beforeAll`, so it covers all 8 cases of
the three runs.
## Mechanism, measured
- The probe reads the clock through `new Date()` only
(`dashboard-window.ts` lines 575, 795 and 884). The server resolves the
same presets on `new Date()` in this process
(`packages/services/service-analytics/src/dataset-executor.ts` line 127,
`filterTokenContextFrom(context, new Date())`). So faking `Date` reaches
both sides, and the frozen run's presets agree with the server's.
- Timers stay real, so nothing the run waits on stalls. Wall time, the
base file against this file, alternated twice, each pair in one lock
hold on a shared box (ratios survive the sharing, the absolutes do not):
| pair | this file: wall / vitest `tests` | base file: wall / vitest
`tests` | ratio, `tests` |
|---|---|---|---|
| A | 38.5 s / 13.55 s | 41.1 s / 13.41 s | 1.01 |
| B | 43.1 s / 14.74 s | 41.6 s / 13.42 s | 1.10 |
## Ablation, and a one-shot check of the other side of noon
Both legs went through `scripts/ablation-replace.mjs` (anchor must hit,
blob checked) inside a script with its own `trap` restore. Both were
restored to the HEAD blob `49740f917f02` with `git diff HEAD` empty. No
mutation file is left.
- **Freeze removed, wall clock at 23:59:59.900Z.** The two
`onFrozenClock` lines that fake and set `Date` are replaced. Anchor 1 →
0, blob `49740f917f02` → `4d765d5b68a4`; on disk the freeze anchor
counts 0 and the injected marker 1. Result: `Tests 6 failed | 5 passed
(11)`. The failures are the positive run's "proves every bound count
widget…" and "counts every dashboard…", plus all four NEGATIVE CONTROL
cases. Every measure reads `inconclusive: the day turned after the run
started (2026-10-15 → 2026-10-16) …` or `the day turned during the probe
…`. The ATTRIBUTION case fails with `expected 'the day turned after the
run started …' to match /reads back logged_at = "2020-01-01T00…/`, which
is run 38486827994's signature, now on demand. THE DAY TURN, the two
derive cases and the two positive cases a day turn does not change stay
green.
- **Frozen at noon of the previous day.** This is about 13 h before the
session's real sign-in: the other side of the noon-versus-now offset
this suite meets over a day. At 01:2xZ today's noon is about 10.5 h
ahead. Anchor 1 → 0, blob → `9336e35e133d`. Result: `Tests 11 passed
(11)`. A frozen instant hours away from the real boot, in either
direction, does not change a verdict.
## Tests and gates, all at `c9e7b172f`
- `pnpm --filter @objectstack/verify exec vitest run --maxWorkers=2
src/dashboard-window.test.ts`: `Tests 11 passed (11)`, three runs: the
verbose run and the fixed-file leg of each timing pair. Before the edit,
at 252775d: `Tests 11 passed (11)`.
- `pnpm --filter @objectstack/verify typecheck`: exit 0 (`tsc --noEmit`,
then `check:test-typecheck`: 0 errors). `tsc --listFiles -p
tsconfig.test.json` holds `dashboard-window.test.ts` (1 of the 41 test
files in the program).
- eslint over `packages/verify` with `--no-inline-config`: exit 0. 59
files, 0 errors, 0 warnings, and the target file was linted. Repo-wide
`pnpm lint` is left to CI.
- `node scripts/pm/dispatch-gates.mjs --commands --repo
objectstack-ai/objectstack`: 50 commands, each run with its exit code
recorded before any pipe. `--ran` reports 50 derived, 49 run (all exit
0), 1 NOT MEASURED, 0 unrun. The NOT MEASURED one is `pnpm
check:dual-build-cjs-loads`: exit 3, PREREQUISITE NOT MET. It reads
every package's `dist/` and needs a whole-workspace `pnpm build`. This
diff changes no built output, and CI runs it.
- `skip-changeset`, by its criterion. `files[]` is `dist`, `README.md`
and `CHANGELOG.md`. After `pnpm --filter @objectstack/verify build`,
`onFrozenClock` and `wallClockAtMidnight` hit 0 files there, while the
positive control `runDashboardWindowProofs` hits 4.
## Acceptance notes
- `packages/cli/test/verify-dashboard-windows.test.ts` runs the same
family through a spawned `os verify --dashboard-windows` child on the
real clock. It asserts `proven` and `contradicted`, so a run that
crosses 00:00Z would read `not-run` there too. `vi.useFakeTimers` cannot
reach a child process, so the fix there is not this mechanical edit, and
that file is outside this card's file surface. This is a read-only
inference and has not been measured red. Carrier: none.
- Inside a frozen run the structured logger stamps every line
`12:00:00.000Z`, because it reads `Date` too. Log times there are not
wall time.
- `origin/main` gained 3 commits after the base (hono adapter,
metadata-protocol, objectql tests). None touches `packages/verify`, and
there is no conflict, so they are not merged in.
---
_Generated by [Claude
Code](https://claude.ai/code/session_01FLwgbTSmGMrqsXkBDsiwfG)_
Co-authored-by: Claude <noreply@anthropic.com>1 parent cac0be8 commit 744b73f
1 file changed
Lines changed: 53 additions & 13 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
18 | 24 | | |
19 | 25 | | |
20 | 26 | | |
| |||
139 | 145 | | |
140 | 146 | | |
141 | 147 | | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
142 | 185 | | |
143 | 186 | | |
144 | 187 | | |
| |||
178 | 221 | | |
179 | 222 | | |
180 | 223 | | |
181 | | - | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
182 | 227 | | |
183 | 228 | | |
184 | 229 | | |
| |||
336 | 381 | | |
337 | 382 | | |
338 | 383 | | |
339 | | - | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
340 | 387 | | |
341 | 388 | | |
342 | 389 | | |
| |||
404 | 451 | | |
405 | 452 | | |
406 | 453 | | |
407 | | - | |
408 | | - | |
409 | | - | |
410 | | - | |
411 | | - | |
412 | | - | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
413 | 457 | | |
414 | 458 | | |
415 | 459 | | |
| |||
421 | 465 | | |
422 | 466 | | |
423 | 467 | | |
424 | | - | |
425 | | - | |
426 | | - | |
427 | | - | |
428 | | - | |
| 468 | + | |
429 | 469 | | |
430 | 470 | | |
431 | 471 | | |
| |||
0 commit comments