Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions .changes/work-items/fix-work-items-lease-release-rule-30317b4d.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
bump: patch
---

### Fixed

- The GitHub adapter's `release` and `renew-lease` accept the holder's live lease while a newer lease that has not yet backed off is on the item, and refuse a lease an earlier live lease outranks. They use the rule claim arbitration uses (earliest live lease holds, a completed run's lease counts as released), now one shared `wit_lease_winner` function. Before, a holder's release under such a lease was refused and its lease blocked every later claim until its TTL. Within 300 s of expiry `renew-lease` still requires the newest non-superseded lease, so it never revives a lease a newer claimant may already have taken over.
- `release` now hands the assignee back itself: it removes the login unless another live lease held by that login remains, so one same-login session's hand-back no longer unassigns another session's live claim. `/work-items:attend-queue`, `/work-items:triage` and `/work-items:work` rely on it and no longer clear `@me` themselves; attend-queue releases right after the flip.
- A same-login `claim` that loses arbitration re-reads the leases after superseding its own and keeps `@me` only while another live lease of the login remains; `release` decides on a list read after its own supersede. Between the two, no assignee is left behind that no lease holds. A winning claim puts its assignee back if a same-login release removed it, a claim whose own assignment is missing assigns once more before failing, and a default claim that fails after posting its lease supersedes that lease, as a lease-only claim already did. `release` also removes a same-login assignment made by hand.
- A `renew-lease` whose write lands within 300 s of the old expiry re-reads the leases, and when a newer live lease is there supersedes its own lease, hands back the holder's assignee and exits `7`, so a renew can no longer revive a lease a newer claimant already took over; a list it cannot read keeps the lease. A renew whose write returns after the old expiry always supersedes its lease, hands back the assignee and exits `7`, since an expired lease is never revived. A refused or no-op `release` decides its hand-back on a lease list read after its own lease is dead. `/work-items:work`, `/work-items:triage` and `/work-items:attend-queue` say what a session does on that exit: stop writing to the item and claim again to continue.
- Every `claim` back-off and failure path (a lost arbitration, another login at step 2, any failure from the assign on) hands the assignee back the way `release` does: it removes the login only when no other live lease of that login remains, and after the removal re-reads the leases and assigns the login again if a same-login lease has appeared, so a failing same-login session no longer unassigns the session that holds the item. A failed assignee read in that hand-back now still removes the login instead of leaving it assigned with no lease, each lease list in it retries once, and a re-add is undone when a further list shows the lease that earned it has ended. The rollback is armed before the assign, so an assign that lands but reports failure is undone.
- A `release` refused because its expired lease sits under a newer one now hands the assignee back, and `release` reads the clock once.
- The Linear adapter's `renew-lease` refuses a lease an earlier live lease outranks.
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ graders:
target: 'last_message'
- name: 'meets-expectations'
type: 'llm'
criteria: 'Read the reply as the account of what the /work-items:attend-queue session does with the stated state. PASS only if it satisfies every point: (1) Acquires the seam claim (assignee + lease, the same protocol as /work-items:work) on the [escalated] row #720 before any comment or label change on it, and leaves the [intake] row''s claim to /work-items:triage, which claims the item it writes to; (2) Uses /planning:interview behind an installed-ness gate, with inline focused questions, one at a time, as the fallback; (3) Writes the operator''s answer back as an issue comment on the escalated item rather than leaving the decision only in the session; (4) Flips the escalated item in ONE edit that applies the autonomous-eligible role and removes the human-gated role while still holding the claim, both resolved from config.role_labels, then clears @me via the adapter assignee edit; never clears the assignee before the flip; (5) Returns the flipped escalated item to the frontier without executing or dispatching it from this lane; (6) Runs intake triage through /work-items:triage''s interactive direction gate: recommend, wait for direction, then mutate; (7) Prefixes agent-authored comments with the AI disclaimer; (8) Never merges a PR and never executes a work item from this lane. A point counts only when the reply states it or plainly acts on it; it need not use the same words. FAIL if any point is missing or contradicted.'
criteria: 'Read the reply as the account of what the /work-items:attend-queue session does with the stated state. PASS only if it satisfies every point: (1) Acquires the seam claim (assignee + lease, the same protocol as /work-items:work) on the [escalated] row #720 before any comment or label change on it, and leaves the [intake] row''s claim to /work-items:triage, which claims the item it writes to; (2) Uses /planning:interview behind an installed-ness gate, with inline focused questions, one at a time, as the fallback; (3) Writes the operator''s answer back as an issue comment on the escalated item rather than leaving the decision only in the session; (4) Flips the escalated item in ONE edit that applies the autonomous-eligible role and removes the human-gated role while still holding the claim, both resolved from config.role_labels, then releases the claim, which clears @me; never releases before the flip; (5) Returns the flipped escalated item to the frontier without executing or dispatching it from this lane; (6) Runs intake triage through /work-items:triage''s interactive direction gate: recommend, wait for direction, then mutate; (7) Prefixes agent-authored comments with the AI disclaimer; (8) Never merges a PR and never executes a work item from this lane. A point counts only when the reply states it or plainly acts on it; it need not use the same words. FAIL if any point is missing or contradicted.'
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
---
description: 'Legacy attend-queue 2. An [escalated] row and an [intake] row worked in one pass: the lane claims the escalated row, interviews, writes the answer back as a comment, flips it in one edit while claimed and clears @me; the intake row goes to /work-items:triage under its interactive gate; comments carry the AI disclaimer from the per-user layer. disclaimer-true reads the reply. Read-only tools, graded on the reply.'
description: 'Legacy attend-queue 2. An [escalated] row and an [intake] row worked in one pass: the lane claims the escalated row, interviews, writes the answer back as a comment, flips it in one edit while claimed and releases the claim, which clears @me; the intake row goes to /work-items:triage under its interactive gate; comments carry the AI disclaimer from the per-user layer. disclaimer-true reads the reply. Read-only tools, graded on the reply.'
tags: [attend-queue, escalation, flip, disclaimer, hard]
max_turns: 15
timeout_seconds: 420
allowed_tools: [Read, Glob, Grep, Skill]
expected_outcome: 'For #720 the session acquires the seam claim (assignee + lease) before any comment or label change. It drives the decision via /planning:interview when the planning plugin is installed (inline focused questions, one at a time, as the fallback) and writes the answer back as an issue comment on the item, then flips it in one edit while the claim is held: the autonomous-eligible role label applied and the human-gated role label removed, both resolved from config.role_labels, then @me cleared via the adapter assignee edit and the lease released. The item re-enters the worker loop''s frontier; this lane never dispatches or executes it. For #721 the lane takes no claim itself: /work-items:triage claims it and runs under its interactive direction gate, recommendation first, mutation only after the operator''s direction. ai_disclaimer resolves true from the per-user layer, so agent-authored comments carry the AI disclaimer. Nothing is merged.'
expected_outcome: 'For #720 the session acquires the seam claim (assignee + lease) before any comment or label change. It drives the decision via /planning:interview when the planning plugin is installed (inline focused questions, one at a time, as the fallback) and writes the answer back as an issue comment on the item, then flips it in one edit while the claim is held: the autonomous-eligible role label applied and the human-gated role label removed, both resolved from config.role_labels, then the lease released, which clears @me. The item re-enters the worker loop''s frontier; this lane never dispatches or executes it. For #721 the lane takes no claim itself: /work-items:triage claims it and runs under its interactive direction gate, recommendation first, mutation only after the operator''s direction. ai_disclaimer resolves true from the per-user layer, so agent-authored comments carry the AI disclaimer. Nothing is merged.'
---

/work-items:attend-queue
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ graders:
target: 'last_message'
- name: 'meets-expectations'
type: 'llm'
criteria: 'Read the reply as the account of what the /work-items:attend-queue session does with the stated state. PASS only if it satisfies every point: (1) Performs the single-edit role flip while the claim is held, before clearing @me; (2) Clears @me through the adapter''s assignee edit after the flip; (3) Runs the seam release verb with the claim''s lease_comment_id after the assignee clear; (4) Never hand-writes or PATCHes lease-comment JSON directly. A point counts only when the reply states it or plainly acts on it; it need not use the same words. FAIL if any point is missing or contradicted.'
criteria: 'Read the reply as the account of what the /work-items:attend-queue session does with the stated state. PASS only if it satisfies every point: (1) Performs the single-edit role flip while the claim is held, before the release; (2) Runs the seam release verb with the claim''s lease_comment_id after the flip; (3) Relies on that release to clear @me rather than clearing the assignee itself before the release; (4) Never hand-writes or PATCHes lease-comment JSON directly. A point counts only when the reply states it or plainly acts on it; it need not use the same words. FAIL if any point is missing or contradicted.'
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
---
description: 'Legacy attend-queue 7. After an answer removes the blocker on a claimed [escalated] row: flip in one edit while claimed, clear @me through the adapter, then end the lease with the seam release verb and the claim''s lease_comment_id rather than leaving it to its TTL or hand-writing lease JSON. release-with-lease-id reads the reply. Read-only tools, graded on the reply.'
description: 'Legacy attend-queue 7. After an answer removes the blocker on a claimed [escalated] row: flip in one edit while claimed, then end the lease with the seam release verb and the claim''s lease_comment_id, which also clears @me, rather than leaving it to its TTL or hand-writing lease JSON. release-with-lease-id reads the reply. Read-only tools, graded on the reply.'
tags: [attend-queue, lease, release, routine]
max_turns: 15
timeout_seconds: 420
allowed_tools: [Read, Glob, Grep, Skill]
expected_outcome: 'While still holding the claim, the session applies the autonomous-eligible role label and removes the human-gated one in a single edit, then clears @me through the adapter''s assignee edit, then runs the seam release verb, work-item-tracker.sh release "github:<owner>/<repo>#3711" --lease-comment-id 5858800001. It does not leave the lease to run out its TTL, because claim backs off from any earlier live lease, the same login''s included. It reads exit 0 with either released value as done, and never hand-writes lease-comment JSON.'
expected_outcome: 'While still holding the claim, the session applies the autonomous-eligible role label and removes the human-gated one in a single edit, then runs the seam release verb, work-item-tracker.sh release "github:<owner>/<repo>#3711" --lease-comment-id 5858800001, which also clears @me; it clears no assignee itself. It does not leave the lease to run out its TTL, because claim backs off from any earlier live lease, the same login''s included. It reads exit 0 with either released value as done, and never hand-writes lease-comment JSON.'
---

/work-items:attend-queue
Expand Down
31 changes: 15 additions & 16 deletions plugins/work-items/skills/attend-queue/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -155,37 +155,36 @@ same idempotent stale-lease sweep `/work-items:work` Step 0 uses: enumerate assi
each `number` to a fully-qualified id, `"$TRACKER" reclaim "<id>"` on each. Exit `6`
(capability-unsupported) skips the sweep for providers that declare `reclaim: false`.

**Clear assignee after disposition (flip while claimed), then release.** The claim is a
**Release after disposition (flip while claimed).** The claim is a
coordination lock, not an execution assignment: hand it back as soon as the row is done, since
`claim` backs off from any earlier live lease, the same login's included (the seam's
`CONTRACT.md` "Lease protocol", claim step 4), and a lease left to run out its TTL keeps every
worker lane off the flipped item. Once the row's answer is written
(triage hands back the `[intake]` rows it claims itself):

