Skip to content

fix(opencode-claimant): single-instance fire lock (#8039) - #11433

Merged
dezren39 merged 1 commit into
mainfrom
fix/8039-claimant-single-instance
Nov 17, 2026
Merged

dezren39 merged 1 commit into
mainfrom
fix/8039-claimant-single-instance

Conversation

@dezren39

@dezren39 dezren39 commented Nov 17, 2026 •

Copy link
Copy Markdown
Member

Closes #8039

Before: claimant.py had no lock, so a scheduled fire and an ad-hoc run could overlap (two fires 11 s apart on 2026-11-09). Each computed cap_room from the same active-root count, so together they could launch past the cap of 36 or race one candidate. The packet in prompt.md also claimed a parallel bounded pool that the code never had.

After: a fire holds an exclusive non-blocking flock on ~/.local/state/opencode-claimant/claimant.lock (the file already existed and was unused). A second fire exits immediately with exit code 0 and logs {"reason": "already_running"}, with candidates_seen and cap_room null because it read nothing. The packet now says fires launch one at a time under that lock.

How: new acquire_fire_lock(); main() takes the lock, then runs the old body (now _fire(mode)) and releases the lock in finally. The kernel drops the lock if the process dies, so a crashed fire leaves no stale lock. Issue item 3 (real candidates_seen) already landed with #8038.

Testing: new TestSingleInstanceLock (second fire exits with already_running and never runs the fire; the lock is free after normal and raising fires). python3 -I run_hermetic_tests.py: 157 tests OK. test_prompt_constants OK.


Generated by Claude Code


Autofix with [code]smith
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

Overlapping fires (the scheduled task plus an ad-hoc run) each read
cap_room from the same active-root count, so they could spend the same
free slots or race one candidate. main() now takes an exclusive
non-blocking flock on STATE_DIR/claimant.lock around the whole fire; a
second fire exits at once and logs reason already_running. The kernel
drops the lock on exit, so a crashed fire leaves nothing stale.

The packet (prompt.md) said fires launch in parallel under a bounded
pool; the code launches sequentially. Keep the sequential loop, as the
issue allows, and make the packet say so.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@dezren39
dezren39 marked this pull request as ready for review November 17, 2026 22:37
@dezren39
dezren39 requested a review from a team as a code owner November 17, 2026 22:37
@coderabbitai

coderabbitai Bot commented Nov 17, 2026

Copy link
Copy Markdown

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-17T22:38:48.790789Z b6e6e96 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

opencode-claimant(claimant.py): no single-instance lock or bounded pool — a live fire overlapped another fire 11 s apart

2 participants