The three local stores this title names already exist and work — packages/gittensory-miner/lib/run-state.js (miner_run_state table, own run-state.sqlite3 file, initRunStateStore), claim-ledger.js (miner_claims table, own claim-ledger.sqlite3, openClaimLedger, #2291/#2314), and portfolio-queue.js (miner_portfolio_queue table, own portfolio-queue.sqlite3, initPortfolioQueueStore, #2292). Each is independently coded: its own resolveXDbPath env-var resolution (GITTENSORY_MINER_X_DB → GITTENSORY_MINER_CONFIG_DIR → XDG_CONFIG_HOME/~/.config), its own mkdirSync(…, 0o700) + chmodSync(…, 0o600) setup, its own PRAGMA busy_timeout — the same ~15 lines hand-duplicated four times (run-state.js:12-33, claim-ledger.js:17-38, portfolio-queue.js:17-38, and event-ledger.js:18-39 the same pattern again). There is no shared base module (local-store.js/db-common.js or similar) anywhere in packages/gittensory-miner/lib/.
There's also no dedicated "PR portfolio" table. manage-status.js (#2325/#3070) synthesizes PR-portfolio rows at READ time by joining portfolio-queue.js rows (using a pr:{number} identifier convention — MANAGED_PR_IDENTIFIER_PREFIX in manage-status.js:6) against event-ledger.js's free-form JSON manage_pr_update events, reduced via a full linear scan (indexLatestManageUpdates, manage-status.js:42-53) on every single read. The actual PR-shaped fields — branch, ciState, gateVerdict, outcome, lastPolledAt — live only as opaque JSON blobs in the general event ledger, not as indexed/queryable columns of their own.
So the remaining gap here isn't "create the schema" — it's (a) documenting the four local stores as one coherent local-storage model (the package README currently describes each store in isolated paragraphs — packages/gittensory-miner/README.md:27-37 — with no single section listing all local SQLite files/tables together), (b) extracting the duplicated path-resolution/permission boilerplate into one shared helper the four modules call into, and (c) deciding — and documenting the decision — whether the PR-portfolio's read-time join is the intended long-term shape or whether it should become a first-class indexed table once PR-portfolio reads get frequent (e.g., from the dashboard panel in the sibling manage-phase issue).
Deliverables
References
packages/gittensory-miner/lib/run-state.js:12-33,52-93 (resolveRunStateDbPath, initRunStateStore, miner_run_state table)
packages/gittensory-miner/lib/claim-ledger.js:17-38,75-94 (resolveClaimLedgerDbPath, openClaimLedger, miner_claims table)
packages/gittensory-miner/lib/portfolio-queue.js:17-38,79-98 (resolvePortfolioQueueDbPath, initPortfolioQueueStore, miner_portfolio_queue table)
packages/gittensory-miner/lib/event-ledger.js:18-39,109-127 (same boilerplate pattern once more, for comparison)
packages/gittensory-miner/lib/manage-status.js:6,42-53 (MANAGED_PR_IDENTIFIER_PREFIX, indexLatestManageUpdates — the read-time PR-portfolio join)
packages/gittensory-miner/README.md:27-37 (current per-store documentation, no unified section)
The three local stores this title names already exist and work —
packages/gittensory-miner/lib/run-state.js(miner_run_statetable, ownrun-state.sqlite3file,initRunStateStore),claim-ledger.js(miner_claimstable, ownclaim-ledger.sqlite3,openClaimLedger, #2291/#2314), andportfolio-queue.js(miner_portfolio_queuetable, ownportfolio-queue.sqlite3,initPortfolioQueueStore, #2292). Each is independently coded: its ownresolveXDbPathenv-var resolution (GITTENSORY_MINER_X_DB→GITTENSORY_MINER_CONFIG_DIR→XDG_CONFIG_HOME/~/.config), its ownmkdirSync(…, 0o700)+chmodSync(…, 0o600)setup, its ownPRAGMA busy_timeout— the same ~15 lines hand-duplicated four times (run-state.js:12-33, claim-ledger.js:17-38, portfolio-queue.js:17-38, and event-ledger.js:18-39 the same pattern again). There is no shared base module (local-store.js/db-common.jsor similar) anywhere inpackages/gittensory-miner/lib/.There's also no dedicated "PR portfolio" table.
manage-status.js(#2325/#3070) synthesizes PR-portfolio rows at READ time by joiningportfolio-queue.jsrows (using apr:{number}identifier convention —MANAGED_PR_IDENTIFIER_PREFIXin manage-status.js:6) againstevent-ledger.js's free-form JSONmanage_pr_updateevents, reduced via a full linear scan (indexLatestManageUpdates, manage-status.js:42-53) on every single read. The actual PR-shaped fields — branch, ciState, gateVerdict, outcome, lastPolledAt — live only as opaque JSON blobs in the general event ledger, not as indexed/queryable columns of their own.So the remaining gap here isn't "create the schema" — it's (a) documenting the four local stores as one coherent local-storage model (the package README currently describes each store in isolated paragraphs — packages/gittensory-miner/README.md:27-37 — with no single section listing all local SQLite files/tables together), (b) extracting the duplicated path-resolution/permission boilerplate into one shared helper the four modules call into, and (c) deciding — and documenting the decision — whether the PR-portfolio's read-time join is the intended long-term shape or whether it should become a first-class indexed table once PR-portfolio reads get frequent (e.g., from the dashboard panel in the sibling manage-phase issue).
Deliverables
resolveXDbPath/mkdirSync(0o700)+chmodSync(0o600)/busy_timeoutboilerplate (currently hand-copied inrun-state.js:12-33,claim-ledger.js:17-38,portfolio-queue.js:17-38,event-ledger.js:18-39) into one shared internal helper inpackages/gittensory-miner/lib/.sqlite3file and env var — this is a DRY pass, not a merge into one database)packages/gittensory-miner/README.mddocumenting all four local SQLite stores together: file name, table name, module, and the env vars that override each pathportfolio-queue.js(via thepr:identifier convention) againstevent-ledger.js'smanage_pr_updateevents, not a dedicated table — and record the decision on whether that's intended to stay that wayReferences
packages/gittensory-miner/lib/run-state.js:12-33,52-93(resolveRunStateDbPath,initRunStateStore,miner_run_statetable)packages/gittensory-miner/lib/claim-ledger.js:17-38,75-94(resolveClaimLedgerDbPath,openClaimLedger,miner_claimstable)packages/gittensory-miner/lib/portfolio-queue.js:17-38,79-98(resolvePortfolioQueueDbPath,initPortfolioQueueStore,miner_portfolio_queuetable)packages/gittensory-miner/lib/event-ledger.js:18-39,109-127(same boilerplate pattern once more, for comparison)packages/gittensory-miner/lib/manage-status.js:6,42-53(MANAGED_PR_IDENTIFIER_PREFIX,indexLatestManageUpdates— the read-time PR-portfolio join)packages/gittensory-miner/README.md:27-37(current per-store documentation, no unified section)