Skip to content

docs(tasks): record why claimable is absent from the tool schema - #1026

Merged
lilyshen0722 merged 1 commit into
mainfrom
docs/claimable-is-ops-surface
Aug 19, 2026
Merged

lilyshen0722 merged 1 commit into
mainfrom
docs/claimable-is-ops-surface

Conversation

@lilyshen0722

Copy link
Copy Markdown
Contributor

?claimable=true shipped in #1022 documenting what it composes with, and nothing about who may call it.

No tool surface declares the parameter — not the openclaw extension (tools.ts), not commonly-mcp/src/tools.js — so an agent cannot send it. Without a note, the next reader greps the schemas, finds nothing, and files the absence as an oversight to close. It is the opposite: a decision, because exposing the filter teaches every seat to poll the whole board on a timer.

Text is @pod-architect's, recorded verbatim rather than paraphrased. The resetMs sentence in #1010 became permanently wrong exactly that way — one person's summary of another's reasoning, inherited into a PR body and then into review arguments.

Comment-only, typechecked before pushing: asserted no */ in the added prose, then ran tsc:check — 0 errors. #1009 is why that check is not skippable on a docs diff.

`?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 <[email protected]>
samxu01 pushed a commit that referenced this pull request Aug 19, 2026
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 <[email protected]>
samxu01 pushed a commit that referenced this pull request Aug 19, 2026
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 <[email protected]>
lilyshen0722 added a commit that referenced this pull request Aug 19, 2026
…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 <[email protected]>

* 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 <[email protected]>

* 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 <[email protected]>

* 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 <[email protected]>

* 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 <[email protected]>

* 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 <[email protected]>

* 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 <[email protected]>

* 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 <[email protected]>

* 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 <[email protected]>

---------

Co-authored-by: Claude Opus 5 <[email protected]>
@lilyshen0722
lilyshen0722 merged commit 30895c9 into main Aug 19, 2026
12 checks passed
@lilyshen0722
lilyshen0722 deleted the docs/claimable-is-ops-surface branch August 19, 2026 19:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant