Skip to content

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

Closed

Description

@dezren39

What

The claimant packet and the deployed claimant.py disagree about concurrency control:

  • Packet: "claimant.py launches distinct candidates in parallel under a bounded pool and a single-instance lock".
  • Deployed pm-stack/opencode-claimant/claimant.py at origin/main 9fbddc76c6: a sequential for candidate in unbound_opencode: loop, no file lock, no pool (grep -n 'flock\|lock\|ThreadPool\|max_workers' → nothing). ~/.local/state/opencode-claimant/claimant.lock exists on disk and is never used by the code.

Evidence from the 2026-11-09T12:22Z fire (live)

~/.local/state/opencode-claimant/fires.jsonl, five consecutive fires in six minutes from more than one entry point:

line timestamp (UTC) cap_room launched wrapper fire-run-live-*.out present
423 2026-11-09T12:16:53Z 0 0 yes (12:16:51)
424 2026-11-09T12:17:51Z 0 0 no
425 2026-11-09T12:20:39Z 0 0 no
426 2026-11-09T12:22:28Z 0 0 yes (12:22:26, this fire)
427 2026-11-09T12:22:39Z 0 0 no

Line 426 and line 427 are 11 s apart: two invocations overlapped. The entries with no wrapper output are ad-hoc session runs of the same script; the ones with output are the */10-minute OpenChamber scheduled task (f1b4a33b-14d5-4a69-9ad6-d221e42e3ac9).

Why it matters

cap_step() computes cap_room = 36 - active_roots once, and launch_step() then decrements its own local copy. Two overlapping fires each start from the same cap_room; the atomic bind keeps the same task from being double-bound, but nothing stops two fires from spending the same free slots (active roots above 36 — the exact condition the cap exists to prevent) or from racing one candidate, where the loser wastes a create→bind-fail→delete cycle (the recurring bind_failed skips already seen in lines 420/421).

Both overlapping fires saw cap_room 0 this time, so nothing was harmed. A 47 s launching fire (line 421) overlaps a scheduled fire easily.

Proposal

  1. flock (LOCK_EX|LOCK_NB) on ~/.local/state/opencode-claimant/claimant.lock around the whole fire; a second fire exits early with a distinguishable fire-log reason (already_running), not no_candidates.
  2. Either a bounded ThreadPoolExecutor as the packet describes, or — simpler and matching the observed wave behaviour — keep the sequential loop and record the packet change. Whichever lands, packet and code must state the same thing.
  3. While in there: pass the discovered candidate list to log_fire so candidates_seen is real (currently hardcoded [] on every fire — related to opencode-claimant(claimant.py): gate-exit logs a hardcoded cap_room 0 — idle fires read as cap-saturated #7732).

Scope note

Slice 1 of #3026 (claim/bind/launch/record). Fail-closed both times: no session was created, bound or deleted while this defect was live.

Activity

  1. developing-today commented on Nov 9, 2026

    @developing-today
    Contributor
  2. added
    kind/bugSomething isn't working (prefixed form of the classic bug label)
    on Nov 12, 2026
  3. dezren39 commented on Nov 16, 2026

    @dezren39
    MemberAuthor

    Recurrence evidence (2026-11-16, live mode, OpenChamber scheduled invocation):

    • 13:17:11Z — claimant-fire-exec-20261116T131711Z.out (another entry point)
    • 13:17:14Z — claimant-fire-exec-session-20261116T131714Z.out (this fire)

    Two live fires overlapped 3 s apart. Both found zero unbound candidates (skips: [{"reason": "no_candidates"}]), so no session was created and there was no double-launch — the overlap is benign only because the gate was empty. grep -n 'flock\|fcntl\|claimant.lock' pm-stack/opencode-claimant/claimant.py still returns nothing, and the 0-byte ~/.local/state/opencode-claimant/claimant.lock is still unused: the lock gap itself is unchanged.

    Worth noting for whoever picks this up: a concurrent pair that does find candidates is bounded against duplicate work by the atomic DB bind (the loser's bind errors and it must not prompt), but it is not bounded against leaked unbound sessions — each fire creates its session before binding, and the loser leaves one behind. The single-instance lock is still the correct fix.

  4. dezren39 commented on Nov 17, 2026

    @dezren39
    MemberAuthor

    [agent: repo-worker-code / lane code-a, task 18575] Triage of #8039: CONFIRMED live, fix routed as queue task 20061.

    Fresh checks (2026-11-17): issue OPEN (bug, kind/bug, pm-stack; no hold labels). Current main pm-stack/opencode-claimant/claimant.py (1017 lines) still contains no flock/fcntl/claimant.lock/ThreadPool code — the packet/code disagreement is exactly as filed, and the 2026-11-16 recurrence comment (two live fires 3 s apart, benign only because the candidate gate was empty) still describes the present state.

    The issue's own proposal is the fix scope, unchanged: flock (LOCK_EX|LOCK_NB) on the existing ~/.local/state/opencode-claimant/claimant.lock around the whole fire with an already_running fire-log reason; keep the sequential loop and align the packet wording (or implement the bounded pool — packet and code must agree); pass the candidate list to log_fire so candidates_seen is real (#7732). Task 20061 carries that scope with an overlap-refusal acceptance check.

  5. added a commit that references this issue on Nov 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingepic/opencode-platformReprioritization program epic (2026-11-12)kind/bugSomething isn't working (prefixed form of the classic bug label)pm-stackstatus:done

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions