fix(test): resolve the store version from the upstream lane in persistedVersion - #382
Conversation
…tedVersion `getPersistedSchemaVersion` (storage-db.ts:269-274) already bounds its read with `WHERE version < FORK_MIGRATION_VERSION_FLOOR`, so a downstream fork recording its own migrations in the reserved >= 10_000 lane still reports this binary's upstream schema version. The `persistedVersion` helper in this test did a bare MAX(version), so it read a fork's 10_000+ row as the store version and failed the shared OpenCode/Pi boot assertion for any fork using the documented lane. Mirror the production bound in the helper and add a regression that seeds a fork-lane row and asserts the resolved version is still LATEST_MIGRATION_VERSION. Reverting the helper bound makes it fail with Expected 82 / Received 10100.
8a6c0dd to
2580291
Compare
|
Pushed one correction, caught by running this against a real fork rather than only against clean The regression test seeded its fork-lane row with a plain Which is a poor property for a test whose entire purpose is to protect forks using the lane. Changed to Verified both directions now: |
|
Verified and merging. The helper now mirrors |
What
persistedVersioninstorage-db-initialize-order.test.tsreads the store's schema version with a bareMAX(version). Production doesn't —getPersistedSchemaVersionbounds the same read by the reserved fork lane:So for a downstream fork recording its migrations in the documented
>= 10_000lane, production resolves the version correctly while this test helper reads the fork's row as the store version:The test is correct in what it asserts — it's the helper that doesn't match the production rule it's standing in for.
Change
Mirror the production bound in the helper, plus a regression that seeds a fork-lane row and asserts the resolved version is still
LATEST_MIGRATION_VERSION.Red-check: reverting the helper bound while keeping the new test gives
Expected: 82 / Received: 10100— the same symptom, now caught directly rather than as a side effect of an unrelated boot-path assertion.Scope
One test file, +35/−2. No production code touched.
tsc --noEmitclean. Lint reports the same 6 pre-existing errors as cleanmaster(verified by stashing), none in this file.Why it matters
This is the only place I found where the reserved-lane convention from #280 isn't honoured. Production code, the schema fence, and the migration runner all respect the floor; this helper was the one straggler. Without it, any fork using the lane as documented sees a red suite on an upstream test that has nothing to do with its changes — which is exactly the friction the reserved lane was introduced to remove.
Found while rebasing a fork onto
masterafter #376/#378 merged: the failure looked like one of the known full-suite concurrency artifacts, but it reproduced in isolation (2.6s, single file) and passed on cleanmaster, which is what pointed at the helper rather than the environment.Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.Summary by cubic
Fixes the
persistedVersiontest helper so it resolves the store version from the upstream migration lane, matching production'sgetPersistedSchemaVersion. Previously the helper used a bareMAX(version)query, so a downstream fork recording migrations in the reserved10_000+lane was treated as the store version and failed the shared boot assertion.LATEST_MIGRATION_VERSION.Written for commit 2580291. Summary will update on new commits.
Greptile Summary
This PR aligns the test-only
persistedVersionhelper with production by excluding migration rows in the reserved downstream-fork lane.FORK_MIGRATION_VERSION_FLOORto the helper query.Confidence Score: 5/5
The PR appears safe to merge, with no actionable defects identified in the test-only change.
The updated query uses the same constant and strict boundary as production, while the regression fixture remains isolated and is cleaned up through the existing database lifecycle.
Important Files Changed
Reviews (2): Last reviewed commit: "fix(test): resolve the store version fro..." | Re-trigger Greptile