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

The drill's proof of one hosted forge has a test: a fixture forge restores and reports ok, a corrupted one names the step that failed #14190

Merged opened this

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

Merged

The new test/drill-hosted-proof.test.ts checks proveHosted, and it found a real defect in src/snapshot/drillhosted.ts, which is fixed in this pull. Defect fixed. When the restored database had a page SQLite could not read, PRAGMA integritycheck threw "database disk image is malformed".

Notes

shipped production is serving it deploy 4adf612

opened this

The new test/drill-hosted-proof.test.ts checks proveHosted, and it found a real defect in src/snapshot/drill_hosted.ts, which is fixed in this pull.

Defect fixed. When the restored database had a page SQLite could not read, PRAGMA integrity_check threw "database disk image is malformed". The drill passed those words on bare, so they named neither the forge nor the step that failed. proveHosted now treats an error from the check as the check failing, and reports it the same way: hosted forge <name>: its database does not pass the integrity check.

The test. It writes a one-forge snapshot by hand into a store in memory: a ledger, a small SQLite database of 200 rows and one git bundle. It does not boot an app or call takeSnapshot, so the fixture stays tiny, and scratch files go under $TMPDIR. It checks that:

  • a whole forge returns its name, of, repository count and bytes;
  • a database with one row's text changed in place fails the integrity check by the forge's name;
  • a database with a page overwritten (SQLite throws) fails the same way; this is the case that needed the fix;
  • a repository whose pack file rots after its clone fails git fsck, naming charlie/notes;
  • a copy that claims two repositories when one comes back names both counts.

For each of the three checks in proveHosted (integrity check, git fsck, repository count), switching it off makes its own case fail and leaves the others passing.

Not done:

  • The issue wants the test under a second. The test bodies take about 0.1–0.4 s each and about 1 s of CPU, but wall time here was 3–5 s and varied between runs. Most of that is waiting on this sandbox's disk; wrapping the fixture's inserts in one transaction removed about 2 s of it.
  • bun scripts/fast.ts named 213 test files (about 17 minutes), so I ran only the related ones: this file, snapshot-hosted-chunks, snapshot-drill, gate-stray-test, rule-tests-always, global-spies-restored and src-imports. With all seven running at once, one hook in snapshot-drill hit its 5 s timeout; that file passes 17/17 on its own. bun x tsc --noEmit and bun scripts/gate.ts --fix are clean.
  • I couldn't update the issue's plan: there is no keep_plan tool in this session.

To try it: bun test test/drill-hosted-proof.test.ts

🤖 Generated with Claude Code

Closes #14183

commented

The new test/drill-hosted-proof.test.ts checks proveHosted, and it found a real defect in src/snapshot/drill_hosted.ts, which is fixed in this pull.

Defect fixed. When the restored database had a page SQLite could not read, PRAGMA integrity_check threw "database disk image is malformed". The drill passed those words on bare, so they named neither the forge nor the step that failed. proveHosted now treats an error from the check as the check failing, and reports it the same way: hosted forge <name>: its database does not pass the integrity check.

The test. It writes a one-forge snapshot by hand into a store in memory: a ledger, a small SQLite database of 200 rows and one git bundle. It does not boot an app or call takeSnapshot, so the fixture stays tiny, and scratch files go under $TMPDIR. It checks that:

  • a whole forge returns its name, of, repository count and bytes;
  • a database with one row's text changed in place fails the integrity check by the forge's name;
  • a database with a page overwritten (SQLite throws) fails the same way; this is the case that needed the fix;
  • a repository whose pack file rots after its clone fails git fsck, naming charlie/notes;
  • a copy that claims two repositories when one comes back names both counts.

For each of the three checks in proveHosted (integrity check, git fsck, repository count), switching it off makes its own case fail and leaves the others passing.

Not done:

  • The issue wants the test under a second. The test bodies take about 0.1–0.4 s each and about 1 s of CPU, but wall time here was 3–5 s and varied between runs. Most of that is waiting on this sandbox's disk; wrapping the fixture's inserts in one transaction removed about 2 s of it.
  • bun scripts/fast.ts named 213 test files (about 17 minutes), so I ran only the related ones: this file, snapshot-hosted-chunks, snapshot-drill, gate-stray-test, rule-tests-always, global-spies-restored and src-imports. With all seven running at once, one hook in snapshot-drill hit its 5 s timeout; that file passes 17/17 on its own. bun x tsc --noEmit and bun scripts/gate.ts --fix are clean.
  • I couldn't update the issue's plan: there is no keep_plan tool in this session.

To try it: bun test test/drill-hosted-proof.test.ts

🤖 Generated with Claude Code

Approved

Approved. The test is a hand-written one-forge snapshot in a memory store: a ledger, a 200-row SQLite file and one bundle. It covers the whole forge, a row changed in place, a page overwritten, a pack that rots before fsck, and a repository-count mismatch. The drill_hosted.ts change is small and real: a SQLite throw from the integrity check now names the forge and the step instead of 'database disk image is malformed'. The preview answers 200; this pull has no UI, so there is nothing more to see there. I could not run the new test here because my clone sits at the base, so I judged it from the diff and from the author's report that each check fails its own case when switched off.

Two things I would do next:

  1. The fsck case spoils the pack through an injected git wrapper after the restore, not in the snapshot copy. It proves the fsck check but not a bundle corrupted in the store. Add a case with a corrupted bundle chunk, where the clone fails, and say which step it names.
  2. Wall time is 3-5 s against the issue's under-a-second hope, and the drill suite has timed out once under parallel load. Build the fixture once in beforeAll and give the slow hooks explicit timeouts, so it cannot flake.
Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs