Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
59 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
0a814fe
refactor(orchestration): lift the take rule and resend backoff into p…
claude Oct 27, 2026
cdc1107
refactor(orchestration): lift the take rule and resend backoff into p…
claude Oct 27, 2026
874afbf
feat(workforce): a worker message lands once (FIX-2240)
claude Oct 27, 2026
dbd9e84
feat(workforce): a taken message is never ended for its age; sends re…
claude Oct 27, 2026
b1b86b4
feat(shift-manager): a message reads on its way until taken, and coul…
claude Oct 27, 2026
6b3a3bb
docs(workforce): a message lands once: delivery, statuses, the late-f…
claude Oct 27, 2026
393f159
Merge remote-tracking branch 'origin/claude/project-thread-3uc91a' in…
claude Oct 27, 2026
dd932cb
chore(workforce): say user, not person, in the delivery comments (FIX…
claude Oct 27, 2026
9413821
FIX-2238: every worker flow on an installation hears a message
claude Oct 27, 2026
933dc2f
feat(orchestration,engine): a task id finds its partition, and a bloc…
claude Oct 27, 2026
ddd8a9b
feat(harness-manager): harnessTalkTurn, the session door's talk half,…
claude Oct 27, 2026
a30cfd9
feat(workforce): sendMessage takes { task } and { session }, checked …
claude Oct 27, 2026
c8f0c0c
fix(workforce): name a message row's target field addressedBy
claude Oct 27, 2026
ce4902a
docs(workforce): leave FIX-2238's renames to its own PR (FIX-2240)
claude Oct 27, 2026
b42660c
feat(shift-manager): the coder answers a message to its finished task…
claude Oct 27, 2026
1feba42
FIX-2238: docs, changeset, goal amended, epic seams updated
claude Oct 27, 2026
77f3584
Merge FIX-2160 into FIX-2240 for the stack
claude Oct 27, 2026
85da1aa
spec(FIX-2240): record the three seams folded while building
claude Oct 27, 2026
d94227d
feat(orchestration,engine): a task id finds its partition, and a bloc…
claude Oct 27, 2026
aa3852c
feat(harness-manager): harnessTalkTurn, the session door's talk half,…
claude Oct 27, 2026
dfd7fe1
feat(workforce): sendMessage takes { task } and { session }, checked …
claude Oct 27, 2026
c3e3cb6
fix(workforce): name a message row's target field addressedBy
claude Oct 27, 2026
cf5e871
feat(shift-manager): the coder answers a message to its finished task…
claude Oct 27, 2026
ae2bb6b
test(goals): legs 6-8 message a task, a conversation and the coder's …
claude Oct 27, 2026
0979138
test(workforce): a taker that dies after the take is resent and lands…
claude Oct 27, 2026
b03e4fe
Merge main into FIX-2238; review fixes
claude Oct 27, 2026
759d851
docs: message a task or a conversation by id; harnessTalkTurn; the le…
claude Oct 27, 2026
c6d6191
test(goals): leg 6 opens a delegate session for leg 7; goal.md names …
claude Oct 27, 2026
39b85ea
fix: parse id-index markers with their schema; the request host is cl…
claude Oct 27, 2026
0b01f18
Merge FIX-2160 (#4012) into FIX-2240 for the stack
claude Oct 27, 2026
acdd330
FIX-2238: one chain for a task filed held; drop the dead messaged-wor…
claude Oct 27, 2026
b5a893e
Merge FIX-2238's branch (main merged) into FIX-2160
claude Oct 27, 2026
a0149c2
spec(FIX-2160): notes from the cross-spec review, recorded at impleme…
claude Oct 27, 2026
973404f
fix(workforce): a { task } target counts only partitions that hold th…
claude Oct 27, 2026
dd83e61
Merge FIX-2160 (#4012, with main) into FIX-2240
claude Oct 27, 2026
e088b23
chore(workforce): keep undeliveredLine module-private (FIX-2240)
claude Oct 27, 2026
752d290
FIX-2238: a received message's budget is what its chain has left
claude Oct 27, 2026
0961e69
fix(goals): type leg 8's setWorkProject call (FIX-2160)
claude Oct 27, 2026
c748982
Merge FIX-2160 (#4012) into FIX-2240
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
fa37e7d
fix(workforce): record a message delivered only once its items are st…
claude Oct 27, 2026
d19f32a
spec(FIX-2240): record the accepted fast-path loss window
claude Oct 27, 2026
0776b40
refactor(workforce): one close step in the message pass; parse the ow…
claude Oct 27, 2026
67b7ee5
Merge FIX-2238's latest into FIX-2160
claude Oct 27, 2026
18268d2
refactor(workforce): the take answers the row or nothing; one refusal…
claude Oct 27, 2026
00fef9e
Merge FIX-2160 (#4012) into FIX-2240
claude Oct 27, 2026
6b3987d
fix(workforce): a worker's other conversation can answer it (FIX-2160)
claude Oct 27, 2026
594fd76
fix(workforce): a resent answer keeps the send's answering exception …
claude Oct 27, 2026
7b5466b
fix(workforce): a taken message whose destination is gone ends past t…
claude Oct 27, 2026
3aecb45
fix(workforce): a repeat of a refused send answers the refusal (FIX-2…
claude Oct 27, 2026
5efdc4d
fix(workforce): a resend to a task refuses once the task moved sessio…
claude Oct 27, 2026
ac6d701
Merge remote-tracking branch 'origin/claude/project-thread-i68jr1' in…
claude Oct 27, 2026
eec5d61
Merge main (FIX-2238 #4010 and FIX-2160 #4012 landed) into FIX-2240
claude Oct 27, 2026
6123c83
fix(engine): a failed item write rejects the filesystem store's flush…
claude Oct 27, 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
11 changes: 11 additions & 0 deletions .changeset/a-message-lands-once.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
"@flow-state-dev/workforce": minor
"@flow-state-dev/orchestration": minor
"@flow-state-dev/engine": patch
---

A worker message lands once (FIX-2240). The recipient's `onMessageReceived` takes a message on its log row before it lands, so a late copy lands nothing, and the sending session's board pass sends a message again, backing off from 2 s to 5 min, until it is delivered, refused or past the host's debt age. A message that can't land after the send returned leaves a line in the sending session, which its next turn reads.

**Migration.** The `sendMessage` tool answers `{ sent }` only: `unconfirmed` is gone, and `SendOutcome` no longer carries it. A log row's `status` is one of `unconfirmed` (on its way), `delivered` (landed in the recipient's conversation, not just accepted by its host), `refused` or `undeliverable`, and gains `toState`, `takenBy`, `deliveredAs`, `deliveredAt`, `resent` and `toldAt`. `dispatch-rejected`, `no-dispatch-operation` and `flow-not-found` are no longer final. The session's 500-id seen window (`workerMessagesSeen`, `messageReceivedStateShape`) is removed. The server function `sendMessage` takes an optional `{ id }`, so a repeated send under one server-chosen id is one message. Orchestration exports the take rule (`takeRule`, `decideTake`, `TakeRule`, `hasEnded`) and the resend backoff (`nextResendAt`, `NOTICE_RESEND_CAP_MS`) its task notices and worker messages share.

The filesystem request store's `flushItems` now rejects when an item write failed, as `flushEvents` does, so a resolved flush means the items are stored.
4 changes: 2 additions & 2 deletions apps/docs/docs/shift-manager/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ These are Shift Manager's own screens and words. Where one maps onto a Workforce
| **Roster** | Every worker, grouped as on shift (running a task, or waiting on you) or off shift. Each worker has a **Settings** button that opens its settings page. Its Rules section lists the notes the worker keeps for you, its [standing rules](../workforce/standing-rules.md), with when each was added and where it came from. Add, edit or delete them there; the next turn reads the change. For a worker whose flow doesn't keep rules, the section says so. |
| **A project** | Shared with your org, or private to you. Tabs: Stream (your own [project coordinator](../workforce/projects.md#talking-to-a-project)), Workstreams (every workstream's entry, with the progress worked out from them), Board (the tasks of your own workstreams) and Brief, which also names the project's repository, or says its coding work runs on the project's files. See [Projects](../workforce/projects.md). |
| **A workstream** | On a project, your own workstream opens on its lead's conversation. Someone else's opens on its details and latest report. |
| **Messages** | Every [message](../workforce/messaging-workers.md) one of your workers sent another, newest first, with a message and its answers kept together. Each line shows when it was sent, who sent it, who got it and its first line of text. The sender and the recipient are links: each opens the conversation that holds the message on that side. A message that wasn't delivered, or whose delivery couldn't be confirmed, says so. Messages aren't tasks, so nothing here shows on Tasks. |
| **Messages** | Every [message](../workforce/messaging-workers.md) one of your workers sent another, newest first, with a message and its answers kept together. Each line shows when it was sent, who sent it, who got it and its first line of text. The sender and the recipient are links: each opens the conversation that holds the message on that side. A delivered message shows nothing more. One still on its way says *on its way*, a refused one *not delivered*, and one that never landed in time *couldn't be delivered*. See [Delivery](../workforce/messaging-workers.md#delivery). Messages aren't tasks, so nothing here shows on Tasks. |
| **Scheduled work** | Your [schedules](../workforce/delegating-work.md#recurring-work), soonest first. Each line shows when the schedule is next due, the task it files, on whose board and for whom, and its cron and time zone. A schedule that is off says so. The tasks a schedule files show on Tasks like any other. |
| **Usage** | How much of each coding agent's subscription you have used, one card per agent: each limit window's percent and reset time, the plan, and where the numbers came from and how old they are. Opening Usage asks for a fresh reading, at most once a minute. A window whose reset has passed shows when it reset instead of a percent. An agent with no number (an API key, nobody signed in, a read that failed) says why. |
| **Settings** | Your own keys for the MCP servers the Lab offers its projects' coding runs. See [Settings](./settings.md). |
Expand All @@ -73,7 +73,7 @@ In your own app, `openWorkstream` takes whichever lead you name. See [Projects](

Shift Coordinator, a workstream and a task also have a panel on the right. The sidebar and the right panel each collapse from their own toggle or from the keyboard: `[` for the sidebar, which shrinks to a column of icons, and `]` for the right panel, which shrinks to a strip. Each one's state is kept in the browser for the signed-in user. On a window narrower than 1180px, the right panel starts collapsed and opens over the center.

In a conversation, a message the worker sent another worker shows as its own line, *To <worker>: <text>*, with a link to Messages. One that was refused says it wasn't sent, and why. A message the worker received shows as its own item: the sender's name, the time it arrived, *answering your message* when it answers one the worker sent, a *Messages ›* link, and the text.
In a conversation, a message the worker sent another worker shows as its own line, *To <worker>: <text>*, with a link to Messages. One that was refused says it wasn't sent, and why. If it was sent but can't be delivered, Messages marks it, and the sender's conversation gets a line saying so. A message the worker received shows as its own item: the sender's name, the time it arrived, *answering your message* when it answers one the worker sent, a *Messages ›* link, and the text.

A board has five columns: QUEUED, RUNNING, IN REVIEW, NEEDS YOU and DONE. In a workstream's composer, a message that starts with `@` and a worker's name goes to that worker's task in the workstream.

Expand Down
59 changes: 48 additions & 11 deletions apps/docs/docs/workforce/messaging-workers.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,19 +37,15 @@ The model calls `sendMessage` with the recipient's worker id and the text:

The input takes `to`, `text` and, for an answer, `inReplyTo`. Nothing else. `to` is usually a worker id; it can also name [a task or a conversation](#messaging-a-task-or-a-conversation). The tool's description lists the workers the send would take, by id and description, so the model picks from real ids. The sending worker itself, and workers that hear only in task sessions, aren't listed.

A sent message answers with its id:
Once the message is written to the [log](#showing-messages-in-your-app), the tool answers with its id:

```json
{ "sent": "msg_3f1c0a9e2b7d4c6a8e10" }
```

`text` holds up to 8,000 characters. A longer one is refused, not cut.

If the delivery couldn't be confirmed, the answer says so. The message may still arrive:
That answer means the message is on its way, not that it has landed. See [Delivery](#delivery) for what happens next.

```json
{ "sent": "msg_3f1c0a9e2b7d4c6a8e10", "unconfirmed": "the delivery couldn't be confirmed (…); it may still arrive." }
```
`text` holds up to 8,000 characters. A longer one is refused, not cut.

## What the recipient sees

Expand Down Expand Up @@ -126,6 +122,42 @@ A worker whose flow hears messages only in its tasks' sessions, such as the codi

That coding worker answers from the coding session the task ran in, by resuming it with the message. It has no `sendMessage`, so its reply stays in the task's session, where you can read it. Nothing goes back to the sender. To build the same on your own coding flow, pass `harnessTalkTurn` as the flow's message turn (see [Answering a worker's message](https://github.com/fixpoint-labs/flow-state-dev/blob/main/packages/harness-manager/README.md#answering-a-workers-message) in the `@flow-state-dev/harness-manager` README).

## Delivery

A message is delivered once it lands in the recipient's conversation. The recipient *takes* a message when it starts landing it there. Its row in the [log](#showing-messages-in-your-app) says where it got to, in `status`:

| `status` | What it means |
|----------|---------------|
| `unconfirmed` | On its way: written to the log, and not yet taken by the recipient. |
| `delivered` | It landed in the recipient's conversation. |
| `refused` | It can't be delivered. Final, with the reason in `reason`. |
| `undeliverable` | Nobody had taken it by the host's debt age, [`maxDebtAgeMs`](../configuration/runtime.md), a day by default. Final. |

**It's sent again until it lands.** While a message is `unconfirmed`, the session that sent it sends it again. The first resend comes 2 seconds after the send, then the gap doubles each time, up to 5 minutes. It stops once the message is delivered, refused or past the debt age. The row's `resent` holds how many times it was sent again and when last, and `reason` holds why the last try failed.

Some failures are waited out. The message is sent again when:

- the recipient's host is busy and turns the delivery away for now (`dispatch-rejected`);
- the host has no way to deliver it (`no-dispatch-operation`);
- a flow is missing for a moment (`flow-not-found`);
- the delivery throws.

Others are final, and the message is `refused`: the recipient's flow has no entry for messages, its session is missing or can't be addressed, or creating the session was refused.

Each resend checks the recipient again, the same way the send did. If the recipient is fired after the send, the message is refused with `no_worker` or `worker_unavailable` and never reaches it.

**It's heard once.** However many copies arrive, and however late, the message lands in the recipient's conversation once and wakes one turn. If a delivery stops partway, the next copy finishes it.

**The sender hears when it can't land.** If the recipient's host refuses the first delivery for good, the tool answers [`not_delivered`](#when-a-send-is-refused) with the reason. If a message can't land after the tool has answered `{ sent }`, the sending session gets one line in its conversation:

```text
Your message msg_3f1c0a9e2b7d4c6a8e10 to chief-of-staff wasn't delivered: <reason>.
```

Its next turn reads the line in its history. No turn is started for it.

**Resends need a host that keeps wakes.** The resend runs on the sending session's [wake](../advanced/durable-execution.md#wakes), so it needs a durable host. On a host without wakes, an owed message is sent again only when that session's board runs for something else. A worker flow without the session kit's entries, `board.entries(turn)`, sends a message once and never again.

## The budget

Messages between workers can't run on forever. Each line you type starts a **budget**: at most 6 messages (`hopLimit`) for everything that descends from that line, across every worker. The messages, the turns they wake, the answers those turns send and the tasks filed along the way all draw on the same 6, parallel branches included. On top of that, any one request sends at most 3 (`perTurn`).
Expand Down Expand Up @@ -156,7 +188,7 @@ Each must be a whole number of at least 1, or `hireWorkforce` throws.

## When a send is refused

A refused send answers `{ ok: false, error }`, and nothing is sent. The error starts with a code, then says what happened in words the model can act on:
A refused send answers `{ ok: false, error }`, and the message isn't delivered. The error starts with a code, then says what happened in words the model can act on:

```json
{ "ok": false, "error": "task_sessions_only: \"eng.coder\" answers only from its tasks' sessions, so it can't be messaged by name. File it a task instead." }
Expand All @@ -178,7 +210,7 @@ A refused send answers `{ ok: false, error }`, and nothing is sent. The error st
| `no_such_message` | `inReplyTo` names no message the `to` worker sent this worker, or is passed with `{ task }` or `{ session }`. |
| `budget` | The send would go past `messages.hopLimit` messages since the user's last line. |
| `per_request_limit` | This request already sent `messages.perTurn` messages. |
| `not_delivered` | The server refused the delivery. The error carries its reason. |
| `not_delivered` | The recipient's host refused the first delivery for good. The error carries its reason, and the message's row in the log is `refused`. See [Delivery](#delivery). |

## Message or delegate?

Expand Down Expand Up @@ -333,8 +365,13 @@ Each row has:
| `toSession`, `toFlow` | The session it landed in, and that session's flow. |
| `chain` | The id of the budget the message drew on: everything descending from one user's line. Optional. |
| `hop` | Its place in that budget, from 1. |
| `status` | `delivered`, `refused`, or `unconfirmed`. |
| `reason` | Why it was refused or is unconfirmed. |
| `status` | `unconfirmed`, `delivered`, `refused` or `undeliverable`. See [Delivery](#delivery). The package root exports the list as `MESSAGE_STATUSES`. |
| `reason` | Why it was refused or couldn't be delivered. While it's `unconfirmed`, why the last try failed. |
| `toState` | The state the recipient's conversation starts with. Optional. |
| `takenBy` | The recipient's request that took it. Optional. |
| `deliveredAs`, `deliveredAt` | The request it landed in, and when. Set once, on delivery. |
| `resent` | `{ n, at }`: how many times it was sent again, and when last. Optional. |
| `toldAt` | When the sending session was told it was refused or couldn't be delivered. Optional. |
| `at` | When it was sent, in ms. |

The read never returns another user's messages.
Expand Down
20 changes: 20 additions & 0 deletions packages/core/src/types/block.ts
Original file line number Diff line number Diff line change
Expand Up @@ -731,6 +731,26 @@ export interface BlockContext<
}
): Promise<void>;

/**
* @internal Emit a message item and AWAIT its delivery: the message twin of
* {@link _emitComponentAwaited}, settling once the item has been added and
* completed and rejecting rather than swallowing. Absent in a hand-built
* context; a caller that depends on it treats absence as a failure.
*/
_emitMessageAwaited?(
text: string,
options?: { itemVisibility?: ItemVisibility; agentName?: string; transient?: boolean }
): Promise<void>;

/**
* @internal Resolve once every item this request has completed so far is
* written to the request store (`flushItems` on the request's id). An item
* emitted with an awaited emitter is completed when that emitter settles, so
* awaiting the emitter, then this, is the barrier for "the item is stored"
* before a write that says it was. Absent in a hand-built context.
*/
_flushItems?(): Promise<void>;

/**
* @internal Top up the per-scope resource caches with an action's or block's
* declared resources at dispatch time (FIX-688 Waves 2 & 3). Loads only the
Expand Down
34 changes: 34 additions & 0 deletions packages/engine/src/context/createExecutionContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,37 @@ function createEmitComponentAwaited(
};
}

/**
* The awaited message emitter behind `ctx._emitMessageAwaited`: as
* {@link createEmitMessage}, but it settles on the emission and rejects if
* either step does, as {@link createEmitComponentAwaited} does for components.
*/
function createEmitMessageAwaited(
emCtx: EmissionContext
): (text: string, options?: { itemVisibility?: ItemVisibility; agentName?: string; transient?: boolean }) => Promise<void> {
return async function emitMessageAwaited(text, options): Promise<void> {
const itemIndex = emCtx.nextItemIndex();
const item: MessageItem = {
id: `item_message_${itemIndex}_${Math.random().toString(16).slice(2)}`,
type: "message",
status: "completed",
transient: options?.transient === true ? true : undefined,
requestId: emCtx.requestId,
itemIndex,
provenance: emCtx.provenance(),
ts: Date.now(),
ownedBy: emCtx.ownedBy,
taskId: emCtx.taskId,
itemVisibility: options?.itemVisibility ?? emCtx.itemVisibility,
agentName: options?.agentName ?? emCtx.agentName,
role: "assistant",
content: [{ type: "output_text", text }]
};
await emCtx.response.emitItemAdded(item);
await emCtx.response.emitItemDone(item);
};
}

/**
* Request-scoped status slot. Shared across every `createEmitStatus` call
* within a single request so nested scopes see the same "current message"
Expand Down Expand Up @@ -4311,6 +4342,9 @@ export async function createExecutionContext<
// — `emit.component` stays `void`, and a caller that needs delivery to be
// observable asks for it by name.
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);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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


Object.defineProperty(context, "sequencer", {
enumerable: true,
Expand Down
12 changes: 12 additions & 0 deletions packages/engine/src/stores/filesystem/request-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,8 @@ export class FilesystemRequestStore implements RequestStore {
* propagate persist failures instead of silently swallowing them (FIX-399).
*/
private readonly lastEventError = new Map<string, Error>();
/** The same for item writes: `flushItems` throws (and clears) it. */
private readonly lastItemError = new Map<string, Error>();
private readonly pollIntervalMs: number;
private readonly onPersistError?: PersistErrorHandler;

Expand Down Expand Up @@ -419,6 +421,7 @@ export class FilesystemRequestStore implements RequestStore {
// An event write failure not yet reported belonged to the deleted
// request; the id's next owner must not be handed it by its first flush.
this.lastEventError.delete(id);
this.lastItemError.delete(id);
}

async deleteIfStatus(
Expand All @@ -443,6 +446,7 @@ export class FilesystemRequestStore implements RequestStore {
if (!deleted) return { applied: false, status: found };
this.pendingNewEvents.delete(id);
this.lastEventError.delete(id);
this.lastItemError.delete(id);
return { applied: true, status: found };
}

Expand Down Expand Up @@ -554,6 +558,13 @@ export class FilesystemRequestStore implements RequestStore {
if (queue !== undefined) {
await queue.drain();
}
// A failed write rejects the flush, as `flushEvents` does: a caller that
// treats a resolved flush as proof the items are stored must not be told so.
const lastError = this.lastItemError.get(requestId);
if (lastError !== undefined) {
this.lastItemError.delete(requestId);
throw lastError;
}
}

async countItems(requestId: string): Promise<number> {
Expand Down Expand Up @@ -719,6 +730,7 @@ export class FilesystemRequestStore implements RequestStore {
queue = createSerializedWriteQueue({
label: `request-items:${requestId}`,
onError: (err) => {
this.lastItemError.set(requestId, err);
this.onPersistError?.({ store: "request", id: requestId, error: err });
console.error(
`[flow-state] item persistence failed for ${requestId}`,
Expand Down
Loading
Loading