Skip to content

fix(miner): governor-chokepoint-persisted's load-evaluate-save cycle isn't atomic #8856

Description

@JSONbored

⚠️ 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

  • The load-evaluate-save cycle in governor-chokepoint-persisted.ts runs inside a single atomic transaction
  • A concurrency test simulating two overlapping chokepoint evaluations against the same rate-limit bucket, asserting both advances are correctly reflected (no lost update)

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    gittensor:bugGittensor-scored bug fix — scores a 0.05x multiplier.help wantedExtra attention is needed

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions