fix(miner-governor): wire the real attempt pipeline to persisted governor state (#5134) - #5214
Conversation
…rnor state (#5134) #5203 added evaluateGovernorChokepointGatePersisted and governor- state.js, but attempt-runner.js -- the one real production caller -- still imported and called the old, non-persisting evaluateGovernorChokepointGate directly, so the reset-on-process- start bug #5134 was filed to fix was never actually fixed for the real pipeline, only the infrastructure to fix it existed. Switches the import/call to evaluateGovernorChokepointGatePersisted, adds an optional AttemptDeps.governorState field, and loosens AttemptGovernorContext's rateLimitBuckets/rateLimitBackoffAttempts/ capUsage to optional (via the new GovernorChokepointInputPersisted type) -- without that, callers would still be forced to hand-thread honest-but-stale zero defaults on every invocation, silently defeating the persistence an explicit input value always overrides. Flagged by the gittensory review gate on #5203 after it had already merged; recovered as this fresh PR since pushing to the merged branch would have orphaned the commit.
|
Superagent didn't find any vulnerabilities or security issues in this PR. |
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
gittensory-ui | a0713c2 | Commit Preview URL Branch Preview URL |
Jul 12 2026, 09:44 AM |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #5214 +/- ##
=======================================
Coverage 94.34% 94.34%
=======================================
Files 473 473
Lines 39973 39973
Branches 14573 14573
=======================================
Hits 37712 37712
Misses 1585 1585
Partials 676 676
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
|
Warning 🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨 ⏸️ Gittensory review result - manual review recommendedReview updated: 2026-07-12 09:49:04 UTC
⏸️ Suggested Action - Manual Review
Review summary Nits — 5 non-blocking
Concerns raised — review before merging
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 Gittensory, a quiet PR intelligence layer for OSS maintainers.
|
Summary
evaluateGovernorChokepointGatePersistedandgovernor-state.js(real cross-attempt persistence for rate-limit buckets/backoff/cap usage), butattempt-runner.js— the one real production caller of the governor chokepoint — still imported and called the old, non-persistingevaluateGovernorChokepointGatedirectly. So the actual bug Persist governor cross-attempt state (rate-limit, budget, convergence, reputation, self-plagiarism) #5134 was filed to fix (governor state resetting to zero on every process start) was never fixed for the real pipeline; only the infrastructure to fix it existed.evaluateGovernorChokepointGatePersisted, add an optionalAttemptDeps.governorStatefield (falls back to the wrapper's own default-store behavior when omitted), and loosenAttemptGovernorContext'srateLimitBuckets/rateLimitBackoffAttempts/capUsageto optional via the newGovernorChokepointInputPersistedtype. That last part matters: without it, every caller would still be forced to hand-thread honest-but-stale zero defaults on everyrunMinerAttemptcall (since an explicit input value always wins over persisted state in the wrapper's own precedence), silently defeating the persistence even after the import swap.mainbefore starting this fix.Validation
npm run typechecknpm run test:coveragelocally (740 test files, 0 failures, 14,643 tests). Two new regression tests added totest/unit/miner-attempt-runner.test.ts: one directly proves the fix by runningrunMinerAttempttwice through the real entrypoint with a 1-request rate-limit policy and confirming the second call is denied (this is exactly the failure mode the bug produced — before this fix, the second call would always see a fresh, empty bucket and be allowed); the other confirms the default-governor-state-store fallback works safely. Also addedtempGovernorState()isolation to every existing test in that file — without it, every test run would have silently opened the real~/.config/gittensory-miner/governor-state.sqlite3on whatever machine ran them, since none of the existing tests supplied agovernorStateoverride before this PR.npx tsx scripts/check-engine-parity.tsnpm run build:miner+npm run test:miner-packnpm audit --audit-level=moderateSafety
ls ~/.config/gittensory-miner/before/after — only the pre-existinggovernor-ledger.sqlite3present, nogovernor-state.sqlite3).