feat(miner): track real per-issue attempt-history on the portfolio queue for the Governor - #5662
Closed
lourincedaging0-commits wants to merge 1 commit into
Closed
Conversation
…eue for the Governor buildAttemptGovernorContext hardcoded convergenceInput to a first-attempt literal because the portfolio-queue table tracked no attempt history -- so the non-convergence detector (built since Wave 3) never saw real data and always read 'fresh'. Grow miner_portfolio_queue with additive attempts / consecutive_failures / reenqueues columns (defensive per-column migration, mirroring the leased_at idiom); count an attempt on every claim, a re-enqueue + consecutive failure on every in_progress->queued transition that never reached done (markFailed and the stuck-lease reclaim sweep), and reset the consecutive streak on markDone. Add getAttemptHistory returning a real PortfolioConvergenceInput, and thread it from the queue-driven caller (loop-cli) through runMinerAttempt into buildAttemptGovernorContext, which stays pure and just forwards it (a one-off direct attempt has none, so it fails open to a fresh item). non-convergence.ts's classifier and thresholds are untouched. Closes JSONbored#5654
Contributor
|
Superagent didn't find any vulnerabilities or security issues in this PR. |
Contributor
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #5654.
Problem
buildAttemptGovernorContext(attempt-input-builder.js) hardcodedconvergenceInputto a first-attempt literal{ attempts: 0, consecutiveFailures: 0, reenqueues: 0, reachedDone: false }becauseminer_portfolio_queuetracked no attempt history. So the Governor's non-convergence detector (packages/gittensory-engine/src/portfolio/non-convergence.ts, fully built + tested since Wave 3) was never fed real data — it always read "fresh" and had never actually detected a stuck/looping item.Change
portfolio-queue.js): additiveattempts/consecutive_failures/reenqueuescolumns via a defensive per-column migration (mirrors the existingleased_atmigration idiom;NOT NULL DEFAULT 0, so every pre-existing row reads "fresh").+1 attemptson every claim (dequeueNext,batchClaim);+1 reenqueuesand+1 consecutive_failureson everyin_progress -> queuedtransition that never reached done (markFailedand the stuck-lease reclaim sweep — exactlynon-convergence.ts's reenqueue trigger);consecutive_failuresreset to0onmarkDone(lifetimeattempts/reenqueuessurvive).requeueItem(a completeddonerow re-run) is deliberately excluded — it reached done, so it is not a stuck loop.getAttemptHistory(...)returns a realPortfolioConvergenceInput;reachedDoneis strictlystatus === 'done', never fabricated.loop-cli) reads it and threads it throughrunMinerAttemptintobuildAttemptGovernorContext, which stays pure and just forwards it (a one-off direct attempt has none → fails open to a fresh item).non-convergence.ts's classifier and thresholds are untouched..d.tsfor bothportfolio-queueandattempt-input-builderupdated to match.Validation
New suite
test/unit/miner-portfolio-queue-attempt-history.test.ts, covering every changed line/branch:claim -> markFailed -> ... -> markDonesequences; batch-claim attempt; reclaim sweep; therequeueItemexclusion; unknown-item fresh read.reachedDoneonly ever reflects a real'done'status across queued/in_progress/done.PortfolioConvergenceInputthatclassifyPortfolioConvergenceclassifiesnon_convergent— the detector's first real exercise — while a single fresh attempt still readsconverging.buildAttemptGovernorContextforwards a realconvergenceInputand defaults to a fresh literal when omitted.