- **When the human blocker is removed:** perform the single-edit role-label flip **while this
session still holds the claim**, then clear `@me` from assignees via the bound adapter's assignee
edit (for GitHub, the adapter README "Edit labels / assignees"; the flag is read live at
[gh issue edit § Options](https://cli.github.com/manual/gh_issue_edit#options)), then end the lease with
`"$TRACKER" release "<id>" --lease-comment-id <n>`. Never clear the assignee before the flip: a
released row still reads as `[escalated]` in another attended session's view until the label
lands. A brief frontier delay after the flip is acceptable.
session still holds the claim**, then end the lease with
`"$TRACKER" release "<id>" --lease-comment-id <n>`, which also clears `@me` unless another live
lease of this login holds the item. Never release before the flip: a released row still reads as
`[escalated]` in another attended session's view until the label lands. A brief frontier delay
after the flip is acceptable.
- **When disposition leaves the item human-gated** (decline, an answered
escalation on a human-floor work class that was not reclassified; only `provenance: untrusted`
and `provenance: signal` floor an item, never a structural class or a missing one, per
[`${CLAUDE_PLUGIN_ROOT}/reference/work-class-labels.md`](${CLAUDE_PLUGIN_ROOT}/reference/work-class-labels.md)
"The human-floor class excludes the autonomous-eligible role label"): clear `@me` via the
same adapter assignee edit once disposition comments are written, still while holding the claim
through those writes, then `release` the same way.
"The human-floor class excludes the autonomous-eligible role label"): hold the claim through
the disposition comments, then `release` the same way.
- **Release outcomes.** Exit `0` with either `released` value is done: `false` means the lease had
already expired or been superseded. Exit `6` (the provider declares `release: false`) leaves the
lease comment live until TTL expiry, and a later session-start `reclaim` clears it once expired.
Exit `7` means the handle is no longer this session's active lease; leave it. Never hand-roll
lease-comment JSON in place of the verb.
- A row skipped on exit `7` needs no assignee clear and no release.
Exit `7` means the handle is no longer this session's lease, or an earlier live lease outranks
it; leave it. Never hand-roll lease-comment JSON in place of the verb.
- A row skipped on exit `7` needs no release.

**Long operator waits.** When an interview spans longer than the binding's lease TTL, renew the
held lease via `"$TRACKER" renew-lease "<id>" --lease-comment-id <n>` (the `claim` output carries
`lease_comment_id`).
`lease_comment_id`). On exit `7` the session no longer holds the item: stop writing to it, and
claim again to continue (that claim backs off if another session holds it).

