Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
4eb29cb
refactor(workforce): rename worker messages to sendMessage and onMess…
claude Oct 27, 2026
86f9091
feat(workforce): a received message is its own item, and nothing is r…
claude Oct 27, 2026
f201a3e
FIX-2238: landing rules, task-sessions refusal and one budget
claude Oct 27, 2026
9413821
FIX-2238: every worker flow on an installation hears a message
claude Oct 27, 2026
1feba42
FIX-2238: docs, changeset, goal amended, epic seams updated
claude Oct 27, 2026
b03e4fe
Merge main into FIX-2238; review fixes
claude Oct 27, 2026
acdd330
FIX-2238: one chain for a task filed held; drop the dead messaged-wor…
claude Oct 27, 2026
752d290
FIX-2238: a received message's budget is what its chain has left
claude Oct 27, 2026
367eb69
FIX-2238: an answer reaches a worker that hears only in its tasks' se…
claude Oct 27, 2026
5d7ca95
FIX-2238 goal: the ring's own hand-offs aren't stray rows; the herald…
claude Oct 27, 2026
bfbae4c
FIX-2238 goal: 3:budget-left grades what the chain had left when heard
claude Oct 27, 2026
0e91fad
FIX-2238 follow-up: a fresh budget for a task held before it starts, …
claude Oct 28, 2026
0232b15
Merge the merged FIX-2238 branch history (no changes): the follow-up …
claude Oct 28, 2026
570849b
FIX-2238 follow-up: read a finished task session the way the steer ro…
claude Oct 28, 2026
d9d39a5
goal(FIX-2238): the goal's text for sendMessage, and its verdict
claude Oct 28, 2026
c14d50c
Merge remote-tracking branch 'origin/main' into claude/project-thread…
claude Oct 28, 2026
5bb75da
goal(FIX-2238): leg 6's one failure was the goal's timing, fixed in #…
claude Oct 28, 2026
cccdd43
Merge branch 'main' into claude/project-thread-n6abql
jhoffner Oct 28, 2026
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
Prev Previous commit
Next Next commit
FIX-2238: one chain for a task filed held; drop the dead messaged-wor…
…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
  • Loading branch information
claude committed Oct 27, 2026
commit acdd3303c999e68d37110e57fac5018a883fb96f
15 changes: 6 additions & 9 deletions packages/workforce/src/messages/hop.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,6 @@ export const TURN_CHAIN_STATE = "workforceTurnChain";
/** The request-state field a turn's hop count is copied to, and the per-turn send count beside it. */
export const TURN_HOP_STATE = "workforceTurnHop";
export const TURN_SENT_STATE = "workforceMessagesSent";
/** The request-state field the workers this turn has messaged are kept in. */
export const TURN_MESSAGED_STATE = "workforceMessagedWorkers";

