⚠️ Definition of Done: this issue must be completed in full, in a single PR. Do not split this
work across multiple PRs, and do not defer any Deliverable below to a follow-up issue. A PR that
satisfies only some of the Deliverables, stubs a required test, or leaves a checkbox
partially-done does NOT resolve this issue and will be closed.
Context
packages/loopover-miner/lib/governor-chokepoint-persisted.ts:42-53's loadRateLimitState()/loadCapUsage() are read outside any transaction, then fed through evaluateGovernorChokepointGate, then saved via saveRateLimitState's own BEGIN IMMEDIATE -- which only protects the write, not the preceding read. Two fleet containers evaluating concurrently can both load the same bucket state and independently compute "advance by one," and the second save clobbers the first -- a lost update in the rate-limit safety core.
Requirements
Wrap the load+evaluate+save sequence in a single transaction (or add an atomic load-apply-save method on GovernorState that performs the whole cycle inside one BEGIN IMMEDIATE block), so two concurrent evaluations against the same bucket cannot interleave.
Deliverables
All of the above Deliverables are required in the same PR unless the deliverable text itself states otherwise.
Test Coverage Requirements
packages/loopover-miner/** -- 99%+ patch coverage including the new concurrency test path.
Expected Outcome
Two fleet containers evaluating the rate-limit chokepoint concurrently can no longer clobber each other's state update; the rate-limit safety core's bucket counts stay correct under concurrent load.
Links & Resources
packages/loopover-miner/lib/governor-chokepoint-persisted.ts:42-53
Context
packages/loopover-miner/lib/governor-chokepoint-persisted.ts:42-53'sloadRateLimitState()/loadCapUsage()are read outside any transaction, then fed throughevaluateGovernorChokepointGate, then saved viasaveRateLimitState's ownBEGIN IMMEDIATE-- which only protects the write, not the preceding read. Two fleet containers evaluating concurrently can both load the same bucket state and independently compute "advance by one," and the second save clobbers the first -- a lost update in the rate-limit safety core.Requirements
Wrap the load+evaluate+save sequence in a single transaction (or add an atomic load-apply-save method on
GovernorStatethat performs the whole cycle inside oneBEGIN IMMEDIATEblock), so two concurrent evaluations against the same bucket cannot interleave.Deliverables
governor-chokepoint-persisted.tsruns inside a single atomic transactionAll of the above Deliverables are required in the same PR unless the deliverable text itself states otherwise.
Test Coverage Requirements
packages/loopover-miner/**-- 99%+ patch coverage including the new concurrency test path.Expected Outcome
Two fleet containers evaluating the rate-limit chokepoint concurrently can no longer clobber each other's state update; the rate-limit safety core's bucket counts stay correct under concurrent load.
Links & Resources
packages/loopover-miner/lib/governor-chokepoint-persisted.ts:42-53