Context
packages/loopover-miner/lib/status.js's storeIntegrityChecks function carries this comment directly
above its store list:
/** Per-store `PRAGMA integrity_check` sweep for `doctor` (#4834) — flags a corrupted store instead of probing
* only one with `SELECT 1`. A store file that does not exist yet is healthy by absence. Keep in sync with
* migrate-cli.js's `STORES` list (#6768): every durable local SQLite store using resolveLocalStoreDbPath. */
function storeIntegrityChecks(env) {
const stores = [
["event-ledger", resolveEventLedgerDbPath(env)],
["governor-ledger", resolveGovernorLedgerDbPath(env)],
["prediction-ledger", resolvePredictionLedgerDbPath(env)],
["portfolio-queue", resolvePortfolioQueueDbPath(env)],
["claim-ledger", resolveClaimLedgerDbPath(env)],
["run-state", resolveRunStateDbPath(env)],
["plan-store", resolvePlanStoreDbPath(env)],
["governor-state", resolveGovernorStateDbPath(env)],
["attempt-log", resolveAttemptLogDbPath(env)],
["replay-snapshot", resolveReplaySnapshotDbPath(env)],
["worktree-allocator", resolveWorktreeAllocatorDbPath(env)],
["contribution-profile", resolveContributionProfileCacheDbPath(env)],
["policy-verdict-cache", resolvePolicyVerdictCacheDbPath(env)],
];
...
packages/loopover-miner/lib/migrate-cli.js's STORES array (its #6768-referenced counterpart, required
to stay "in sync") lists the exact same 13 stores.
packages/loopover-miner/lib/policy-doc-cache.js (#4842, the local ETag cache for
AI-USAGE.md/CONTRIBUTING.md policy-doc fetches, distinct from policy-verdict-cache.js) is not in
either list, despite matching the stated inclusion criterion exactly:
// lib/policy-doc-cache.js
import { normalizeLocalStoreDbPath, openLocalStoreDb, resolveLocalStoreDbPath } from "./local-store.js";
...
export function resolvePolicyDocCacheDbPath(env = process.env) {
return resolveLocalStoreDbPath(defaultDbFileName, "LOOPOVER_MINER_POLICY_DOC_CACHE_DB", env);
}
...
export function initPolicyDocCacheStore(dbPath = resolvePolicyDocCacheDbPath()) {
const resolvedPath = normalizeDbPath(dbPath);
const db = openLocalStoreDb(resolvedPath);
...
It is a real, durable, per-machine SQLite file (policy-doc-cache.sqlite3) created via the same
resolveLocalStoreDbPath/openLocalStoreDb helpers from local-store.js that every listed store uses, and
it is opened for real by discover-cli.js's runDiscover in the exact same way the other listed stores are.
This is not a re-tread of #6987 ("policy_verdict_cache missing from purge/status/migrate 'known local
stores' lists", closed) — that issue was about the separate policy-verdict-cache.js store (#4843), which
is already present in both lists (see "policy-verdict-cache" above). policy-doc-cache.js is a
different file/store that #6987's fix never added, and it was also not one of the "four real local stores"
#6768 originally added.
Practical effect: loopover-miner doctor's per-store PRAGMA integrity_check sweep never checks
policy-doc-cache.sqlite3 for corruption, and loopover-miner migrate's proactive sweep never brings an
existing policy-doc-cache.sqlite3 file's schema up to date — an operator relying on either command to
cover "every durable local store" silently misses this one.
Requirements
- In
packages/loopover-miner/lib/status.js: import resolvePolicyDocCacheDbPath from
./policy-doc-cache.js (alongside the existing import { resolvePolicyVerdictCacheDbPath } from "./policy-verdict-cache.js"), and add ["policy-doc-cache", resolvePolicyDocCacheDbPath(env)] to the
stores array inside storeIntegrityChecks.
- In
packages/loopover-miner/lib/migrate-cli.js: import initPolicyDocCacheStore, resolvePolicyDocCacheDbPath from ./policy-doc-cache.js (alongside the existing policy-verdict-cache.js
import), and add { name: "policy-doc-cache", resolveDbPath: resolvePolicyDocCacheDbPath, open: initPolicyDocCacheStore } to the STORES array.
- Do not reorder or modify any of the existing 13 entries in either list — this is strictly an addition.
- The entry's
name string must be exactly "policy-doc-cache" (matching the existing naming convention of
hyphenated, lowercase store names already used for every other entry, and distinct from the existing
"policy-verdict-cache" entry so the two are never conflated in doctor/migrate output).
Deliverables
Test Coverage Requirements
This repo's Codecov patch gate (codecov/patch) enforces target: 99%, threshold: 0%, branch-counted, on
every changed line/branch under src/**/packages/** — both changed files are inside packages/** and are
gated. Add the two regression tests described above (one for doctor, one for migrate) so both new list
entries are exercised, not just visually present. Measure locally with npm run test:coverage (unsharded).
Expected Outcome
loopover-miner doctor and loopover-miner migrate both cover policy-doc-cache.sqlite3 the same way they
already cover the other 13 known local stores — a corrupted policy-doc-cache.sqlite3 file is flagged by
doctor's integrity sweep, and an existing one is proactively brought up to date by migrate, closing the
gap #6768's "keep in sync" comment intends to prevent.
Links & Resources
Context
packages/loopover-miner/lib/status.js'sstoreIntegrityChecksfunction carries this comment directlyabove its store list:
packages/loopover-miner/lib/migrate-cli.js'sSTORESarray (its#6768-referenced counterpart, requiredto stay "in sync") lists the exact same 13 stores.
packages/loopover-miner/lib/policy-doc-cache.js(#4842, the local ETag cache forAI-USAGE.md/CONTRIBUTING.mdpolicy-doc fetches, distinct frompolicy-verdict-cache.js) is not ineither list, despite matching the stated inclusion criterion exactly:
It is a real, durable, per-machine SQLite file (
policy-doc-cache.sqlite3) created via the sameresolveLocalStoreDbPath/openLocalStoreDbhelpers fromlocal-store.jsthat every listed store uses, andit is opened for real by
discover-cli.js'srunDiscoverin the exact same way the other listed stores are.This is not a re-tread of #6987 ("
policy_verdict_cachemissing from purge/status/migrate 'known localstores' lists", closed) — that issue was about the separate
policy-verdict-cache.jsstore (#4843), whichis already present in both lists (see
"policy-verdict-cache"above).policy-doc-cache.jsis adifferent file/store that #6987's fix never added, and it was also not one of the "four real local stores"
#6768 originally added.
Practical effect:
loopover-miner doctor's per-storePRAGMA integrity_checksweep never checkspolicy-doc-cache.sqlite3for corruption, andloopover-miner migrate's proactive sweep never brings anexisting
policy-doc-cache.sqlite3file's schema up to date — an operator relying on either command tocover "every durable local store" silently misses this one.
Requirements
packages/loopover-miner/lib/status.js: importresolvePolicyDocCacheDbPathfrom./policy-doc-cache.js(alongside the existingimport { resolvePolicyVerdictCacheDbPath } from "./policy-verdict-cache.js"), and add["policy-doc-cache", resolvePolicyDocCacheDbPath(env)]to thestoresarray insidestoreIntegrityChecks.packages/loopover-miner/lib/migrate-cli.js: importinitPolicyDocCacheStore, resolvePolicyDocCacheDbPathfrom./policy-doc-cache.js(alongside the existingpolicy-verdict-cache.jsimport), and add
{ name: "policy-doc-cache", resolveDbPath: resolvePolicyDocCacheDbPath, open: initPolicyDocCacheStore }to theSTORESarray.namestring must be exactly"policy-doc-cache"(matching the existing naming convention ofhyphenated, lowercase store names already used for every other entry, and distinct from the existing
"policy-verdict-cache"entry so the two are never conflated indoctor/migrateoutput).Deliverables
packages/loopover-miner/lib/status.js'sstoreIntegrityChecksincludes a"policy-doc-cache"entrypointing at
resolvePolicyDocCacheDbPath(env).packages/loopover-miner/lib/migrate-cli.js'sSTORESincludes a"policy-doc-cache"entry usingresolvePolicyDocCacheDbPath/initPolicyDocCacheStore.loopover-miner doctor --json's output contains astore-integrity:policy-doc-cachecheck result, and a regression test assertingloopover-miner migrate --json's output contains a"policy-doc-cache"entry instores(both mirroring thispackage's existing tests for the
"policy-verdict-cache"entry policy_verdict_cache missing from purge/status/migrate 'known local stores' lists #6987 added).Test Coverage Requirements
This repo's Codecov patch gate (
codecov/patch) enforcestarget: 99%, threshold: 0%, branch-counted, onevery changed line/branch under
src/**/packages/**— both changed files are insidepackages/**and aregated. Add the two regression tests described above (one for
doctor, one formigrate) so both new listentries are exercised, not just visually present. Measure locally with
npm run test:coverage(unsharded).Expected Outcome
loopover-miner doctorandloopover-miner migrateboth coverpolicy-doc-cache.sqlite3the same way theyalready cover the other 13 known local stores — a corrupted
policy-doc-cache.sqlite3file is flagged bydoctor's integrity sweep, and an existing one is proactively brought up to date bymigrate, closing thegap #6768's "keep in sync" comment intends to prevent.
Links & Resources
packages/loopover-miner/lib/status.js(storeIntegrityChecks, the file/function to fix)packages/loopover-miner/lib/migrate-cli.js(STORES, the file/list to fix)packages/loopover-miner/lib/policy-doc-cache.js(resolvePolicyDocCacheDbPath,initPolicyDocCacheStore— the store being added)
policy-verdict-cache.jsstore; this issue is not aduplicate of it)