feat(miner): add local portfolio/queue store - #2751
Conversation
|
🚨 Contributor flagged. Click here for more info: Superagent Dashboard |
|
Fixed the re-enqueue ordering inconsistency. Re-enqueueing a tracked item now re-activates it in place — it refreshes the (placeholder) priority and resets status to |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2751 +/- ##
==========================================
+ Coverage 96.12% 96.13% +0.01%
==========================================
Files 248 248
Lines 27548 27569 +21
Branches 10007 10012 +5
==========================================
+ Hits 26480 26503 +23
Misses 443 443
+ Partials 625 623 -2 🚀 New features to boost your workflow:
|
|
Warning 🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨 ⏸️ Gittensory review result - manual review recommendedReview updated: 2026-07-03 19:13:58 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.
|
50a0ada to
47d8593
Compare
|
Fixed the dequeue race. |
Add packages/gittensory-miner/lib/portfolio-queue.js: a 100% client-side prioritized backlog of candidate work items across every repo the miner is pointed at, backed by a local SQLite table, mirroring the run-state store (lib/run-state.js). enqueue (upsert), dequeueNext (highest-priority first, claims as in_progress, null on empty), listQueue (all or per-repo), and markDone. Ordering is priority DESC, enqueued_at ASC, rowid ASC so the rowid guarantees the insertion-order tie-break even on identical timestamps. Persistence and read/write API only; priority is a placeholder numeric input that later phases wire to the extracted reward-risk/scoring modules. The DB is owner-only (0o600) and never leaves the machine. Closes JSONbored#2292.
47d8593 to
601a172
Compare
Summary
Adds the local portfolio/queue store to
@jsonbored/gittensory-miner— the last piece of client-side persistence the foundation phase calls for. It tracks the miner's own backlog of candidate work items across every repo it has been pointed at ("what should I look at next, across everything I'm tracking"), backed by a small local SQLite table. The store never uploads, syncs, or phones home — it only lives on the miner's machine, exactly like the existingrun-statestore it mirrors (lib/run-state.js, #2289).Scope is persistence + a FIFO/priority-ordered read-write API only. The
priorityfield is a placeholder numeric input in this phase; later phases populate it from the extracted reward-risk/scoring modules ingittensory-engine— it is not invented here.API (
lib/portfolio-queue.js):enqueue({ repoFullName, identifier, priority? })→QueueEntry. Re-enqueueing a tracked item re-activates it in place: it refreshes the (placeholder) priority and resets status toqueued, but keeps the originalenqueued_at/rowidso it holds its existing FIFO position instead of jumping the queue (restamping would be inconsistent — the fixedrowidstill pins the old position when timestamps collide — so position is deliberately preserved).dequeueNext()→QueueEntry | null— highest-priority-first, claims the item asin_progress;nullon an empty/all-claimed queue.listQueue(repoFullName?)— all items, or one repo's, in the same order.markDone(repoFullName, identifier)— transitions todone(excluded from futuredequeueNext);nullfor a missing item.Ordering is
priority DESC, enqueued_at ASC, rowid ASC: the implicitrowidguarantees the insertion-order tie-break even when two items share both a priority and anenqueued_attimestamp (the test freezes the clock to prove exactly that, rather than relying on timestamp skew).Schema is per the issue spec:
PRIMARY KEY (repo_full_name, identifier),priority REAL NOT NULL DEFAULT 0,status TEXT NOT NULL DEFAULT 'queued' CHECK(status IN ('queued','in_progress','done')),enqueued_at TEXT NOT NULL.Closes #2292.
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-portfolio-queue.test.tspasses (all 10 miner test files, 110 tests, green). This change lives entirely inpackages/**, which Codecov does not measure, so it carries nocodecov/patchobligation; the logic is nonetheless exercised on both sides of every branch (empty vs non-empty dequeue, present vs missingmarkDone, default vs explicit priority, single- vs multi-repo listing, re-enqueue upsert, malformed-input rejection).node --check lib/portfolio-queue.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, Drizzle, or Cloudflare-binding surface is touched. The SQLite table is a miner-local file, not a repo 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/portfolio-queue.js+ itslib/portfolio-queue.d.ts) mirroringlib/run-state.js/lib/run-state.d.ts(path resolution,0o600/0o700perms, prepared statements, default-store singleton), one line added to the packagebuild(node --check) gate, and one new test file mirroringtest/unit/miner-run-state.test.ts. No existing code is modified.