Skip to content

refactor(miner): adopt local-store.js's shared path helpers in three stores#7132

Merged
JSONbored merged 1 commit into
JSONbored:mainfrom
shin-core:fix/dedup-local-store-path-helpers-7083
Jul 18, 2026
Merged

refactor(miner): adopt local-store.js's shared path helpers in three stores#7132
JSONbored merged 1 commit into
JSONbored:mainfrom
shin-core:fix/dedup-local-store-path-helpers-7083

Conversation

@shin-core

Copy link
Copy Markdown
Contributor

What

governor-ledger.js, prediction-ledger.js, and plan-store.js each hand-duplicated the ~15-line env-var/config-dir/XDG path-resolution + normalization logic that local-store.js (#4272) exists to DRY — even though all three already import { 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 for worktree-allocator.js: a future change to local-store.js's env-var precedence would silently skip these three.

How

Replace each file's hand-rolled resolve*DbPath body with a delegating call to resolveLocalStoreDbPath(defaultDbFileName, "<ENV_VAR>", env), and each normalizeDbPath with normalizeLocalStoreDbPath(dbPath, resolve*DbPath(), "<invalid_*_db_path>") — mirroring worktree-allocator.js exactly. The shared helper's resolution chain (explicit env var → LOOPOVER_MINER_CONFIG_DIRXDG_CONFIG_HOME~/.config/loopover-miner/<file>) is byte-for-byte what each copy computed, so behavior is unchanged; the now-unused homedir/join imports 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

…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
@shin-core
shin-core requested a review from JSONbored as a code owner July 17, 2026 23:28
@superagent-security superagent-security Bot added the contributor:flagged Contributor flagged for review by trust analysis. label Jul 17, 2026
@superagent-security

Copy link
Copy Markdown
Contributor

🚨 Contributor flagged. Click here for more info: Superagent Dashboard

@superagent-security

Copy link
Copy Markdown
Contributor

Superagent didn't find any vulnerabilities or security issues in this PR.

@loopover-orb loopover-orb Bot added the gittensor:bug Gittensor-scored bug fix — scores a 0.05x multiplier. label Jul 17, 2026
@loopover-orb

loopover-orb Bot commented Jul 17, 2026

Copy link
Copy Markdown

Warning

⏸️ LoopOver review result - manual review recommended

Review updated: 2026-07-18 00:19:49 UTC

5 files · 1 AI reviewer · no blockers · CI green · unstable

⏸️ Suggested Action - Manual Review

Review summary
This PR replaces the hand-duplicated env-var/config-dir/XDG path-resolution logic in governor-ledger.js, prediction-ledger.js, and plan-store.js with calls to local-store.js's resolveLocalStoreDbPath/normalizeLocalStoreDbPath helpers, mirroring the pattern already established in worktree-allocator.js. The generated env-reference files were correctly regenerated to reflect that these three vars no longer have a detectable static default (shown as `null`/"(none)" instead of `""`), which is consistent with how worktree-allocator.js's own env vars are already rendered. The refactor is behavior-preserving by construction (same env-var precedence chain, same delegation pattern), closes #7083, and the diff is tightly scoped to exactly the three files named in the issue plus the two generated doc artifacts.

Nits — 5 non-blocking
  • No test files were touched in this PR; the description asserts existing store tests already exercise each resolve*DbPath's precedence and pass unchanged against the delegated implementation, but I can't verify that from the diff alone since local-store.js and the test files aren't shown — worth confirming those tests genuinely exist and pass rather than relying on the PR description.
  • I can't see local-store.js's normalizeLocalStoreDbPath/resolveLocalStoreDbPath implementations in this diff, so I'm trusting the stated claim that they are byte-for-byte equivalent to the old inline logic (including exact trim/empty-string-throw semantics) rather than confirming it directly.
  • Consider linking the CI run or test file names in the PR description so reviewers without repo access can confirm the 'existing tests pass unchanged' claim without re-deriving it.
  • If not already done, add a one-line changelog/CHANGELOG entry noting the internal path-resolution consolidation, consistent with how worktree-allocator.js's own comment claims to mirror stores that migrated to openLocalStoreDb, but it never did #6600's worktree-allocator.js fix was likely documented.
  • Code changes lack test evidence — Add focused regression tests or explain why existing coverage is sufficient.
Flagged checks (non-blocking)
  • Contributor trust — Contributor flagged for review

Decision drivers

  • ✅ Code review — No blockers (1 reviewer)
  • ✅ Gate result — Passing (No configured blocker found.)
Context & advisory signals — never blocks the verdict
Signal Result Evidence
Linked issue ✅ Linked #7083
Related work ✅ No active overlap found No same-issue or scoped active PR overlap found.
Change scope ✅ 20/20 Low review scope from cached public metadata (1 linked issue).
Validation posture ✅ 25/25 PR body includes validation/test evidence.
Contributor workload ✅ 10/10 Author activity: 68 registered-repo PR(s), 43 merged, 0 issue(s).
Contributor context ✅ Confirmed Gittensor contributor shin-core; Gittensor profile; 68 PR(s), 0 issue(s).
Improvement ℹ️ None detected risk: low · value: none
Review context
  • Author: shin-core
  • Role context: outside_contributor
  • Public audience mode: oss maintainer
  • Lane context: Repository is configured for direct PR review.
  • Public profile languages: not available
  • Official Gittensor activity: 68 PR(s), 0 issue(s).
  • PR-specific overlap: none found.
Contributor next steps
  • Keep the PR focused and include validation evidence before maintainer review.
Signal definitions
  • Related work = same linked issue, overlapping active PRs, or title/path similarity.
  • Change scope = cached public metadata such as size labels, draft state, and review-burden hints.
  • Validation posture = whether the PR provides enough public validation/test evidence for maintainer review.
  • Contributor workload = public contributor activity and cleanup pressure, not a repo-wide quality failure.
  • Contributor context = public GitHub/Gittensor identity context; non-Gittensor status is not a blocker.
🧪 Chat with LoopOver

Ask 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.

  • @loopover ask &lt;question&gt; answers contribution-quality Q&A with source citations and freshness.
  • @loopover chat &lt;question&gt; answers in natural prose from cached decision-pack facts via local inference (maintainer/collaborator; read-only).
  • A plain-language @loopover mention with a real question is routed to the closest matching read-only command automatically — no exact syntax required.

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.

  • Re-run LoopOver review

@loopover-orb loopover-orb Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LoopOver approves — the gate is satisfied and CI is green.

@JSONbored
JSONbored merged commit 0a6a780 into JSONbored:main Jul 18, 2026
8 of 9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

contributor:flagged Contributor flagged for review by trust analysis. gittensor:bug Gittensor-scored bug fix — scores a 0.05x multiplier.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

governor-ledger.js/prediction-ledger.js/plan-store.js hand-duplicate local-store.js's path-resolution helpers

2 participants