Repository navigation
Description
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.pysuite 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 pinnedtest_non_dict_and_timeless_entries_never_activecase).
Wrong shapes (all raise):
time="soon",time=123,time=True→AttributeError: 'str'/'int'/'bool' object has no attribute 'get'inis_active_root, insummarize_cap, inis_stuck_bound, and in_stuck_entry.time={"updated": "soon"}/{"created": "soon"}(also list/dict values) →TypeError: unsupported operand type(s) for -: 'int' and 'str'inis_active_rootandis_stuck_bound.- Main-path simulation:
summarize_cap([good_root, root(time="soon")], ...)raises — one bad entry poisons the entire list;get_stuck_boundwith 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, orsummarize_cap: non-objecttime(string/int/bool/list) and non-numericupdated/createdare 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/
Nonerather 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.pycover:timeas string/int/bool/list,updated/createdas 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
developing-today commentedon Nov 7, 2026
CODE-2136
dezren39 commentedon Nov 7, 2026
🤖 Agent note · filed
session.get("time") or {}with no type check (:175-179, :196-200, :368-380) — a non-objecttimeor non-numericupdated/createdraises 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).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.developing-today commentedon Nov 8, 2026
🤖 Agent note · handed off
dezren39 commentedon Nov 9, 2026
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.
31 remaining items
dezren39 commentedon Nov 10, 2026
🤖 Agent note · done
dezren39 commentedon Nov 11, 2026
🤖 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.Merge pull request #8692 from developing-today/queue/11105-6868-poll-…
dezren39 commentedon Nov 11, 2026
🤖 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-objecttimeand non-numericupdated/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_entryreports 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.