Title: 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 · Issue #6609 · developing-today/code · GitHub
Open Graph Title: 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 · Issue #6609 · developing-today/code
X Title: 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 · Issue #6609 · developing-today/code
Description: Bug pm-stack/opencode-claimant/poll.py and claimant.py no longer implement the session-cap contract that test_poll.py, prompt.md, and README.md describe — and the claimant's cap arithmetic is inverted, so it launches nothing when idle an...
Open Graph Description: Bug pm-stack/opencode-claimant/poll.py and claimant.py no longer implement the session-cap contract that test_poll.py, prompt.md, and README.md describe — and the claimant's cap arithmetic is inver...
X Description: Bug pm-stack/opencode-claimant/poll.py and claimant.py no longer implement the session-cap contract that test_poll.py, prompt.md, and README.md describe — and the claimant's cap arithmetic is i...
Opengraph URL: https://github.com/developing-today/code/issues/6609
X: @github
Domain: github.com
IPv4 address: 140.82.112.3
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"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","articleBody":"## Bug\n\n`pm-stack/opencode-claimant/poll.py` and `claimant.py` no longer implement the session-cap contract that `test_poll.py`, `prompt.md`, and `README.md` describe — and the claimant's cap arithmetic is inverted, so it launches nothing when idle and over-launches when busy.\n\nVerified on laptop primary @ `083d1a4324d0` (== origin/main), 2026-11-06.\n\n### 1. The pinning test suite errors 36/36 — the functions it tests do not exist\n\n`test_poll.py` (36 tests, header: fixtures mirror the live server's session shape verified 2026-10-31) calls `poll.is_active_root`, `poll.count_active_roots`, `poll.summarize_cap`, `poll.is_candidate`, `poll.parse_lease_ms`, and `poll.is_stuck_bound`, and reads `poll.CAP`. None of these exist in current `poll.py` (its only functions are `get_active_root_sessions`, `get_stuck_bound_tasks`, `get_candidates`, `main`).\n\nProbe (laptop, `requests` stubbed, real modules): `python3 -m unittest pm-stack/opencode-claimant/test_poll.py` → `Ran 36 tests — FAILED (errors=36)`, every error `AttributeError: module 'poll' has no attribute …`.\n\nRoot cause: repo-keeper snapshot commit `8b8e7a1295` (2026-11-06 00:27 CST) rewrote `poll.py` (571 lines changed) and `claimant.py` in the same pass that left `test_poll.py` untouched (0 lines). The pre-snapshot `poll.py` (`8b8e7a1295^`) had exactly this API: `CAP = 36` (:54), `is_candidate` (:72), `parse_lease_ms` (:105), `is_stuck_bound` (:123), `is_active_root` (:164), `count_active_roots` (:181), `summarize_cap` (:185), plus repo-queue-binary `fetch_claimed`.\n\n### 2. Cap room is the active-session COUNT, in both entry points — inverted\n\n- `poll.py:244`: `cap_room = get_active_root_sessions()` — that function (:37) returns a **count** of active roots (or `None` on error). `prompt.md:62-63` and README say `cap_room = 36 − active_root_sessions`, and \"if cap_room is 0 or null, launch nothing\". With 0 active sessions poll now reports `cap_room: 0` (launch nothing, though room is 36); with 40 active it would report 40.\n- `claimant.py:347`: same assignment. `CONCURRENCY_CAP = 36` (:23) is referenced nowhere else in the file (grep count = 1, the definition). `main()` then: count `\u003c= 0` → prints \"Cap saturated … exiting\" (:354-356); otherwise \"Launching up to {count} tasks\" (:360).\n\nProbe (laptop, stubbed `requests.get`, real `claimant.py`): 0 active → count 0 → cap-saturated branch taken; 40 active (over the 36 cap) → count 40 → not saturated, launches up to 40 **more**.\n\n### 3. `poll.py` doesn't recognise the server's session shape\n\n`poll.py`'s counter requires `session.get(\"isRoot\") == True` and reads `time.idle`/`time.prompted`. The verified live shape (test fixtures, and pre-snapshot code) is root = no `parentID`/`parent_id`, activity = `time.updated` falling back to `time.created`, finished = `time.idle` or top-level `outcome`.\n\nProbe: one fresh fixture-shaped root (`time.created` 5 min ago, `time.updated` 1 min ago, no `isRoot` field) → `poll.get_active_root_sessions()` returns **0**; `claimant.py`'s differently-shaped counter returns 1 for the same session (it checks `parent_id` + `time.last_message`/`created` — a third, mutually inconsistent shape).\n\n## Why it matters\n\nThe claimant is the lane that launches opencode sessions for handed-off queue tasks. As written: an idle server reads as saturated (no launches — consistent with the symptom in #6533, handed-off tasks cycling claim → handed_off → park with `session_id` still null), and a busy server reads as having the most room (launches bounded by the active count, never by the 36 cap — the over-concurrency the cap exists to prevent, cf. #5016). The 36-test suite that pinned the correct behaviour (#3026 gate, #4758 recovery, fail-closed on an unreadable active set) is still in the tree and still named in `.github/workflows/pm-stack-tests.yml`, but every test in it errors, so the regression is invisible to anyone who doesn't run it by hand.\n\nRelated (distinct): #6533 (symptom: handed-off tasks never launched), #4757 (GET /api/session truncates at 50), #5016 (cap consumed by lane runners), #5951 (closed; CI wiring for this suite), #5400 (a different snapshot/migration-dropped claimant binding mode).\n\n## Acceptance criteria\n\n- [ ] `python3 -m unittest pm-stack/opencode-claimant/test_poll.py` passes 36/36 against the real `poll.py` (restore the test-pinned API — `CAP`, `is_active_root`, `count_active_roots`, `summarize_cap`, `is_candidate`, `parse_lease_ms`, `is_stuck_bound` — or, if the API is deliberately being replaced, rewrite the suite in the same change so a green run still pins the cap/candidate/stuck-bound rules; a suite that errors 36/36 is not a pin).\n- [ ] `cap_room` reported by `poll.py` and used by `claimant.py` is `CAP − active_root_sessions` (36 cap), is `null`/unknown — never a fabricated number — when the session list or the server active set cannot be read, and the claimant launches nothing in that case.\n- [ ] Probe check: 0 active roots → room 36 and launches proceed; 40 active roots → room 0 and no launches (today: the exact opposite in both cases).\n- [ ] Both counters recognise the same, verified live session shape (`parentID` root marker, `time.updated`/`created` activity, `time.idle`/`outcome` terminal markers) — one fresh fixture-shaped root counts as 1 in both `poll.py` and `claimant.py`.\n- [ ] The restored `poll.py` candidate/stuck-bound logic reads queue state through the repo-queue binary path the pre-snapshot version used (not the `/api/queue/\u003cqueue>/tasks` route on the OpenCode server in current `get_candidates`/`get_stuck_bound_tasks`), or documents and tests whatever route replaces it.\n","author":{"url":"https://github.com/dezren39","@type":"Person","name":"dezren39"},"datePublished":"2026-11-06T19:42:30Z","url":"https://github.com/developing-today/code/issues/6609"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:dc2fa141-886c-cdb4-395b-de4d11633a47 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | CA6A:5CA6C:288CAF:36E5E3:6B0616E3 |
| html-safe-nonce | be7f07dc692a29b4d9d0e56c45b51ea2ca1636aa830c74d8c2373ffeaa9325aa |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDQTZBOjVDQTZDOjI4OENBRjozNkU1RTM6NkIwNjE2RTMiLCJ2aXNpdG9yX2lkIjoiNDIwMzg4NzExMDU4Njk1MzkiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | fe6a1168c24613d59953b1eb8b3182dd34cf8e9792964242360e1b576baad779 |
| hovercard-subject-tag | issue:6249452988 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/developing-today/code/6609/issue_layout |
| twitter:image | https://opengraph.githubassets.com/11b8c63531c6ffd76fc0804e41f9e907809e320825bebaaf20772a2e54445e12/developing-today/code/issues/6609 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/11b8c63531c6ffd76fc0804e41f9e907809e320825bebaaf20772a2e54445e12/developing-today/code/issues/6609 |
| og:image:alt | Bug pm-stack/opencode-claimant/poll.py and claimant.py no longer implement the session-cap contract that test_poll.py, prompt.md, and README.md describe — and the claimant's cap arithmetic is inver... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | dezren39 |
| hostname | github.com |
| expected-hostname | github.com |
| None | 97d4714e567728e1f85f88b0cf68c89f0f8a3dc41e8869af7aeb8195ad990374 |
| turbo-cache-control | no-preview |
| go-import | github.com/developing-today/code git https://github.com/developing-today/code.git |
| octolytics-dimension-user_id | 26439447 |
| octolytics-dimension-user_login | developing-today |
| octolytics-dimension-repository_id | 627308783 |
| octolytics-dimension-repository_nwo | developing-today/code |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 627308783 |
| octolytics-dimension-repository_network_root_nwo | developing-today/code |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 866f202ebf7ac5aff8f633417d9fd8a53818a977 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | max-age=0, private, must-revalidate |
Viewport: width=device-width