Public: anyone can read this; the crew can change it.

The restore drill's result keeps how long the hosted forge took to restore, in whole seconds #14189

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

The restore drill's proof of a hosted forge now records how long that forge's restore and checks took, as ms. Drills saved before this change still read. src/snapshot/drillhosted.ts: HostedProof gains an optional ms.

Notes

shipped production is serving it deploy 4adf612

opened this

The restore drill's proof of a hosted forge now records how long that forge's restore and checks took, as ms. Drills saved before this change still read.

  • src/snapshot/drill_hosted.ts: HostedProof gains an optional ms. proveHosted takes a new ticks clock option (it defaults to performance.now). It reads the clock before the restore and after the last git fsck, and returns the difference rounded to whole milliseconds.
  • src/snapshot/drill.ts: runDrill passes its own tick clock as ticks, so a drill run with a fake clock times the hosted forge with that clock too.
  • src/snapshot/drills.ts: parseHosted reads ms back only when it is a whole, non-negative safe integer. Otherwise it leaves ms out and still returns the rest of the proof. This field lives in the existing phases JSON, so there is no migration.

I stored whole milliseconds rather than the whole seconds the issue title mentions, because the issue's checklist asks for ms. The card can round to seconds when it shows the value. There is no page change; the card is the next issue.

Tests:

  • test/snapshot-hosted-chunks.test.ts: a new test calls proveHosted with a fake clock that reads 1000 then 13,400.6, and expects ms: 12_401. The existing drill test that compares the whole proof now also expects an integer ms.
  • New test/drill-hosted-ms.test.ts: a stored row with ms reads it back. A stored row without ms parses with no ms key. Bad values (-1, 1.5, "12", null, Number.MAX_VALUE) are dropped and the rest of the proof still reads.

Checks run: scripts/gate.ts --fix (its comment rewrap is in the commit), tsc --noEmit, and the drill, snapshot, admin-drill and MCP drill tests (165 tests across 25 files) all passed. scripts/fast.ts named 2,369 files, over its budget, so I picked those test files by hand rather than run the full suite.

🤖 Generated with Claude Code

Closes #14184

commented

The restore drill's proof of a hosted forge now records how long that forge's restore and checks took, as ms. Drills saved before this change still read.

  • src/snapshot/drill_hosted.ts: HostedProof gains an optional ms. proveHosted takes a new ticks clock option (it defaults to performance.now). It reads the clock before the restore and after the last git fsck, and returns the difference rounded to whole milliseconds.
  • src/snapshot/drill.ts: runDrill passes its own tick clock as ticks, so a drill run with a fake clock times the hosted forge with that clock too.
  • src/snapshot/drills.ts: parseHosted reads ms back only when it is a whole, non-negative safe integer. Otherwise it leaves ms out and still returns the rest of the proof. This field lives in the existing phases JSON, so there is no migration.

I stored whole milliseconds rather than the whole seconds the issue title mentions, because the issue's checklist asks for ms. The card can round to seconds when it shows the value. There is no page change; the card is the next issue.

Tests:

  • test/snapshot-hosted-chunks.test.ts: a new test calls proveHosted with a fake clock that reads 1000 then 13,400.6, and expects ms: 12_401. The existing drill test that compares the whole proof now also expects an integer ms.
  • New test/drill-hosted-ms.test.ts: a stored row with ms reads it back. A stored row without ms parses with no ms key. Bad values (-1, 1.5, "12", null, Number.MAX_VALUE) are dropped and the rest of the proof still reads.

Checks run: scripts/gate.ts --fix (its comment rewrap is in the commit), tsc --noEmit, and the drill, snapshot, admin-drill and MCP drill tests (165 tests across 25 files) all passed. scripts/fast.ts named 2,369 files, over its budget, so I picked those test files by hand rather than run the full suite.

🤖 Generated with Claude Code

commented

proveHosted now times its own restore and proof and returns ms, in whole milliseconds. Drills saved before this change still read.

main had already added the same ms field in #14181, timed from outside by the drill. The merge keeps both:

  • src/snapshot/drill_hosted.ts: proveHosted takes an injectable clock, ticks, which defaults to performance.now. It reads it before the restore and after the last git fsck, and returns the difference rounded. The ms?: number | undefined field from main stays, with one comment covering both ways it gets set.
  • src/snapshot/drill.ts: the drill passes its own clock to proveHosted. It uses proof.ms ?? Math.round(tick() - from), so its own outside timing from #13919 now only fills in when the proof has no time, as with a stubbed prove in tests.
  • src/snapshot/drills.ts: parseHosted reads ms only when it is a whole number of zero or more; otherwise it leaves it out and the rest still reads. main's parseHostedSkipped is kept.

Tests:

  • test/snapshot-hosted-chunks.test.ts calls proveHosted with a fake clock that reads 1000 then 13,400.6 and expects ms: 12_401. main's assertions on the drill's wording and the skipped hosted step are kept.
  • test/drill-hosted-ms.test.ts checks that a stored drill with ms reads it back, and one without it still parses. Bad values (-1, 1.5, "12", null, Number.MAX_VALUE) are dropped and the rest of the proof still reads.

There is no page change; the card is the next issue.

scripts/gate.ts --fix and tsc --noEmit are clean. The drill, snapshot and hosted-forge test files, including the ones main changed, pass: 168 tests in 25 files. scripts/fast.ts named 2,369 files, over its time limit, so I chose those test files by hand.

🤖 Generated with Claude Code

Approved

Meets all three boxes: proveHosted times itself on an injectable monotonic clock and returns whole ms, the drill passes its own clock through and only falls back to outside timing when a stubbed prove gives none, and parseHosted drops a missing or malformed ms and still reads the rest. No page change, no new dependency, no README edit, and the preview is unaffected. Two things I would do next: (1) test runDrill itself with a fake clock so the proof.ms ?? fallback is pinned in both directions; drill-hosted-ms.test.ts passes on main already, since parseHosted read ms there, so only the proveHosted test guards this change. (2) Put proveHosted options on one line per field, since the new multi-line type is formatted unlike its neighbours, and show the time in seconds on the card in the next issue.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs