feat(miner): add local claim ledger - #2797
Conversation
Add packages/gittensory-miner/lib/claim-ledger.js: a 100% client-side soft-claim
ledger ("I'm working on issue #N in repo X"), backed by a local SQLite table and
mirroring the package's run-state/portfolio-queue/event-ledger local-store
pattern (plain JS + node:sqlite, owner-only 0o600, never phones home). Schema +
CRUD only: openClaimLedger/recordClaim/releaseClaim/listClaims. UNIQUE(repo,
issue) keeps one row per claim; recordClaim is a single atomic INSERT...ON
CONFLICT so re-claiming an active issue is a no-op (never a duplicate row) while
a released/expired claim can be re-activated. listClaims filters by repo and/or
status.
Closes JSONbored#2314.
|
🚨 Contributor flagged. Click here for more info: Superagent Dashboard |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2797 +/- ##
=======================================
Coverage 96.12% 96.12%
=======================================
Files 248 248
Lines 27548 27548
Branches 10007 10007
=======================================
Hits 26480 26480
Misses 443 443
Partials 625 625 🚀 New features to boost your workflow:
|
|
Warning 🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨 ⏸️ Gittensory review result - manual review recommendedReview updated: 2026-07-03 18:50:38 UTC
⏸️ Suggested Action - Manual Review Review summary Nits — 5 non-blocking
Review context
Contributor next steps
Signal definitions
🟩 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 Gittensory, a quiet PR intelligence layer for OSS maintainers.
|
Summary
Adds the local claim ledger to
@jsonbored/gittensory-miner— a 100% client-side record of "I'm working on issue #N in repo X", so Phase 2's soft-claim adjudication (sibling issues) has somewhere to persist claims. Schema + CRUD only — no adjudication logic, no network calls, no autonomous writes. It mirrors the package's existing local-store pattern (lib/run-state.js,lib/portfolio-queue.js,lib/event-ledger.js): the DB is owner-only and stays on the miner's machine, never phoning home.API (
lib/claim-ledger.js):openClaimLedger(dbPath?)→ a ledger withrecordClaim/releaseClaim/listClaims/close(plus default-singleton top-level functions andresolveClaimLedgerDbPath).recordClaim({ repoFullName, issueNumber, note? })→ClaimEntry— idempotent:UNIQUE(repo_full_name, issue_number)keeps one row per claim, and the write is a single atomicINSERT … ON CONFLICT … DO UPDATE … WHERE status <> 'active', so re-claiming an already-active issue is a true no-op (never a duplicate row), while areleased/expiredclaim can be re-activated.releaseClaim(repoFullName, issueNumber)→ sets statusreleased(returns the entry, ornullif never claimed).listClaims({ repoFullName?, status? })→ claims, optionally filtered by repo and/or status.Schema (
claimstable per the issue):id,repo_full_name,issue_number,claimed_at,status(active|released|expired, CHECK-constrained),note.Location note: the issue sketched
src/claim-ledger/store.ts, but this package is authored as plain-JSlib/*.js+ hand-written.d.tswithnode:sqlite(no TS build — itsbuildisnode --check), exactly like the four existing local stores it sits beside (run-state,ci-poller,opportunity-fanout, and the recently addedportfolio-queue/event-ledger). I followed that established, consistent shape rather than introducing a separate TS toolchain to the package;node:sqliteis the package's existing zero-dependency SQLite choice.Closes #2314.
Scope
type(scope): short summaryConventional Commit format.CONTRIBUTING.mdand does not reintroduce GitHub Pages, VitePress,site/, orCNAME.Validation
git diff --checknpm run typechecknpm run test:coveragelocally — the newtest/unit/miner-claim-ledger.test.tspasses (whole miner suite green). This change lives entirely inpackages/**, which Codecov does not measure, so it carries nocodecov/patchobligation; the logic is nonetheless exercised across record/list/release/re-claim-after-release, the active-claim idempotency no-op, both list filters (and their combination), null-note handling, and input rejection.node --check lib/claim-ledger.jsvianpm run --workspace @jsonbored/gittensory-miner buildnpm audit --audit-level=moderate— this PR adds no dependencies, so dependency-review has nothing new to evaluate.If any required check was skipped, explain why:
packages/gittensory-miner/libplus its test — nosrc/**, UI, API schema, shared D1migrations/, or Cloudflare-binding surface is touched. The SQLite table is a miner-local file, not a hosted-Worker migration.Safety
0o600in a0o700dir, owner-only, and never leaves the machine.UI Evidencesection. — n/a: no visible UI, frontend, docs, or extension change.Notes
Additive and consistent with the package's existing local-store pattern: two new files (
lib/claim-ledger.js+ itslib/claim-ledger.d.ts) mirroringlib/run-state.js(path resolution,0o600/0o700perms, prepared statements, default-store singleton), one line added to the packagebuild(node --check) gate, and one new test file. No existing code is modified.