refactor(miner): adopt local-store.js's shared path helpers in three stores#7132
Conversation
…stores governor-ledger.js, prediction-ledger.js, and plan-store.js each hand-duplicated the env-var/config-dir/XDG path-resolution + normalization logic that local-store.js (JSONbored#4272) exists to DRY, even though all three already import openLocalStoreDb from it. A future change to the shared env-var precedence would silently skip these three. Delegate resolve*DbPath to resolveLocalStoreDbPath and normalizeDbPath to normalizeLocalStoreDbPath, mirroring worktree-allocator.js (JSONbored#6600). The resolution chain is byte-for-byte identical, so behavior is unchanged. The now-unused homedir/join imports are dropped, and the generated env reference is regenerated (the three vars now show `(none)` as their default, matching worktree-allocator.js's already-migrated entry). Closes JSONbored#7083
|
🚨 Contributor flagged. Click here for more info: Superagent Dashboard |
|
Superagent didn't find any vulnerabilities or security issues in this PR. |
|
Warning ⏸️ LoopOver review result - manual review recommendedReview updated: 2026-07-18 00:19:49 UTC
Review summary Nits — 5 non-blocking
Flagged checks (non-blocking)
Decision drivers
Context & advisory signals — never blocks the verdict
Review context
Contributor next steps
Signal definitions
🧪 Chat with LoopOverAsk LoopOver a question about this PR directly in a comment — grounded only in the same cached, public-safe facts shown above, never a new claim.
Full command reference: https://loopover.ai/docs/loopover-commands 🧪 Experimental — new and may change. 🟩 Safe / merged · 🟦 Advisory · 🟨 Held for review · 🟥 Blocked / closed 💰 Earn for open-source contributions like this. Gittensor lets GitHub contributors earn for the work they already do — register to start earning →. Checked by LoopOver, a quiet PR intelligence layer for OSS maintainers.
|
What
governor-ledger.js,prediction-ledger.js, andplan-store.jseach hand-duplicated the ~15-line env-var/config-dir/XDG path-resolution + normalization logic thatlocal-store.js(#4272) exists to DRY — even though all three alreadyimport { openLocalStoreDb }from it. They adopted the shared DB-opener but never the shared path helpers the same module exports for the same purpose. This is the exact "claims to mirror but never did" drift risk #6600 already closed forworktree-allocator.js: a future change tolocal-store.js's env-var precedence would silently skip these three.How
Replace each file's hand-rolled
resolve*DbPathbody with a delegating call toresolveLocalStoreDbPath(defaultDbFileName, "<ENV_VAR>", env), and eachnormalizeDbPathwithnormalizeLocalStoreDbPath(dbPath, resolve*DbPath(), "<invalid_*_db_path>")— mirroringworktree-allocator.jsexactly. The shared helper's resolution chain (explicit env var →LOOPOVER_MINER_CONFIG_DIR→XDG_CONFIG_HOME→~/.config/loopover-miner/<file>) is byte-for-byte what each copy computed, so behavior is unchanged; the now-unusedhomedir/joinimports are dropped.Validation
Behavior-preserving refactor: the existing store tests already assert each
resolve*DbPath's full env-var precedence (explicit → config-dir → XDG → default), and all pass unchanged against the delegated implementation — so the shared helper produces identical resolution.typecheck,build:miner, and the miner test suite pass.Closes #7083