/** The session state a flow that takes messages declares. */
export const messageHopStateShape = {
Expand All @@ -68,8 +66,7 @@ export const messageHopStateShape = {
export const messageTurnStateSchema = z.object({
[TURN_HOP_STATE]: z.number().int().nonnegative().optional(),
[TURN_CHAIN_STATE]: z.string().nullable().optional(),
[TURN_SENT_STATE]: z.number().int().nonnegative().optional(),
[TURN_MESSAGED_STATE]: z.array(z.string()).optional()
[TURN_SENT_STATE]: z.number().int().nonnegative().optional()
});

/** A session's current hop count: 0 for one that keeps none. */
Expand Down Expand Up @@ -134,11 +131,12 @@ export function turnHopMark(ctx: Pick<BlockContext, "request" | "session">): Hop

/**
* The mark for a task filed held (FIX-2238): released, it starts a fresh
* chain at 0, its first send minting one, since no exchange waits on it. The
* filer's user lines are kept, so a user's line since still clears it.
* chain at 0, since no exchange waits on it. The chain is minted here, once,
* so every request the task runs counts in the same budget. The filer's user
* lines are kept, so a user's line since still clears it.
*/
export function freshHopMark(ctx: Pick<BlockContext, "session">): HopMark {
return { hop: 0, chain: null, lines: sessionUserLinesOf(ctx.session.state) };
return { hop: 0, chain: newChainId(), lines: sessionUserLinesOf(ctx.session.state) };
}

/**
Expand Down Expand Up @@ -191,7 +189,6 @@ export async function startTurnAtHop(
...also,
[TURN_HOP_STATE]: hop,
[TURN_CHAIN_STATE]: chain,
[TURN_SENT_STATE]: 0,
[TURN_MESSAGED_STATE]: []
[TURN_SENT_STATE]: 0
} as never);
}
6 changes: 1 addition & 5 deletions packages/workforce/src/messages/send-message.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ import { filingProjectAddressOf, sessionIdOfFiling } from "../conversation-board
import { deriveWorkerSessionId, criteriaState, type WorkerSessionCriteria } from "../workers/derive-session-id";
import type { RosterWorker, WorkerInstallation } from "../workers/installation";
import { FILING_FLOW_STATE_KEY, FILING_SESSION_STATE_KEY, FILING_WORKER_STATE_KEY, WORKER_ID_STATE_KEY } from "../workers/keys";
import { newChainId, TURN_CHAIN_STATE, TURN_MESSAGED_STATE, TURN_SENT_STATE, turnChainOf, turnHopOf } from "./hop";
import { newChainId, TURN_CHAIN_STATE, TURN_SENT_STATE, turnChainOf, turnHopOf } from "./hop";
import { MESSAGE_RECEIVED_ENTRY } from "./keys";
import { messageLimitsOf } from "./message-limits";
import { messageHearingOf } from "./message-received-entry";
Expand Down Expand Up @@ -211,10 +211,6 @@ export async function sendMessage(
return budgetRefusal(placeAfter(chainRow.state.sent.length));
}
const hop = placeAfter(place);
await atomicRequest((current) => {
const messaged = Array.isArray(current[TURN_MESSAGED_STATE]) ? (current[TURN_MESSAGED_STATE] as string[]) : [];
return { [TURN_MESSAGED_STATE]: [...messaged, input.to] };
});

// ---- the row, then the delivery ------------------------------------------
const row: WorkerMessageRow = {
Expand Down
5 changes: 3 additions & 2 deletions packages/workforce/test/conversation-board-filing.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,8 @@ describe("what a filing can't name (BR-8)", () => {
const row = await host.row("alice", filing, filed.taskId!);
// The markers on it are the board's own: the filing turn's hop count (FIX-2106), and the
// project it was filed in, none here, whatever the caller named (FIX-2161).
expect(row?.metadata).toEqual({ note: "kept", [FILED_HOP]: { hop: 0, chain: null, lines: 0 }, [FILED_PROJECT]: null });
// `record` files held, so the mark is a fresh chain of its own (FIX-2238).
expect(row?.metadata).toEqual({ note: "kept", [FILED_HOP]: { hop: 0, chain: expect.any(String), lines: 0 }, [FILED_PROJECT]: null });
// No start was owed, so nothing ran: the row has no assignee.
await host.settled();
expect(host.runs).toEqual([]);
Expand All @@ -280,7 +281,7 @@ describe("what a filing can't name (BR-8)", () => {
expect((await host.row("alice", filing, filed.taskId!))?.metadata).toEqual({
note: "kept",
extra: 1,
[FILED_HOP]: { hop: 0, chain: null, lines: 0 },
[FILED_HOP]: row?.metadata?.[FILED_HOP],
[FILED_PROJECT]: null
});
} finally {
Expand Down
2 changes: 1 addition & 1 deletion packages/workforce/test/standing-rules.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ describe("which turns get the rule tools (V3, BR-4)", () => {
const first = await marked({});
const chain = expect.stringMatching(/^chain_/);
expect(first.patches).toEqual([
{ [USER_TURN_STATE]: true, workforceTurnHop: 0, workforceTurnChain: chain, workforceMessagesSent: 0, workforceMessagedWorkers: [] }
{ [USER_TURN_STATE]: true, workforceTurnHop: 0, workforceTurnChain: chain, workforceMessagesSent: 0 }
]);
// It counts one more user's line on the session, which a filed task's
// record is checked against (FIX-2106).
Expand Down
5 changes: 5 additions & 0 deletions packages/workforce/test/worker-messages.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -732,6 +732,11 @@ describe("the hop count through a delegation", () => {
const first = rows.find((row) => row.from === "otto")!;
const fromTask = rows.find((row) => row.from === "helper-b")!;
expect(fromTask.chain, "a fresh chain, not the filing's").not.toBe(first.chain);
// Minted once, at the filing: every request the task runs reloads this
// mark, so a retry or a continuation counts in the same budget.
const mark = held!.metadata?.[FILED_HOP] as { hop: number; chain: string | null };
expect(mark.hop).toBe(0);
expect(fromTask.chain, "the chain the filing recorded").toBe(mark.chain);
} finally {
await h.dispose();
}
Expand Down
Loading