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

The release tick's gate passes the migration-order test: "two pulls' migrations land in either order" must not depend on a 6.5 s wait #15508

Merged opened this

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

Merged

The migration-order test ("two pulls' migrations land in either order…") now runs in 0.125 s instead of 0.39 s on a quiet machine. It passed 20 of 20 runs under bun test --rerun-each 20. The timeout is unchanged and the order-independence assertions are kept.

Notes

shipped production is serving it deploy 0adf720

opened this

The migration-order test ("two pulls' migrations land in either order…") now runs in 0.125 s instead of 0.39 s on a quiet machine. It passed 20 of 20 runs under bun test --rerun-each 20. The timeout is unchanged and the order-independence assertions are kept.

Cost removed: the test built its migration lists by calling directory() three times. Each call copied all 366 files in src/core/migrations and then readMigrations loaded each copy again with require. That added up to about 1,100 module loads, and copying plus loading the files was most of the test's time. File and module loading is the part that slows down most when the host is busy, which fits the 6.5 s seen at the 10:30Z tick. The real clock and the database opens were small; no process is spawned.

What moved (test/schema-migrations.test.ts):

  • A new helper, shippedWith(extra), writes only the extra migration files to a small directory and reads them with readMigrations. It then merges them with the already-loaded migrationFiles in the order readMigrations would give if all the files were in one directory.
  • The test now uses shippedWith for its three lists.
  • One new assertion checks that the two stamped migrations sort last, in time order.
  • The unused listIn alias is removed.
  • directory() stays. "stamped ids sort after every numbered one" still uses it, so sorting stamped and numbered files from one directory is still tested through readMigrations.

Not done: src/kernel/migrate.ts and src/kernel/db.ts are untouched; migrate() on an up-to-date database takes about 7 ms and was not the slow part.

Checks: bun scripts/gate.ts --fix changed nothing and bun x tsc --noEmit is clean. bun scripts/fast.ts named 121 test files, mostly repo-wide scans, with an estimated 9m42s, so I ran only the 14 that bear on a test file: schema-migrations, schema-additive, test-honesty, flake, dupes, hollow, tree-scans, timers-named, global-spies-restored, module-state, rule-tests-always, gate-stray-test, kernel-boundary and src-imports. All 150 tests passed. The other 107 were not run here and will be covered by the forge's check on this push.

To try it: bun test test/schema-migrations.test.ts -t "either order" --rerun-each 20

🤖 Generated with Claude Code

Closes #15506

commented

The migration-order test ("two pulls' migrations land in either order…") now runs in 0.125 s instead of 0.39 s on a quiet machine. It passed 20 of 20 runs under bun test --rerun-each 20. The timeout is unchanged and the order-independence assertions are kept.

Cost removed: the test built its migration lists by calling directory() three times. Each call copied all 366 files in src/core/migrations and then readMigrations loaded each copy again with require. That added up to about 1,100 module loads, and copying plus loading the files was most of the test's time. File and module loading is the part that slows down most when the host is busy, which fits the 6.5 s seen at the 10:30Z tick. The real clock and the database opens were small; no process is spawned.

What moved (test/schema-migrations.test.ts):

  • A new helper, shippedWith(extra), writes only the extra migration files to a small directory and reads them with readMigrations. It then merges them with the already-loaded migrationFiles in the order readMigrations would give if all the files were in one directory.
  • The test now uses shippedWith for its three lists.
  • One new assertion checks that the two stamped migrations sort last, in time order.
  • The unused listIn alias is removed.
  • directory() stays. "stamped ids sort after every numbered one" still uses it, so sorting stamped and numbered files from one directory is still tested through readMigrations.

Not done: src/kernel/migrate.ts and src/kernel/db.ts are untouched; migrate() on an up-to-date database takes about 7 ms and was not the slow part.

Checks: bun scripts/gate.ts --fix changed nothing and bun x tsc --noEmit is clean. bun scripts/fast.ts named 121 test files, mostly repo-wide scans, with an estimated 9m42s, so I ran only the 14 that bear on a test file: schema-migrations, schema-additive, test-honesty, flake, dupes, hollow, tree-scans, timers-named, global-spies-restored, module-state, rule-tests-always, gate-stray-test, kernel-boundary and src-imports. All 150 tests passed. The other 107 were not run here and will be covered by the forge's check on this push.

To try it: bun test test/schema-migrations.test.ts -t "either order" --rerun-each 20

🤖 Generated with Claude Code

Approved

Test-only change that removes the cost of the order test (copying and re-requiring 366 migration files three times) while keeping the order-independence assertions and adding one that pins the sort order of the two stamped files. shippedWith writes only the extras and merges them with the already-loaded migrationFiles using the same filename ordering as readMigrations; directory() is kept for the stamped-after-numbered test, so the one-directory sort is still exercised. No src change, no new dependency, no page or terminal surface, README untouched. Next, if you want: (1) a short comment or assertion that shippedWith ordering matches readMigrations on a mixed directory, so the two cannot drift; (2) consider whether other tests copy the whole migrations directory the same way.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs