Skip to content

fix(miner-governor): wire the real attempt pipeline to persisted governor state (#5134) - #5214

Merged
JSONbored merged 1 commit into
mainfrom
fix/wire-persisted-governor-state-attempt-runner
Jul 12, 2026
Merged

fix(miner-governor): wire the real attempt pipeline to persisted governor state (#5134)#5214
JSONbored merged 1 commit into
mainfrom
fix/wire-persisted-governor-state-attempt-runner

Conversation

@JSONbored

Copy link
Copy Markdown
Owner

Summary

Validation

  • npm run typecheck
  • npm run test:coverage locally (740 test files, 0 failures, 14,643 tests). Two new regression tests added to test/unit/miner-attempt-runner.test.ts: one directly proves the fix by running runMinerAttempt twice 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 added tempGovernorState() isolation to every existing test in that file — without it, every test run would have silently opened the real ~/.config/gittensory-miner/governor-state.sqlite3 on whatever machine ran them, since none of the existing tests supplied a governorState override before this PR.
  • npx tsx scripts/check-engine-parity.ts
  • npm run build:miner + npm run test:miner-pack
  • npm audit --audit-level=moderate

Safety

  • Verified locally that no file was created at the real default governor-state path during the test run (ls ~/.config/gittensory-miner/ before/after — only the pre-existing governor-ledger.sqlite3 present, no governor-state.sqlite3).

…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-security

Copy link
Copy Markdown
Contributor

Superagent didn't find any vulnerabilities or security issues in this PR.

@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

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

codecov Bot commented Jul 12, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.34%. Comparing base (9fa67f5) to head (a0713c2).
⚠️ Report is 1 commits behind head on main.
✅ All tests successful. No failed tests found.

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           
Flag Coverage Δ
shard-1 46.34% <ø> (-0.13%) ⬇️
shard-2 34.43% <ø> (-0.12%) ⬇️
shard-3 30.80% <ø> (-0.15%) ⬇️
shard-4 33.28% <ø> (-0.02%) ⬇️
shard-5 33.52% <ø> (-0.17%) ⬇️
shard-6 45.17% <ø> (+0.30%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@JSONbored JSONbored self-assigned this Jul 12, 2026
@loopover-orb loopover-orb Bot added the gittensor:bug Gittensor-scored bug fix — scores a 0.05x multiplier. label Jul 12, 2026
@loopover-orb

loopover-orb Bot commented Jul 12, 2026

Copy link
Copy Markdown
Contributor

Warning

🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨

⏸️ Gittensory review result - manual review recommended

Review updated: 2026-07-12 09:49:04 UTC

3 files · 2 AI reviewers · 2 blockers · readiness 93/100 · CI green · unstable

⏸️ Suggested Action - Manual Review

  • No linked issue detected — If this PR is intended to solve an issue, link it explicitly in the PR body.
  • Maintainer requires a linked issue — Link the relevant issue (for example Closes #123) before opening the PR.

Review summary
This swaps attempt-runner.js's real production call from the non-persisting evaluateGovernorChokepointGate to evaluateGovernorChokepointGatePersisted, and correctly loosens AttemptGovernorContext to make rateLimitBuckets/rateLimitBackoffAttempts/capUsage optional so callers stop being forced to hand-thread stale zero defaults that would otherwise override persisted state (an explicit input always wins in the wrapper's precedence). The added regression test exercises this through the real runMinerAttempt entrypoint (not just the lower-level wrapper), demonstrating a rate limit consumed in one call is honored on the next via the shared governor-state store — directly reproducing the wiring gap #5134 was filed for. The options object passed to the persisted gate correctly conditionally spreads both governorLedgerAppend and governorState so omitting either falls back to real defaults, matching the documented behavior and tests for both fallback paths.

Nits — 5 non-blocking
  • packages/gittensory-miner/lib/attempt-runner.js's runMinerAttempt JSDoc still types `governor` as `Omit<...GovernorChokepointInput...>` (the engine's non-persisted type) instead of the new `GovernorChokepointInputPersisted`-based type used in the .d.ts, and the `governorLedgerAppend` doc comment still says 'mirrors evaluateGovernorChokepointGate's own options.append' — both are now stale references to the old function/type names.
  • The header comment notes capUsage's post-attempt save 'stays the caller's job' and isn't wired here — worth confirming there's a tracked follow-up so cap enforcement doesn't quietly stay stale even though rate-limit/backoff persistence is now fixed.
  • Update the two stale JSDoc references in attempt-runner.js noted above to name evaluateGovernorChokepointGatePersisted/GovernorChokepointInputPersisted for consistency with the .d.ts.
  • Consider a brief follow-up issue reference in the header comment for the still-unwired capUsage post-attempt save, since it's the one piece of governor state this PR doesn't close the loop on.
  • nit: packages/gittensory-miner/lib/attempt-runner.js:101 still documents input.governor as the engine GovernorChokepointInput, which conflicts with the new .d.ts contract that intentionally uses GovernorChokepointInputPersisted.

Concerns raised — review before merging

  • No linked issue detected — If this PR is intended to solve an issue, link it explicitly in the PR body.
  • Maintainer requires a linked issue — Link the relevant issue (for example Closes #123) before opening the PR.
Signal Result Evidence
Code review ❌ 2 blockers 2 reviewers, synthesized
Linked issue ⚠️ Missing No linked issue or no-issue rationale found.
Related work ✅ No active overlap found No same-issue or scoped active PR overlap found.
Change scope ✅ 20/20 Low review scope from cached public metadata (no linked issue context).
Validation posture ✅ 25/25 PR body includes validation/test evidence.
Contributor workload ✅ 10/10 Author activity: 45 registered-repo PR(s), 37 merged, 409 issue(s).
Contributor context ✅ Confirmed Gittensor contributor JSONbored; Gittensor profile; 45 PR(s), 409 issue(s).
Gate result ❌ Blocking Repo-configured hard blocker found.
Improvement ✅ Minor risk: clean · value: minor — Code changes are accompanied by test evidence. LLM value judgment: moderate — The diff targets the real production call site for the persisted governor state and adds a regression test that would have failed with the old non-persisting chokepoint wiring.
Review context
  • Author: JSONbored
  • Role context: owner (maintainer lane)
  • Public audience mode: oss maintainer
  • Lane context: Repository is configured for direct PR review.
  • Public profile languages: not available
  • Official Gittensor activity: 45 PR(s), 409 issue(s).
  • PR-specific overlap: none found.
Contributor next steps
  • Treat this as maintainer-lane context rather than normal contributor-lane activity.
  • Explain no-issue PR.
  • Link the issue being solved, or explicitly explain why this is a no-issue PR.
Signal definitions
  • Related work = same linked issue, overlapping active PRs, or title/path similarity.
  • Change scope = cached public metadata such as size labels, draft state, and review-burden hints.
  • Validation posture = whether the PR provides enough public validation/test evidence for maintainer review.
  • Contributor workload = public contributor activity and cleanup pressure, not a repo-wide quality failure.
  • Contributor context = public GitHub/Gittensor identity context; non-Gittensor status is not a blocker.
[BETA] Chat with Gittensory

Ask 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.

  • @gittensory ask &lt;question&gt; answers contribution-quality Q&A with source citations and freshness.
  • @gittensory chat &lt;question&gt; answers in natural prose from cached decision-pack facts via local inference (maintainer/collaborator; read-only).
  • A plain-language @gittensory mention with a real question is routed to the closest matching read-only command automatically -- no exact syntax required.

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.

  • Re-run Gittensory review

@loopover-orb loopover-orb Bot added the manual-review Gittensor contributor context label Jul 12, 2026
@JSONbored
JSONbored merged commit 8802933 into main Jul 12, 2026
20 checks passed
@JSONbored
JSONbored deleted the fix/wire-persisted-governor-state-attempt-runner branch July 12, 2026 09:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gittensor:bug Gittensor-scored bug fix — scores a 0.05x multiplier. manual-review Gittensor contributor context

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Persist governor cross-attempt state (rate-limit, budget, convergence, reputation, self-plagiarism)

1 participant