Skip to content

fix: cancel stale allocation closes, let deliberate ones stick#1244

Closed
MoonBoi9001 wants to merge 3 commits into
mb9/keep-operator-allocate-rule-after-agent-closefrom
mb9/make-allocation-closes-reason-aware
Closed

fix: cancel stale allocation closes, let deliberate ones stick#1244
MoonBoi9001 wants to merge 3 commits into
mb9/keep-operator-allocate-rule-after-agent-closefrom
mb9/make-allocation-closes-reason-aware

Conversation

@MoonBoi9001

@MoonBoi9001 MoonBoi9001 commented Jul 9, 2026

Copy link
Copy Markdown
Member

This PR makes allocation-close handling aware of why and by whom a close was queued: a close that no longer reflects the operator's rules is canceled, while a deliberate close still executes and stays closed.

Background: when an indexing rule opts a deployment out (decision basis never or offchain), the indexer agent queues a close for its allocation and, after closing, writes a never rule so it does not immediately reallocate. A queued close can wait long enough for the operator to flip the rule back to allocate, and before this change it executed anyway.

The change has 2 parts:

  • Just before an approved batch executes, agent-queued closes whose opt-out rule now asks for allocation again are canceled. Closes already in deploying state are left to finish: they are leftovers from a crashed executor run and their transaction may already be on-chain.
  • The check that skips the never stamp when a rule requests allocation now applies only to agent-queued closes. Closes queued by hand through the CLI or management API write the never rule unconditionally, so a deliberate close sticks instead of being reopened.

The rule lookup also falls back to the global rule now, so a global always rule counts as requesting allocation. Stacked on #1242, which introduced the after-close rule check.

A close queued under an opt-out rule now cancels at execution time when that rule has since
flipped back to allocate, and the after-close never-stamp only steps aside for exactly those
stale closes; manual, health-check, and threshold closes stick again as they used to.
@github-project-automation github-project-automation Bot moved this to 🗃️ Inbox in Indexer Jul 9, 2026
@MoonBoi9001 MoonBoi9001 marked this pull request as draft July 9, 2026 12:17
A close in deploying state is leftover from a crashed executor run and its transaction may
already be on-chain; marking it canceled would record the opposite of what happened. The
stale-close check now requires approved status, so deploying closes run to completion.
Filtering the batch scanned a list of canceled ids once per action; a set lookup avoids
the repeated scans.
@MoonBoi9001 MoonBoi9001 changed the title fix: cancel stale queued closes and make deliberate ones stick fix: cancel stale allocation closes, let deliberate ones stick Jul 10, 2026
@MoonBoi9001 MoonBoi9001 marked this pull request as ready for review July 10, 2026 00:49
@github-project-automation github-project-automation Bot moved this from 🗃️ Inbox to ❌ Closed in Indexer Jul 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: ❌ Closed

Development

Successfully merging this pull request may close these issues.

1 participant