Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions pm-stack/opencode-claimant/poll.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,16 @@ def is_candidate(row):
prog = row.get("progress") or {}
if prog.get("lane") != "opencode" or prog.get("session_id"):
return False
# The claiming lane must have RECORDED its yield (instruction
# section 1b: checkpoint stage "handed_off"). Assignment alone is
# not a handoff: lanes on pre-1b instructions assign and then work
# the task themselves, and a launch into a task whose lane is
# mid-work double-executes it (first live batch, 2026-11-02:
# tasks 5565/5867/6397 were launched while their claiming lanes
# worked/parked/failed them in parallel). The recorded yield is
# the only launch-safe signal.
if prog.get("stage") != "handed_off":
return False
lane_id = row.get("lane_id")
if lane_id and UUID_LANE.match(lane_id):
return False
Expand Down
16 changes: 11 additions & 5 deletions pm-stack/opencode-claimant/prompt.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,11 @@ Never claim, bind, launch, or mutate a task in shadow mode.
4. For each candidate, highest queue priority first, while cap room
remains:
a. Re-verify the task is still claimed, still lane `opencode`,
still unbound (re-run poll.py for that task id). If it changed,
skip it -- someone else owns the launch now.
still unbound, and still at stage `handed_off` (re-run poll.py
for that task id -- its candidate filter encodes all four). If
it changed, skip it -- someone else owns the launch now. A task
that is assigned `opencode` but NOT handed off belongs to its
claiming lane, which is working it: never launch into it.
b. Create the worker session on the standing OpenCode server
(`POST /api/session`, directory = the repo's laptop primary,
title naming the queue task and issue, model = the route above).
Expand All @@ -87,9 +90,12 @@ Never claim, bind, launch, or mutate a task in shadow mode.
a different existing binding -- a bind error means someone else
owns the launch; do not prompt your session, note it in the fire
log, and move on. Then run the helper
`checkpoint <id> --worker opencode-claimant --stage launched`
with the session id in the progress JSON. A launch without this
binding is the Oct 28 duplicate-PR defect -- never leave one.
`checkpoint <id> --worker <worker_id> --stage launched`
with the session id in the progress JSON -- the checkpoint verb
enforces claim ownership, so it runs as the candidate's
`worker_id` (the claiming repo worker), not as yourself. A
launch without this binding is the Oct 28 duplicate-PR defect
-- never leave one.
d. Send the worker prompt to the bound session: the queue runbook
for its queue with the task id, issue, and packet inlined,
instructing it to work THAT task (it is already claimed and
Expand Down
9 changes: 8 additions & 1 deletion pm-stack/opencode-claimant/test_poll.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,8 @@ def test_known_counts_give_room(self):

class TestIsCandidate(unittest.TestCase):
def row(self, **over):
r = {"progress": {"lane": "opencode"}, "lane_id": "code-a"}
r = {"progress": {"lane": "opencode", "stage": "handed_off"},
"lane_id": "code-a"}
r.update(over)
return r

Expand All @@ -143,6 +144,12 @@ def test_bound_session_is_not_candidate(self):
self.assertFalse(poll.is_candidate(
self.row(progress={"lane": "opencode", "session_id": "ses_1"})))

def test_assigned_but_not_handed_off_is_not_candidate(self):
self.assertFalse(poll.is_candidate(
self.row(progress={"lane": "opencode", "stage": "verified"})))
self.assertFalse(poll.is_candidate(
self.row(progress={"lane": "opencode"})))

def test_unassigned_task_is_not_candidate(self):
self.assertFalse(poll.is_candidate(self.row(progress={})))

Expand Down
Loading