Repository navigation
feat(workforce): a worker message lands once (FIX-2240) - #4008
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
…ure exports (FIX-2240) takeRule/decideTake (own | busy | takeover) and nextResendAt are what the task-notice take and pass already decide by; worker messages will decide by the same pieces. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NczDiDFT9s67hk1haKhCfg
…ure exports (FIX-2240) takeRule/decideTake (own | busy | takeover) and nextResendAt are what the task-notice take and pass already decide by; worker messages will decide by the same pieces. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NczDiDFT9s67hk1haKhCfg
The send owes its session's board pass and keeps the id on an owed list, writes the row, and dispatches once. onMessageReceived takes the message on its row (orchestration's take rule, with take-over), lands the items, then marks it delivered. The pass sends an owed message again by the notice backoff until it lands, is refused (final), or passes the host's debt age; a late failure leaves a line in the sending session. The two tries, the tool's unconfirmed answer and the 500-id window go. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NczDiDFT9s67hk1haKhCfg
…peat safely under a server id (FIX-2240) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NczDiDFT9s67hk1haKhCfg
…dn't be delivered past the debt age (FIX-2240) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NczDiDFT9s67hk1haKhCfg
…ailure line (FIX-2240) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NczDiDFT9s67hk1haKhCfg
…to claude/project-thread-3uc91a
…-2240) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NczDiDFT9s67hk1haKhCfg
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
…k reads its principal's session (FIX-2160) The partitioned ledger keeps an id index written by its own add (findTaskPartitions, taskLedgerResources); the request host gains sessions.read, which answers a session of the running principal with its flow and readonly state, and any other as absent. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NczDiD7QxMPGxa4XV4dZEF
… shared (FIX-2160)
The door's talk runs as a block of its own that a coder can also run for a
message: it resumes a finished task's coding session once and answers
{ reply, taskId }, and refuses a task still open (task-running), since a
message never steers. rowsInSession, in orchestration, is the one reader of
the rows that run in a session.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NczDiD7QxMPGxa4XV4dZEF
…before the row (FIX-2160)
A { task } target finds its row through the conversation ledger's id index
and lands in the session its run named; a { session } target lands in that
conversation of the user's. Both are checked on the session's record
(requestHost.sessions.read): the user, org and tenant, the worker and its
flow now, and for { session } that it is a conversation. A coder's task
still running is refused task_running. Shift Manager names the target.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NczDiD7QxMPGxa4XV4dZEF
The retired-terms guard reads 'kind' as a worker-flow word on Workforce's ground, so the row field is addressedBy, not toKind. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NczDiD7QxMPGxa4XV4dZEF
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NczDiDFT9s67hk1haKhCfg
… from the coding session (FIX-2160) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NczDiD7QxMPGxa4XV4dZEF
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
|
The latest updates on your projects. Learn more about Vercel for GitHub. 3 Skipped Deployments
|
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NczDiDFT9s67hk1haKhCfg
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NczDiDFT9s67hk1haKhCfg
…k reads its principal's session (FIX-2160) The partitioned ledger keeps an id index written by its own add (findTaskPartitions, taskLedgerResources); the request host gains sessions.read, which answers a session of the running principal with its flow and readonly state, and any other as absent. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NczDiD7QxMPGxa4XV4dZEF
… shared (FIX-2160)
The door's talk runs as a block of its own that a coder can also run for a
message: it resumes a finished task's coding session once and answers
{ reply, taskId }, and refuses a task still open (task-running), since a
message never steers. rowsInSession, in orchestration, is the one reader of
the rows that run in a session.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NczDiD7QxMPGxa4XV4dZEF
…before the row (FIX-2160)
A { task } target finds its row through the conversation ledger's id index
and lands in the session its run named; a { session } target lands in that
conversation of the user's. Both are checked on the session's record
(requestHost.sessions.read): the user, org and tenant, the worker and its
flow now, and for { session } that it is a conversation. A coder's task
still running is refused task_running. Shift Manager names the target.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NczDiD7QxMPGxa4XV4dZEF
The retired-terms guard reads 'kind' as a worker-flow word on Workforce's ground, so the row field is addressedBy, not toKind. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NczDiD7QxMPGxa4XV4dZEF
… from the coding session (FIX-2160) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NczDiD7QxMPGxa4XV4dZEF
…task; changesets (FIX-2160) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NczDiD7QxMPGxa4XV4dZEF
… once (FIX-2240) Pins the case a review on #4010 found: a claim before the items made a retry read as a duplicate. The take alone isn't a delivery, so the sender's pass resends and the next request takes it over. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NczDiDFT9s67hk1haKhCfg
… close (FIX-2240) Folds the Code Snob POC (#4018): a refusal past the age closes once with force, and takeMessage returns the row it took. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NczDiDFT9s67hk1haKhCfg
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NczDiDFT9s67hk1haKhCfg # Conflicts: # packages/workforce/src/messages/message-received-entry.ts # packages/workforce/src/messages/message-tool.ts
|
Code Snob (#4018): I applied the substance of
All 55 message tests pass. #4018 can be closed unmerged. Generated by Claude Code |
There was a problem hiding this comment.
Code Snob. Already tight on 00fef9e4d.
The smaller shape is already on this head. 0776b4030 made close the one end, line, and drop. 18268d263 folded the rest of the code cut: one refusal close (force: pastAge), and takeMessage returns the row. Do not fold 7c297b920, dadd483e4, or 391958643. Those parents are behind this head. Close #4018 unmerged. Do not merge it.
Read: packages/workforce/src/messages/delivery.ts, message-received-entry.ts, send-message.ts, packages/workforce/src/conversation-board/board.ts, packages/orchestration/src/tasks/helpers/request-states.ts, packages/orchestration/src/tasks/notice/task-notice.ts, task-settled-entry.ts, pass.ts.
A further rewrite does not shrink the contract:
closeis the four end-tell-drop sites. The refusal past the age is that one call withforce.takeMessagereturns the row. The false arm had no reason, and it is gone.storedEmittersis the wait beforedeliveredandtoldAt.owedOfparses the list and skips an entry that does not.decideTake,takeRule, andnextResendAtare the shared pieces. The notice path calls them too.- The send's final refusal is told by the tool (
told: true). The pass leaves the line. A shared settler needs a callback and ties. oweMessage's wake is the same try asowePass. Importing the board into messages to share four lines is a worse dependency.passMessagesDueis the message due beside the plan's. The settle takes the earliest.RecheckRecipientis the parameter type ofpayMessageDebts. The file header and thepayMessageDebtscomment restate the functions. Cutting those shortens the comment. It does not shrink the contract.
Left as recorded: the take rule and the backoff stay in orchestration, a flow with no pass stays fast-path only, D1's line, toldAt, force over a take when the recipient is gone past the age.
Sent by Cursor Automation: Code Snob
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 00fef9e4df
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
A { session } message can reach another conversation of the same worker,
so its answer by name (to: the same worker, inReplyTo) now goes through,
back to the conversation that asked. An answer to a message from the
answering session itself is still refused not_yourself.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NczDiD7QxMPGxa4XV4dZEF
…(FIX-2240) recheckRecipient re-ran a by-name check without inReplyTo, so a reply to a worker that hears only in its tasks' sessions was refused for good on its first resend. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NczDiDFT9s67hk1haKhCfg
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 594fd76a9a
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
…he age (FIX-2240) A final dispatch refusal on a resend now forces the end once the row is past maxDebtAgeMs, as a recheck refusal does, so a reply whose session was deleted after a take stops being resent and its sender is told. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NczDiDFT9s67hk1haKhCfg
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 7b5466b284
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
…240)
A send repeated under its server-chosen id now answers as the row reads, so a
row that ended refused or undeliverable stays not_delivered instead of {ok}.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NczDiDFT9s67hk1haKhCfg
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 3aecb45dd0
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| row.addressedBy === "task" && row.toTask !== undefined | ||
| ? await checkTaskTarget(ctx, installation, row.toTask) | ||
| : await checkTargetSession(ctx, installation, row.toSession, { session: true }); | ||
| return checked.ok ? undefined : checked.error; |
There was a problem hiding this comment.
Recheck the destination actually stored on a task message
If the first dispatch fails and the task is retried and reassigned from worker A to worker B before the resend, checkTaskTarget validates B's current session, but dispatchMessage still dispatches to A's stored row.toSession and row.toFlow. Consequently, even firing A does not stop the resend from reaching A's old session: the recipient recheck now checks B instead. Task reassignment creates a different session (conversation-board/board.ts, taskSessionKey), so validate the pinned recipient/session or explicitly reconcile the stored address with the checked target before dispatching.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in 5efdc4d. recheckRecipient now compares the checked target's session with row.toSession. If the task has moved to another session, the recheck refuses with task_moved: the row ends refused and the sender is told. We don't re-address it to B, because a message written for A's run shouldn't silently reach a different worker. The sender can send it again. New test: worker-messages-recheck.test.ts. Without the comparison it fails.
Generated by Claude Code
| if (isFinalRefusal(outcome.refused) && (await endMessage(ref, "refused", reason, { told: true }))) { | ||
| if (resends) await dropOwed(ctx, [id]); |
There was a problem hiding this comment.
Record the initial refusal notification only after it is stored
On a persistent host, a crash after this terminal write but before the tool output is persisted leaves the sender permanently untold. { told: true } records toldAt before sendMessage even returns, and the next line removes the owed pointer. Even if the pointer survives the crash, payMessageDebts skips notification for rows that already have toldAt. Keep the refusal notification owed until its tool output is durable, or persist a sender notification before marking it told, as the late-refusal path does.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Not changing this. It's a recorded decision: the send's own final refusal is told by the tool's answer (told: true), and only a refusal after the send returned gets D1's line. To close this window, every send-time refusal would also need a stored line in the session. The model would then read every such refusal twice, once in the tool output and once as a line. The window itself is a crash after the row's end and before the tool output is stored. That crash also loses the sending turn, and the turn is what would have acted on the answer. I'm leaving it as it is.
Generated by Claude Code
…ns (FIX-2240) recheckRecipient checked the task as it reads now, but the resend goes to the session on the row. A reassigned task is worked in another session, so the recheck now refuses task_moved instead of passing on the new session. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NczDiDFT9s67hk1haKhCfg
|
Architect: not approving yet. Two fresh Codex P2s on — FSD Architect |
…to claude/project-thread-3uc91a
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NczDiDFT9s67hk1haKhCfg
|
For the Architect's note:
Generated by Claude Code |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: eec5d61923
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| context._emitComponentAwaited = createEmitComponentAwaited(activeEmCtx); | ||
| context._emitMessageAwaited = createEmitMessageAwaited(activeEmCtx); | ||
| // The barrier after an awaited emission: its item is in the request store. | ||
| context._flushItems = () => stores.request.flushItems(activeEmCtx.requestId); |
There was a problem hiding this comment.
Propagate item-write failures through the durability barrier
On the filesystem adapter, an item-write failure can still leave a message marked delivered without durable received items. The fresh evidence beyond the earlier ordering finding is that FilesystemRequestStore.flushItems only drains its queue, while createSerializedWriteQueue catches write failures and resolves its drain waiters; the item queue's error callback logs rather than rethrows. Consequently, this new barrier resolves even after persistence fails, allowing markDelivered or tellSender to record delivered or toldAt. A crash before the request's final items write then permanently loses the message or notification because subsequent passes trust those markers. Make the barrier propagate item-persistence failures before treating its completion as proof of storage.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Agreed. Fixed in 6123c83, at the store rather than in the barrier. The filesystem request store now records an item write's error and rethrows it from flushItems, the same way flushEvents already does and the Postgres store's flush already rejects. With that, a failed write makes the entry throw before markDelivered or toldAt is written. The row stays taken, and the pass's resend takes it over once that request has ended. New test in persist-error-observable.test.ts: a failed item write rejects flushItems once and is reported. Without the recorded error it fails. The full engine suite passes (4104), and an engine patch line is added to the changeset.
Generated by Claude Code
…Items (FIX-2240) The serialized queue swallows write errors, so flushItems resolved after a failed write and the message entry's barrier marked delivered without stored items. The filesystem store now records the item error and rethrows it from flushItems, as flushEvents already does and the Postgres store's flush does. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NczDiDFT9s67hk1haKhCfg
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NczDiDJDLpHhanaY6z9YCB


Requested by Jake. Implements the merged spec specs/issues/FIX-2240 (#3999).
Based on main. FIX-2238 (#4010) and FIX-2160 (#4012) have landed, so this diff is FIX-2240's work only. FIX-2239 stacks on it. Goal leg 9 (real model) is still owed.
What changes
unconfirmedand nothing more{ sent }, and the sending session's board pass sends it again until it landsdelivered, and the message is lostunconfirmeduntil the recipient'sonMessageReceivedtakes it, and is sent again until thenunconfirmedforeverrefused(final), and the sending session gets a line its next turn readsmessages/send-message.ts) owes the session's pass a wake (DISPATCH_ENTRY,NOTICE_DUE_MS), puts the id on an owed list in session state beside the sending request's id, writes the row (now withtoState), and dispatches once. A final refusal ends the rowrefused, told by the tool's answer. Anything else leaves itunconfirmed. A flow that carries no pass sends on the fast path only, and owes nothing.messages/delivery.ts→takeMessage,markDelivered) is FIX-2123's take on the message row. It uses orchestration'sdecideTake(own, busy, or take over from a taker that ended), then the items, thendelivered/deliveredAs/deliveredAt, then the turn.delivered(and a sender'stoldAt) is written only after the items are stored: the entry awaits its emitters and flushes the request's items first. The session's 500-id window is gone.payMessageDebts) runs in the board pass's first half, outside the files branch. Its next due time is folded into the settle (passMessagesDue, besidepassPlanDue). It drops an id that has landed or ended and been told, and drops an id with no row once its sending request has ended. It ends a never-taken messageundeliverablepastmaxDebtAgeMs. A taken one is never ended for its age, unless its destination is gone for good (a recheck refusal, or a final dispatch refusal). It re-checks the recipient (recheckRecipient: the roster, or a task's or conversation's record, refusingtask_movedwhen a task is now worked in another session; an answer keeps its exception), then resends with the notice backoff, and recordsresent. Retryable refusals: a throw,dispatch-rejected,no-dispatch-operation,flow-not-found. Every other refusal is final.takeRule,decideTake,hasEnded) and the backoff (nextResendAt,NOTICE_RESEND_CAP_MS). The notice take and the notice pass now call them._emitMessageAwaitedand_flushItems, so the entry can wait for its items to be stored.sendMessage(…, from, { id }). When that row already exists, a repeat writes nothing and pays nothing, and answers as the row reads: an ended row staysnot_delivered. FIX-2241 uses it.messaging-workers.md, the Messages row inshift-manager/overview.md, and the Worker messages section of the workforce README.a-message-lands-once.md(workforce and orchestration, minor).Seams from the cross-spec review, folded in
sendMessagecan't be read from its definition. The Error Reporter still doesn't mount its board's entries, so its sends are fast-path only. That's a follow-up for the reporter's owner.delivered, then the turn. FIX-2239's hold goes between the take and the items. A taken row backs off at the cap and is never marked undeliverable while it is taken.All three are recorded in
specs/issues/FIX-2240/DECISIONS.md→ "Amendments while building".Evidence
packages/workforce/test/worker-messages-delivery.test.ts(durable host, the real sweeper). Covers: a fast path that throws is resent and heard once; a host that accepts nothing stays owed and lands later; an accepted dispatch never taken is resent; a final refusal is told and never resent; a late copy runs nothing; a take-over from an ended taker; a taker that died after the take and before the items is sent again;deliveredis written only after the items are flushed; a fired recipient is refused and told with one line; the age limit; a taken message whose destination is gone ends past the age; a repeat-safe id holds one row and one budget place, and a repeat of a refused send stays refused.worker-messages.test.ts(a resent answer keeps its exception) andworker-messages-recheck.test.ts(a resend to a reassigned task is refused).no-debt(5 fail),accept-clears(3),no-recheck(1),take-is-final(1), no early return for the repeat id (1), delivered-at-the-take (1), no flush barrier (1), and one for each review fix.packages/orchestration/test/tasks/delivery-rules.test.ts, plus the notice suites (70 pass). A take rule that never takes over fails 6 of them.🤖 Generated with Claude Code
https://claude.ai/code/session_01NczDiDFT9s67hk1haKhCfg