feat(miner-governor): wire rate-limit + jittered backoff into live write enforcement (#2344) - #4984
Conversation
|
Superagent didn't find any vulnerabilities or security issues in this PR. |
|
Tip 🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩 ✅ Gittensory review result - approve/merge recommendedReview updated: 2026-07-11 07:18:35 UTC
✅ Suggested Action - Approve/Merge
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.
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #4984 +/- ##
=======================================
Coverage 94.31% 94.31%
=======================================
Files 454 455 +1
Lines 39034 39083 +49
Branches 14234 14256 +22
=======================================
+ Hits 36813 36862 +49
Misses 1572 1572
Partials 649 649
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
Closes #2344
Summary
Wires the existing pure
evaluateLocalRateLimit/jitteredBackoffMscalculator into Governor write enforcement: every write action is checked against both a global and a per-repo rolling-window bucket. Over-limit writes are throttled with jittered retry scheduling (not permanent failure or busy-looping) and recorded to the governor ledger.Changes
packages/gittensory-engine/src/governor/write-rate-limit.tsevaluateWriteRateLimit, bucket advance/deny helpers, ledger event builderpackages/gittensory-engine/src/index.tspackages/gittensory-miner/lib/governor-write-rate-limit.jsevaluateWriteRateLimitGate— check + retry schedule + ledger writepackages/gittensory-miner/lib/governor-write-rate-limit.d.tspackages/gittensory-miner/package.jsonbuild --checkfor governor-write-rate-limitgovernor-write-rate-limit.test.ts,miner-governor-write-rate-limit.test.ts, engine package testBehavior
allowed; global + per-repo buckets advancethrottledwithper_repo_rate_limit; jitteredretryAfterMsgrows with burst attemptsthrottledwithglobal_rate_limiteven when the repo bucket is under its own limitTest plan
buildWriteRateLimitGovernorLedgerEventrecords retry metadataevaluateWriteRateLimitGatepersists allowed/throttled decisions to governor ledgernpm run test:unit -- test/unit/governor-write-rate-limit.test.ts test/unit/miner-governor-write-rate-limit.test.tsnpm run test --workspace @jsonbored/gittensory-enginenpm run test:ci(full gate before push)Notes
governor/rate-limit.tswas already onmain; this PR adds the enforcement layer only.open_pr30/min global, 3/min per-repo;comment60/min global, 10/min per-repo; 1s jitter base.Test plan
npm run test:ci