Repository navigation
FIX-2238 follow-up: a fresh budget for a task held before it starts, and for a person's line in a finished task's session - #4021
Conversation
…ageReceived (FIX-2238) The tool is sendMessage, the entry onMessageReceived, replyTo is inReplyTo; no alias for the old names (FIX-2070 ER-7). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NczDiDWiB5JZRCvyAFUpe9
…elayed (FIX-2238) onMessageReceived lands a history-only line and a client-only workforce:received component, and hands the flow's turn the received message (id, from, text, call, inReplyTo, budget). The relay goes: a worker answers with sendMessage and inReplyTo, or not at all. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NczDiDWiB5JZRCvyAFUpe9
An answer lands in its original's session; a message to the filer lands in the filing session (new readonly filingWorkerId). Workers that hear only in their tasks' sessions are refused by name before the row is written. The delegate's ongoing session is born with its filer's count, and a task held from its filing starts a fresh chain when released. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NczDiDJDLpHhanaY6z9YCB
hireWorkforce refuses a worker flow without an onMessageReceived built by messageReceivedEntry. The coder hears only in its tasks' sessions; the error reporter's turn runs for a message. messageReceivedEntry and its types are exported. Shift Manager draws workforce:received as its own item under the sender's name, replacing the 'From X:' prefix match. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NczDiDWiB5JZRCvyAFUpe9
Docs and READMEs describe sendMessage, onMessageReceived, the received item (which now carries the budget left), the landing rules, the budget and the refusals. The workers-message-each-other goal gets the spec's new legs, controls and sweep. The epic's seam table, ER-6 and stack order follow the cross-spec review. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NczDiDWiB5JZRCvyAFUpe9
Resolve the FIX-2070 DECISIONS.md conflict by keeping both amendments: the stack order and FIX-2160's addressedBy/toTask from this branch, the FIX-2240 take-and-resend fields from main. Review on #4010: - send-message: one placeAfter helper for a send's place; the pre-read of the chain row is gone, since reserve, conditional update and give-back already refuse an over-budget send at no cost. - messageReceivedProblem takes the flow and reads its internal actions itself, so the hire carries no copy of the flow's shape. - runs-on-one-task goal: the roster's own tools are listDelegates and sendMessage. - Goal leg 2b names sendMessage, since "wait" alone led the model to file a task and wait on it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NczDiDWiB5JZRCvyAFUpe9
…kers state - freshHopMark mints the held task's chain at filing, so every request the task runs (a retry, a continuation after a question) counts in one budget instead of minting a new one each time (Codex on #4010). - TURN_MESSAGED_STATE was read only by the relay this change removed; the field, its reset and the write on every send are gone (Cursor). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NczDiDWiB5JZRCvyAFUpe9
A message queued behind a busy recipient, or heard after its sender sent again, read its budget from its own row's hop, so it could report places already spent. The receipt reads the chain row and reports from the larger of the two (Codex on #4010). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NczDiDWiB5JZRCvyAFUpe9
…ssions recipientRefusal refused task_sessions_only before inReplyTo was read, so a task-sessions worker's question could never be answered. An answer lands in the session its original came from, so only a message by name is refused now (Codex on #4010). sendMessageOutputSchema is no longer exported: nothing outside the tool reads it (Fallow). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NczDiDWiB5JZRCvyAFUpe9
… sends after a refusal Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NczDiDWiB5JZRCvyAFUpe9
A ring that branches spends places before a later message is heard, so the received budget can be below 6 minus its place. The leg now checks it is at most that, never negative, and counts down along the ring. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NczDiDWiB5JZRCvyAFUpe9
…and for a person's line in a finished task's session Two Codex findings that landed as #4010 merged: - A task held by updateTask before its first start is held from its filing: its filed mark becomes a fresh chain, as a filing held writes. - A person's line in a finished task's session (every follow-up there ended too) starts a fresh budget. It is still no user's turn for the rule tools. Epic seam table: FIX-2239's queuedBehind on the message row (cross-spec review, approved). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NczDiDWiB5JZRCvyAFUpe9
|
The latest updates on your projects. Learn more about Vercel for GitHub. 3 Skipped Deployments
|
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Second-look + architecture review (read-only; for the next agent to triage)Overall: the direction is right and small. Both fixes match the FIX-2238 notes, and the tests were red first. Findings below, ranked. None blocks the intent; #1 and #2 are worth doing in this PR because they touch the lines being changed. 1.
|
There was a problem hiding this comment.
Code Snob — already tight. No POC.
Head 0232b15f6. I read packages/workforce/src/conversation-board/board.ts (keepFiledHopInChain, freshenFiledHop, patchSettings), packages/workforce/src/standing-rules/user-turn.ts, packages/workforce/src/messages/hop.ts (freshHopMark, heldFromFiling, startTurnAtHop), the two new tests in packages/workforce/test/worker-messages.test.ts and the filed-held test beside them, and the message-row cell in specs/epics/FIX-2070/DECISIONS.md. I compared steer.ts (sessionOpenTask), board-above.ts, and task-entry.ts (sessionTaskOf).
freshenFiledHopis the one write: a fresh chain, the filer's line count kept. Inlining it intopatchSettingsmoves those lines.freshHopMark(ctx, mark.lines)drops the spread and adds a parameter; the filing sites want the session's current lines. The call-site comment repeats the helper. Cutting it shortens the comment. The helper comment is why a started row and a row with no mark return.markUserTurnwrites either the user-turn flag or an empty patch. A ternary repeatstypeof taskId === "string"and saves thelet.taskSessionEndedis the list, the filter, andevery. Inlining it drops the name and keeps the dynamic import: a static import of the ledger hangsanswer-again-finished-tasks.test.tsat load.sessionOpenTasktreats a missing row as finished and readsboardAboveOf, which also takesroutedFrom. This check requires a row onfilingSessionId.(followUpOf ?? id) === taskIdskips a root whosefollowUpOfis set.- The two tests are the two cases. The filed-held test also pins hop 0 and the chain minted at filing. A shared tail drops that or takes a flag. File, hold, assign, release is this case; file-already-held is the other.
- The seam cell adds
queuedBehind. That clause is the record.
Left as recorded: a hold before the first start rewrites the filed mark; a person's line in a finished task session starts a fresh chain and is still not a user's turn; the ledger import stays dynamic.
Sent by Cursor Automation: Code Snob
There was a problem hiding this comment.
Simplify / approach review
Verdict: The follow-up is appropriately small (~100 lines, two edge cases from FIX-2238). I would not call the overall direction over-engineered — freshenFiledHop and the finished-session hop reset are localized fixes with good integration tests. There are still a few places a cleaner shape would reduce duplication and future drift without changing behavior.
What looks right
- Hold-before-start → fresh chain: Wiring
freshenFiledHopoffpatchSettingswhenpatch.held === truematches howupdateTask({ status: "held" })maps in orchestration (held: true), and parallels filing-timeheldFromFiling ? freshHopMark : turnHopMark. The test that holds, reassigns, releases, and asserts@1hops + distinct chains is strong evidence. - Finished task session, user line: Keeping
USER_TURN_STATEoff (still task input / no rule tools) while callingstartTurnAtHopwith an empty mark is the right split — consistent withstanding-rules.test.ts(“not a user’s turn”) but fixes budget for post-completion chatter (FIX-2238). - Open-task hot path:
steerOrTalkstill routes open-chain messages to steer;markUserTurnonly runs whensessionOpenTaskis undefined, so in-progress task work is not regressed on the busiest path.
Where complexity crept in (and simpler alternatives)
-
Duplicate ledger scan on the finished-chain
respondpath
steerOrTalkalready callssessionOpenTask()→ fullledger.list()+ chain filter. When the chain is closed, the same request then hitsmarkUserTurn→taskSessionEnded()→ secondconversationLedgerAt+list()+ filter (inverted predicate).
Cleaner: Share one helper withsteer.ts(e.g.chainRows(ledger, rootTaskId)/chainAllTerminal) or pass the outcome ofsessionOpenTask === undefinedinto the user-turn door so hop reset does not re-resolve the ledger. Same semantics, half the work on the path this PR cares about. -
Hop-mark policy in three places
Filing (heldFromFiling→freshHopMark), hold-via-update (freshenFiledHop), andhop.tsdocs. The bodies are almost the same (“fresh chain, keeplines”).
Cleaner: One exported helper inmessages/hop.ts(e.g.filedHopMarkWhenHeldFromFiling(ctx, priorMark?)) used at add +patchSettings, so hold-at-filing and hold-before-start cannot diverge. -
Dynamic import in
markUserTurn
Understandable for cycle avoidance, but it pushes async + module boundary into standing-rules for every call wheretaskIdis set (partition missing still bails before import; open-chain calls are rare on this path because ofsteerOrTalk).
Cleaner (larger change, optional): Set a session flag when the task chain fully settles (or reuse an existing settlement hook) somarkUserTurnstays sync and does not reach into the ledger. I’m not insisting on this in this PR — flagging as the architectural alternative if hop/session rules keep growing. -
Hold-time vs release-time freshen
RunningfreshenFiledHopon hold (not onheld: false/ release) is defensible — the mark is fixed before the row runs. Minor nit: repeatedheld: trueon an already-held unstarted row would mint a newchainagain; if that happens in the wild, consider freshen only on transition into held or when the mark is not already a held-from-filing shape. -
Scope
TheFIX-2070/DECISIONS.mdqueuedBehindsentence looks unrelated to this follow-up; worth splitting to keep review/merge narrative tight (soft preference, not a functional concern).
Chain membership
taskSessionEnded uses id === taskId || followUpOf === taskId, aligned with sessionOpenTask’s (followUpOf ?? id) === taskId for the flat follow-up pattern the suite uses (follow-ups point at the root task id). If nested followUpOf chains ever ship without normalization, both steer and this check would need the same transitive closure — same class of issue, not introduced only here.
Tests
Integration coverage in worker-messages.test.ts is the right tier. Optional: a small unit test on markUserTurn with mocked ledger / partition for the “all terminal → fresh chain, no USER_TURN” branch (would catch regressions without booting the harness).
Summary: Ship-worthy behavior; I’d merge after considering (1) shared chain/terminal helper with steer.ts and (2) centralizing filed-hop mark policy in hop.ts. Neither is a blocker if you want this follow-up landed quickly — they’re the main simplification levers if you touch this area again.
Sent by Cursor Automation: Review For Best Approach
…uter does markUserTurn now asks steer.ts whether the session's task chain has finished (sessionTaskChainEnded, over sessionOpenTask), so a line counts as a fresh budget exactly when it no longer steers: the same board (boardAboveOf) and the same chain predicate. Still false with no board. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NczDiDWiB5JZRCvyAFUpe9
Outcome, input, legs 1 to 4 and the controls now describe FIX-2238: sendMessage and onMessageReceived, landing rules, the budget, the coder's refusal, the round-robin coordinator and the hire check. The verdict log records 3 passing runs of legs 1 to 5, the one ring run that stopped short, and each control's FAIL. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NczDiDWiB5JZRCvyAFUpe9
|
FIX-2238 goal verdict ( Controls first. Every control failed on the assertion it targets:
These ran on Then PASS: legs 1 to 5 passed in 3 runs. One run was on One more run on A finding for FIX-2160's leg 6, which ran alongside. It failed The verdict row and the goal's updated text for Generated by Claude Code |
…-n6abql # Conflicts: # goals/shift-manager/workers-message-each-other/goal.md # specs/epics/FIX-2070/DECISIONS.md
…4026 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NczDiDWiB5JZRCvyAFUpe9


The problem
Codex left two findings on #4010 shortly before it merged. Both are cases the approved FIX-2238 spec lists, and #4010 did not handle either:
updateTaskkept its filing's chain. Once released, it could not send a single message if that chain was already spent. The spec says a task held before its first start counts as held from its filing, so it gets a fresh 6.markUserTurnskipped every task session. The spec asks for this case to be marked.What this does
board.ts: when a hold succeeds on a row that hasn't started,freshenFiledHoprewrites the row's filed mark as a fresh chain, the same mark a held filing writes. It keeps the filer's user-line count. A hold on a row that has already started is a midway hold, and keeps its budget.user-turn.ts: a person's line in a task session starts a fresh chain and counts as a user's line, but only once the task and every follow-up in that session have ended. It is still not marked as a user's turn, so standing-rule tools stay off there.standing-rules.test.tspins that ("still not a user's turn").answer-again-finished-tasks.test.tsat load.specs/epics/FIX-2070/DECISIONS.md): adds FIX-2239'squeuedBehindto the message row, as Jake approved in the cross-spec review.What's asked of you
Nothing to decide. This implements two notes the approved spec already records.
Everything else
Verification
test/worker-messages.test.ts. Each was run against the old code first and failed:helper-b>otto@2when the fix is disabled.user-turn.ts(expected +0 to be 1).packages/workforce: 1611 of 1612 pass. The one failure is "refuses a post's round at 50 open" (a 5s timeout), and it also fails on a clean checkout ofmainin this container.packages/workforce.Changeset: none. The behaviour is internal and the public API is unchanged.
History note: the branch carries a no-change merge of the already-merged #4010 branch. Its tree is
mainplus this diff.Generated by Claude Code