Skip to content

miner(store): add a drift guard for the doctor/migrate twin store lists #9689

Description

@JSONbored

⚠️ Definition of Done: this issue must be completed in full, in a single PR. Do not split this
work across multiple PRs, and do not defer any Deliverable below to a follow-up issue. A PR that
satisfies only some of the Deliverables, stubs a required test, or leaves a checkbox
partially-done does NOT resolve this issue and will be closed.

Context

Two hand-maintained lists of the miner's durable local SQLite stores are required to stay identical:

  • storeIntegrityChecks in packages/loopover-miner/lib/status.ts:391-417 (what doctor runs PRAGMA integrity_check against), whose comment says: "Keep in sync with migrate-cli.js's STORES list (doctor's integrity sweep and migrate's proactive sweep both omit four real local stores #6768): every durable local SQLite store using resolveLocalStoreDbPath."
  • STORES in packages/loopover-miner/lib/migrate-cli.ts:53-83 (what migrate opens to apply pending migrations), whose header says it "Mirrors status.js's storeIntegrityChecks ... store list exactly".

The contract is stated in both directions and enforced in neither. It has already been broken twice, each time needing its own issue to notice: #8318 (orb-export was missing from both) and #8641 (laptop-state was missing from both) — see the inline #8318 / #8641 comments in each file. A store missing from storeIntegrityChecks is never integrity-checked by doctor; a store missing from STORES is never proactively migrated by migrate and only gets its migrations whenever some command happens to open it first.

Both lists currently hold the same eighteen entries, so they are in sync today — but two of migrate-cli.ts's own comments state otherwise and would mislead anyone extending them: lines 6-8 say "same eleven stores doctor already covers" and line 159 says "defaults to the real seven-store list". test/unit/miner-migrate-cli.test.ts covers migrateStore's behaviour but never compares the two lists.

Requirements

  • Export the store-name list from each module so it can be compared: add a named export STORE_INTEGRITY_NAMES: readonly string[] from packages/loopover-miner/lib/status.ts (derived from the same array storeIntegrityChecks builds — do not duplicate the literal) and export the existing STORES constant from packages/loopover-miner/lib/migrate-cli.ts.
  • Add a drift-guard test asserting the two name lists are equal as sets and equal in length, so adding a store to one and not the other fails CI.
  • Add a second assertion in that test pinning both lists to the same explicit sorted array of store names written out in full, so a store silently dropped from BOTH lists at once also fails.
  • Replace the stale counts in migrate-cli.ts's module header (lines 6-8) and in runMigrateChecks's doc comment (line 159) with wording that does not hardcode a number.
  • No change to what either list contains, to the doctor/migrate output, or to MigrateStoreDescriptor.

⚠️ Required pattern: the drift guard must be a real assertion over the two exported lists in test/unit/miner-migrate-cli.test.ts. It does NOT satisfy this issue to merge the two lists into one shared constant and refactor both call sites (each entry carries different data — a resolver vs. a resolver plus an opener), to add a lint rule, to only fix the stale comments, or to assert only that the lengths match.

Deliverables

  • packages/loopover-miner/lib/status.ts exports STORE_INTEGRITY_NAMES, derived from the same array storeIntegrityChecks iterates (no duplicated literal).
  • packages/loopover-miner/lib/migrate-cli.ts exports STORES.
  • A new test in test/unit/miner-migrate-cli.test.ts asserts STORE_INTEGRITY_NAMES and STORES.map((s) => s.name) are equal as sorted arrays, and separately asserts that sorted array equals an explicit literal listing all eighteen store names.
  • migrate-cli.ts's module header no longer says "eleven stores" and runMigrateChecks's doc comment no longer says "seven-store list".

All Deliverables above are required in a single PR. A PR that satisfies only some of them — for example fixing the two stale comments without adding the drift-guard test, which is the only thing that stops a third recurrence of #8318/#8641 — does not resolve this issue.

Test Coverage Requirements

packages/loopover-miner/lib/**/*.ts IS inside Codecov's coverage.include in vitest.config.ts, so the 99%+ branch-counted codecov/patch gate applies exactly as for src/**. The new exports are plain constants, so the patch is mostly test code plus a small refactor of the existing array into a named export — every changed line must still be executed by the new test.

Expected Outcome

Adding a nineteenth durable local store to one of doctor's and migrate's twin lists but not the other fails CI immediately, instead of shipping and being noticed months later (as with orb-export in #8318 and laptop-state in #8641).

Links & Resources

packages/loopover-miner/lib/status.ts:388-417, packages/loopover-miner/lib/migrate-cli.ts:1-9, :53-83, :158-165, test/unit/miner-migrate-cli.test.ts. Precedents: #8318, #8641, #6768.

Metadata

Metadata

Assignees

No one assigned

    Labels

    gittensor:bugGittensor-scored bug fix — scores a 0.05x multiplier.help wantedExtra attention is needed

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions