Skip to content

opencode-claimant(poll): a session entry with a wrong-shaped time crashes all of poll.py — one malformed session kills candidate discovery for every queue #6868

Closed

Description

@dezren39

opencode-claimant(poll): a session entry with a wrong-shaped time crashes all of poll.py — one malformed session kills candidate discovery for every queue

Summary

pm-stack/opencode-claimant/poll.py reads the OpenCode server's session list and classifies every entry through is_active_root (:186), is_stuck_bound (:145), and _stuck_entry (:366). All three do t = session.get("time") or {} and then call t.get(...) and do arithmetic on t.get("updated") or t.get("created") or 0 (:175-179, :196-200, :368-380) with no type check on time itself or on the timestamp values. A single session entry whose time is a non-empty string, an int, or a bool raises AttributeError; an entry whose time.updated/time.created is a string, list, or object raises TypeError. Because main() (:419) runs summarize_cap and get_stuck_bound over the whole list with no per-entry guard, one such entry crashes the whole poll: no JSON is printed at all, so the claimant discovers no candidates and no stuck-bound rows for any of the four queues.

Evidence (verified this run, laptop @ 65beb42)

Probe: ~/git/fleet/probe-poll-time-shape/ on the laptop — poll.py copied verbatim from origin/main (md5 matches git show), existing suite as control, classifiers called directly:

Controls (all pass):

  • Existing test_poll.py suite on the verbatim copy: 41 tests OK.
  • is_active_root(fresh root) → True; summarize_cap([fresh, finished], set(), now) → (2, 1, 35); timeless dict {"id": "ses_x"} → False (the pinned test_non_dict_and_timeless_entries_never_active case).

Wrong shapes (all raise):

  • time="soon", time=123, time=True → AttributeError: 'str'/'int'/'bool' object has no attribute 'get' in is_active_root, in summarize_cap, in is_stuck_bound, and in _stuck_entry.
  • time={"updated": "soon"} / {"created": "soon"} (also list/dict values) → TypeError: unsupported operand type(s) for -: 'int' and 'str' in is_active_root and is_stuck_bound.
  • Main-path simulation: summarize_cap([good_root, root(time="soon")], ...) raises — one bad entry poisons the entire list; get_stuck_bound with the bad session raises the same way.

Falsy non-dict time values ([]) slip through via or {} and are silently treated as timeless — inconsistent with the truthy cases crashing, and for is_stuck_bound an empty-list time yields updated=0, i.e. "silent forever", which can mark a bound task stuck on no evidence.

Why it matters

poll.py is the claimant's only discovery surface: its own header states the claimant treats its output as the launch decision input for all four pilot queues. The module's documented contract is fail-closed on unknowns — summarize_cap returns None counts rather than guess, parse_lease_ms refuses to call an unparseable lease expired, is_stuck_bound says "Fail closed on every unknown". A wrong-shaped time is exactly such an unknown, but instead of failing closed it raises out of main(): the claimant gets no output whatsoever (worse than the cap_room: null no-launch signal the design intends), and the crash repeats every poll cycle for as long as the malformed session remains in the server's list — finished sessions are returned forever until archived, per the module header. The server is an external trust boundary (its payload shape has already changed under this code: #4757 truncation, #6609 cap API), so one unexpected entry shape must not be able to take down discovery fleet-wide.

Related: #6865 (claimant.py missing imports) is a different defect in the sibling file; this issue is only poll.py's session-time handling. #4757/#6609 covered fetch truncation and the cap API, not per-entry field shapes.

Acceptance criteria

  • No session entry shape raises out of is_active_root, is_stuck_bound, _stuck_entry, count_active_roots, or summarize_cap: non-object time (string/int/bool/list) and non-numeric updated/created are handled, not raised.
  • Fail-closed semantics preserved: an entry whose timing cannot be read must never be counted as a known-inactive root to manufacture cap room, and never classified stuck-bound on missing timing evidence; the cap summary treats an unreadable-timing entry consistently with the module's unknown-propagation rule (unknown/None rather than a guessed count), or documents and tests the chosen equivalent.
  • main() still prints its full JSON (candidates + stuck_bound + cap fields) when the session list contains one malformed entry among good ones.
  • Regression tests in pm-stack/opencode-claimant/test_poll.py cover: time as string/int/bool/list, updated/created as string/list/object, across the active-root, stuck-bound, and stuck-entry paths, plus the existing 41 tests still pass.

Verification

