@jive-sh/workflow-platform 0.7.0 → 1.0.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 +66 -435
- package/component/_generated/api.ts +72 -0
- package/component/_generated/component.ts +621 -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 +755 -0
- package/component/errors.ts +66 -0
- package/component/events.ts +17 -0
- package/component/notes.ts +13 -0
- package/component/places.ts +136 -0
- package/component/retention.ts +205 -0
- package/component/runEngine.ts +25 -0
- package/component/schema.ts +132 -0
- package/component/steps.ts +188 -0
- package/component/store.ts +512 -0
- package/component/tasks.ts +289 -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 +111 -0
- package/dist/definition/workflow.js.map +1 -0
- package/dist/graph.js +301 -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 +255 -0
- package/src/graph.ts +341 -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 +138 -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/src/step-times.ts
DELETED
|
@@ -1,151 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* EACH STEP'S TIME DISTRIBUTION OVER THE CURRENT VERSION OF ITS WORKFLOW, FROM EVERY TASK'S DATA. Alex, 2026-11-21: "it must
|
|
3
|
-
* be drawn via every task's data"; "one point is (time taken, number of tasks with that time taken)".
|
|
4
|
-
*
|
|
5
|
-
* ONE VALUE PER TASK PER RUN: the task's whole time in the step within that run, every call of it added up (Write C's 1 to 3
|
|
6
|
-
* variants for one function are one value). A record's task is its item (`subject`), or its run where it names none; a batch
|
|
7
|
-
* record counts each item by its own part (`step_functions`). A value counts once the run has left the step (a record of
|
|
8
|
-
* another step is newer, or the run has ended) and none of its calls is open; a run that comes back to the step shows the
|
|
9
|
-
* value again, larger, once it leaves again.
|
|
10
|
-
*
|
|
11
|
-
* HELD IN MEMORY, NEVER SCANNED FOR A PAGE: a workflow's records of its current version (`steps.ts` `versionOf`) are read
|
|
12
|
-
* once through their index (`step_runs_by_version`), then each refresh reads only the records written since and the ones
|
|
13
|
-
* still open, by id. Where the current version has no value yet, the previous version's are read once and shown as that.
|
|
14
|
-
*/
|
|
15
|
-
import { Effect } from 'effect';
|
|
16
|
-
import type { EngineRecords } from './storage/engine-records';
|
|
17
|
-
import type { StepRecords, TimedPart, TimedRecord } from './storage/step-records';
|
|
18
|
-
import type { StorageError } from './storage/storage-error';
|
|
19
|
-
import type { WorkflowVersion } from './steps';
|
|
20
|
-
|
|
21
|
-
/** One step's values: each task's time in it, seconds to 0.1, fastest first. */
|
|
22
|
-
export interface StepValues {
|
|
23
|
-
readonly step: string;
|
|
24
|
-
readonly values: ReadonlyArray<number>;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
/** Every step's values of one version of a workflow. */
|
|
28
|
-
export interface VersionTimes {
|
|
29
|
-
readonly version: string;
|
|
30
|
-
readonly steps: ReadonlyArray<StepValues>;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
/** What a page draws each step's distribution from (`WorkflowsDashboard`). */
|
|
34
|
-
export interface StepTimes extends VersionTimes {
|
|
35
|
-
readonly workflow: string;
|
|
36
|
-
/** When the newest file of the current version last changed, unix seconds. */
|
|
37
|
-
readonly since: number;
|
|
38
|
-
/** Where the current version has no value yet: the previous version's, and when its newest record started. */
|
|
39
|
-
readonly previous: (VersionTimes & { readonly at: number }) | null;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* EACH STEP'S VALUES FROM ITS RECORDS: one per task per run, its calls added up, counted once the run has left the step and
|
|
44
|
-
* none of its calls is open. `unfinished` is the runs still going. Pure, so it is tested alone.
|
|
45
|
-
*/
|
|
46
|
-
export const taskTimes = (input: {
|
|
47
|
-
readonly records: ReadonlyArray<TimedRecord>;
|
|
48
|
-
readonly parts: ReadonlyArray<TimedPart>;
|
|
49
|
-
readonly unfinished: ReadonlySet<string>;
|
|
50
|
-
}): ReadonlyMap<string, ReadonlyArray<number>> => {
|
|
51
|
-
const newest = new Map<string, TimedRecord>();
|
|
52
|
-
for (const r of input.records) if ((newest.get(r.run)?.id ?? -1) < r.id) newest.set(r.run, r);
|
|
53
|
-
const partsOf = new Map<number, TimedPart[]>();
|
|
54
|
-
for (const p of input.parts) partsOf.set(p.stepRun, [...(partsOf.get(p.stepRun) ?? []), p]);
|
|
55
|
-
const groups = new Map<string, { readonly run: string; readonly step: string; seconds: number; open: boolean }>();
|
|
56
|
-
const add = (r: TimedRecord, task: string, started: number, ended: number | null) => {
|
|
57
|
-
const key = `${r.run}\u0000${r.step}\u0000${task.toLowerCase()}`;
|
|
58
|
-
const g = groups.get(key) ?? { run: r.run, step: r.step, seconds: 0, open: false };
|
|
59
|
-
if (ended === null) g.open = true;
|
|
60
|
-
else g.seconds += Math.max(0, ended - started);
|
|
61
|
-
groups.set(key, g);
|
|
62
|
-
};
|
|
63
|
-
for (const r of input.records) {
|
|
64
|
-
const parts = r.scope === 'functions' ? partsOf.get(r.id) : undefined;
|
|
65
|
-
if (parts !== undefined && parts.length > 0) for (const p of parts) add(r, p.subject, p.started, p.ended);
|
|
66
|
-
else add(r, r.subject ?? r.run, r.started, r.ended);
|
|
67
|
-
}
|
|
68
|
-
const values = new Map<string, number[]>();
|
|
69
|
-
for (const g of groups.values()) {
|
|
70
|
-
const left = !input.unfinished.has(g.run) || newest.get(g.run)?.step !== g.step;
|
|
71
|
-
if (g.open || !left) continue;
|
|
72
|
-
values.set(g.step, [...(values.get(g.step) ?? []), Math.round(g.seconds * 10) / 10]);
|
|
73
|
-
}
|
|
74
|
-
for (const v of values.values()) v.sort((a, b) => a - b);
|
|
75
|
-
return values;
|
|
76
|
-
};
|
|
77
|
-
|
|
78
|
-
/** A version's records held: by id, with each batch record's parts, and the newest id read of every workflow's. */
|
|
79
|
-
interface Held {
|
|
80
|
-
readonly version: string;
|
|
81
|
-
readonly records: Map<number, TimedRecord>;
|
|
82
|
-
readonly parts: Map<number, ReadonlyArray<TimedPart>>;
|
|
83
|
-
newestId: number;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
export const makeStepTimes = (deps: {
|
|
87
|
-
readonly records: Pick<StepRecords, 'versionRecords' | 'recordsSince' | 'previousVersion'>;
|
|
88
|
-
readonly engine: Pick<EngineRecords, 'unfinishedRuns'>;
|
|
89
|
-
readonly versionOf: (workflow: string) => WorkflowVersion;
|
|
90
|
-
/** A workflow's steps, in their declared order. */
|
|
91
|
-
readonly stepsOf: (workflow: string) => ReadonlyArray<string>;
|
|
92
|
-
}) => {
|
|
93
|
-
const held = new Map<string, Held>();
|
|
94
|
-
const previous = new Map<string, { readonly version: string; readonly at: number; readonly held: Held } | null>();
|
|
95
|
-
|
|
96
|
-
const hold = (r: { readonly workflow: string; readonly version: string }): Effect.Effect<Held, StorageError> =>
|
|
97
|
-
Effect.map(deps.records.versionRecords(r), (read) => ({
|
|
98
|
-
version: r.version,
|
|
99
|
-
records: new Map(read.records.map((x) => [x.id, x])),
|
|
100
|
-
parts: groupParts(read.parts),
|
|
101
|
-
newestId: read.newestId,
|
|
102
|
-
}));
|
|
103
|
-
|
|
104
|
-
/** Reads the records written since, and those still open again, into what is held. */
|
|
105
|
-
const refresh = (workflow: string, h: Held): Effect.Effect<void, StorageError> => Effect.gen(function* () {
|
|
106
|
-
const open = [...h.records.values()].filter((x) => x.ended === null).map((x) => x.id);
|
|
107
|
-
const read = yield* deps.records.recordsSince({ after: h.newestId, again: open });
|
|
108
|
-
for (const x of read.records) {
|
|
109
|
-
h.newestId = Math.max(h.newestId, x.id);
|
|
110
|
-
if (x.workflow === workflow && x.version === h.version) h.records.set(x.id, x);
|
|
111
|
-
}
|
|
112
|
-
for (const [id, parts] of groupParts(read.parts)) h.parts.set(id, parts);
|
|
113
|
-
});
|
|
114
|
-
|
|
115
|
-
const valuesOf = (workflow: string, h: Held, unfinished: ReadonlySet<string>): ReadonlyArray<StepValues> => {
|
|
116
|
-
const byStep = taskTimes({ records: [...h.records.values()], parts: [...h.parts.values()].flat(), unfinished });
|
|
117
|
-
const declared = deps.stepsOf(workflow);
|
|
118
|
-
return [...declared, ...[...byStep.keys()].filter((s) => !declared.includes(s))].map((step) => ({ step, values: byStep.get(step) ?? [] }));
|
|
119
|
-
};
|
|
120
|
-
|
|
121
|
-
/** A workflow's step times now: its current version's values, and the previous version's where the current has none. */
|
|
122
|
-
const timesOf = (workflow: string): Effect.Effect<StepTimes, StorageError> => Effect.gen(function* () {
|
|
123
|
-
const current = deps.versionOf(workflow);
|
|
124
|
-
const known = held.get(workflow);
|
|
125
|
-
const h = known !== undefined && known.version === current.version ? known : yield* hold({ workflow, version: current.version });
|
|
126
|
-
if (h !== known) held.set(workflow, h);
|
|
127
|
-
else yield* refresh(workflow, h);
|
|
128
|
-
const unfinished = new Set((yield* deps.engine.unfinishedRuns()).map((u) => u.run));
|
|
129
|
-
const steps = valuesOf(workflow, h, unfinished);
|
|
130
|
-
if (steps.some((s) => s.values.length > 0)) return { workflow, version: current.version, since: current.since, steps, previous: null };
|
|
131
|
-
if (!previous.has(workflow)) {
|
|
132
|
-
const before = yield* deps.records.previousVersion({ workflow, version: current.version });
|
|
133
|
-
previous.set(workflow, before === null ? null : { ...before, held: yield* hold({ workflow, version: before.version }) });
|
|
134
|
-
}
|
|
135
|
-
const before = previous.get(workflow) ?? null;
|
|
136
|
-
return {
|
|
137
|
-
workflow, version: current.version, since: current.since, steps,
|
|
138
|
-
previous: before === null ? null : { version: before.version, at: before.at, steps: valuesOf(workflow, before.held, unfinished) },
|
|
139
|
-
};
|
|
140
|
-
});
|
|
141
|
-
|
|
142
|
-
return { timesOf };
|
|
143
|
-
};
|
|
144
|
-
|
|
145
|
-
const groupParts = (parts: ReadonlyArray<TimedPart>): Map<number, ReadonlyArray<TimedPart>> => {
|
|
146
|
-
const out = new Map<number, TimedPart[]>();
|
|
147
|
-
for (const p of parts) out.set(p.stepRun, [...(out.get(p.stepRun) ?? []), p]);
|
|
148
|
-
return out;
|
|
149
|
-
};
|
|
150
|
-
|
|
151
|
-
export type StepTimesReader = ReturnType<typeof makeStepTimes>;
|
package/src/step-usage.ts
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* THE STEP A PIECE OF CODE IS WORKING FOR, as the project's code reads it to pass to its process starter: the step's meter
|
|
3
|
-
* inside a step (`step-meter.ts`). Outside a step, in a process a step started, the step record it was told about by the
|
|
4
|
-
* project's `stepRecordVariable` gets its compiles: that process's CPU reaches the step through the process's own usage.
|
|
5
|
-
*/
|
|
6
|
-
import { Context, Effect } from 'effect';
|
|
7
|
-
import type { UsageSink } from './project';
|
|
8
|
-
import { isCompile } from './step-meter';
|
|
9
|
-
|
|
10
|
-
export const makeStepUsage = (options: { readonly variable: string; readonly addStepCompile: (record: number) => void }) => {
|
|
11
|
-
const startedFor = Number(process.env[options.variable]);
|
|
12
|
-
const processSink: UsageSink | null = Number.isInteger(startedFor) && startedFor > 0
|
|
13
|
-
? { record: startedFor, add: (u) => { if (isCompile(u)) options.addStepCompile(startedFor); } }
|
|
14
|
-
: null;
|
|
15
|
-
|
|
16
|
-
const CurrentStepUsage = Context.Reference<UsageSink | null>('CurrentStepUsage', { defaultValue: () => processSink });
|
|
17
|
-
|
|
18
|
-
/** `go` given where its processes' usage goes; for code that starts one from a Promise. */
|
|
19
|
-
const withStepUsage = <A, E, R>(go: (usage: UsageSink | null) => Effect.Effect<A, E, R>): Effect.Effect<A, E, R> =>
|
|
20
|
-
Effect.flatMap(CurrentStepUsage, go);
|
|
21
|
-
|
|
22
|
-
return { CurrentStepUsage, withStepUsage };
|
|
23
|
-
};
|