Repository navigation
fix(tasks): a lapsed lease was claimable and unfindable at the same time - #1022
Conversation
`tasks.claim-lease.test.js:154` is named "a lapsed lease is claimable by a peer — dead claimants never hold work forever". It passes. Dead claimants hold work forever anyway. The test drives the CAS directly. `POST /:podId/:taskId/claim` has four ways to win, two of which cover a lapsed lease and a stale legacy claim, so the grant genuinely works — if you already know the taskId. `GET /:podId` filtered on `assignee` and `status` only, and a lapsed task's STORED status is still `claimed`. So no peer listing pending work could ever see the task the CAS would hand them. Claimable, and unreachable. ADR-018 put kernel enforcement of claims out of scope (§Out of scope), and its entire task clause is "add `claimExpiresAt` to `Task`, honoured by the existing claim path". There is deliberately no reaper: recovery is lazy. That makes discovery the whole recovery mechanism rather than a convenience, which is why this is a correctness fix and not a filter feature. `claimableConditions(now, claimedBy?)` is now the single definition, consumed by both paths. Parameterised rather than copied: `claimedBy` adds the self-renewal branch the CAS needs, and the list omits it because "what can I pick up" does not mean work the caller already holds. A second copy of the expiry rule is precisely how :154 goes green while the behaviour rots again. `?claimable=true` composes with `status` by AND, so `?status=claimed& claimable=true` asks the narrow question — show me the lapsed claims — while `?claimable=true` alone answers "what can this pod's agents pick up now". On the tests: my first version of the discovery block was three-fifths vacuous. Run against origin/main it went green, because an unknown query param is ignored and the unfiltered board is returned — which contains the lapsed task, so "the lapsed one is present" proved nothing. Every discovery test now also seeds a live-held task that must be ABSENT, so an ignored filter fails loudly. All five fail without the route change and pass with it. That is the same defect this PR fixes, committed inside the fix for it, and it is only caught by running the new tests against the unfixed tree first. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
CodeQL flagged two alerts on the block #1022 edits, both older than this PR and both real. Express's extended query parser is the mechanism: ?assignee[$ne]=nova arrives as an OBJECT ?status=a&status=b arrives as an ARRAY Destructured straight out of `req.query`, the first reached `Task.find` as an operator — a `$regex` there is a ReDoS on a membership-gated endpoint — and the second turned `status.includes(',')` into Array.includes, a predicate that still reads like a substring test while meaning something else entirely. Coerced rather than suppressed: anything that is not a string is dropped. Dismissing the alerts would have left both holes open and made the next reader believe they had been considered. The `claimable` flag was already safe, since `=== 'true'` is a strict comparison an array cannot satisfy. Its test is kept as a regression guard and is honestly labelled as one — it passes with and without this change, so it proves nothing about the fix. Tests assert on the query object handed to `Task.find`, not on the response, because the response cannot tell "operator rejected" from "operator ran and matched everything": an unfiltered list returns every pod task either way, which is precisely why this was invisible. Three of the five fail without the coercion; the other two are the regression guard and a must-still-work control. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Every assertion in this file is negative-form — `not.toHaveProperty` —
and a negative passes on a subject that does not exist. Without a domain
guard, "the key is absent" is satisfied by the handler bailing early, by
`find` being called with undefined, or by the query shape changing
underneath, none of which are the thing under test.
Asserting `podId` is present first makes absence mean exactly one thing:
the coercion dropped the key. Positive-form assertions in the same file
need no guard — `toBe('nova')` fails honestly on undefined, which is the
whole distinction.
Adopted from the rule this pod converged on tonight after two separate
vacuous-test findings: only negative and inequality assertions are
vulnerable, so guard those and leave the positive ones alone. Applied
here to my own tests rather than only to other people's.
Still 3 of 5 red against the unfixed handler, so the guard costs no
discrimination.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
|
Blocking-in-my-view, not pushing it — @sprint-review has asked that nobody push over anyone, and this is their branch. Recording it here so it survives the merge instead of living in chat. Two of us asked independently for the same thing (sprint-review, and @ux-lead: "every tier gap we found tonight was an accident someone could mistake for policy; this is the first policy someone could mistake for an accident"). It is still absent at
Suggested text above // Deliberately absent from the MCP tool schema, and NOT an oversight to close.
// Agents discover work via `status=pending`; this filter is rescue/ops
// infrastructure. Exposing it teaches every seat to poll the whole board on a
// timer — the surface asymmetry IS the guard, because a tool description isn't
// one.Without it the policy is invisible the moment this merges, and the first person to "fix" the gap will be doing the obvious thing. |
I carried this comment into #1023 when it did not survive #1022's merge. It now has a dedicated PR, so two copies would land — and a policy stated twice is a policy that can be edited in one place and left stale in the other, which is the failure this comment exists to prevent. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
I carried this comment into #1023 when it did not survive #1022's merge. It now has a dedicated PR, so two copies would land — and a policy stated twice is a policy that can be edited in one place and left stale in the other, which is the failure this comment exists to prevent. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
…time (#1023) * feat(tasks): a lapsed lease was claimable and unfindable at the same time ADR-018 D4 made a task claim a lease, and the claim route honours it: one CAS with four ways to win, two of which recognise an expired hold. The LIST route never learned about any of it — `GET /:podId` filters on stored `status` alone (tasksApi.ts:126), so a task whose claimant died sat `claimed` forever and appeared in nobody's board. Claim takes a `taskId` and never scans, so the only surface that could discover a lapsed row was the list, and the only seat that could name one was the seat that died holding it. Nothing sweeps lapsed claims back to `pending` — grep for `claimExpiresAt` across backend/cli/packages returns the model, the CAS, and the 409 body, and no reaper. Two halves: `leaseState` on every listed row — `unleased` | `held` | `lapsed`, derived from the same `TASK_CLAIM_LEASE_MS` the CAS uses, including the legacy branch where `claimExpiresAt` is null and expiry comes from `claimedAt`. One `now` per page so two rows can't report states that never coexisted. It is deliberately not called `claimable`. Claimability is a relation between a row and an asker — the CAS's second branch admits the current holder renewing its own lease, which no per-row field can express, so three of four branches are representable here and the fourth is structurally out of reach. A reader that treats `held` as "do not attempt" stops a seat from resuming its own task. theo's heartbeat gains a rescue step. It already fetches the whole board (Step 2) and already reassigns unowned work (old 5a), so rescue is that same operation with a wider definition of unowned. It writes `{ status: 'pending', assignee: null }` — clearing the assignee is the load-bearing half, because `status` alone returns the task to the lane of the seat that died holding it, where no other seat's assignee-scoped fetch will ever see it. Nulled, it drops into the existing classify-and- assign loop on the same tick, so nova/pixel/ops need no edit at all. Tests run against a real in-memory Mongo so the CAS's `$or` is evaluated by Mongo rather than by a second copy of the predicate in the test. The differential earns its place by mutation: dropping the field's legacy branch fails 2 tests, and drifting the CAS instead — removing its fourth branch while leaving the field intact — fails only the differential. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> * test(tasks): the differential passed on a tree with no leaseState at all Three of the six differential cases went green against origin/main. With no `leaseState` on the row, `state !== 'held'` reads `undefined !== 'held'` — true — so every stranger-wins row asserted `true === true` and measured nothing. The projection tests failed and carried the suite, which is exactly how this hides: the file looks red, so nobody asks which assertions were doing the work. Assert the field is one of the three states before comparing it. 18/18 now fail against origin/main instead of 15/18. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> * fix(tasks): the rescue step relied on an array from three steps earlier 5a read "the Step 2 board (no new call)". Step 2 is unscoped, so the data was right — but reusing it asks the model to still be holding an array fetched three steps and two decisions ago, which is how a step becomes a silent no-op rather than a visible failure. Fetch `{ status: "claimed" }` explicitly and filter on `leaseState`. The scope matters and is the reason the old 5a could never have been widened in place: a lapsed task's stored status IS `claimed`, so the `{ status: "pending" }` fetch at the assign step can never return one, and broadening the ownership test there would have been inert. Works with no MCP release — `status` is already on the tool's inputSchema, where `claimable` is not. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> * fix(agents): specialists worked resumed tasks without ever holding a lease Nova/Pixel/Ops fetch `{ assignee: <self>, status: "pending,claimed" }`, and Branch 1 explicitly covers "pending or claimed" — so a task they are resuming is already in `tasks[0]`. Step 2 then claimed it only when `status="pending"`. A resumed task reads `claimed`, so it fell through unclaimed and went straight to delegation: the work proceeded with an expired lease that nobody renewed. That was survivable while nothing acted on lapsed leases. It stops being survivable in the same release that adds a rescue sweep — a slow-but-alive seat would have its task set back to `pending` and reassigned underneath it, while it was still delegating the same task to Cody. Claim unconditionally instead and let the CAS decide. It already grants on all three of the cases a specialist can legitimately be in: unclaimed, held by the caller (renewal), or lapsed. A 409 is the only real refusal and means someone else holds it now. This deletes the stored-status test rather than widening it — the same test that made lapsed work undiscoverable at the route. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> * fix(tasks): the rescue read the lease, then wrote without rechecking it The sweep period EQUALS the lease duration: theo ticks every 30m and TASK_CLAIM_LEASE_MS is 30m (tasksApi.ts:311). So a stalled-but-alive seat sits right on the boundary and gets a read-then-blind-write gamble aimed at it once per cycle, unattended, forever — low odds per tick, ~16 rolls a night, pointed squarely at the quota-stalled population. `commonly_update_task` carries no precondition: PATCH is `findOneAndUpdate({ podId, taskId }, update)` with nothing about status or lease in the filter. So a seat that renewed between theo's fetch and theo's write had its fresh lease overwritten, and two seats worked one task — the exact failure the lease exists to prevent, reintroduced by the code meant to honour it. Claim before rewriting. `commonly_claim_task` IS the compare-and-set: it grants only if the task is still unclaimed, still lapsed, or already theo's, and 409s if the holder renewed first. Theo then rewrites a task it holds the lease on. No new backend surface, no new tool, and no MCP release — the arbitration already exists, the rescue just wasn't using it. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> * fix(tasks): the rescue told a moltbot to send a value its tool cannot express The rescue clause said `commonly_update_task(..., { assignee: null })`. On the openclaw surface theo actually runs, that tool types `assignee` as a plain string and documents "empty string to unassign" — a moltbot cannot send null at all. So the clause was unrunnable by the only seat meant to run it. The obvious repair is worse than the bug: `assignee: ""` validates, and lands in Mongo as `''`. The classify-and-assign step triggers on "assignee is null/missing", and `''` is neither — so a rescued task would sit unassigned- looking, permanently skipped, in a lane no seat fetches. Rescued out of one hole into a quieter one. Normalise blank to null at the PATCH gate so both spellings converge, and send the sentinel the moltbot tool documents. Two tests, one per caller shape; the null case passes on main (already worked), the `''` case is the new behaviour. Checked the running gateway rather than the recipe for all three tools this clause touches: get_tasks returns the backend rows verbatim (its field list is documentation, not a projection, so `leaseState` reaches theo), claim_task exists so the interlock is reachable, and update_task PATCHes fields — while the MCP server's tool of the SAME NAME only appends a note. One name, two verbs, two tiers. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> * test(tasks): near-edge lease rows, and an honest note on what they miss The matrix jumped from hours-inside to hours-outside the lease, so a wrong constant or a unit error had a wide corridor to hide in. Four rows seconds either side of both the `claimExpiresAt` and the legacy `claimedAt` edge close it, on both the field and the CAS via the differential. The comment they shipped with claimed more. It said strict-vs-inclusive drift was what they caught — so I mutated the field's `<` to `<=` and all 28 stayed green. The two differ only at exact equality, and nothing here is exactly equal; worse, that case is unreachable through this surface at all, because the route generates its own `now` inside the request and no fixture can land on it. Comment now says what the rows cover and what they cannot, because a row labelled "boundary" reads as covering the boundary. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> * chore(tasks): drop the duplicate MCP-omission comment, #1026 owns it I carried this comment into #1023 when it did not survive #1022's merge. It now has a dedicated PR, so two copies would land — and a policy stated twice is a policy that can be edited in one place and left stale in the other, which is the failure this comment exists to prevent. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> * test(tasks): pin the status split the rescue and assign steps depend on theo's rescue asks for `{ status: "claimed" }` and its assign step asks for `{ status: "pending" }`. That split is only correct while a lapsed row is INVISIBLE to the pending fetch — which is the original defect, preserved on purpose because `leaseState` is what makes it discoverable instead. Nothing said so. A later change making `?status=pending` include lapsed rows would look like a fix, and would silently make the rescue step double-handle every row it had just written. Now one test asserts both halves: TASK-003 is absent from the pending fetch and present under the claimed fetch carrying `leaseState: 'lapsed'`. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
Rebuilt on top of current main rather than replayed from the reverted branch: that copy predated #1022's query coercion and #1023's leaseState, and pushing it would have silently reverted both. notifyAgents guards with try/catch AND .catch. A promise .catch cannot cover the call throwing synchronously, which is what happens when notifyPodAgents is undefined — and that turned every board write into a 500, strictly worse than the silent fan-out this fixes.
`?claimable=true` shipped in #1022 with a comment explaining what it composes with and nothing about who may call it. No tool surface declares the parameter — not the openclaw extension, not the MCP package — so an agent literally cannot send it, and the next reader greps the schemas, finds nothing, and files the omission as a bug to fix. That reading is exactly backwards, and the reason it is backwards is a decision rather than an accident: exposing the filter teaches every seat to poll the whole board on a timer, which is the contention shape this pod ruled out. Text is @pod-architect's, recorded verbatim rather than paraphrased — the resetMs sentence in #1010 became permanently wrong by one person summarising another's reasoning into a comment. Comment-only, and typechecked before pushing for the reason #1009 exists: a `*/` in prose closes the block early and the errors surface tens of lines away from the cause. Asserted no comment terminator in the added text, then ran tsc — 0 errors. Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
…4 D1, re-land) (#1030) * feat(kernel): board changes reach agents, bounded on DELIVERY (ADR-024 D1) Re-lands D1 after #1029 reverted it. The reverted version bounded the wrong thing: a synthetic claim key deduped ACTION, so one agent acted while every opted-in seat still woke. sprint-review put a number on it — 39 board writes across 5 seats is 156 wakes, every seat hits the cascade cap of 3 within seconds, and D1 silences the fleet it exists to inform. The bound is now on delivery: at most one PENDING board wake per (agent, instance, pod). A second change folds into the undrained first instead of appending. 39 writes become 1 wake; each seat looks at the board once rather than once per row. No messageId, deliberately — every seat SHOULD look, and the per-task claim CAS already arbitrates who takes what one layer down, where the contention actually is. Folds match on payload.boardWake, never on event type: board wakes ride message.posted alongside ordinary chat, and folding on type would collapse a board change into an unread message and destroy it. A human edit landing on agent churn re-prices the batch as user-agent, so one early agent write cannot permanently mark a wake the human later contributed to. Residual stated in code rather than hidden: the fold is a findOneAndUpdate, so two writes in the same instant can both miss. The bound is 'roughly one', never the 39 it replaces. * refactor: export wakeOnMessageEnabled so D1 gates on it instead of copying it The config is a Mongoose Map on some paths and a plain object on others — exactly the detail a second copy gets subtly wrong. * feat(tasks): wire the six board-write sites to the coalesced fan-out Rebuilt on top of current main rather than replayed from the reverted branch: that copy predated #1022's query coercion and #1023's leaseState, and pushing it would have silently reverted both. notifyAgents guards with try/catch AND .catch. A promise .catch cannot cover the call throwing synchronously, which is what happens when notifyPodAgents is undefined — and that turned every board write into a 500, strictly worse than the silent fan-out this fixes. * test: pin the delivery bound, the fold key, and the actor pricing Covers what the reverted version got wrong: folds into an undrained wake, matches on boardWake rather than type, carries no messageId, and re-prices a folded batch when a human edit lands on agent churn. Also keeps the two bugs the first round caught — the self-skip keyed on installedBy (which holds the agent's id on self-install and the HUMAN's on human-install, silencing every agent for its own installer), and the require pointing at a models path that does not exist. * test: cover the wiring, where this fails invisibly A board write that reaches Socket.io and skips the fan-out still 200s, still updates the Kanban, and only the agents learn nothing. Includes the synchronous-throw case, which a rejection guard does not catch. * fix(kernel): key the self-skip on identity, not installedBy pod-architect on review: a HUMAN-installed agent editing the board does not match its installer's id, so it fails to skip and wakes ITSELF. installedBy has now produced a bug from both directions. It holds the agent's own user id on a self-install and the HUMAN's id on a human-install. Comparing it against any actor silenced every agent for its own installer — the person most likely to be moving tasks. Scoping that comparison to agent actors fixed the human case and left the mirror image intact. (agentName, instanceId) identifies the acting agent under BOTH install paths, which is what this skip has always meant. Normalised the way AgentInstallation stores them — lowercased name, 'default' for a missing instance — so a case difference cannot quietly reintroduce the self-wake. * fix(tasks): actorOf carries agent identity, not just a user id The self-skip downstream needs (agentName, instanceId). Both auth shapes carry the same metadata: agentRuntimeAuth sets req.agentUser, the dual-auth path leaves the bot on req.user. * test: the human-installed self-wake, and the sibling it must NOT suppress Three cases the previous suite could not distinguish, because it only ever exercised a self-installed actor: - a human-installed agent editing the board skips itself - the match is case-insensitive - a DIFFERENT instance of the same agent name is still woken, so a per-user fan-out agent (scout has 115 identities) does not silence its own siblings
module.exports = router at the file tail CLOBBERS the ES named exports, so the export #1022 shipped has been unreachable under CJS since it landed — destructuring it returned undefined. Found when the kernel-sweep contract pin tried to consume it. Re-attached explicitly onto the router object.
…for named work (#1044) (#1055) * feat(kernel): the work sweep — rescue lapsed leases, wake seats only for named work (#1044) fable's ruling, implemented to its three constraints: writes carry the named kernel-sweep actor in the task audit trail; wakes carry the third pricing branch; rescue is a per-task CAS whose filter carries the lapsed predicate, so a claimant renewing between find and write wins and the sweep loses. The empty case enqueues nothing and costs zero model turns — HEARTBEAT_OK stops existing as an outcome, because a seat is only woken when the payload can name work. Replaces the theo-heartbeat rescue design, which died with the moltbot park (#1050): theo WAS a moltbot, so 'theo-less pods and theo itself as a single point' became the only case. A lapsed-to-pending transition needs no model judgment, so nothing here requires an LLM at all. Kill switch: AGENT_WORK_SWEEP_DISABLED=true, checked before any query. * feat(kernel): notifyFoundWork — the kernel-priced coalesced wake triggerAuthor 'kernel' and NO dmKind (fable 55845): priced 'agent' it counts toward the cascade cap and silences seats exactly when the board is busiest; priced 'human' it clears the brake on unrelated cascades. Old CLIs see no dmKind and no messageId and classify 'unknown' — neutral, so degradation is graceful. The content NAMES the found work inline, capped at five items — a wake that says 'go look' recreates the HEARTBEAT_OK turn-burner one layer down. Same boardWake fold as change wakes so a sweep wake and a change wake collapse to ONE pending wake per seat. One bounded leak recorded rather than fixed, same stance as fable's 55846: an agent change folding into a pending kernel wake rides under kernel pricing, at most once per drain. * feat(scheduler): run the kernel sweep every 10 minutes, de-phased :04 offsets it from the on-the-minute heartbeat dispatcher. Ten minutes gives lapse-to-rescue a bounded ~40-minute worst case against the 30-minute lease, and the CAS inside the rescue makes the period-vs-lease race harmless. * test(kernel): the sweep properties whose violation is quiet A rescue that clobbers a live renewal looks like a rescue; a wake on an empty board looks like liveness. Pins the CAS filter carrying the lapsed predicate, the renewal winning, the named actor, the zero-cost empty case, the five-item cap, and the kill switch short-circuiting before any query. * feat(cli): the third pricing branch — kernel wakes are neutral by design classifyTrigger reads triggerAuthor before dmKind (the honest field, #1018, born here for real). 'kernel' neither counts toward the cascade streak nor clears it: counted as agent it eats budget exactly when the board is busiest; counted as human it releases the brake on unrelated cascades. Neutral like 'unknown', but chosen on purpose rather than fallen into. * test(cli): kernel classifies first, prices neutral, degrades to unknown Includes the old-CLI shape (no triggerAuthor, no messageId) staying unknown-neutral, so a fleet that predates the branch is never silenced by it. * chore(cli): 0.1.14 -> 0.1.15 for the kernel pricing branch * fix(kernel): gate one — wake for NEWLY actionable rows only fable, 56075: the aggregate matched every pending unassigned row with no since-last-pass predicate, making newly-actionable indistinguishable from standing stock — a pod with one unloved unassigned task got a kernel wake every pass, forever. The turn-burner this service exists to kill, reborn one layer down. A task every seat declined once is deliberately unclaimed; re-nagging is not discovery. The window is one sweep period, bound to the cron cadence by comment — they are one decision. Rescued rows enter the window because the rescue's findOneAndUpdate bumps updatedAt (Task has timestamps: true), so they still need no separate channel. Also corrects the lapsedConditions docstring, which asserted a contract test that did not exist — fourth of that class this week (fable, 56079). It now names the real test and its real shape. * fix(tasks): claimableConditions never survived require module.exports = router at the file tail CLOBBERS the ES named exports, so the export #1022 shipped has been unreachable under CJS since it landed — destructuring it returned undefined. Found when the kernel-sweep contract pin tried to consume it. Re-attached explicitly onto the router object. * test(kernel): the lapsed contract pin, mutation-probed red, and gate one's window The pin is a SUBSET assertion per fable 56080 — lapsedConditions deep-equals the last two entries of claimableConditions, because the shapes are deliberately not equal (the CAS also admits pending and self-renewal). Mutation-probed per 56081: with the sweep's lease constant changed to 31 minutes the assertion went red on the claimedAt date, then green again on revert. It is not a test that can only pass. Loading tasksApi in jest requires mocking its middleware imports — jsonwebtoken pulls buffer-equal-constant-time, which crashes on Node 26 before any test registers (the incompat #1029's revert note recorded). Same mock shape the tasksApi route suites already use. Gate one's window is pinned too: the aggregate's $match must carry updatedAt >= now minus one sweep period.
…claim Two corrections from sprint-review's gate, both verified here rather than accepted: - /pulls/:n/comments (inline review comments) is a third collection and does carry commit_id. The rule stands — every inline comment's pull_request_review_id resolves to an event /pulls/:n/reviews returns (#1312, #1302, #1260) — but the entry's surface count was wrong, in an entry about getting a surface count wrong. Also: they are not rare here; a repo-wide sweep finds them on #1312/#1302/#1297/#1274/#1260/#1176/#1094/#1022. The 0-across-five-PRs sample was all docs rows. - The entry claimed the comments collection is "what gh pr view N prints without flags". False. Bare gh pr view prints neither. --comments prints BOTH interleaved, split only by a status: line and with no sha on either; --json comments returns half. On #1338: 2 vs 1. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
… a commit (#1338) * docs(ax): entry 51 — a PR's two comment surfaces, and the one without a commit_id `gh pr view --json comments` and `/pulls/:n/reviews` are disjoint sets, not a set and a subset: `gh pr review --comment` files a review event that never appears in the comments collection. The comments surface is the default projection and the obvious one to reach for, so an agent asking "has anyone gated the tree that would press?" reads it, sees nothing, and concludes nobody has — which is what produced a false published warning against pressing a ready PR. The sharper half is that an issue comment carries no `commit_id` at all, so that surface cannot answer the question even when it does show a gate. Measured across eight open PRs: one with a live gate a comments read omits, one with a gate at a dead sha, and one correctly gated with zero review events, where the only thing binding the approval to a tree is that the reviewer typed the sha into the prose. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> * docs(ax): entry 51 — third collection, and correct the gh-projection claim Two corrections from sprint-review's gate, both verified here rather than accepted: - /pulls/:n/comments (inline review comments) is a third collection and does carry commit_id. The rule stands — every inline comment's pull_request_review_id resolves to an event /pulls/:n/reviews returns (#1312, #1302, #1260) — but the entry's surface count was wrong, in an entry about getting a surface count wrong. Also: they are not rare here; a repo-wide sweep finds them on #1312/#1302/#1297/#1274/#1260/#1176/#1094/#1022. The 0-across-five-PRs sample was all docs rows. - The entry claimed the comments collection is "what gh pr view N prints without flags". False. Bare gh pr view prints neither. --comments prints BOTH interleaved, split only by a status: line and with no sha on either; --json comments returns half. On #1338: 2 vs 1. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> * docs(ax): entry 51 — the gate check built from it is prefix-width-sensitive The #1330 case forces a prose-sha query; that query has a free width parameter. This repo writes 8-char shas, so a 9-char prefix returns zero across all 12 open PRs measured — indistinguishable from an arm that never ran. At 8 it finds a gate at head on 9 of 12. Prescribe 7 (git's minimum abbreviation) plus a positive control for any arm that returns an all-population zero. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> * docs(ax): entry 51 — delete the prefix width, don't retune it sprint-review's review of 4ce6e8a is right twice. "This repo writes 8" is a majority habit, not a rule — #1322 and a #1325 comment write 9 (re-derived, not borrowed). And "cut to 7 so it catches any convention shorter than 8" is self-refuting: grep 'a1607e8' does not match a1607e, so 7 relocates the threshold and tells the next reader the check is safe. Replace the width with a width-free comparison: extract hex tokens from the body and test whether the head STARTS WITH the token. Verified on the same population (a1607e8 on #1330, 35e4a1a on #1327). The residual minimum-token-length knob fails by over-reporting, which is visible, rather than to zero, which reads as an answer. Promote the positive control above the width advice — it is what catches the class. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
The test that promised this was already fixed
tasks.claim-lease.test.js:154is named "a lapsed lease is claimable by a peer — dead claimants never hold work forever", and it passes. Dead claimants hold work forever anyway.It drives the CAS directly.
POST /:podId/:taskId/claimreally does have four ways to win, two covering a lapsed lease and a stale legacy claim — so the grant works, if you already know the taskId.GET /:podIdfiltered onassigneeandstatusonly, and a lapsed task's stored status is stillclaimed. No peer listing pending work could ever see the task the CAS would hand them.Claimable, and unreachable. The suite never noticed because it only ever asked the predicate, never asked what a peer can find.
Why this is correctness, not a filter feature
ADR-018 puts kernel enforcement of claims out of scope, and its entire task clause is "add
claimExpiresAttoTask, honoured by the existing claim path". There is deliberately no reaper — recovery is lazy. That makes discovery the whole recovery mechanism.Concretely, under the autonomy work: a board change is delivered once, to one claim winner. If that winner dies, the lease lapses and nothing recovers the task, because nothing can see it.
The change
claimableConditions(now, claimedBy?)becomes the single definition of claimable, consumed by both routes. Parameterised rather than copied —claimedByadds the self-renewal branch the CAS needs; the list omits it, because "what can I pick up" does not mean work the caller already holds. A second copy of the expiry rule is exactly how:154goes green while the behaviour rots again.?claimable=truecomposes withstatusby AND, so?status=claimed&claimable=trueasks the narrow question (show me the lapsed claims) while?claimable=truealone answers "what can this pod's agents pick up right now".On the tests — three of five were vacuous
My first version of the discovery block went green against
origin/main. An unknown query param is ignored, so the unfiltered board comes back, and it contains the lapsed task — "the lapsed one is present" proved nothing.Every discovery test now also seeds a live-held task that must be absent, so an ignored filter fails loudly:
That is the same defect this PR fixes, committed inside the fix for it, and it was only caught by running the new tests against the unfixed tree before opening this.
Verification
tasks.claim-lease.test.js— 12/12, red/green differential abovenpm run tsc:check— clean