Probe directory (laptop): ~/git/fleet/probe-poll-time-shape/ (poll.py verbatim from main @ 65beb42, md5-verified; probe.py; test_poll.py control suite 41/41 OK). Dedup: gh searches (all states) for poll.py time/session shape and claimant-poll malformed-session terms — no issue covers per-entry time shapes; #6394-style config validation and #2800 sync shapes are different files/mechanisms.

Activity

  1. developing-today commented on Nov 7, 2026

    @developing-today
    Contributor
  2. added
    kind/bugSomething isn't working (prefixed form of the classic bug label)
    task/small-fixQueue packet kind: bounded fix with reproduction and targeted tests
    source/creatorFiled by the new-issue-creator job
    priority/normalOrdinary priority (the default)
    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 (new-issue-creator-code-a)
    • Session / ID: cron job new-issue-creator-code-a, run 2026-11-07 05:05 CST
    • Found via: filed this run
    • Task: poll.py classifies every server session through session.get("time") or {} with no type check (:175-179, :196-200, :368-380) — a non-object time or non-numeric updated/created raises Attribute/TypeError out of main(), so one malformed session kills candidate discovery for all four queues; filed with laptop probe evidence (real file verbatim, existing 41-test suite as control).
    • Expectation: effort/s — shape-guard the time/timestamp reads in is_active_root/is_stuck_bound/_stuck_entry with the module's fail-closed unknown semantics + regression tests in test_poll.py; done when main() still prints full JSON with a malformed entry in the list.
    • Links: probe ~/git/fleet/probe-poll-time-shape (laptop); body file creator-a-2026-11-07-0505/issue-poll-session-time-shape.md
  4. developing-today commented on Nov 8, 2026

    @developing-today
    Contributor

    🤖 Agent note · handed off

  5. dezren39 commented on Nov 9, 2026

    @dezren39
    MemberAuthor

    Agent note - handed off. Agent: repo queue worker, lane code-h (repo-worker-code). Session: cron repo-queue-worker-shift-h run 2026-11-09 05:05 CST; task 11105. Found via: claimed task 11105 this shift (lane stamp code-h verified); execution-lane assignment returned opencode (lane row 3580). Task: task 11105 for issue #6868 (small_fix). Fresh revalidation: issue #6868 OPEN, no hard-stop labels. Handed off to the opencode claimant per runbook 1b; task parked 1200s pending claimant. Expectation: claimant session drives task 11105 to a terminal state. Links: task 11105, issue #6868.

  6. added
    queue/parkedQueue task is parked (waiting on CI, time, or an event)
    status/parkedDeliberately paused with a recorded resume condition
    and removed on Nov 9, 2026
  7. 31 remaining items

  8. dezren39 commented on Nov 10, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · done

  9. added
    priority/lowNice to have; do when convenient
    queue/claimedQueue worker lifecycle state
    and removed
    priority/normalOrdinary priority (the default)
    status/parkedDeliberately paused with a recorded resume condition
    queue/parkedQueue task is parked (waiting on CI, time, or an event)
    on Nov 11, 2026
  10. dezren39 commented on Nov 11, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · picked up

    Claimed direct (lane assignment row returned direct; the earlier opencode handoffs never produced a PR — fresh check: issue #6868 OPEN, no PR). Implementing the shape guards in poll.py in worktree ~/git/fleet/11105 on branch queue/11105-6868-poll-time-shape.

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

    @dezren39
    MemberAuthor

    🤖 Agent note · done (fixed_merged)

    PR #8692 MERGED 2026-11-11T14:03:41Z (merge commit c2a73a7); issue #6868 CLOSED by the merge.

    Fix: _session_timing() shape guard in pm-stack/opencode-claimant/poll.py — non-object time and non-numeric updated/created (bool included) now fail closed instead of raising: cap counting goes unknown (None, propagated by summarize_cap; -1 sentinel in both get_active_root_session_count wrappers, incl. the claimant.py ripple), stuck-bound never classifies on unreadable timing, and _stuck_entry reports session_updated None. Tests: test_poll 65 OK (8 new TestWrongShapeTime cases), test_claimant 23 OK, git diff --check clean — run on the laptop against the exact PR head. PR CI was still queued at merge time (fleet-wide Actions backlog); merged under the standing merge authority on local verification.

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/lowNice to have; do when convenientsource/creatorFiled by the new-issue-creator jobstatus:donetask/small-fixQueue packet kind: bounded fix with reproduction and targeted tests

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions