fix(miner): add the tenant_id column to governor-ledger and plan-store - #6707
Conversation
JSONbored#4939 added an additive, nullable tenant_id column to every local ledger schema as a prerequisite for any future hosted, multi-tenant use, but governor-ledger.js and plan-store.js were left out despite being two of the package's seven canonical local stores -- both still called applySchemaMigrations(db, []) with an empty migrations array. Adds addTenantIdColumn to both, mirroring event-ledger.js's and run-state.js's existing implementation exactly (idempotent against a column-presence guard). No consumer reads or writes tenant_id yet, so self-host behavior is byte-identical: every row's tenant_id is NULL. Closes JSONbored#6597
|
Superagent didn't find any vulnerabilities or security issues in this PR. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #6707 +/- ##
=======================================
Coverage 93.65% 93.65%
=======================================
Files 681 682 +1
Lines 68098 68120 +22
Branches 18695 18702 +7
=======================================
+ Hits 63775 63796 +21
Misses 3347 3347
- Partials 976 977 +1
Flags with carried forward coverage won't be shown. Click here to find out more.
|
|
Tip ✅ LoopOver review result - approve/merge recommendedReview updated: 2026-07-16 20:09:05 UTC
Review summary Nits — 2 non-blocking
Decision drivers
Context & advisory signals — never blocks the verdict
Linked issue satisfactionAddressed 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.
|
Summary
#4939 ("Add tenant-scoping columns to all local ledger schemas") added an additive, nullable
tenant_id TEXTcolumn to every local ledger schema as a prerequisite for any future hosted,multi-tenant use of the same ledger logic.
governor-ledger.jsandplan-store.js— two of thepackage's seven canonical local stores (tracked by both
status.js'sstoreIntegrityChecksandmigrate-cli.js'sSTORES) — were left out despite #4939 being closed as complete; both still callapplySchemaMigrations(db, [])with an empty migrations array.governor_events(governor-ledger.js) andminer_plans(plan-store.js) both gain an additiveaddTenantIdColumnmigration, mirroringevent-ledger.js's/run-state.js's existing implementationexactly: a
PRAGMA table_infocolumn-presence guard beforeALTER TABLE ... ADD COLUMN tenant_id TEXT, idempotent against a file already migrated.tenant_idyet in either store — self-host behavior is byte-identical:every existing row and every newly-inserted row has
tenant_id = NULL, matching Add tenant-scoping columns to all local ledger schemas #4939's own statedbehavior for the other four stores.
governor-ledger.js/plan-store.jsstore now reportsPRAGMA user_version = 2(baseline 1plus the one new migration); a pre-existing on-disk file upgrades in place with every existing row
preserved.
Test plan
test/unit/miner-governor-ledger.test.ts: newschema migrations (#6597)describe block —v1→v2 upgrade preserves existing rows and adds the column (verified via
readSchemaVersion), aregression test for a v1 file that already unusually carries
tenant_id(no duplicate-columnerror), and a fresh-store
user_version = 2assertion — 14/14 passingtest/unit/miner-plan-store.test.ts: identical three-test shape forplan-store.js— 14/14passing
files via scoped
vitest --coverage+ direct lcovDA:/BRDA:inspection (the aggregate coveragenumbers for these two files are below the informational 90% local threshold only because of
pre-existing, unrelated gaps elsewhere in each file — none inside this diff)
test/unit/miner-status.test.ts,test/unit/miner-migrate-cli.test.ts,test/unit/miner-governor-ledger-cli.test.ts,test/unit/miner-plan-store-cli.test.ts,test/unit/governor-ledger.test.ts— 64/64 passingnode --checkon both changed files (this package's ownbuildscript convention) — cleangit diff --check,npm run actionlint,npm audit --audit-level=moderate— all cleanpackages/**+test/**diff only (theseare the miner CLI's own local SQLite stores, unrelated to the product's root
migrations/)Closes #6597