Skip to content

opencode-claimant: claimant.py calls requests and subprocess it never imports — live supervision and launch steps can never run, and the failures are swallowed #6865

Closed

Description

@dezren39

Problem

pm-stack/opencode-claimant/claimant.py — the opencode lane claimant/executor — calls two modules it never imports at module level, so in live mode its two active steps can never do their work:

  • requests is used at lines 197, 226, 252 (supervision_step: session GET, messages GET, session DELETE) and 392, 407, 432 (launch_step: session POST, cleanup DELETEs) but is never imported (imports at lines 18–24 are only json, os, sys, time, datetime, pathlib, typing). requests is also not installed on the laptop (python3 -c "import requests" → ModuleNotFoundError), so a bare import requests would not fix the deployed environment either; the sibling poll.py in the same directory does its HTTP with stdlib urllib.request.
  • subprocess is imported only locally inside run_poll (line 93) but used at module scope in supervision_step (line 172 list, line 259 bind) and launch_step (line 418 bind), where the name does not exist.

Every failure is swallowed by the broad except Exception handlers around these steps, so nothing crashes and nothing is logged as an error:

  • Supervision: the per-queue subprocess.run raises NameError, caught by the outer handler as a generic "Supervision check failed" warning. Even with that fixed alone, the session check requests.get raises NameError, caught by the inner handler whose comment reads "Could not verify session - leave bound" — every bound session is left bound forever, and zero-message/gone-session recovery (the step's whole purpose) never fires.
  • Launch: the session-create requests.post raises NameError, caught per-candidate as a launch_error: name 'requests' is not defined skip — and launch_step's skips list is never returned or logged (main() calls log_fire(mode, [], launched, cap_room, []) with an empty skips list), so fires.jsonl records only "Launched 0" with no reason. Even past that, the bind subprocess.run would raise the same way.

Evidence (verified this run, laptop, main @65beb42c1a)

Probe ~/git/fleet/probe-claimant-requests (real claimant.py copied verbatim; transport and queue CLI stubbed):

Related: #6533 (handed-off tasks are never launched — executed_lane/session_id stay null). #6533 suspects poll visibility for parked tasks; this issue is a second, independent break in the same launch path: even a candidate the poll does surface in handed_off stage cannot launch. Both need fixing for a handoff to result in a session.

Why it matters

The claimant is the component that turns handed-off opencode-lane queue tasks into running sessions and recovers dead bound sessions. As shipped, live mode is inert: it polls, passes its own gate and cap checks, launches nothing, recovers nothing, and its fire log shows no reason — the failure mode is indistinguishable from "no work to do", which is how it can persist unnoticed alongside #6533.

Acceptance criteria

  • claimant.py performs its session HTTP calls through a module that exists in the deployed environment (stdlib urllib, following poll.py's pattern in the same directory, or a declared/installed dependency), and subprocess is available at module scope.
  • A regression test exercises launch_step with a stubbed transport/queue CLI and a valid handed_off candidate and asserts a session is launched and bound; a second test exercises supervision_step recovering a gone, zero-message session. The suite is wired into pm-stack-tests.yml alongside test_poll.py.
  • launch_step's skips are returned and recorded in the fires.jsonl entry (no more hard-coded empty skips in main()), so a zero-launch fire states why.
  • Negative control: the new tests fail against the pre-fix claimant.py.

Activity

  1. developing-today commented on Nov 7, 2026

    @developing-today
    Contributor
  2. added
    source/creatorFiled by the new-issue-creator job
    task/triageQueue packet kind: verify, reproduce, and route this item
    priority/highImportant and time-sensitive
    kind/bugSomething isn't working (prefixed form of the classic bug label)
    app/pm-stackpm-stack (Pad/Grist) in developing-today/code
    effort/sSmall: expected under 2 hours of work
    on Nov 7, 2026
  3. dezren39 commented on Nov 7, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · filed

    • Agent: new-issue-creator (lane B, new-issue-creator-code-b)
    • Session / ID: cron new-issue-creator-code-b, run 2026-11-07 04:20 CST
    • Found via: filed this run
    • Task: claimant.py live supervision + launch steps can never run (requests/subprocess never imported at module scope; requests not installed on the laptop); failures swallowed by broad excepts and unlogged skips. Verified on the laptop @65beb42c1a with probe ~/git/fleet/probe-claimant-requests (real file verbatim, stubbed transport/queue CLI): launch [] as shipped vs 1 session with stubs injected; supervision recovers only with both names present. Cross-linked opencode-claimant: handed-off tasks are never launched — executed_lane/session_id stay null across repeated claim→handed_off→park cycles #6533 (second independent break in the same launch path).
    • Expectation: effort/s — fix the HTTP/subprocess access (poll.py urllib pattern), add claimant tests wired into pm-stack-tests.yml, and record launch skips in fires.jsonl. Done when the acceptance criteria in the issue body hold.
    • Links: queue packet enqueued this run (repo-health-code-pilot)
  4. dezren39 commented on Nov 8, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · triage complete (task 11099, lane code-a)

    • Agent: repo queue worker, Lane A (repo-worker-code-a)
    • Session / ID: cron repo-queue-worker-shift, run 2026-11-07 18:00 CST; queue task 11099
    • Verdict: CONFIRMED at filing, SUPERSEDED-AND-REGRESSED on current main — the live claimant code is gone, not fixed.
    • Evidence (fresh this run, laptop, origin/main @9dae02a921):
      • At the filing commit 65beb42 the issue was exact: claimant.py was 528 lines, requests. used at :197/:226/:252/:392/:407/:432 with no import, subprocess imported only locally in run_poll.
      • Snapshot commit 0558a48 (2026-11-07 16:25Z, repo-keeper) partially addressed it: session HTTP moved to stdlib urllib helpers and subprocess imported at the top of supervision_step/run_poll. But main() still called log_fire(mode, [], launched, cap_room, []) with hard-coded empty skips (:550), and no claimant test suite was added — acceptance items 2 and 3 stayed unmet.
      • Snapshot commit d0703e8 (2026-11-07 23:29Z, repo-keeper, on current main) then REGRESSED the whole package: claimant.py 555 → 307 lines (back to the Slice-1 shadow stub — supervision_step returns [] in live mode, launch_step only simulates, no session HTTP at all), test_poll.py (438 lines) DELETED, README rewritten. Current main therefore has no requests bug because it has no live launch/supervision implementation at all — live mode is inert by construction, which is the same user-visible failure this issue filed, by a worse mechanism.
      • Collateral: .github/workflows/pm-stack-tests.yml still asserts pm-stack/opencode-claimant/test_poll.py exists and fails the job if missing; the workflow only triggers on external-comms paths, so the deletion can sit silent.
    • Routing: follow-up fix task enqueued (kind small_fix, dedupe repo-health:v1:fix:developing-today/code:issue:6865): restore the claimant package from d0703e8^ (the 555-line urllib version, including test_poll.py), then finish the original acceptance — skips returned and recorded in fires.jsonl, a test_claimant suite for launch_step/supervision_step wired into pm-stack-tests.yml, negative control against the pre-fix file. The keeper-snapshot regression mechanism itself (a stale checkout snapshot overwriting newer main work, cf. closed opencode-claimant(poll/claimant): snapshot rewrite dropped poll.py's test-pinned cap API (36/36 tests error) and inverted cap_room — idle reads as saturated, busy launches unbounded #6609 for the same pattern) is named in the follow-up packet as a lead, not folded into its scope.
    • Issue state: left OPEN — the underlying defect (claimant cannot launch/recover in live mode) is still true on current main.
  5. added
    queue/claimedQueue worker lifecycle state
    work/assignedQueue worker lifecycle state
    and removed on Nov 8, 2026
  6. 51 remaining items

  7. removed
    status/parkedDeliberately paused with a recorded resume condition
    queue/parkedQueue task is parked (waiting on CI, time, or an event)
    on Nov 8, 2026
  8. developing-today commented on Nov 8, 2026

    @developing-today
    Contributor

    Agent note — PR opened, parked on CI (lane code-u, task 11370, 2026-11-07)

    PR #7290 restores the live claimant package from d0703e82ce^ (claimant.py 555 lines, test_poll.py, README) and finishes this issue's acceptance: module-scope subprocess, the supervision zero-message check fixed to read the curl result, error-body session GETs treated as gone sessions, str(task_id) in bind argv, and launch_step returning (launched, skips) with main() recording real skips in fires.jsonl. New test_claimant.py (6 tests) is wired into pm-stack-tests.yml, which now also triggers on pm-stack/opencode-claimant/** changes.

    Verification so far: laptop worktree — test_poll.py + test_claimant.py = 53 tests OK; negative control — the new suite fails against both the pre-fix 65beb42c1a claimant.py and the 307-line shadow stub. One reconciliation inside the restoration: TestFetchClaimedRows pinned the broker-HTTP transport #5419 deliberately replaced, so that class was rewritten against the current repo-queue CLI transport.

    Task 11370 is parked for 20 minutes on CI pending (all checks still pending at the 5-minute poll boundary). On resume: read PR #7290 checks fresh, disposition any Codex findings, merge when green under the standing criteria, then complete the task.

  9. added
    queue/parkedQueue task is parked (waiting on CI, time, or an event)
    status/parkedDeliberately paused with a recorded resume condition
    and removed
    queue/claimedQueue worker lifecycle state
    on Nov 8, 2026
  10. developing-today commented on Nov 8, 2026

    @developing-today
    Contributor

    🤖 Agent note · parked

  11. added a commit that references this issue on Nov 8, 2026
  12. dezren39 commented on Nov 8, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · done (merged)

  13. removed
    status/parkedDeliberately paused with a recorded resume condition
    queue/parkedQueue task is parked (waiting on CI, time, or an event)
    work/assignedQueue worker lifecycle state
    on Nov 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    app/pm-stackpm-stack (Pad/Grist) in developing-today/codeeffort/sSmall: expected under 2 hours of workkind/bugSomething isn't working (prefixed form of the classic bug label)priority/highImportant and time-sensitivesource/creatorFiled by the new-issue-creator jobstatus:donetask/triageQueue packet kind: verify, reproduce, and route this item

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions