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

opened this

Merged 16d 21h ago, live in production

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

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

Sign in to join this conversation.

Search
↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs