GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — feat(server): durable workflows by juliusmarminge · Pull Request #38882 · pingdotgg/t3code

feat(server): durable workflows #38882

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.

Sign up for GitHub

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
juliusmarminge merged 75 commits into main from feat/workflow-child-runs
Nov 23, 2026
+14,092 −92
Merged

feat(server): durable workflows #38882

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
75 commits
Select commit Hold shift + click to select a range
ac1fe7e
feat(server): durable workflows
juliusmarminge Nov 19, 2026
df0c1e1
fix(server): workflow reloads keep what is loaded when the folder can…
juliusmarminge Nov 19, 2026
960098e
fix(server): a workflow step's timeout stops only its own turn
juliusmarminge Nov 19, 2026
0ebf8fe
test(server): a signal buffered as its wait opens still reaches that …
juliusmarminge Nov 19, 2026
102ddc2
fix(server): a workflow step whose timeout cannot stop its turn pause…
juliusmarminge Nov 19, 2026
602beff
fix(server): a wait another signal claimed first wakes with that sign…
juliusmarminge Nov 19, 2026
6cc0802
fix(server): a workflow started at a version that is not registered f…
juliusmarminge Nov 19, 2026
7624d66
fix(server): a workflow agent whose dead turn cannot be stopped does …
juliusmarminge Nov 19, 2026
08f14a3
test(server): workflow races, versions and malformed definitions are …
juliusmarminge Nov 19, 2026
678b765
fix(server): workflow reloads keep what runs when the folder cannot b…
juliusmarminge Nov 19, 2026
00f9c40
fix(server): the workflow runtime keeps its types while it retries an…
juliusmarminge Nov 19, 2026
56e100d
fix(server): workflow stops and signal claims hold up when they fail,…
juliusmarminge Nov 19, 2026
1506f05
fix(evals): the workflow-authoring grader follows the renumbered work…
juliusmarminge Nov 19, 2026
fdf36df
test(server): a workflow agent whose result cannot be read and whose …
juliusmarminge Nov 19, 2026
60f8fe8
fix(server): workflow steps, signals, cancels, triggers and owed resu…
juliusmarminge Nov 19, 2026
6c93375
fix(server): a kept copy of a signal id that already woke a wait wake…
juliusmarminge Nov 19, 2026
1fcf425
fix(server): dropping a workflow version checks every unfinished run,…
juliusmarminge Nov 19, 2026
aaf2cc7
test(server): a workflow stop turned down once gets through on its retry
juliusmarminge Nov 19, 2026
62f179a
fix(server): workflow cancel stops only its own turn, and saves say w…
juliusmarminge Nov 19, 2026
fc97d27
feat(server): settle the workflow authoring API for v1
juliusmarminge Nov 19, 2026
ba4717b
fix(server): a workflow file that exports nothing loads on a real server
juliusmarminge Nov 19, 2026
44bdddf
fix(server): every workflow call refuses options it does not take
juliusmarminge Nov 19, 2026
73d3a97
docs(skills): rewrite the workflow skill around a quick start and the…
juliusmarminge Nov 19, 2026
e66c35e
fix(server): a turn asked for no result is not waited past for one
juliusmarminge Nov 21, 2026
6ff02a5
fix(server): a submitted result goes to the turn that still owes it
juliusmarminge Nov 21, 2026
6f4ecc5
fix(server): an agent step past its time keeps a result that already …
juliusmarminge Nov 21, 2026
0ef707f
fix(server): an agent step that will not give its result is not run a…
juliusmarminge Nov 21, 2026
063a350
fix(server): short workflow sleeps survive a restart
juliusmarminge Nov 21, 2026
a4b00c1
fix(server): a retried webhook request is the same workflow run
juliusmarminge Nov 21, 2026
f9e141d
fix(server): a scheduled workflow start that fails is tried again
juliusmarminge Nov 21, 2026
25eb862
fix(server): a workflow key starts one run, even when a start is cut off
juliusmarminge Nov 21, 2026
a22ae1c
fix(server): a paused workflow run stays paused until it should go on
juliusmarminge Nov 21, 2026
0f03e40
fix(server): a cancelled workflow run is fully stopped and cleaned up
juliusmarminge Nov 21, 2026
87e3df6
fix(server): workflow files without imports reload, and a file given …
juliusmarminge Nov 21, 2026
dba4bfa
fix(server): a refused definitions change no longer becomes a file's …
juliusmarminge Nov 21, 2026
c7804fb
fix(server): waiting on a run hears of a reload that lands as the wai…
juliusmarminge Nov 21, 2026
9188d46
fix(server): an issue trigger starts each item once instead of again …
juliusmarminge Nov 21, 2026
6c1ba5c
fix(server): signals no longer strand waits or break a run with a val…
juliusmarminge Nov 21, 2026
c08d371
fix(server): a retried step's signals to new places are no longer tak…
juliusmarminge Nov 21, 2026
c07cdf2
fix(server): answering a workflow question twice answers it once
juliusmarminge Nov 21, 2026
a3690e7
fix(server): invoke refuses a name already taken before it starts the…
juliusmarminge Nov 21, 2026
a5981fa
fix(evals): the workflow grader loads the file afresh for each server…
juliusmarminge Nov 21, 2026
144a210
test(server): the workflow folder retry test moves time itself
juliusmarminge Nov 21, 2026
0433897
fix(server): workflow fixes pass the Effect diagnostics
juliusmarminge Nov 21, 2026
8c83301
docs(skills): the workflow skill and internals say what the engine ac…
juliusmarminge Nov 21, 2026
96a6c5a
fix(server): a workflow run cancelled without a reason records none
juliusmarminge Nov 21, 2026
0b47ede
fix(server): title refuses a second argument
juliusmarminge Nov 21, 2026
fb1a138
fix(server): one refused workflow file no longer freezes the others
juliusmarminge Nov 21, 2026
2d3daf8
fix(server): two workflow hooks never share a URL, and a hook named t…
juliusmarminge Nov 21, 2026
fd7cb9f
fix(server): a schedule taken out and put back waits one interval again
juliusmarminge Nov 21, 2026
680754c
fix(server): a workflow file left out for its name says so
juliusmarminge Nov 21, 2026
1c8ec8c
fix(server): a duration or retry option a workflow cannot read names …
juliusmarminge Nov 21, 2026
6a421e9
fix(server): a held workflow change keeps retrying and no longer bloc…
juliusmarminge Nov 21, 2026
a994051
fix(server): a signal to a paused run no longer runs its failed step
juliusmarminge Nov 21, 2026
6c54890
fix(server): a run result with an undefined field no longer pauses fo…
juliusmarminge Nov 21, 2026
d101dae
fix(server): an agent is told its result's checks, and why a submitte…
juliusmarminge Nov 21, 2026
f177734
fix(server): invoke given a workflow's name says to pass its definition
juliusmarminge Nov 21, 2026
e44b647
fix(server): a step's attempts count the tries its retry made
juliusmarminge Nov 21, 2026
8100716
fix(server): thread lists leave out workflow agent threads
juliusmarminge Nov 21, 2026
df35098
fix(server): the CLI reports refused arguments instead of an unreacha…
juliusmarminge Nov 21, 2026
80c3124
fix(server): workflow CLI takes a cancel reason and says when it did …
juliusmarminge Nov 21, 2026
73d2845
docs: the workflow skill and policy guide match what end-to-end testi…
juliusmarminge Nov 21, 2026
99942ff
fix(server): a workflow change held back by runs goes in once they end
juliusmarminge Nov 21, 2026
cf395bf
fix(server): an agent whose results were all refused is not said to h…
juliusmarminge Nov 21, 2026
f6f5b96
fix(server): the workflow CLI refuses a blank --key itself
juliusmarminge Nov 21, 2026
859d1ad
docs(skills): the workflow skill covers late timeouts, title length a…
juliusmarminge Nov 21, 2026
6cc1cac
feat(server): workflows are a Labs setting, off by default
juliusmarminge Nov 21, 2026
6debedf
docs(workflows): workflows are off until turned on in Labs
juliusmarminge Nov 21, 2026
ebd314a
test(server): the agent context budget is measured again on top of main
juliusmarminge Nov 21, 2026
a3b4755
feat(server): a workflow run keeps the issues and pull requests it to…
juliusmarminge Nov 21, 2026
9f954e5
fix(server): an ended workflow run's engine journal is pruned
juliusmarminge Nov 22, 2026
f7ac5c0
feat(server): outside agents can follow workflow runs as milestones
juliusmarminge Nov 22, 2026
eb54b67
fix(server): workflow commands are feedback subjects
juliusmarminge Nov 23, 2026
7218b47
feat(server): workflow milestones say when a run resumes, mute invoke…
juliusmarminge Nov 23, 2026
024bde5
refactor(server): one migration creates the workflow tables
juliusmarminge Nov 23, 2026
File filter
Filter by extension


Clear filters
Conversations
Failed to load comments.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Jump to
Jump to file
Failed to load files.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Diff view
Diff view

There are no files selected for viewing

4 changes: 4 additions & 0 deletions 4 apps/server/src/auth/RpcAuthorization.ts
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,10 @@ export const RPC_REQUIRED_SCOPES = {
[WS_METHODS.serverSignalProcess]: AuthEnvironmentMaintainScope,
[WS_METHODS.serverReportClientActivity]: AuthOrchestrationReadScope,
[WS_METHODS.scheduledTasksSubscribe]: AuthOrchestrationReadScope,
[WS_METHODS.workflowsSubscribe]: AuthOrchestrationReadScope,
[WS_METHODS.workflowsCounts]: AuthOrchestrationReadScope,
[WS_METHODS.workflowsGet]: AuthOrchestrationReadScope,
[WS_METHODS.workflowsGetDefinition]: AuthFilesystemReadScope,
[WS_METHODS.secretsAnswerRequest]: AuthOrchestrationOperateScope,
[WS_METHODS.agentFeedbackAnswerRequest]: AuthOrchestrationOperateScope,
// Delivery logs hold request bodies, so they need the same scope as the URL.
Expand Down
2 changes: 2 additions & 0 deletions 2 apps/server/src/binCli.ts
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import { sharedServerCommandFlags } from "./cli/config.ts";
import { projectCommand } from "./cli/project.ts";
import { feedbackCommand } from "./cli/feedback.ts";
import { threadCommand } from "./cli/thread.ts";
import { workflowCommand } from "./cli/workflow.ts";
import { runDefaultServerCommand, serveCommand, startCommand } from "./cli/server.ts";
import { updateCommand } from "./cli/update.ts";
import {
Expand Down Expand Up @@ -93,6 +94,7 @@ export const makeCli = ({ cloudEnabled = hasCloudPublicConfig } = {}) =>
projectCommand,
threadCommand,
feedbackCommand,
workflowCommand,
upCommand,
statusCommand,
serviceCommand,
Expand Down
20 changes: 16 additions & 4 deletions 20 apps/server/src/cli/thread.ts
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,15 @@ const toolFailureDetail = (result: typeof ToolResult.Type) => {
});
};