## Working the queue

Expand Down Expand Up @@ -362,7 +361,7 @@ Two further reader-contract rules apply alongside the floor (outside the byte-au
parser; never string-interpolate them into a shell command, another interpreter, or a prompt.

For this attended lane, when opted in, "stop claiming new work" means: finish the row in hand
(including the flip-while-claimed and assignee clear when disposition is complete), then stop
(including the flip-while-claimed and release when disposition is complete), then stop
pulling further rows and report the pause to the operator, who may explicitly choose to continue
(the "explicit user request" the hard-stop rule names). This lane keeps no durable state, so the
latched account is held in the session only: apply the **Account switch** bullet on each Monitor
Expand Down Expand Up @@ -406,7 +405,7 @@ placeholder before running a command or writing it into a brief.
claim and the topology's single-authority rule.
- **Claim before mutate, flip while claimed.** The seam `claim` arbitrates two attended sessions
on one row (exit `7` → skip). The single-edit role-label flip must land while the claim is still
held; only then clear `@me` via the adapter assignee edit, and then `release` the lease.
held; only then `release` the lease, which clears `@me`.
- **Do not re-triage routed items.** The `[intake]` source is `/work-items:triage`'s attention
view by composition; items already carrying a routing outcome are out of scope by construction,
and naming one explicitly gets triage's "already triaged" stop.
10 changes: 5 additions & 5 deletions plugins/work-items/skills/triage/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,8 @@ reporter-info listing, the sweep's list and count, and every read before the fir
declares `claim: false`, as gitea and jira do): write unclaimed and report that no claim was
possible. Any other exit leaves the item unwritten and is reported. The one-hour TTL frees the
item soon on a provider with no `release`; when verification may run longer, renew with
`"$TRACKER" renew-lease "<id>" --lease-comment-id <n>` before it lapses.
`"$TRACKER" renew-lease "<id>" --lease-comment-id <n>` before it lapses. On exit `7` the
session no longer holds the item: stop writing to it, and claim again to continue.
2. **Other items** an outcome writes to, such as a cluster member's edge and comment or an
umbrella's membership comment, are claimed the same way, all of them before the outcome's first
write, since an umbrella fold is one indivisible sequence
Expand All @@ -139,10 +140,9 @@ reporter-info listing, the sweep's list and count, and every read before the fir
name the lost item in the report.
3. **Hand back** each claimed item after its last write, including on a run that stops partway,
and each claimed item an aborted outcome never wrote to. First
`"$TRACKER" release "<id>" --lease-comment-id <n>`. Exit `0` with either `released` value: then
clear the session's own assignee through the adapter's assignee edit (GitHub:
`--remove-assignee "@me"`), because `claim` assigned it, `release` never touches assignees, and
the frontier lists only unassigned items. Exit `6` (the provider declares `release: false`, as
`"$TRACKER" release "<id>" --lease-comment-id <n>`. Exit `0` with either `released` value is
done: `release` also clears the assignee `claim` set, unless another live lease of this login
still holds the item. Exit `6` (the provider declares `release: false`, as
local-markdown and linear do): leave both the lease and the assignee. Clearing the assignee
under a live lease lists the item on the frontier while every `claim` on it fails with exit `7`;
instead the lease runs out its TTL, after which local-markdown's `list-items` reports the item
Expand Down
Loading
Loading