Repository navigation
fix(goals): split-to-roster counts a turn parked on its piece's wait gate as ended (FIX-2124) - #3714
Conversation
…gate as ended (FIX-2124) Leg 1's waiting-while-b-works read A's turn as ended only once its request finalized. Since FIX-2082 the agent waits on its piece with getTask, which parks the request on the piece's wait gate: it runs nothing and holds no lease, but never finalizes before B ends, so the leg read B ending first. A turn now ends when its request finalized (task waitingOn filed) or parked on the wait gate of B's piece (request suspended, the piece's wait slot naming it; task waitingOn wait). The read then waits for nothing to run in A's task session while B still works, since the board's own short pass can follow a park. A request still in progress until B ends still fails it, which the new hold-session control shows. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VaN4uTiYqiabCbsFLWM52A
…s controls (FIX-2124) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VaN4uTiYqiabCbsFLWM52A
|
The latest updates on your projects. Learn more about Vercel for GitHub. 3 Skipped Deployments
|
Bugbot couldn't run - usage limit reachedBugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit. A user or team admin can review and increase usage limits in the Cursor dashboard. (requestId: c40e1d0d-2e78-4133-af55-01e920a9ae11) |
jhoffner
left a comment
There was a problem hiding this comment.
Stand-in review (correctness and restraint). Nothing blocking.
- The promise is kept, and the check is no weaker. A parked turn counts only when the piece's wait slot names A's request and isn't lapsed. Any other
suspendedrequest doesn't count. Two cases still fail: a request stillin_progress, and anything still running in A's session when B ends. The expectedwaitingOnfollows how the turn ended (filedorwait). - The new
hold-sessioncontrol fails exactly1:waiting-while-b-works, so the red state can be re-checked. - 🟣 Two controls stale on main.
first-answerno longer reddens1:report-is-output, andwake-coordinatorno longer reddens4:desk-hears-tasks-only. Both predate this PR (FIX-2082), and goal.md records them. They're filed as a follow-up on the epic, not here.
Generated by Claude Code
There was a problem hiding this comment.
Simplify review (FIX-2124)
Scope: Two files only (goal.md, run.mts) — appropriately narrow for “leg 1 must treat a getTask park as turn-ended.” No production/runtime changes.
Did the approach go too far?
No on the core fix. After FIX-2082, the default model parks on the piece wait gate (suspended, waitingOn: wait) instead of finalizing the work request. Grading only finalizedAtMs was the bug; extending the read to “finalized or parked on this piece’s slot” matches conversation-board-wait / wait-slot contracts. The extra “session quiet” loop after turn-end is not gold-plating — the verdict log’s ~140 ms board dispatch pass after park is a real race if you snapshot too early.
Alternatives considered (and why this PR is reasonable):
| Alternative | Why not (for this issue) |
|---|---|
Finalize the request when parking on getTask |
Product semantics change; goals should observe store truth |
Treat any suspended / waitingOn: wait as ended |
Too loose — wrong request or lapsed slot |
Move logic into @flow-state-dev/workforce or vitest split-harness |
Wrong layer: this goal needs real hireWorkforce + HTTP + model; harness is for scripted splits |
Where complexity crept in (optional follow-ups, not blockers):
- Comment weight — Leg 1’s block comment (~lines 315–325) largely duplicates
goal.mdleg 1. One line pointing at the spec would shrink the diff without losing intent. - Poll loop I/O — Per 25 ms tick you sometimes call
store.rows()three times andstore.requests(own)twice with items. For a goal script this is fine; if leg 1 ever feels slow, reuse onerowssnapshot per iteration and poll requests withwithItems: falseuntil the post-quiet()assertion that needs tool output. - Local structure — A tiny
turnEnded(turn, piece, runId) → 'finished' \| 'parked' \| undefined(same predicates as today) would shorten the loop;busyvsduring.busyis a loose state machine but readable enough. hold-sessionpatch —KEEPER_HOLD_MS + 2_000inlined in the patch string is brittle; a named constant besideKEEPER_HOLD_MSwould document the “2 s past B’s hold” contract.
Controls
hold-session— Good negative control for the new invariant; keep it.first-answer— Honestly documented as not isolating when A answers via resumed parked wait (patch never hitsnoteTaskAnswer). I’d treat that as a follow-up test-design item (retire, narrow, or add a path-specific control), not a reason to block this fix.wake-coordinator— Verdict log shows failure onmaintoo (desk hand-over); pre-existing, out of scope here.
Reuse / packages
No new cross-package imports; no third-party helper buys much here. If a second workforce goal needs the same “turn ended (finalize or park) + session quiet” poll, then extract to goals/lib — not worth it for one consumer.
Performance
Goal-only polling; no production hot-path concern.
Verdict: Approve. The right layer (goal grading), the right semantics (parked turn counts as ended + session quiescence), and the hold-session control backs the new read. Optional nits above are polish, not a simpler approach.
Sent by Cursor Automation: Review For Best Approach
| @@ -300,11 +314,28 @@ await runGoal(async (failures) => { | |||
| const taskId = await fileForA(ask("release", B)); | |||
| // While B works: A's task running, waiting on its piece, and nothing | |||
There was a problem hiding this comment.
Simplify nit: this block largely restates goal.md leg 1 (finished vs parked, session quiet). Consider one line here (“see goal.md leg 1”) and keep the normative wording in the spec only — easier to maintain when the read evolves again.
| const turn = own === undefined || runId === undefined ? undefined : (await store.requests(own)).find((r) => r.id === runId); | ||
| if (turn?.finalizedAtMs == null) { | ||
| const slot = (piece as { wait?: { requestId?: string; lapsed?: true } }).wait; | ||
| const ended = |
There was a problem hiding this comment.
The parked/finished predicates match the right contracts (suspended + wait slot ownership). If this loop grows again, a local turnEnded(turn, piece, runId) helper (same three checks) would be my first readability win — not a different approach.
| } | ||
| continue; | ||
| } | ||
| const inSession = (await store.requests(own!)).filter((r) => r.status === "in_progress"); |
There was a problem hiding this comment.
Optional perf/readability: this iteration can call store.rows() up to three times and store.requests(own) twice. Reusing the rows from line 340 and a single requests list (items only when you need tool_output after quiet()) would be a mechanical shrink — fine to defer for a goal script.
| // works, and reads B's ending without parking. | ||
| module: "packages/orchestration/src/tasks/helpers/wait-on-task.ts", | ||
| from: String.raw`\n const marked = await collection\.markWait!\(taskId, \{`, | ||
| to: `\n await new Promise((resolve) => setTimeout(resolve, ${KEEPER_HOLD_MS + 2_000}));\n const marked = await collection.markWait!(taskId, {` |
There was a problem hiding this comment.
KEEPER_HOLD_MS + 2_000 in the patch template couples the control to leg timing by magic. A named constant (e.g. HOLD_SESSION_EXTRA_MS) next to KEEPER_HOLD_MS would make the “2 s past B’s hold” contract obvious when someone changes the taker hold.
| **Controls:** each is a scratch patch to Workforce applied as the process loads it (`goals/lib/module-patch.mts`), printed by the run and refused when it never reached the code. | ||
|
|
||
| - `GOAL_CONTROL=first-answer`: the woken turn's answer is never noted (`conversation-board/task-settled.ts`, the woken turn's `noteTaskAnswer`), so the task completes with A's first answer. Leg 1 must fail **`1:report-is-output`**, alone. | ||
| - `GOAL_CONTROL=first-answer`: the woken turn's answer is never noted (`conversation-board/task-settled.ts`, the woken turn's `noteTaskAnswer`), so the task completes with A's first answer. Leg 1 must fail **`1:report-is-output`**, alone. Red only on a run where A ends its turn: a turn parked on a `getTask` wait resumes in its own request, whose answer the task's own entry notes, so this patch never touches it (seen 2026-10-23; open). |
There was a problem hiding this comment.
Good honesty that this control doesn’t isolate 1:report-is-output on the parked-wait path. I’m not blocking on it, but a follow-up issue to retire/replace first-answer (or grade only runs that end via finalize + woken turn) would restore a discriminating negative control — otherwise leg 1’s output check is mostly plain-run only for that scenario.
There was a problem hiding this comment.
Code Snob. Outcome 1. The check is already the contract. The extra lines are comments that restate it. Fold 48c89645c onto main. Do not reset onto the POC. Close #3719 unmerged. This head has already landed, so fold onto main.
POC: #3719 (poc/shorter-parked-turn @ 48c89645c). Net −9 (5/14) in goals/workforce/split-to-roster/run.mts. Comment-stripped source is identical to e3029419, so the ended check, the quiet wait, both failure sentences, and the hold-session patch are unchanged.
What to drop:
- Leg 1's comment restated goal.md (two endings,
filed/wait, the end-of-request check, anin_progressrequest holds the session). Five lines stay: read once the turn has ended (request finalized, or parked on this piece's live wait slot) and the session is quiet. The board's own short pass may follow a park. - The
busynote restated the failure sentence. - The
hold-sessionnote restated the control line in goal.md. One line stays: delaymarkWaitpast B's hold, so the request stays open while B works.
Left as recorded: the slot must name A's request and not be lapsed, a quiet session rather than skipping dispatch by name, waitingOn follows how the turn ended, hold-session, the two failure sentences, goal.md's signal and verdict log, the open first-answer and wake-coordinator gaps.
Tried and left: one rows() snapshot needs a binding and is longer. Keeping busy on during changes what a timeout prints. Dropping running: 0 drops the grade. A helper around the ended check is longer.
Passed: comment-stripped identity with e3029419. TypeScript parse diagnostics 0. eslint exit 0. Live goal not re-run; no assertion text changed. Red: deleting && slot?.lapsed !== true drops the conjunct the short comment names.
Sent by Cursor Automation: Code Snob


The problem
The
split-to-rostergoal's leg1:waiting-while-b-worksfails onmain. The product is behaving correctly; the check is out of date. The leg promises that worker A doesn't hold its session while delegate B works on A's piece. It counted A's turn as over only once A's request had finished. Since FIX-2082 the agent waits for its piece withgetTask, which parks the request on the piece's wait gate. A parked request runs nothing and holds no lease, but it never finishes before B ends, so the goal reported that B ended first. A red goal for correct behaviour hides real regressions and blocks the FIX-2087 closure.What this does
A's turn now counts as ended in either of two cases. Its request finished (the task then waits on
filed), or its request is parked on the wait gate of B's piece (the request issuspended, the piece's wait slot names it, and the task waits onwait). After A's turn ends, the read waits until nothing is running in A's session, and B must still be working at that point. It then checks that A's task is running, has no lease, and is waiting on the right thing. If A's request is still running when B ends, or anything is still running in A's session, the leg fails as before.A new control,
hold-session, demonstrates the red state. It makes A'sgetTaskhold its request open past B's hold, and leg 1 then fails1:waiting-while-b-worksalone.What's asked of you
Nothing here is yours to decide. The EM already ruled that a request parked on a wait gate counts as A's turn having ended. The PR is the gate.
Parts worth reviewing closely
goals/workforce/split-to-roster/run.mts, leg 1's read loop. It tells a finished turn from a parked one. A parked turn has to be parked on B's piece: the piece's live (not lapsed) wait slot must name A's request id. A parked turn also has to readwaitingOn: "wait", and a finished turnfiled.dispatchpass running in A's session (about 140 ms, an internal pass and not A's turn). The read now keeps polling until the session is quiet, and that has to happen before B ends.Linear: FIX-2124 · epic FIX-2056 · found by the closure FIX-2087 (#3692). Goals-only, no changeset (BP-022: private package). Draft, not for merge by the agent.
How to review this
Engineering calls
suspendedisn't enough: the piece's wait slot has to name A's request, and the slot can't be lapsed. A park on anything else (an approval, a webhook) doesn't count.dispatchaction by name. This keeps "no request running in A's session" as written and doesn't hard-code which internal actions are harmless. It only needs one moment of quiet while B works. That is the same strength as the old read (A could also finish its turn early on the old path).hold-sessionrather than a one-off local patch, so the red state of this assertion can be re-checked. It only fires on runs where A waits withgetTask, which was every run here; a model that ends its turn never reaches the patch.Everything else
Red, then green
main34cebe6,GOAL_LEGS=1:1:waiting-while-b-works — … crew.keeper's piece ended before A's turn did. The log shows A'sworkrequestaction execution suspendedwhile B held its answer.GOAL_LEGS=1: PASS. During B:{"ended":"parked","status":"in_progress","waitingOn":"wait","running":0}.mainand doesn't contain FIX-2097. Runs 2 and 3: PASS. Run 1 failed2:reads-the-failureonly, because the model messagedcrew.broken(messageWorker) instead of filing a piece. That is model behaviour in a leg this change doesn't touch.hold-session: FAIL1:waiting-while-b-worksalone, as intended.Controls that no longer fail as intended (both already broken on main, not fixed here)
first-answer:1:report-is-outputheld. When A parks on agetTaskwait, its resumed request gives the answer, which the task's own entry records. The patched woken-turn line intask-settled.tsnever runs, so the control only goes red on runs where A ends its turn instead of waiting. This dates from FIX-2082, not this change.wake-coordinator:4:desk-hears-tasks-onlyheld. A's piece errored at the desk's hand-over, the desk acted on no notice at all, and A's task stayedin_progress. Main's version ofrun.mtsgives the same result, so this change didn't cause it.Both are recorded in goal.md's verdict log as open. They should go in a follow-up issue.
Checks
pnpm typecheck(includes control-shape guard),pnpm lint,pnpm fallow:ci,node scripts/check-retired-terms.mjs, the vocabulary sweep and its--control: all pass. No package code changed, so there are no package tests to run. The task-surface sweep isn't needed because no task tools, endings or docs were touched.Files
goals/workforce/split-to-roster/run.mts: leg 1's ended-turn read, thehold-sessioncontrol.goals/workforce/split-to-roster/goal.md: leg 1's signal, the controls, verdict log.Generated by Claude Code
Note
Low Risk
Goals-only changes to assertions and documentation; no production workforce/orchestration code ships in this PR.
Overview
Updates the split-to-roster goal so leg
1:waiting-while-b-worksmatches current agent behavior: after filing a piece, A maygetTask-park on the delegate piece’s wait gate instead of finalizing its request.run.mtsnow treats A’s turn as ended when the request is finalized (waitingOn: "filed") or suspended on B’s piece with a live wait slot (waitingOn: "wait"). It then polls until A’s task session has no in-progress requests (so brief boarddispatchafter a park doesn’t false-fail) while B’s piece is still running, and asserts no lease and zero running requests.goal.mddocuments the two end-of-turn paths (FIX-2124), adds thehold-sessionscratch control (delaysmarkWaitso the leg should fail alone), and extends the verdict log with 2026-10-23 runs—including known gaps wherefirst-answerandwake-coordinatorno longer isolate ongetTaskpark paths.Reviewed by Cursor Bugbot for commit e302941. Configure here.