/** JSON-RPC's invalid params: the arguments failed the tool's schema. */
const INVALID_PARAMS = -32602;
const rpcErrorDetail = (error: { readonly code: number; readonly message: string }) => {
const message = error.message.replaceAll(/\s*\n\s*/g, " ");
return error.code === INVALID_PARAMS
? `The server refused the arguments: ${message}`
: `The server refused the request: ${message}`;
};

const makeThreadTools = (session: McpToolSession, origin: string) => {
const unexpected = (tool: string) =>
new ThreadToolFailedError({
Expand All @@ -214,10 +223,13 @@ const makeThreadTools = (session: McpToolSession, origin: string) => {
> {
const raw = yield* session.call(tool, args).pipe(
Effect.mapError((cause) =>
// Effect's MCP server words an unknown or hidden tool exactly this way.
cause.rpcError?.code === -32602 && cause.rpcError.message === `Tool '${tool}' not found`
? new ThreadToolMissingError({ tool })
: new ThreadServerUnreachableError({ origin, cause }),
cause.rpcError === undefined
? new ThreadServerUnreachableError({ origin, cause })
: // Effect's MCP server words an unknown or hidden tool exactly this way.
cause.rpcError.code === -32602 &&
cause.rpcError.message === `Tool '${tool}' not found`
? new ThreadToolMissingError({ tool })
: new ThreadToolFailedError({ tool, detail: rpcErrorDetail(cause.rpcError) }),
),
);
const result = yield* decodeToolResult(raw).pipe(Effect.mapError(() => unexpected(tool)));
Expand Down
186 changes: 186 additions & 0 deletions 186 apps/server/src/cli/workflow.test.ts
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
@@ -0,0 +1,186 @@
import * as NodeCrypto from "@effect/platform-node/NodeCrypto";
import * as NodeServices from "@effect/platform-node/NodeServices";
import { assert, it } from "@effect/vitest";
import { AuthSessionId, type WorkflowRun } from "@t3tools/contracts";
import * as NetService from "@t3tools/shared/Net";
import * as ConfigProvider from "effect/ConfigProvider";
import * as DateTime from "effect/DateTime";
import * as Effect from "effect/Effect";
import * as FileSystem from "effect/FileSystem";
import * as Layer from "effect/Layer";
import * as Path from "effect/Path";
import * as TestConsole from "effect/testing/TestConsole";
import { Command } from "effect/cli";
import { vi } from "vite-plus/test";

import * as McpBridge from "../mcp/AcpMcpStdioBridge.ts";
import {
makePersistedServerRuntimeState,
persistServerRuntimeState,
} from "../serverRuntimeState.ts";
import { workflowCommand } from "./workflow.ts";

vi.mock("../auth/EnvironmentAuth.ts", async (importOriginal) => {
const actual = await importOriginal<typeof import("../auth/EnvironmentAuth.ts")>();
return {
...actual,
layerRuntime: Layer.mock(actual.EnvironmentAuth)({
issueMcpClientSession: () =>
Effect.map(DateTime.now, (expiresAt) => ({
sessionId: AuthSessionId.make("test-session"),
token: "synthetic-token",
expiresAt,
})),
revokeSession: () => Effect.succeed(true),
}),
};
});

const makeRun = (status: WorkflowRun["status"]): WorkflowRun => ({
runId: "run-1",
workflow: "review",
version: 1,
title: "review pr-1",
status,
detail: null,
result: null,
pauses: 0,
retired: false,
resumesAt: null,
parentRunId: null,
parentStep: null,
startedAt: "2026-11-20T00:00:00.000Z",
updatedAt: "2026-11-20T00:00:00.000Z",
endedAt: ["running", "waiting", "paused"].includes(status) ? null : "2026-11-20T00:00:00.000Z",
});

/** Runs `t3 workflow <args>` against a live-looking server whose t3_workflow is `call`. */
const runCli = (
args: ReadonlyArray<string>,
call: McpBridge.McpToolSession["call"] = () => Effect.die("no tool call expected"),
) =>
Effect.gen(function* () {
const fs = yield* FileSystem.FileSystem;
const path = yield* Path.Path;
const baseDir = yield* fs.makeTempDirectoryScoped({ prefix: "t3-workflow-cli-" });
yield* persistServerRuntimeState({
path: path.join(baseDir, "userdata", "server-runtime.json"),
state: yield* makePersistedServerRuntimeState({
config: { host: "127.0.0.1", devUrl: undefined },
port: 3_773,
}),
});
const calls: Array<Readonly<Record<string, unknown>>> = [];
using _session = vi.spyOn(McpBridge, "mcpToolSession").mockReturnValue(
Effect.succeed({
call: (tool, input) => {
calls.push(input);
return call(tool, input);
},
}),
);
const error = yield* Command.runWith(workflowCommand, { version: "0.0.0" })([
...args,
"--base-dir",
baseDir,
]).pipe(
Effect.flip,
Effect.orElseSucceed(() => undefined),
);
return { error, calls, errors: yield* TestConsole.errorLines };
}).pipe(
Effect.scoped,
Effect.provide(
Layer.mergeAll(
NodeServices.layer,
NodeCrypto.layer,
NetService.layer,
ConfigProvider.layer(ConfigProvider.fromEnv({ env: { T3CODE_PORT: "3773" } })),
),
),
);

/** Answers each action with the run in `status`, as the server does. */
const serving =
(status: WorkflowRun["status"]): McpBridge.McpToolSession["call"] =>
() =>
Effect.succeed({ structuredContent: { run: makeRun(status), steps: [] } });

it.effect("cancel sends --reason, and steers nothing when the run cannot take it", () =>
Effect.gen(function* () {
const cancelled = yield* runCli(
["cancel", "run-1", "--reason", "superseded"],
serving("running"),
);
assert.deepStrictEqual(cancelled.calls.at(-1), {
action: "cancel",
runId: "run-1",
reason: "superseded",
});

for (const [command, status, said] of [
["cancel", "completed", "Run run-1 is completed; nothing to cancel."],
["resume", "waiting", "Run run-1 is waiting; nothing to resume."],
["resume", "cancelled", "Run run-1 is cancelled; nothing to resume."],
] as const) {
const { error, calls, errors } = yield* runCli([command, "run-1"], serving(status));
assert.isUndefined(error, command);
assert.deepStrictEqual(
calls.map((input) => input.action),
["read"],
);
assert.include(errors, said);
}
}),
);

it.effect("reports what the server refused instead of calling it unreachable", () =>
Effect.gen(function* () {
// A blank key is refused here, before the server is asked.
const blank = yield* runCli(["start", "review", "--key", " "], () =>
Effect.die("the server is not asked"),
);
assert.strictEqual(blank.error?.message, "--key cannot be blank.");

const refused = yield* runCli(["start", "review", "--key", "r1"], () =>
Effect.fail(
new McpBridge.AcpMcpBridgeError({
message: "T3 Code MCP tools/call failed.",
rpcError: {
code: -32602,
message: 'Expected a non-blank string\n at ["idempotencyKey"]',
},
}),
),
);
assert.strictEqual(refused.error?._tag, "ThreadToolFailedError");
assert.strictEqual(
refused.error?.message,
'The server refused the arguments: Expected a non-blank string at ["idempotencyKey"]',
);

const unreachable = yield* runCli(["start", "review", "--key", "pr-1"], () =>
Effect.fail(new McpBridge.AcpMcpBridgeError({ message: "fetch failed" })),
);
assert.strictEqual(unreachable.error?._tag, "ThreadServerUnreachableError");
}),
);

it.effect("signal refuses both addresses at once before reaching the server", () =>
Effect.gen(function* () {
const { error, calls } = yield* runCli([
"signal",
"{}",
"--run",
"run-1",
"--wait",
"approve",
"--workflow",
"review",
"--channel",
"pr-1",
]);
assert.strictEqual(error?._tag, "ThreadUsageError");
assert.lengthOf(calls, 0);
}),
);
Loading
Oops, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Loading
Oops, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

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.
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.