feat(miner): read loop-cli convergence history from the persisted portfolio queue - #5679
Conversation
…tfolio queue loop-cli.js kept its own in-memory convergenceHistory Map for the run-loop-boundary gate -- redundant with, and less durable than, the SQLite-persisted attempt-history portfolio-queue.js's getAttemptHistory already provides (JSONbored#5654). A loop-daemon restart (crash/deploy/systemd bounce) silently reset every in-flight item's convergence/consecutive-failure counters, weakening the stuck-loop detector exactly when a real stuck item most needs catching. Read convergence from getAttemptHistory instead -- the same source attempt-cli.js's buildAttemptGovernorContext already consumes, so the loop daemon and a one-shot attempt share one real source of truth. The dequeueNext claim + markDone/markFailed calls already maintain those persisted counters, so the in-memory Map, its per-cycle increments, and the convergenceKey/ zeroConvergence helpers are removed, along with the now-stale DOCUMENTED GAP header. The boundary gate's own thresholds are untouched. Closes JSONbored#5677
|
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 #5679 +/- ##
==========================================
- Coverage 95.04% 95.04% -0.01%
==========================================
Files 577 577
Lines 45987 45973 -14
Branches 14708 14708
==========================================
- Hits 43707 43693 -14
Misses 1527 1527
Partials 753 753
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
|
Tip 🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩 ✅ LoopOver review result - approve/merge recommendedReview updated: 2026-07-14 02:19:24 UTC
✅ Suggested Action - Approve/Merge
Review summary Nits — 4 non-blocking
Review context
Contributor next steps
Signal definitions
[BETA] Chat with GittensoryAsk Gittensory 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://gittensory.aethereal.dev/docs/gittensory-commands 🟩 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.
|
Closes #5677.
Problem
loop-cli.jskept its own in-memoryconvergenceHistoryMap for the run-loop-boundary gate — redundant with, and less durable than, the SQLite-persisted attempt-historyportfolio-queue.js'sgetAttemptHistoryalready provides (#5654). A loop-daemon restart (crash/deploy/systemd bounce) silently reset every in-flight item's convergence/consecutive-failure counters, so a genuinely stuck item read "fresh" and got re-attempted from zero — weakening the non-convergence detector exactly when it matters.Change
portfolioQueue.getAttemptHistory(...)— the same real sourceattempt-cli.js'sbuildAttemptGovernorContextalready consumes (Track real per-issue attempt-history on the portfolio queue, feed the Governor's convergenceInput #5654), so the loop daemon and a one-shotattemptshare one source of truth.dequeueNextclaim +markDone/markFailedcalls already maintain those persisted counters, so the in-memory Map, its per-cycle increments, and the now-unusedconvergenceKey/zeroConvergencehelpers are removed, along with the staleDOCUMENTED GAPheader comment.convergenceThresholds— only the data source changes.Validation
test/unit/miner-loop-cli.test.ts: an item taken to the re-enqueue threshold, then a fresh loop process (new handles to the same on-disk files, no in-memory Map) halts before its first attempt — proving the convergence streak survives a restart. Pre-change, a reset in-memory Map read zero and re-attempted the stuck item.node --checkclean;getAttemptHistorycounter semantics independently exercised via node:test.