Repository navigation
FIX-1661: the engine records each request's action result; the DevTool row reads it #2429
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
2013d34
feat(engine,client,devtool): record each request's action result; the…
claude 5851e3f
test(goals), docs: the row reads its action's result goal check; docu…
claude 65ddb90
fix(engine): bound and faithful stored outputs; one settle helper for…
claude 70cc085
docs(FIX-1661): writer and editor pass over the request result docs
claude 4620725
fix(engine): store large outputs whole, and mark built-in containers …
claude c096773
fix(devtool): keep streamed-only traces in the Stream and Trace tabs …
claude b9fdfea
fix(engine): snapshot the recorded output when the action answers, be…
claude d2c9bd0
Merge origin/main into fix/fix-1661
claude File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| --- | ||
| "@flow-state-dev/engine": patch | ||
| "@flow-state-dev/client": patch | ||
| "@flow-state-dev/devtool": patch | ||
| "@flow-state-dev/fsdev": patch | ||
| --- | ||
|
|
||
| Each request's record now stores its action result (`output` as JSON, and/or `error`) with its final status, `listSessionRequests` returns it (the output with `includeResultOutput`), the DevTool task row reads it instead of reconstructing it from traces, and a run a completion hook failed after the action answered now reports that answer as `output` (including `fsdev run`'s result, where it was `null`) (FIX-1661). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
130 changes: 130 additions & 0 deletions
130
goals/devtool-workforce-visibility/reads-a-row-actions-result/fixtures/flow.mts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,130 @@ | ||
| /** | ||
| * The fixture flow: one durable task board, its task tools as actions, and | ||
| * five app actions shaped as the goal's row legs. | ||
| * | ||
| * Every leg action takes a `taskId`, so the DevTool offers it on each row, and | ||
| * answers with a value the goal check fixes through `ROW_RESULT_ANSWERS` (the | ||
| * fixture's `answers`, held out). Each is shaped as one of the cases a trace | ||
| * reading could not see: | ||
| * | ||
| * - `handover` — a transient block refuses. Nothing it traced is persisted. | ||
| * - `hook` — a refusal, with the flow's completion hooks running after it | ||
| * as root blocks of the same request. | ||
| * - `ref` — a success whose value a sequencer holds by reference to its | ||
| * step's trace. | ||
| * - `suspend` — suspends for a person, and answers with what they resumed it | ||
| * with. | ||
| * - `hookFails` — refuses, then the action's own completion hook throws, so the | ||
| * request fails after the action answered. | ||
| * | ||
| * No model anywhere: every block is a deterministic handler. | ||
| */ | ||
| import { defineFlow, handler, sequencer } from "@flow-state-dev/core"; | ||
| import { taskBoard, taskToolActions } from "@flow-state-dev/orchestration/task-board"; | ||
| import { defineTaskCollection, type TaskWorker } from "@flow-state-dev/orchestration/tasks"; | ||
| import { z } from "zod"; | ||
|
|
||
| /** The flow kind the goal check addresses, and the board its rows are on. */ | ||
| export const ROW_RESULTS_KIND = "row-results"; | ||
| export const ROW_BOARD = "rows"; | ||
|
|
||
| /** The answers each leg returns, fixed by the goal check. */ | ||
| export type RowAnswers = { | ||
| handover: string; | ||
| hook: string; | ||
| ref: unknown; | ||
| suspend: string; | ||
| hookFails: { refusal: string; error: string }; | ||
| }; | ||
|
|
||
| const taskInput = z.object({ taskId: z.string() }); | ||
|
|
||
| const noopWorker = handler({ | ||
| name: "row-results-noop-worker", | ||
| inputSchema: z.unknown(), | ||
| outputSchema: z.null(), | ||
| execute: () => null, | ||
| }) as TaskWorker; | ||
|
|
||
| /** Build the flow for one set of answers. */ | ||
| export function rowResultsFlow(answers: RowAnswers) { | ||
| const rows = defineTaskCollection({ id: ROW_BOARD, scope: "session" }); | ||
| const board = taskBoard({ name: ROW_BOARD, collection: rows, workers: noopWorker }); | ||
|
|
||
| const refStep = handler({ | ||
| name: "row-results-ref-step", | ||
| inputSchema: taskInput, | ||
| execute: () => answers.ref, | ||
| }); | ||
|
|
||
| const gate = handler({ | ||
| name: "row-results-gate", | ||
| inputSchema: z.unknown(), | ||
| execute: async (_input, ctx) => { | ||
| const decision = (await ctx.suspend!({ | ||
| reason: "human_input", | ||
| message: "Answer this row", | ||
| resumeSchema: { type: "object", properties: { answer: { type: "string" } } }, | ||
| })) as { answer?: string } | undefined; | ||
| return { ok: true, answer: decision?.answer ?? null }; | ||
| }, | ||
| }); | ||
|
|
||
| // Root blocks of every request, before and after its action, taking the | ||
| // request's own id as input: what a trace reading had to tell apart. | ||
| const hookBlock = (name: string) => | ||
| handler({ name, inputSchema: z.unknown(), execute: () => ({ observed: name }) }); | ||
|
|
||
| return defineFlow({ | ||
| kind: ROW_RESULTS_KIND, | ||
| request: { | ||
| onStarted: hookBlock("row-results-on-started"), | ||
| onCompleted: hookBlock("row-results-on-completed"), | ||
| onFinished: hookBlock("row-results-on-finished"), | ||
| }, | ||
| actions: { | ||
| ...taskToolActions(board), | ||
| handover: { | ||
| inputSchema: taskInput, | ||
| block: handler({ | ||
| name: "row-results-handover", | ||
| transient: true, | ||
| inputSchema: taskInput, | ||
| execute: () => ({ ok: false, error: answers.handover }), | ||
| }), | ||
| }, | ||
| hook: { | ||
| inputSchema: taskInput, | ||
| block: handler({ | ||
| name: "row-results-hook", | ||
| inputSchema: taskInput, | ||
| execute: () => ({ ok: false, error: answers.hook }), | ||
| }), | ||
| }, | ||
| ref: { | ||
| inputSchema: taskInput, | ||
| block: sequencer({ name: "row-results-ref", inputSchema: taskInput }).step(refStep), | ||
| }, | ||
| suspend: { | ||
| inputSchema: taskInput, | ||
| durable: true, | ||
| block: sequencer({ name: "row-results-suspend", durable: true, inputSchema: taskInput }).step(gate), | ||
| }, | ||
| hookFails: { | ||
| inputSchema: taskInput, | ||
| block: handler({ | ||
| name: "row-results-hook-fails", | ||
| inputSchema: taskInput, | ||
| execute: () => ({ ok: false, error: answers.hookFails.refusal }), | ||
| }), | ||
| onCompleted: handler({ | ||
| name: "row-results-failing-hook", | ||
| inputSchema: z.unknown(), | ||
| execute: () => { | ||
| throw new Error(answers.hookFails.error); | ||
| }, | ||
| }), | ||
| }, | ||
| }, | ||
| } as never); | ||
| } |
39 changes: 39 additions & 0 deletions
39
goals/devtool-workforce-visibility/reads-a-row-actions-result/fixtures/fsdev.config.mts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| /** | ||
| * What `fsdev dev` serves for this goal: the fixture flow, durable, on SQLite | ||
| * under the server's working directory, with the debug endpoints on so the | ||
| * check can find the suspension it resumes. | ||
| * | ||
| * ROW_RESULT_ANSWERS='<json>' fsdev dev --config <this file> | ||
| * | ||
| * The answers come from the goal check (its fixture, held out); a person | ||
| * running the server by hand gets placeholder ones. | ||
| */ | ||
| import { mkdirSync } from "node:fs"; | ||
| import { createFlowState } from "@flow-state-dev/engine"; | ||
| import { sqliteStores } from "@flow-state-dev/store-sqlite"; | ||
| import { ROW_RESULTS_KIND, rowResultsFlow, type RowAnswers } from "./flow.mts"; | ||
|
|
||
| /** The user the DevTool's navigator lists sessions for. */ | ||
| export const ROW_RESULTS_USER = "u_row_results"; | ||
|
|
||
| const answers: RowAnswers = process.env.ROW_RESULT_ANSWERS | ||
| ? (JSON.parse(process.env.ROW_RESULT_ANSWERS) as RowAnswers) | ||
| : { | ||
| handover: "refused (handover)", | ||
| hook: "refused (hook)", | ||
| ref: { ok: true, value: "ref" }, | ||
| suspend: "approved", | ||
| hookFails: { refusal: "refused (hook fails)", error: "the hook failed" }, | ||
| }; | ||
|
|
||
| mkdirSync(".fsdev/data", { recursive: true }); | ||
|
|
||
| const flow = rowResultsFlow(answers)(); | ||
|
|
||
| export default createFlowState({ | ||
| flows: { [ROW_RESULTS_KIND]: flow }, | ||
| stores: { default: { primary: sqliteStores({ filename: ".fsdev/data/row-results.db" }) } }, | ||
| durable: true, | ||
| debugEndpointsEnabled: true, | ||
| devtool: { userId: ROW_RESULTS_USER }, | ||
| } as never); |
19 changes: 19 additions & 0 deletions
19
goals/devtool-workforce-visibility/reads-a-row-actions-result/fixtures/input.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| { | ||
| "rows": { | ||
| "handover": "a transient row that the handover leg refuses", | ||
| "hook": "a row the hook leg refuses under the flow's completion hooks", | ||
| "ref": "a row the ref leg answers with a value held by reference", | ||
| "suspend": "a row the suspend leg answers after a person resumes it", | ||
| "hookFails": "a row whose action answers before a hook fails the request" | ||
| }, | ||
| "answers": { | ||
| "handover": "handover: task is cancelled, which is terminal", | ||
| "hook": "hook: task is not claimable while it is parked", | ||
| "ref": { "ok": true, "value": "ref: priority raised to 7" }, | ||
| "suspend": "suspend: approved by the on-call reviewer", | ||
| "hookFails": { | ||
| "refusal": "hook-fails: the task was already settled", | ||
| "error": "hook-fails: the notification service is down" | ||
| } | ||
| } | ||
| } |
34 changes: 34 additions & 0 deletions
34
goals/devtool-workforce-visibility/reads-a-row-actions-result/goal.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| # devtool-workforce-visibility › it reads a row action's result | ||
|
|
||
| **Issue:** FIX-1661. The spec's goal check. | ||
|
|
||
| **Outcome:** A developer runs an action from a task's row in the DevTool and the row shows what that action came to: refused with the action's own words, done with its answer, or failed with the error, even when the answer only ever existed in a transient block, behind completion hooks, by reference inside a sequencer, after a person resumed it, or before a hook failed the request. The row reads it from the result the engine recorded for the request, never from traces or the live stream. | ||
|
|
||
| **Input:** The fixture flow (`fixtures/flow.mts`), served by the ordinary `fsdev dev --config fixtures/fsdev.config.mts` on SQLite, durable, with no model. `fixtures/input.json` holds one row goal per leg and the answer each leg's action returns. Both are **held out**: the server gets the answers through `ROW_RESULT_ANSWERS`, and rows are filed through the board's own `addTask_rows` action and found by the ids it returned. Different answers must pass too. | ||
|
|
||
| **Signal:** Chromium on the shipped DevTool bundle, rebuilt at the start of the run, at **1280×800**. The page talks to the server through a pass-through proxy the check runs. Each leg runs its action from the row's own Actions strip, with the task id locked in the form. Every failure line names its leg. | ||
|
|
||
| - **handover.** A transient block refuses. Then the hook leg's dispatch takes the one live stream, and the handover row is graded again: it still reads `refused` with the fixture's words. | ||
| - **hook.** A refusal with the flow's `onStarted`/`onCompleted`/`onFinished` hooks running as root blocks of the same request. The row reads `refused` with the fixture's words. | ||
| - **ref.** A sequencer whose step returns the answer. The row reads `ok` and shows that value. | ||
| - **suspend.** A durable sequencer suspends for a person. While suspended the row reads pending (checked after 4.5s). The check resumes it over HTTP with the fixture's answer, and the same row then reads `ok` with it. | ||
| - **hook-fails.** The action refuses, then its own `onCompleted` hook throws. The row reads `failed` with the hook's error and the action's refusal. | ||
| - **api.** Through the proxy, `GET /sessions/:id/requests?include_result_output=true` lists each leg's request with its recorded result and output. Without the flag it lists the status, `result.error` and `hasOutput` only. | ||
| - The page loads once. Any further main-frame navigation fails the run. | ||
|
|
||
| **Anti-game:** The hollow pass is a row that still reconstructs the answer from traces or the stream, and happens to get these cases right. The `no-result` control rules it out: with `result` stripped from the listing, every row leg must go red, so nothing but the recorded result can turn a row green. Rows are found by `data-task-id`, never by text. The check never reads the store to decide what is on screen. | ||
|
|
||
| **Model:** n/a. Every block is a deterministic handler. | ||
|
|
||
| **Run:** `PLAYWRIGHT_BROWSERS_PATH=/opt/pw-browsers pnpm tsx goals/devtool-workforce-visibility/reads-a-row-actions-result/run.mts`. The run builds the DevTool bundle first. On a clean checkout, run `pnpm packages:build` once before it. | ||
|
|
||
| **Controls:** Each control must FAIL at exactly the legs named, and the run checks that itself. | ||
|
|
||
| - `GOAL_CONTROL=no-result`: the proxy strips `result` from the session request list, which is what a server that does not record results sends. Must fail **every leg**: handover, hook, ref, suspend, hook-fails and api. | ||
|
|
||
| ## Verdict log | ||
|
|
||
| | Date | Commit | Model | Verdict | Notes | | ||
| |------|--------|-------|---------|-------| | ||
| | 2026-09-30 | `2013d34f6` + this goal (on `fix/fix-1661`) | n/a | FAIL (expected) | Control `no-result`: **every leg**, and no other. The handover, hook, ref and suspend rows read *"No result recorded for this request."*; hook-fails read *"Failed: The request ended failed. No result recorded for this request."*; api reported each leg listing no result. | | ||
| | 2026-09-30 | `2013d34f6` + this goal (on `fix/fix-1661`) | n/a | **PASS** | handover: *"Refused: handover: task is cancelled, which is terminal"*, still so after hook's dispatch. hook: *"Refused: hook: task is not claimable while it is parked"*. ref: *"Done: {"ok":true,"value":"ref: priority raised to 7"}"*. suspend: pending while suspended, then *"Done: {"ok":true,"answer":"suspend: approved by the on-call reviewer"}"*. hook-fails: *"Failed: hook-fails: the notification service is down (the action itself refused: hook-fails: the task was already settled)"*. api: all five results with the flag; status, error and `hasOutput` only without. One page load. | |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.