@jive-sh/workflow-platform 0.7.0 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +70 -435
- package/component/_generated/api.ts +72 -0
- package/component/_generated/component.ts +629 -0
- package/component/_generated/dataModel.ts +60 -0
- package/component/_generated/server.ts +169 -0
- package/component/convex.config.ts +3 -0
- package/component/engine.ts +756 -0
- package/component/errors.ts +66 -0
- package/component/events.ts +17 -0
- package/component/notes.ts +19 -0
- package/component/places.ts +136 -0
- package/component/retention.ts +205 -0
- package/component/runEngine.ts +25 -0
- package/component/schema.ts +135 -0
- package/component/steps.ts +188 -0
- package/component/store.ts +513 -0
- package/component/tasks.ts +290 -0
- package/component/worker.ts +109 -0
- package/component/workflows.ts +83 -0
- package/dist/definition/agent-runner.js +9 -0
- package/dist/definition/agent-runner.js.map +1 -0
- package/dist/definition/file-store.js +9 -0
- package/dist/definition/file-store.js.map +1 -0
- package/dist/definition/program-build.js +10 -0
- package/dist/definition/program-build.js.map +1 -0
- package/dist/definition/step.js +1 -0
- package/dist/definition/step.js.map +1 -0
- package/dist/definition/task-schema.js +5 -0
- package/dist/definition/task-schema.js.map +1 -0
- package/dist/definition/tasks.js +9 -0
- package/dist/definition/tasks.js.map +1 -0
- package/dist/definition/workflow.js +117 -0
- package/dist/definition/workflow.js.map +1 -0
- package/dist/graph.js +310 -9
- package/dist/graph.js.map +1 -1
- package/dist/index.js +7 -196
- package/dist/index.js.map +1 -1
- package/package.json +9 -4
- package/src/definition/agent-runner.ts +59 -0
- package/src/definition/file-store.ts +20 -0
- package/src/definition/program-build.ts +30 -0
- package/src/definition/step.ts +106 -0
- package/src/definition/task-schema.ts +15 -0
- package/src/definition/tasks.ts +43 -0
- package/src/definition/workflow.ts +262 -0
- package/src/graph.ts +352 -19
- package/src/index.ts +8 -238
- package/worker/directory-file-store.ts +42 -0
- package/worker/index.ts +12 -0
- package/worker/platform-client.ts +144 -0
- package/worker/step-meter.ts +80 -0
- package/worker/worker-tasks.ts +27 -0
- package/worker/worker.test.ts +200 -0
- package/worker/worker.ts +240 -0
- package/dist/budget-states.js +0 -30
- package/dist/budget-states.js.map +0 -1
- package/dist/cpu-limit/limiter.js +0 -839
- package/dist/cpu-limit/limiter.js.map +0 -1
- package/dist/cpu-limit/use.js +0 -139
- package/dist/cpu-limit/use.js.map +0 -1
- package/dist/dashboard/agent-usage.js +0 -25
- package/dist/dashboard/agent-usage.js.map +0 -1
- package/dist/dashboard/dashboard.css +0 -148
- package/dist/dashboard/drilldown.js +0 -47
- package/dist/dashboard/drilldown.js.map +0 -1
- package/dist/dashboard/queue-lines.js +0 -44
- package/dist/dashboard/queue-lines.js.map +0 -1
- package/dist/dashboard/queue-table.js +0 -16
- package/dist/dashboard/queue-table.js.map +0 -1
- package/dist/dashboard/run-doing-words.js +0 -29
- package/dist/dashboard/run-doing-words.js.map +0 -1
- package/dist/dashboard/setting-words.js +0 -18
- package/dist/dashboard/setting-words.js.map +0 -1
- package/dist/dashboard/spending-words.js +0 -24
- package/dist/dashboard/spending-words.js.map +0 -1
- package/dist/failure.js +0 -35
- package/dist/failure.js.map +0 -1
- package/dist/keep-running.js +0 -79
- package/dist/keep-running.js.map +0 -1
- package/dist/outside-failure.js +0 -31
- package/dist/outside-failure.js.map +0 -1
- package/dist/pick-wakes.js +0 -125
- package/dist/pick-wakes.js.map +0 -1
- package/dist/project.js +0 -1
- package/dist/project.js.map +0 -1
- package/dist/queue-counts.js +0 -51
- package/dist/queue-counts.js.map +0 -1
- package/dist/reasons.js +0 -33
- package/dist/reasons.js.map +0 -1
- package/dist/retention.js +0 -59
- package/dist/retention.js.map +0 -1
- package/dist/settings.js +0 -88
- package/dist/settings.js.map +0 -1
- package/dist/spending-limit.js +0 -82
- package/dist/spending-limit.js.map +0 -1
- package/dist/step-files.js +0 -200
- package/dist/step-files.js.map +0 -1
- package/dist/step-meter.js +0 -97
- package/dist/step-meter.js.map +0 -1
- package/dist/step-times.js +0 -114
- package/dist/step-times.js.map +0 -1
- package/dist/step-usage.js +0 -19
- package/dist/step-usage.js.map +0 -1
- package/dist/steps.js +0 -1205
- package/dist/steps.js.map +0 -1
- package/dist/storage/agent-claims.js +0 -3
- package/dist/storage/agent-claims.js.map +0 -1
- package/dist/storage/budgets.js +0 -121
- package/dist/storage/budgets.js.map +0 -1
- package/dist/storage/engine-records.js +0 -91
- package/dist/storage/engine-records.js.map +0 -1
- package/dist/storage/engine-storage.js +0 -67
- package/dist/storage/engine-storage.js.map +0 -1
- package/dist/storage/input-records.js +0 -12
- package/dist/storage/input-records.js.map +0 -1
- package/dist/storage/move-store.js +0 -251
- package/dist/storage/move-store.js.map +0 -1
- package/dist/storage/sqlite-store.js +0 -901
- package/dist/storage/sqlite-store.js.map +0 -1
- package/dist/storage/step-records.js +0 -11
- package/dist/storage/step-records.js.map +0 -1
- package/dist/storage/storage-error.js +0 -19
- package/dist/storage/storage-error.js.map +0 -1
- package/dist/storage/task-store.js +0 -30
- package/dist/storage/task-store.js.map +0 -1
- package/dist/system-workflows.js +0 -54
- package/dist/system-workflows.js.map +0 -1
- package/dist/tasks.js +0 -500
- package/dist/tasks.js.map +0 -1
- package/dist/views/format.js +0 -37
- package/dist/views/format.js.map +0 -1
- package/dist/views/runs-now.js +0 -117
- package/dist/views/runs-now.js.map +0 -1
- package/dist/views/step-funnel.js +0 -98
- package/dist/views/step-funnel.js.map +0 -1
- package/dist/views/step-graph.js +0 -39
- package/dist/views/step-graph.js.map +0 -1
- package/dist/views/workflows-view.js +0 -236
- package/dist/views/workflows-view.js.map +0 -1
- package/src/budget-states.ts +0 -54
- package/src/cpu-limit/limiter.ts +0 -935
- package/src/cpu-limit/use.ts +0 -166
- package/src/dashboard/agent-usage-line.tsx +0 -28
- package/src/dashboard/agent-usage.ts +0 -48
- package/src/dashboard/dashboard.css +0 -148
- package/src/dashboard/drilldown.ts +0 -70
- package/src/dashboard/index.tsx +0 -4
- package/src/dashboard/limits-and-runs.tsx +0 -191
- package/src/dashboard/machine-controls.tsx +0 -53
- package/src/dashboard/queue-bar.tsx +0 -62
- package/src/dashboard/queue-chart.tsx +0 -149
- package/src/dashboard/queue-lines.ts +0 -87
- package/src/dashboard/queue-table.ts +0 -37
- package/src/dashboard/run-doing-words.ts +0 -41
- package/src/dashboard/setting-words.ts +0 -30
- package/src/dashboard/spending-limit-control.tsx +0 -47
- package/src/dashboard/spending-words.ts +0 -32
- package/src/dashboard/time-distribution.tsx +0 -61
- package/src/dashboard/workflow-dag.tsx +0 -322
- package/src/dashboard/workflow-drilldown.tsx +0 -31
- package/src/dashboard/workflows-dashboard.tsx +0 -532
- package/src/failure.ts +0 -36
- package/src/keep-running.ts +0 -85
- package/src/outside-failure.ts +0 -39
- package/src/pick-wakes.ts +0 -182
- package/src/project.ts +0 -127
- package/src/queue-counts.ts +0 -64
- package/src/reasons.ts +0 -30
- package/src/retention.ts +0 -90
- package/src/settings.ts +0 -171
- package/src/spending-limit.ts +0 -139
- package/src/step-files.ts +0 -208
- package/src/step-meter.ts +0 -120
- package/src/step-times.ts +0 -151
- package/src/step-usage.ts +0 -23
- package/src/steps.ts +0 -1616
- package/src/storage/agent-claims.ts +0 -63
- package/src/storage/budgets.ts +0 -152
- package/src/storage/engine-records.ts +0 -119
- package/src/storage/engine-storage.ts +0 -82
- package/src/storage/input-records.ts +0 -43
- package/src/storage/move-store.ts +0 -265
- package/src/storage/sqlite-store.ts +0 -1022
- package/src/storage/step-records.ts +0 -358
- package/src/storage/storage-error.ts +0 -35
- package/src/storage/task-store.ts +0 -235
- package/src/system-workflows.ts +0 -70
- package/src/tasks.ts +0 -586
- package/src/views/format.ts +0 -40
- package/src/views/runs-now.ts +0 -188
- package/src/views/step-funnel.ts +0 -163
- package/src/views/step-graph.ts +0 -77
- package/src/views/workflows-view.ts +0 -484
- package/src/workflow-dag.test.tsx +0 -89
- package/src/workflow-page.test.tsx +0 -170
package/README.md
CHANGED
|
@@ -1,450 +1,85 @@
|
|
|
1
1
|
# @jive-sh/workflow-platform
|
|
2
2
|
|
|
3
|
-
Durable workflows
|
|
4
|
-
|
|
3
|
+
Durable workflows in Convex. A workflow is one primitive, drawn as one diagram: a task schema, steps (code, an agent,
|
|
4
|
+
or another workflow), the lines between them, the events that bring tasks in, and the end states it names. Every line
|
|
5
|
+
is a queue, every step and line counts its tasks, and each workflow has an agent budget and a CPU budget. Workers on
|
|
6
|
+
your machines take tasks from Convex and run the code and agent steps; sub-workflow steps run inside Convex.
|
|
5
7
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
- **One way to define a workflow and its steps.** Each step has a kind, which a page says in words: plain code, an agent
|
|
10
|
-
step, a check (it decides whether the work passes) or a sub-workflow. It also says what it may write and which step can
|
|
11
|
-
follow it. Nothing else defines a step.
|
|
12
|
-
- **Workflows all the way down.** A workflow is a step of another through `defineSubWorkflow`: the step starts it as a run
|
|
13
|
-
of its own and waits for it, the engine suspending the run above until it ends. One record in the workflow above names
|
|
14
|
-
that run, its steps work on the item the run above works on, and its run's agent claim counts against the agents' limit
|
|
15
|
-
of the workflow at the top. The top of a project is one workflow, which a page enters at and drills down from.
|
|
16
|
-
- **Every step is measured, never self-reported.** Time, tokens, CPU (its own and its child processes'), peak memory,
|
|
17
|
-
files written and compiles go on one record per step run, per item.
|
|
18
|
-
- **Every item is a task**, with an append-only log of notes and one of four statuses read from them: queued, in
|
|
19
|
-
progress, blocked or done (`src/tasks.ts`). Done means its workflow's final check passed. A queue is first in, first out,
|
|
20
|
-
and one call reorders it by hand (`moveToFront`). Blocking is the logic of the step that picks: 10 failed tries, flipping
|
|
21
|
-
between two versions, nothing new since its last failed try, or a reason of the workflow's own, each in words on the task.
|
|
22
|
-
A failed try is a run that did its work and ended without success: a run that stood down, or one an outside service
|
|
23
|
-
failed (a step failing with `OutsideServiceUnavailable`, or Claude's own usage-limit or rate-limit words), is none
|
|
24
|
-
(`src/outside-failure.ts`).
|
|
25
|
-
- **Waiting is event-driven.** A Pick with nothing to claim waits for an event that can change that (a note, a new item,
|
|
26
|
-
a run ending, a budget change) and never polls.
|
|
27
|
-
- **A run limit on every workflow, and an agents' limit where it has agent steps.** Every start of every workflow, however it
|
|
28
|
-
starts (a timer, its inputs changing, its queue, a request), passes its run limit (`steps.ts` `gatedExecute`): a new run
|
|
29
|
-
starts only while fewer are going, 0 starts none, and none set is no limit, or for a workflow with an agent step and a list
|
|
30
|
-
of work its agents' limit. That kind of workflow also keeps its run limit's number of runs going, and the runs under it
|
|
31
|
-
hold at most its agents' limit of agents at once (below). Setting either limit
|
|
32
|
-
(`runPlanChanged`) has the run planner plan again at once. The run limit is the one way to stop a workflow: at 0 no run
|
|
33
|
-
of it starts, and a run already going ends before it takes on more work (`steps.ts` `standDownIfSurplus`). In a workflow
|
|
34
|
-
its budget keeps going that is before an agent step: the run still picks and tests with no agent, and ends at a Pick
|
|
35
|
-
that finds nothing. In any other it is before a Pick, before an agent step, or at its first step when the engine
|
|
36
|
-
resumes it after a restart. A step between those still runs, so what an agent step just made is checked and recorded.
|
|
37
|
-
There is no pause beside it.
|
|
38
|
-
- **A run claims its agents at its first agent step and holds them to its end** (`steps.ts` `claimAgentsOrEnd`; Alex, 2026-11-22: "a subworkflow write C
|
|
39
|
-
claims one on decompiles agents so while that task's own workflow is doing all these different things ... decompile is
|
|
40
|
-
down one agent"). A workflow with an agent step of its own claims 1 agent, or the number it declares (`agentsClaimed`),
|
|
41
|
-
at a run's first agent step, against the agents' limit of the workflow at the top of the run: Write C's against
|
|
42
|
-
Decompile's. Its steps before that (a Pick, a Test with no agent) run with none, so a run at 0 agents still does what
|
|
43
|
-
needs no agent and reaches its agent step with its task named. From then it holds the claim through every step, agent and deterministic, and through a handover or a restart, until the run ends, and its
|
|
44
|
-
agent steps never wait for or take an agent of their own. A run under a run that holds a claim takes none. Each claim is
|
|
45
|
-
a row of `agent_claims` (`storage/agent-claims.ts`: its start, end and outcome), and counts only while the run at its top
|
|
46
|
-
is unfinished in the engine, so a claim whose end was never written cannot hold an agent once that run is gone.
|
|
47
|
-
- **A run that can have no agent never waits: it gives its task back and ends.** Where no claim is free (every agent the
|
|
48
|
-
limit allows is claimed, the limit is 0, or the spending limit holds), the run marks its task "needs an agent" with why
|
|
49
|
-
in words, which puts it at the back of its queue, and ends, giving its run slot to the next task. A run already holding a
|
|
50
|
-
claim does the same before its next agent call once the limit is set to 0 or the spending limit holds; a limit lowered
|
|
51
|
-
to above 0 ends no run. Its Pick passes over marked tasks while no agent is free, and takes them in queue order once a
|
|
52
|
-
claim ends, which wakes it. Something new from outside the workflow clears the mark (a return to its queue, a move to
|
|
53
|
-
the front, any note by a person or another workflow), and so do a run on the task taking an agent and its final check
|
|
54
|
-
passing. A run with no task ends the same way, unmarked, and its trigger tries again. The status table's queued row says
|
|
55
|
-
how many need agent, "804 queued (12 need agent)", and an open workflow lists them by reason.
|
|
56
|
-
- **One spending limit for the whole account: "agents stop at X% of the week"** (`spending-limit.ts`, 95 when none is
|
|
57
|
-
set). While the newest good reading of the week is at or past X, no run of any workflow is given an agent claim, and a
|
|
58
|
-
run holding one ends before its next agent call, as at an agents' limit of 0, its task marked "needs an agent: the week's
|
|
59
|
-
use is N%, at or past the spending limit of X%"; runs claim again once a reading is below X. It judges the account's week, not the step records' tokens,
|
|
60
|
-
because the week also counts what no workflow runs (agent threads run by hand). The project gives the reading
|
|
61
|
-
(`WorkflowProject.weekUsage`) and tells the platform of each one it takes (`platform.spending.readingTaken`); a project
|
|
62
|
-
that gives none has no spending limit. A failed or old reading never lifts it: the limit keeps the newest good reading's
|
|
63
|
-
verdict, however old, and the page says the reading is stale and why. An unreadable one holds the same way.
|
|
64
|
-
- **Each queue's counts, kept current.** When a queue may have changed (a wake of its Picks, or a Pick claiming an item),
|
|
65
|
-
the process that runs the workflows counts it within 5 seconds and stores each status's count where it moved
|
|
66
|
-
(`queue-counts.ts`, `queue_counts`). A page reads the newest rows and their history and never counts.
|
|
67
|
-
- **A page read from the records at each request.** Every workflow with its limits, its queue and where work goes between
|
|
68
|
-
them is a few small readings (`platform.view`, under 100 ms for 52 workflows and 166,000 step records); one workflow's
|
|
69
|
-
steps, costs, graph and funnel are read from its own records when a page opens it (`platform.figures`). Nothing is built
|
|
70
|
-
on a schedule or stored for a page.
|
|
71
|
-
Nothing else decides how many run, and a page can set both (`WorkflowsDashboard`'s `setLimit`).
|
|
72
|
-
- **Runs only when their inputs change.** A workflow declares what it runs on (`inputs`); its trigger starts a run only
|
|
73
|
-
when their fingerprint differs from its last successful run's, whose result stands meanwhile. A timer is only the fallback
|
|
74
|
-
that checks. A workflow with a list of work can declare what each task runs on (`taskInputs`): each outcome records the
|
|
75
|
-
task's fingerprint as its run left it, and its Pick blocks a task nothing new has reached since its last failed try.
|
|
76
|
-
- **A reason with every outcome.** Each step record says why it ended as it did; the dashboard counts endings per step,
|
|
77
|
-
where runs stopped and why, what each workflow yields per run, per million tokens and per compile against the window
|
|
78
|
-
before, and what a run costs, its child processes included.
|
|
79
|
-
- **A declared step graph.** Each workflow names which step can follow which and when; a run that takes another edge fails
|
|
80
|
-
in tests.
|
|
81
|
-
- **One CPU limit.** Every heavy process of the project holds a slot of one pool from before it starts until it exits, and
|
|
82
|
-
running work is paused while what the project uses is over the limit (`makeCpuLimiter`). The project says only what it
|
|
83
|
-
alone knows: where its pool lives, which commands are light, which processes are its own. The dashboard shows where the
|
|
84
|
-
project stands against it.
|
|
85
|
-
- **Storage is behind interfaces, in one database.** Step records, tasks, input runs, both limits and the engine's own
|
|
86
|
-
records each have an interface and a SQLite implementation. Every call is an effect that fails with `StorageError`, so
|
|
87
|
-
another database (Convex) can stand behind any of them; a step whose record cannot be written goes on and says so. The
|
|
88
|
-
platform's tables, the CPU limit's pool and the engine's records live in the project's own database, beside the schema
|
|
89
|
-
the project declares (`STORAGE.md`); a held lock is tried again while yielding, never waited on inside SQLite. The
|
|
90
|
-
engine gets that from `lockRetryingSingleRunner`, effect/cluster's single runner on SQL storage whose every call is
|
|
91
|
-
retried this way, with a client set to wait 0 ms (`busyTimeout: Duration.zero`).
|
|
92
|
-
|
|
93
|
-
It runs today inside the aoe2-in-browser decompilation service, its first project
|
|
94
|
-
(`aoe2-in-browser/decomp-service/src/workflows/platform.ts`).
|
|
95
|
-
|
|
96
|
-
## A first workflow
|
|
97
|
-
|
|
98
|
-
```ts
|
|
99
|
-
import { createWorkflowPlatform, sqliteStorage, RUN_STARTS, RUN_ENDS } from '@jive-sh/workflow-platform';
|
|
100
|
-
import { Effect, Schema } from 'effect';
|
|
101
|
-
|
|
102
|
-
const platform = createWorkflowPlatform<never>({
|
|
103
|
-
project: {
|
|
104
|
-
sourceRoot: ROOT,
|
|
105
|
-
tree: { root: ROOT, snapshots: `${ROOT}/local/step-files`, notTree: ['local'] },
|
|
106
|
-
texts: { write: storeText, read: readText },
|
|
107
|
-
runLightNow,
|
|
108
|
-
processes: { thisProcess, isAlive },
|
|
109
|
-
stepRecordVariable: 'MY_STEP_RECORD',
|
|
110
|
-
isTransientFailure: (e) => String(e).includes('database is locked'),
|
|
111
|
-
},
|
|
112
|
-
storage: sqliteStorage({ stepRecordsFile: () => `${ROOT}/local/app.db`, engineFile: () => `${ROOT}/local/app.db`, budgetsFile: () => `${ROOT}/local/app.db`, processes: { thisProcess, isAlive } }),
|
|
113
|
-
});
|
|
114
|
-
const { defineStep, defineWorkflow } = platform.steps;
|
|
115
|
-
|
|
116
|
-
const COUNT = defineStep({ name: 'Count', runs: 'deterministic', shared: true, description: 'Counts the files.', at: import.meta.path, success: Schema.Number });
|
|
117
|
-
|
|
118
|
-
export const CountFiles = defineWorkflow({
|
|
119
|
-
item: null, description: 'Counts the files.', at: import.meta.path, steps: () => [COUNT],
|
|
120
|
-
graph: () => [{ from: RUN_STARTS, to: COUNT.name, when: 'each run' }, { from: COUNT.name, to: RUN_ENDS, when: 'always' }],
|
|
121
|
-
})('Count files', { payload: { turn: Schema.Number }, idempotencyKey: ({ turn }) => String(turn), success: Schema.Number, error: Schema.String });
|
|
122
|
-
|
|
123
|
-
export const CountFilesLive = CountFiles.toLayer(() => COUNT.run(Effect.succeed(42)));
|
|
124
|
-
```
|
|
125
|
-
|
|
126
|
-
The step's record (start, end, outcome, CPU) is written by `COUNT.run`; the workflow body has no measuring code.
|
|
8
|
+
1.0.0 replaces the 0.x platform (`effect/workflow` over SQLite), which lives on as the `v0` branch for fixes.
|
|
9
|
+
[DESIGN.md](DESIGN.md) holds the design and the decisions behind it, and [MIGRATION.md](MIGRATION.md) maps each
|
|
10
|
+
decomp-service workflow onto this one.
|
|
127
11
|
|
|
128
12
|
## Installing it
|
|
129
13
|
|
|
130
14
|
```sh
|
|
131
|
-
bun add @jive-sh/workflow-platform effect
|
|
15
|
+
bun add @jive-sh/workflow-platform convex effect
|
|
132
16
|
```
|
|
133
17
|
|
|
134
|
-
It
|
|
135
|
-
with a new version publishes it to npm through Jive's pipeline (`.github/workflows/pipeline.yml`, the six `jive:cicd:*`
|
|
136
|
-
scripts of `jive-abstract-library`); a push without a version bump publishes nothing.
|
|
137
|
-
|
|
138
|
-
## Using it from a checkout
|
|
139
|
-
|
|
140
|
-
The package runs inside its consumer's processes and must share their one copy of `effect`, so a checkout beside its
|
|
141
|
-
consumer has no packages of its own: `node_modules` here is a link to the consumer's (`aoe2-in-browser/install/setup.ts`
|
|
142
|
-
makes it). Never run `bun install` in such a checkout: it would write through the link into the consumer's packages. The
|
|
143
|
-
pipeline installs the package's own devDependencies from `bun.lock`, on a clean runner. The consumer imports
|
|
144
|
-
it by path, through its tsconfig (`"@jive-sh/workflow-platform": ["../../workflow-platform/src/index.ts"]`).
|
|
145
|
-
|
|
146
|
-
```sh
|
|
147
|
-
bun test # the package's own tests
|
|
148
|
-
node_modules/.bin/tsc --noEmit # its typecheck
|
|
149
|
-
```
|
|
150
|
-
|
|
151
|
-
## Modules
|
|
152
|
-
|
|
153
|
-
Each module's inputs come from `createWorkflowPlatform` (`src/index.ts`), which builds them in this order.
|
|
154
|
-
|
|
155
|
-
| Module | What it does | Takes | Gives |
|
|
156
|
-
|---|---|---|---|
|
|
157
|
-
| `project.ts` | What a project tells the platform about itself | n/a | `WorkflowProject`, `ProcessIdentity`, `UsageSink`, `TextStore`, `ProjectTree`, `WeekUsage` |
|
|
158
|
-
| `storage/storage-error.ts` | What every store call fails with, and a synchronous store's calls as effects | a store's calls | `StorageError`, `storeCall`, `storeCalls` |
|
|
159
|
-
| `storage/step-records.ts` | The step records' interface: one record per step run, and every read of them | n/a | `StepRecords`, its row types, `noSpend`, `StepScope` |
|
|
160
|
-
| `storage/task-store.ts` | The task store's interface: tasks, their append-only notes, their listing | n/a | `TaskStore`, `TaskNote`, `TaskRef`, `Listed` |
|
|
161
|
-
| `storage/engine-records.ts` | Which runs the engine has not finished, from its `cluster_*` tables | the engine's file | `EngineRecords`, `sqliteEngineRecords`, `ensureEngineIndexes` |
|
|
162
|
-
| `storage/budgets.ts` | Each workflow's two limits: runs going and agents its runs may hold; and the one spending limit | the file with `workflow_budgets` and `spending_limit` | `LimitStore`, `runLimit`, the limit SQL |
|
|
163
|
-
| `spending-limit.ts` | The spending limit: the rule, its verdict for a page, its wake on a reading, the one way to set it | limits, the project's `WeekUsage`, wakes | `makeSpendingLimit` (also `platform.spending`), `judgeSpending`, `spendingWait` |
|
|
164
|
-
| `storage/input-records.ts` | What each run ran on and how it ended; the check of re-runs on unchanged inputs | runs a trigger started | `InputRecords`, `rerunsOnUnchangedInputs` |
|
|
165
|
-
| `storage/agent-claims.ts` | Each run's claim on its top workflow's agents: taken at its first agent step, ended as it ends, with its outcome | `agent_claims` in the platform's database | `AgentClaims`, `claimsCounting` |
|
|
166
|
-
| `reasons.ts` | Why a step ended as it did, in a line, read from its result | a step's result | `standardReason`, `oneLine` |
|
|
167
|
-
| `storage/sqlite-store.ts` | Step records, tasks and input runs in the project's database | its file, the project's processes, the file they moved from | `sqliteStore`, `applyStepRecordsSchema` |
|
|
168
|
-
| `storage/move-store.ts` | The live move of the step records and tasks, and of the engine's records, from files of their own into the project's database | both files | `moveRecordsInto`, `catchUpMove`, `engineFileFree`, `moveEngineInto`, `movedInto` |
|
|
169
|
-
| `storage/engine-storage.ts` | The engine's message and runner storage in the project's database, every call tried again while yielding on a held lock | a SQL client that waits 0 ms | `lockRetryingSingleRunner`, `lockRetryingMessageStorage`, `lockRetryingRunnerStorage`, `retryHeldLock`, `isHeldLock` |
|
|
170
|
-
| `pick-wakes.ts` | What wakes a waiting Pick, and a minute's count of wakes by source | n/a | `PickWakes` |
|
|
171
|
-
| `step-meter.ts` | Measures what a step uses: CPU, memory, compiles, files | process usage, files written | `StepMeter` |
|
|
172
|
-
| `step-usage.ts` | Which step a piece of code works for, so its processes' usage reaches it | the step-record variable | `CurrentStepUsage` |
|
|
173
|
-
| `step-files.ts` | What an agent step changed in the tree, and taking it back | the project's tree | `StepFiles`, `filesChanged` |
|
|
174
|
-
| `tasks.ts` | The task rules (the four statuses, first-in-first-out order and the reorder call, the blocking a Pick runs) and the task writes | task store, engine records, step records, wakes, texts | `Tasks`, `queueOrder`, `standardBlock`, `PendingWork` |
|
|
175
|
-
| `settings.ts` | What every workflow and step inherits, set once on the app (`WorkflowProject.settings`) and overridable on any workflow or step below: how long its runs' records are kept (7 days where nothing sets it) and its agent steps' model | declarations, the app's settings | `stepSetting`, `workflowSetting`, `appSetting`, `InheritedSettings` (also `platform.settings`) |
|
|
176
|
-
| `steps.ts` | `defineWorkflow`, `defineStep`, `defineItemTest`: running and recording every step; an agent step's `AgentStep.model` | every store above | `Steps` |
|
|
177
|
-
| `retention.ts` | Deletes each finished run's records, and each task that was a run, once past what its steps keep; the platform's Retention runs it | declarations, the app's settings, step records, task store, engine records | `makeRetention` |
|
|
178
|
-
| `system-workflows.ts` | The platform's own workflows, which every app has and none defines (Retention, hourly): defined before the app's, refused to the app to define or hold as a step, their schedules the app's | the definer, retention, the app's schedules | `makeSystemWorkflows` (also `platform.system`), `SYSTEM_WORKFLOW_SCHEDULES` |
|
|
179
|
-
| `keep-running.ts` | The trigger's plan: how many runs of each budgeted workflow to start | declarations, budgets, runs going | `planRunStarts`, `oneTurnAtATime` |
|
|
180
|
-
| `budget-states.ts` | Each budget against the runs it has, for a page | budgets, runs | `workflowBudgetStates` |
|
|
181
|
-
| `failure.ts` | A failure as one line of text | any failure | `describeFailure`, `startAndEnd` |
|
|
182
|
-
| `cpu-limit/use.ts` | The CPU limit's arithmetic: room to start, what project work uses, what to pause | `ps` output, the pool's counts | `roomInThreads`, `readUse`, `pauseOrResume` |
|
|
183
|
-
| `cpu-limit/limiter.ts` | The CPU limit: the slot pool, the line, readings of use, holding work to the limit, the one way to start a process | the project's facts (`CpuLimiterFacts`) | `makeCpuLimiter`, `CpuLimiter` |
|
|
184
|
-
| `graph.ts` | A workflow's declared step graph and the check of a move against it; no dependencies, so a page can import it | declared edges, a run's last step | `StepEdge`, `edgeDeclared`, `RUN_STARTS`, `RUN_ENDS` |
|
|
185
|
-
| `views/runs-now.ts` | Where each unfinished run is now: the step it is in or waits after, and what a waiting step waits on | unfinished runs, their newest step records | `runsNow`, `WorkflowRunsNow` |
|
|
186
|
-
| `views/step-funnel.ts` | For each step, the window's runs that reached it, stopped or finished there, and why most stopped | the window's step records and item outcomes | `stepFunnel` |
|
|
187
|
-
| `views/step-graph.ts` | The declared graph (or, with none declared, the steps in their declared order) with the window's runs on each edge, and the moves it does not declare | declarations, the window's moves | `workflowGraphs`, `inOrder` |
|
|
188
|
-
| `queue-counts.ts` | Each queue counted when it may have changed, and stored where a count moved | tasks, task store, wakes | `makeQueueCounts` (also `platform.queueCounts`) |
|
|
189
|
-
| `views/workflows-view.ts` | The dashboard's two readings: every workflow (limits, queue, the top and the other outermost workflows), and one workflow's figures (steps with their cost, graph, funnel) | task store, limits; step records, engine records | `buildWorkflowsView`, `buildWorkflowFigures` (also `platform.view`, `platform.figures`) |
|
|
190
|
-
| `dashboard/` | React components for a project's page: `WorkflowsDashboard`, which a project gives its own header and controls; `dashboard.css` | the two readings and runs now, as JSON | `src/dashboard/index.tsx`, named by path from the host page |
|
|
191
|
-
|
|
192
|
-
`src/imports.test.ts` fails on any import from outside this package other than effect, Bun and Node (and, in a test, the
|
|
193
|
-
SQL client it runs the engine on), and on a dashboard file importing anything but React, its own folder, `graph.ts`,
|
|
194
|
-
`views/format.ts` and other modules' types.
|
|
195
|
-
|
|
196
|
-
## Limits
|
|
197
|
-
|
|
198
|
-
- The CPU limit's pool (`cpu-limit/limiter.ts`) is not behind a store interface: it is this machine's, read every 250 ms,
|
|
199
|
-
and opened by a project's setup before anything is installed, `effect` included.
|
|
200
|
-
- A project still writes each workflow's limits with its own statements (`storage/budgets.ts`),
|
|
201
|
-
and the engine's own writes are effect/cluster's `MessageStorage`: a store elsewhere needs its own of each.
|
|
202
|
-
- Some stored names keep the first project's words: the per-item part table is `step_functions`, and a step with per-item
|
|
203
|
-
parts has scope `'functions'`.
|
|
204
|
-
- Wakes reach only the Picks of the process that raised them, and another process's only through the project's relay
|
|
205
|
-
(`relayTo`, then `wake` there).
|
|
206
|
-
- A task's inputs changed by anything but a note, a listing or one of its workflow's runs ending (another workflow's write,
|
|
207
|
-
say) wake no waiting Pick: the next of those events reads them.
|
|
208
|
-
- A claim lasts one run: Write C's rounds are each a run of it, so between two rounds, while Decompile's Byte check runs,
|
|
209
|
-
the agent is free and another run can claim it first; the round after then gives its task back, as no try.
|
|
210
|
-
- `agent_claims` is not in retention or the records export yet: its rows stay in the working database.
|
|
211
|
-
- The scheduler's job ledger (which job turn is due) is still the first project's own, so an app starts the platform's own
|
|
212
|
-
workflows on their schedules itself (below).
|
|
213
|
-
|
|
214
|
-
## Agents claimed by a run, held to its end (2026-11-22)
|
|
215
|
-
|
|
216
|
-
A run of a workflow with an agent step claims its agents at its first agent step and holds them to its end, and a run that
|
|
217
|
-
can claim none gives its task back and ends: nothing waits for an agent any more (above). What a consumer changes:
|
|
218
|
-
|
|
219
|
-
- **`WorkflowStorage` has `claims`** (`storage/agent-claims.ts`): `sqliteStorage` gives it, in the `agent_claims` table the
|
|
220
|
-
store makes. `StepRecords` no longer has `runsInAgentStep` or `agentTakenUnder`.
|
|
221
|
-
- **`runsNow` takes `claims`**, the claims that count now (`platform.steps.agentClaimsNow()`). Its `RunDoing` kinds are
|
|
222
|
-
`holding an agent`, `in a step`, `waiting at a step`, `between steps` and `not started`: `with an agent`, `waiting for an
|
|
223
|
-
agent` and `held by the spending limit` are gone, and so is `StepRunsNow.heldBySpendingLimit`. `onAgents` is the agents
|
|
224
|
-
its runs hold.
|
|
225
|
-
- **The spending limit** gives `holdsAgents()` as why in words, or none; `SpendingHold`, `spendingWait`,
|
|
226
|
-
`isSpendingLimitWait`, `heldSteps` and `heldStepsWords` are gone, and `SpendingLimitControl` takes no `held`.
|
|
227
|
-
- **An agent step under a sub-workflow** is how a workflow does its work with no agent while none is free: Decompile has
|
|
228
|
-
none of its own, and its Write C and Judge claim about another file runs claim one each.
|
|
229
|
-
- **A mark clears** on the new note kind `a run took an agent for it` (`AGENT_TAKEN`); `an agent step ran` is read on
|
|
230
|
-
older notes. `defineWorkflow` takes `agentsClaimed` for a run that claims more than 1.
|
|
231
|
-
|
|
232
|
-
## The platform's own workflows, and the app's settings (2026-11-22)
|
|
233
|
-
|
|
234
|
-
Alex, 2026-11-22: "retention is supposed to be configurable at the platform layer and something configurable for all
|
|
235
|
-
tasks. not a bespoke workflow that every implementation must define. perhaps there can be some notion of system workflows
|
|
236
|
-
at the top level which can be configured but not amended without changing the platform itself".
|
|
237
|
-
|
|
238
|
-
- **Every app has the platform's own workflows and defines none of them** (`system-workflows.ts`). `createWorkflowPlatform`
|
|
239
|
-
defines each before the app defines any of its own, so each is declared, measured, queued and shown like any workflow,
|
|
240
|
-
marked `system`. The first is **Retention**: one step, Prune, that runs `retention.prune` every hour and whose record
|
|
241
|
-
says what it deleted ("deleted 1,204 step records, 0 per-item parts of them, and 31 tasks that were runs with 62 notes").
|
|
242
|
-
- **The app configures them, never amends them.** It sets each one's schedule (`WorkflowProject.systemSchedules`), its run
|
|
243
|
-
limit (the limits table and the page's − / +, as for any workflow) and the settings it inherits. A workflow of the app
|
|
244
|
-
named like one, or holding one as a step (`defineWorkflowStep`, `defineSubWorkflow`), fails the app's start; the definer
|
|
245
|
-
the app gets (`platform.steps`) has no way to define one. Changing their steps is changing the platform.
|
|
246
|
-
- **The app's settings are the top level** (`WorkflowProject.settings`): `retentionDays`, `keepAtLeastRuns` and `model`, given
|
|
247
|
-
once, over the platform's defaults (7 days, 10,000 runs, no model), for every workflow and step, the platform's own
|
|
248
|
-
included. A workflow or step below still sets its own. A page says where each is set: "keeps 7 days, at least 10,000
|
|
249
|
-
runs (set on the app)".
|
|
250
|
-
- **Retention keeps each step's newest runs however old** (Alex, 2026-11-22: "a project might complete or stall but we
|
|
251
|
-
shouldn't lose run data in that case", "10k runs"): a step's records of a run go only once the run ended more than
|
|
252
|
-
`retentionDays` ago and it is none of that step's newest `keepAtLeastRuns` runs; a workflow whose tasks are its runs
|
|
253
|
-
keeps its newest that many tasks the same way. There is no most it keeps.
|
|
254
|
-
- **The retention settings are set while the app runs** (Alex: "like it needs to be configurable"): on the app, a workflow
|
|
255
|
-
or a step, from the page's − / + (`SetSetting`), stored with when (`workflow_settings`, `storage/budgets.ts`), a value
|
|
256
|
-
stored at a level winning over the code's value there, "default" putting it back. The model is set in code alone. The
|
|
257
|
-
project makes the table and serves the route, as for `workflow_budgets`; `platform.settings.changeRefusal` checks a change.
|
|
258
|
-
- **What an app wires once**, for every system workflow there is or will be: its engine runs `platform.system.layer` beside
|
|
259
|
-
its own workflows' layers, and its scheduler starts each of `platform.system.workflows` every `everySeconds`, first
|
|
260
|
-
`firstAfterSeconds` after its start, with `run(turn)` (it waits for the run) or `start(turn)`.
|
|
261
|
-
- **The page** shows them on each top-level page under "Platform workflows", after the workflow's own sections (every
|
|
262
|
-
workflow's page keeps the same sections), each said in words to be part of the platform, with its runs and its limits; a
|
|
263
|
-
system workflow's own page says the same under its title.
|
|
264
|
-
- **Every workflow's page has a Runs section and a Limits section** (`dashboard/limits-and-runs.tsx`; Alex: "i really want
|
|
265
|
-
to see all this on separate lines. the set limits controls and the current runs status"): Runs, a line for each state its
|
|
266
|
-
runs are in and their total, laid out as its tasks are; Limits, a line each for its run limit, its agents' limit, the
|
|
267
|
-
days it keeps and the runs it keeps at least, each with its − / + and where its value is set. Each step's box has its own
|
|
268
|
-
retention lines, and the page's header the app's.
|
|
269
|
-
|
|
270
|
-
## The dashboard
|
|
18
|
+
It ships its source, and three entry points:
|
|
271
19
|
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
and a breadcrumb says where it is. The host routes each level's address back as `path`. Every workflow, at every depth,
|
|
278
|
-
the top included, gets the same page (`WorkflowPage`), with these sections in this order whatever kind of workflow it is;
|
|
279
|
-
a section with nothing to show says so in a line:
|
|
20
|
+
| Import | Holds |
|
|
21
|
+
| --- | --- |
|
|
22
|
+
| `@jive-sh/workflow-platform` | Defining workflows (`Workflow.make`, `TaskSchema.make`), the step services (`AgentRunner`, `FileStore`, `ProgramBuild`, `Tasks`) and the graph types |
|
|
23
|
+
| `@jive-sh/workflow-platform/component/convex.config.js` | The Convex component a workforce installs once per workflow (`app.use(workflowPlatform, { name })`) |
|
|
24
|
+
| `@jive-sh/workflow-platform/worker/index.js` | The worker loop (`workOnce`, `workUntilIdle`, `workForever`) and its Convex client |
|
|
280
25
|
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
(`WorkflowFigures.passingThrough`); one made of workflows says its tasks are its steps', each counted under its own;
|
|
285
|
-
- **Steps**: its step graph (`src/dashboard/workflow-dag.tsx`), laid out by ELK, its declared graph or, where it declares
|
|
286
|
-
none, its steps in their declared order (`views/step-graph.ts` `inOrder`). Each step is a box headed by its name, with
|
|
287
|
-
what it is and how it runs in words and its description as text. A step that is a workflow links to that workflow's own
|
|
288
|
-
page and shows that workflow's tasks, runs and limits, or, where it has none of its own, this workflow's calls of it;
|
|
289
|
-
any other step shows its own calls in the window as an addition, `in progress + failed + done = calls` (its step
|
|
290
|
-
records: nothing records a task's status at a step), its runs in it now, and what its calls cost. Each edge carries its
|
|
291
|
-
condition and the window's runs beside its own line;
|
|
292
|
-
- **Tasks over time**: each line one status as a percent of a workflow's tasks, chosen in a table with a row for it and
|
|
293
|
-
each workflow among its steps (`src/dashboard/queue-chart.tsx`);
|
|
294
|
-
- **Blocked, by reason**, **Queued, needing an agent**, **What its runs gave** and **Where runs stopped**, read from its
|
|
295
|
-
own records while it is open.
|
|
26
|
+
Write `.js` in the import: TypeScript and Convex's bundler both resolve it to the shipped `.ts`. Convex's codegen
|
|
27
|
+
writes `@jive-sh/workflow-platform/component/_generated/component.js` into an app installing the component, for the
|
|
28
|
+
component's API types.
|
|
296
29
|
|
|
297
|
-
|
|
298
|
-
limit with − and + (`setCpuLimit`, `cpu.threads`), the stop of everything and its resume (`stopEverything`, `resume`,
|
|
299
|
-
`stopped`), and what the account has used of each of its limits (`usage`, `src/dashboard/agent-usage.ts`).
|
|
30
|
+
## A workflow
|
|
300
31
|
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
32
|
+
```ts
|
|
33
|
+
import { TaskSchema, Workflow } from "@jive-sh/workflow-platform"
|
|
34
|
+
import { Schema } from "effect"
|
|
35
|
+
|
|
36
|
+
export const review = Workflow.make({
|
|
37
|
+
name: "review",
|
|
38
|
+
task: TaskSchema.make({ fields: Schema.Struct({ title: Schema.String, good: Schema.Boolean }) }),
|
|
39
|
+
endStates: ["approved", "rejected"],
|
|
40
|
+
budgets: { agents: 0, cpu: 1 },
|
|
41
|
+
events: { arrive: { kind: "task" } },
|
|
42
|
+
steps: (step) => ({
|
|
43
|
+
check: step.code({
|
|
44
|
+
endStates: ["ok", "bad"],
|
|
45
|
+
run: function* (task) {
|
|
46
|
+
return { endState: task.fields.good ? ("ok" as const) : ("bad" as const) }
|
|
47
|
+
},
|
|
48
|
+
}),
|
|
49
|
+
}),
|
|
50
|
+
lines: [
|
|
51
|
+
{ from: { event: "arrive" }, to: { step: "check" } },
|
|
52
|
+
{ from: { step: "check", endState: "ok" }, to: { end: "approved" } },
|
|
53
|
+
{ from: { step: "check", endState: "bad" }, to: { end: "rejected" } },
|
|
54
|
+
],
|
|
55
|
+
})
|
|
311
56
|
```
|
|
312
57
|
|
|
313
|
-
|
|
314
|
-
the
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
##
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
error carries them, so outcomes recorded before 0.6.2 count right too: a task that had 9 tries and 2 such failures, and
|
|
342
|
-
so was blocked, gets its tenth try without being returned to its queue. Nothing stored changes shape.
|
|
343
|
-
## Workflows made of workflows, and no phases (2026-11-21)
|
|
344
|
-
|
|
345
|
-
One concept at every depth: a workflow is steps, and a step is code, an agent call or another workflow (Alex: "just one
|
|
346
|
-
fucking workflow that has steps some of which can be other workflows"). A project's top is a workflow it declares like
|
|
347
|
-
any other, and so is each grouping of workflows under it.
|
|
348
|
-
|
|
349
|
-
- **`steps.defineWorkflowStep(name)`** is a step that is another workflow on its own trigger (its queue, its inputs, a
|
|
350
|
-
timer): no run of the workflow above starts it, so its runs and limits stay its own. A workflow whose steps are all such
|
|
351
|
-
steps (`isMadeOfWorkflows`) has no runs of its own: its runs and agents now are its steps', added up (`runsNow`), it has
|
|
352
|
-
no limits, and its view says it starts on its steps (`StartsOn` `its steps`). `defineSubWorkflow` is unchanged: a step
|
|
353
|
-
whose workflow a run of the one above starts and waits for. `startedAsSteps` names those.
|
|
354
|
-
- **`steps.graphOfFeeds(steps)`** is the step graph of a workflow made of workflows, from `fedBy` at any depth under each step.
|
|
355
|
-
- **`platform.view({ now, top })`**: `top` is the name of the declared workflow a page enters at, and `phases` is gone.
|
|
356
|
-
`WorkflowsView.workflows` lists every workflow in the order defined (it was `groups`, by phase), and `outermost` names
|
|
357
|
-
the other workflows no workflow has as a step, which a page opens at their own names. `flows` is gone.
|
|
358
|
-
|
|
359
|
-
Phases are gone. `defineWorkflow` and `oneStepWorkflow` take no `phase`; `WorkflowDeclaration<R>`, `makeSteps<R>`,
|
|
360
|
-
`createWorkflowPlatform<R>` and `WorkflowPlatform<R>` lose their `Phase` parameter; `AssignedRun` and
|
|
361
|
-
`WorkflowBudgetState` lose `phase`, `WorkflowView` loses `phase` and `place`, and `runsNow` takes no `phases` and
|
|
362
|
-
returns one `WorkflowRunsNow` a workflow (`PhaseRunsNow` is gone). A project moves each group of its workflows into a
|
|
363
|
-
workflow made of them, and its top into one more.
|
|
364
|
-
|
|
365
|
-
One renderer: the map of workflows (`views/workflow-flows.ts`) is gone, and with it the store's `returnedBetween` and
|
|
366
|
-
`listedWaits`, which only it read. `WorkflowsDashboard` takes no `phaseLabel`. Nothing stored changes shape.
|
|
367
|
-
|
|
368
|
-
One page and one graph, the map's: every workflow's page has the same sections, and its steps are drawn by the map's
|
|
369
|
-
renderer and box (`dashboard/workflow-dag.tsx`, ELK), each step a box with its name, kind, description and bar; the bare
|
|
370
|
-
step graph (`dashboard/step-graph.tsx`) and the list of steps (`StepList`) are gone. A workflow that declares no graph has
|
|
371
|
-
its steps in their declared order (`inOrder`), so `WorkflowGraph.edges` is never empty for one with steps. A host keeps its
|
|
372
|
-
alias for `elkjs/lib/elk.bundled.js`.
|
|
373
|
-
|
|
374
|
-
One task a run: a workflow that works on no item, has runs of its own and runs on its own trigger (`steps.tasksAreRuns`)
|
|
375
|
-
gets a task for each run, its item the run's id (`tasks.runStarted`): in progress while the run goes, done when it
|
|
376
|
-
succeeds, blocked when it fails or stands down, with why (the step it failed at, or the stand-down's reason). A start its
|
|
377
|
-
run limit refuses leaves no run waiting, so none is queued. Every task is kept and read, as any workflow's are. Its
|
|
378
|
-
counts start at its first run after this change.
|
|
379
|
-
|
|
380
|
-
Each step's time distribution, over the current version of its workflow, from every task's data:
|
|
381
|
-
|
|
382
|
-
- **A workflow's version** (`steps.versionOf`) is a hash of the code a process loaded: its own file and each step's file (an
|
|
383
|
-
agent step's prompt included), a step that is a workflow counted by that workflow's version. Each step record carries
|
|
384
|
-
its run's version (`step_runs.version`, indexed with workflow and step); a run resumed under newer code keeps the version
|
|
385
|
-
of its first record. Whole files are hashed (`codeOf`), so any change in such a file is a new version; records from
|
|
386
|
-
before versions were recorded have none, and are no version's (`previousVersion` reads only versions).
|
|
387
|
-
- **One value per task per run** (`step-times.ts` `taskTimes`): the task's whole time in the step within the run, its calls
|
|
388
|
-
added up; a batch record counts each item by its own part. A value counts once the run has left the step.
|
|
389
|
-
- **Held in memory** (`makeStepTimes`, `platform.stepTimes.timesOf`): a version's records are read once through their index,
|
|
390
|
-
then each read takes only the records written since and those still open. Where the current version has no value yet,
|
|
391
|
-
the previous version's are given, said to be that. A host routes it (`/api/platform/workflows/<name>/times`) and names
|
|
392
|
-
the route as `timesUrl`; the page reads it each minute.
|
|
393
|
-
- **Drawn in each step's box** (`dashboard/time-distribution.tsx`): a continuous bar graph, x time taken on a linear axis
|
|
394
|
-
from 0 to the slowest, one bar per pixel column, y how many tasks took that long; n, the median (▲) and the 90th
|
|
395
|
-
percentile (◆) in words, both marked on the axis by those shapes.
|
|
396
|
-
|
|
397
|
-
## The spending limit, and tasks that need an agent (0.6.0, 2026-11-20)
|
|
398
|
-
|
|
399
|
-
A project gets a spending limit by giving its week and storing the setting:
|
|
400
|
-
|
|
401
|
-
- **`WorkflowProject.weekUsage`**: `now()`, its newest good reading of the week (used percent, when read, when it resets)
|
|
402
|
-
and a read that failed after it; and `staleAfterSeconds`, when a page calls the reading stale. Without it nothing
|
|
403
|
-
changes.
|
|
404
|
-
- **`platform.spending.readingTaken()`** after each reading it stores: a verdict that changed wakes every waiting step.
|
|
405
|
-
- **A table `spending_limit`** in the file with `workflow_budgets` (`storage/budgets.ts` gives its shape); no row is 95%.
|
|
406
|
-
- **A route** that calls `platform.spending.set({ weekPercent, from, write })`, which checks the percent, writes it with
|
|
407
|
-
the platform's statement, wakes every waiting step and logs who asked; and the page's `setSpendingLimit`.
|
|
408
|
-
|
|
409
|
-
Three shapes grew: `LimitStore` has `spendingLimit`, `WorkflowsView` has `spending`, and `StepRunsNow` has
|
|
410
|
-
`heldBySpendingLimit`, so a store of its own, or a test building these by hand, needs them.
|
|
411
|
-
|
|
412
|
-
The same release marks a task that needs an agent no run can have (above). Nothing stored changes shape: the mark is two
|
|
413
|
-
new note kinds, `needs an agent` and `an agent step ran` (`storage/task-store.ts`), and the queued tasks marked are a
|
|
414
|
-
count of their own in `queue_counts` (`queue-counts.ts` `QUEUED_NEEDING_AN_AGENT`). A workflow that branches on
|
|
415
|
-
`isStoodDown` treats the new end of a run, `NEEDS_AN_AGENT_STOOD_DOWN`, as it treats a run that stood down: no try, its
|
|
416
|
-
item given back. Shapes that grew: `TaskState` and `TaskSummary` have `needsAgent`, a fake `AgentBudgets.agentSlot`
|
|
417
|
-
answers `unavailable` beside `why`, `WorkflowFigures` has `needingAnAgent`, `WorkflowView` has `queuedNeedingAnAgent`,
|
|
418
|
-
and `QueueBar` takes it.
|
|
419
|
-
|
|
420
|
-
## Moving from six buckets to four statuses (0.x, 2026-11-19)
|
|
421
|
-
|
|
422
|
-
Until this version a task stood in one of six derived buckets (queued, running, waiting, stuck, held, done) and its queue
|
|
423
|
-
was ranked. A consumer changes this:
|
|
424
|
-
|
|
425
|
-
| Before | Now |
|
|
426
|
-
|---|---|
|
|
427
|
-
| `createWorkflowPlatform({ ..., rules: { urgent } })` | No `rules`. A step that needs a task first calls `tasks.moveToFront`. |
|
|
428
|
-
| `tasks.giveNewInput`, `tasks.releaseTask` | `tasks.requeue`: the task joins the back of its queue, its failed tries counted again. |
|
|
429
|
-
| `tasks.hold` | `tasks.block`, with the reason in words. A run's own step can also block its task with its outcome (`RunOutcome.blocked`). |
|
|
430
|
-
| `tasks.bucketOf`, `bucketCounts`, `BUCKETS`, `TaskSummary.bucket` | `tasks.statusOf`, `statusCounts`, `TASK_STATUSES`, `TaskSummary.status`. |
|
|
431
|
-
| `TaskSummary.front`, `urgent`, `reopened`, `unchanged`, `PendingWork.last` | Gone, with the ordering rules they fed. `TaskSummary.returned`: a step or a person put it back, and it has not finished since. |
|
|
432
|
-
| `tasks.recordListing(workflow, work)` | `tasks.recordListing({ workflow, work, everyItem })`. |
|
|
433
|
-
| A waiting, stuck or held task | Blocked by its Pick, with the reason (`settleQueue`, which `queueNow` and `pickOrder` run). |
|
|
434
|
-
| Done: off its workflow's list | Done: its final check passed (a run's outcome with `finished`). A task that only left a `pending` list is no longer its workflow's task and is not counted. |
|
|
435
|
-
|
|
436
|
-
Nothing stored changes shape. Notes written before are read as what they did (`storage/task-store.ts` `STATUS_KINDS`),
|
|
437
|
-
and counts recorded under the six names are drawn as the four (`views/workflows-view.ts` `historyByStatus`).
|
|
438
|
-
|
|
439
|
-
A workflow keeps its `pending` list and works unchanged. It declares `items` in place of it (every item it has a task
|
|
440
|
-
for, done or not) once its final check is the one thing that marks its task done.
|
|
441
|
-
|
|
442
|
-
The dashboard changed with it. `WorkflowsDashboard` now takes two more props, both required: `path`, the sub-workflow
|
|
443
|
-
steps opened below the top workflow, and `hrefOf`, each level's address, which the host page routes back as `path`.
|
|
444
|
-
`platform.view` takes `top`, the project's top workflow in its own words. Each workflow's view shows its own steps with
|
|
445
|
-
their kinds, its tasks as `queued + in progress + blocked + done = total`, and its blocked tasks counted by reason.
|
|
446
|
-
The top level draws the map of workflows again (`src/dashboard/workflow-dag.tsx`): a box a workflow, its name a link to its own level, with the arrows work takes between them, from `fedBy` on a workflow and the store's `returnedBetween` and `listedWaits` (`views/workflow-flows.ts`). A host keeps its alias for `elkjs/lib/elk.bundled.js`, which lays the map out.
|
|
447
|
-
A step declares how it runs, `runs: 'deterministic' | 'agentic' | 'classification'`, where it declared `agent: true` or `false`; its kind is what it is: step, check or sub-workflow. The `panels` and `phaseSummary` props are gone, and `sourceHref` is optional now. A sub-workflow step starts its workflow with no run limit of that workflow's own asked, and its steps stand down by the budget of the run at the top: a limit belongs to the workflow whose runs it lets start.
|
|
448
|
-
|
|
449
|
-
Two projects run on the platform: the aoe2-in-browser decompilation service, by path from a checkout beside it, and
|
|
450
|
-
skill-sync's daemon, on the published release. A release with these changes is a breaking one for the second.
|
|
58
|
+
A package that builds its steps as values of their own, to export them (as a compiled diagram binds its elements to
|
|
59
|
+
them), gets the same builder outside a workflow from `Workflow.stepsOf(taskSchema)` (1.1.0).
|
|
60
|
+
|
|
61
|
+
A step's `access` lists what its code may use: services (the platform's or an organization's) and the workflows whose
|
|
62
|
+
tasks it may read and write. Nothing listed grants nothing, a `run` that uses anything else fails to compile, and the
|
|
63
|
+
worker gives a run only what its step lists.
|
|
64
|
+
|
|
65
|
+
## What a workflow can do
|
|
66
|
+
|
|
67
|
+
- **Events:** a task, a request, a change to a field (which can resume a task waiting at an end state), a timer (whose
|
|
68
|
+
turn task is what the schema decodes from `{}`), and a declared item list kept in step by `step.syncList`.
|
|
69
|
+
- **Steps:** code, an agent, a sub-workflow (`step.workflow`, or `step.each` with `collect`), an inputs gate
|
|
70
|
+
(`step.inputsChanged`), retries with a delay and a give-up end state, notes on a task that later steps read, and
|
|
71
|
+
writes to other tasks (`StepOutcome.others`) in the same transaction as the step's own result. A note written that
|
|
72
|
+
way carries its writer as `by: { workflow, step, task }` (1.1.0; 1.0.0 put the writer in the note's words).
|
|
73
|
+
- **Agents:** `AgentRunner` with no tools, a reading mode or a working mode with write scopes, a cached input, and a
|
|
74
|
+
turn limit; the organization implements it.
|
|
75
|
+
- **Queues:** requeue with a note, move tasks to the front, an in-progress limit per workflow or per field value (a
|
|
76
|
+
lock across steps), and retention of records (7 days and the newest 10,000 runs by default).
|
|
77
|
+
- **Records:** every step run's worker, times, end state, error, spend (tokens by kind, requests, cost, compiles),
|
|
78
|
+
CPU and memory, files and agent transcripts, read through the workforce's `stepStats`, `stepRuns`, `tasksAt`,
|
|
79
|
+
`counts` and `task` queries.
|
|
80
|
+
|
|
81
|
+
## Developing it
|
|
82
|
+
|
|
83
|
+
`bun run typecheck` checks `src`, `component` and `worker` (`tsconfig.check.json`); `tsconfig.json` is the library
|
|
84
|
+
abstract's one line, which its build uses for `src`. `bun test src worker` runs the unit tests. The end-to-end tests
|
|
85
|
+
run in an organization package against a local anonymous Convex deployment.
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/* eslint-disable */
|
|
2
|
+
/**
|
|
3
|
+
* Generated `api` utility.
|
|
4
|
+
*
|
|
5
|
+
* THIS CODE IS AUTOMATICALLY GENERATED.
|
|
6
|
+
*
|
|
7
|
+
* To regenerate, run `npx convex dev`.
|
|
8
|
+
* @module
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import type * as engine from "../engine.js";
|
|
12
|
+
import type * as errors from "../errors.js";
|
|
13
|
+
import type * as events from "../events.js";
|
|
14
|
+
import type * as notes from "../notes.js";
|
|
15
|
+
import type * as places from "../places.js";
|
|
16
|
+
import type * as retention from "../retention.js";
|
|
17
|
+
import type * as runEngine from "../runEngine.js";
|
|
18
|
+
import type * as steps from "../steps.js";
|
|
19
|
+
import type * as store from "../store.js";
|
|
20
|
+
import type * as tasks from "../tasks.js";
|
|
21
|
+
import type * as worker from "../worker.js";
|
|
22
|
+
import type * as workflows from "../workflows.js";
|
|
23
|
+
|
|
24
|
+
import type {
|
|
25
|
+
ApiFromModules,
|
|
26
|
+
FilterApi,
|
|
27
|
+
FunctionReference,
|
|
28
|
+
} from "convex/server";
|
|
29
|
+
import { anyApi, componentsGeneric } from "convex/server";
|
|
30
|
+
|
|
31
|
+
const fullApi: ApiFromModules<{
|
|
32
|
+
engine: typeof engine;
|
|
33
|
+
errors: typeof errors;
|
|
34
|
+
events: typeof events;
|
|
35
|
+
notes: typeof notes;
|
|
36
|
+
places: typeof places;
|
|
37
|
+
retention: typeof retention;
|
|
38
|
+
runEngine: typeof runEngine;
|
|
39
|
+
steps: typeof steps;
|
|
40
|
+
store: typeof store;
|
|
41
|
+
tasks: typeof tasks;
|
|
42
|
+
worker: typeof worker;
|
|
43
|
+
workflows: typeof workflows;
|
|
44
|
+
}> = anyApi as any;
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* A utility for referencing Convex functions in your app's public API.
|
|
48
|
+
*
|
|
49
|
+
* Usage:
|
|
50
|
+
* ```js
|
|
51
|
+
* const myFunctionReference = api.myModule.myFunction;
|
|
52
|
+
* ```
|
|
53
|
+
*/
|
|
54
|
+
export const api: FilterApi<
|
|
55
|
+
typeof fullApi,
|
|
56
|
+
FunctionReference<any, "public">
|
|
57
|
+
> = anyApi as any;
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* A utility for referencing Convex functions in your app's internal API.
|
|
61
|
+
*
|
|
62
|
+
* Usage:
|
|
63
|
+
* ```js
|
|
64
|
+
* const myFunctionReference = internal.myModule.myFunction;
|
|
65
|
+
* ```
|
|
66
|
+
*/
|
|
67
|
+
export const internal: FilterApi<
|
|
68
|
+
typeof fullApi,
|
|
69
|
+
FunctionReference<any, "internal">
|
|
70
|
+
> = anyApi as any;
|
|
71
|
+
|
|
72
|
+
export const components = componentsGeneric() as unknown as {};
|