@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/src/system-workflows.ts
DELETED
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* THE PLATFORM'S OWN WORKFLOWS, which every app built on it has and none defines. Alex, 2026-11-22: "retention is supposed
|
|
3
|
-
* to be configurable at the platform layer and something configurable for all tasks. not a bespoke workflow that every
|
|
4
|
-
* implementation must define. perhaps there can be some notion of system workflows at the top level which can be
|
|
5
|
-
* configured but not amended without changing the platform itself".
|
|
6
|
-
*
|
|
7
|
-
* `createWorkflowPlatform` defines each before any of the app's, so each is declared, measured, queued and shown like any
|
|
8
|
-
* other workflow (`steps.ts`), at the top level, and marked as the platform's (`WorkflowDeclaration.system`). What the app
|
|
9
|
-
* sets of one is its schedule (`WorkflowProject.systemSchedules`), its run limit (the limits table, as for any workflow)
|
|
10
|
-
* and the settings it inherits from the app (`WorkflowProject.settings`). What it cannot do is define a workflow of its
|
|
11
|
-
* name or hold it as a step (`steps.ts` `refuseSystem`): changing its steps is changing the platform.
|
|
12
|
-
*
|
|
13
|
-
* The app's engine runs each one's layer (`SystemWorkflows.layer`) and its scheduler starts each one's run on its
|
|
14
|
-
* schedule (`SystemWorkflows.workflows`), as it starts any workflow of its own on a timer.
|
|
15
|
-
*
|
|
16
|
-
* Retention every hour, deletes each finished run's step records once past what its steps keep (`retention.ts`).
|
|
17
|
-
*/
|
|
18
|
-
import { Effect, Layer, Schema } from 'effect';
|
|
19
|
-
import type { Retention, RetentionPass } from './retention';
|
|
20
|
-
import type { makeSteps } from './steps';
|
|
21
|
-
|
|
22
|
-
/** Each of the platform's own workflows, by name, and how often it runs where the app sets nothing: its first run after the app's start, then every `everySeconds`. */
|
|
23
|
-
export const SYSTEM_WORKFLOW_SCHEDULES = {
|
|
24
|
-
Retention: { everySeconds: 3600, firstAfterSeconds: 300 },
|
|
25
|
-
} as const;
|
|
26
|
-
|
|
27
|
-
export type SystemWorkflowName = keyof typeof SYSTEM_WORKFLOW_SCHEDULES;
|
|
28
|
-
|
|
29
|
-
/** What an app sets of a system workflow's schedule (`WorkflowProject.systemSchedules`). */
|
|
30
|
-
export interface SystemSchedule {
|
|
31
|
-
readonly everySeconds: number;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
/** One pass of retention as its step's result (`RetentionPass`). */
|
|
35
|
-
const RetentionPassResult = Schema.Struct({ records: Schema.Number, parts: Schema.Number, runTasks: Schema.Number, runTaskNotes: Schema.Number });
|
|
36
|
-
|
|
37
|
-
/** What a pass deleted, in the words its step record keeps as its reason. Pure. */
|
|
38
|
-
export const retentionPassWords = (p: RetentionPass): string => {
|
|
39
|
-
const n = (x: number, one: string, many: string) => `${x.toLocaleString('en-US')} ${x === 1 ? one : many}`;
|
|
40
|
-
return `deleted ${n(p.records, 'step record', 'step records')}, ${n(p.parts, 'per-item part', 'per-item parts')} of them, and ${n(p.runTasks, 'task that was a run', 'tasks that were runs')} with ${n(p.runTaskNotes, 'note', 'notes')}`;
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
/** A schedule as the app set it, checked where it enters: a whole number of seconds, at least one. */
|
|
44
|
-
const checkedEvery = (name: SystemWorkflowName, set: SystemSchedule | undefined): number => {
|
|
45
|
-
if (set === undefined) return SYSTEM_WORKFLOW_SCHEDULES[name].everySeconds;
|
|
46
|
-
if (!(Number.isInteger(set.everySeconds) && set.everySeconds >= 1)) throw new Error(`${name}: its schedule must be a whole number of seconds, at least 1, not ${set.everySeconds}`);
|
|
47
|
-
return set.everySeconds;
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
/** The platform's own workflows, defined on one app's platform. */
|
|
51
|
-
export const makeSystemWorkflows = <R>(deps: {
|
|
52
|
-
readonly define: ReturnType<typeof makeSteps<R>>['oneStepSystemWorkflow'];
|
|
53
|
-
readonly retention: Retention;
|
|
54
|
-
readonly schedules: Readonly<Partial<Record<SystemWorkflowName, SystemSchedule>>> | undefined;
|
|
55
|
-
}) => {
|
|
56
|
-
const unknown = Object.keys(deps.schedules ?? {}).filter((name) => !(name in SYSTEM_WORKFLOW_SCHEDULES));
|
|
57
|
-
if (unknown.length > 0) throw new Error(`the app sets a schedule for ${unknown.join(', ')}, which is none of the platform's own workflows (${Object.keys(SYSTEM_WORKFLOW_SCHEDULES).join(', ')})`);
|
|
58
|
-
const retention = deps.define({
|
|
59
|
-
at: import.meta.path,
|
|
60
|
-
description: "Every hour: each finished run's step records deleted once past the days its steps keep them, set on the app, a workflow or a step; and the tasks that were those runs.",
|
|
61
|
-
stepDescription: "Deletes each finished run's step records past its retention, a chunk a transaction, and says how many went.",
|
|
62
|
-
reason: retentionPassWords,
|
|
63
|
-
}, 'Retention', 'Prune', RetentionPassResult, Effect.suspend(() => deps.retention.prune(Date.now() / 1000)));
|
|
64
|
-
const workflows = [
|
|
65
|
-
{ name: retention.name, everySeconds: checkedEvery('Retention', deps.schedules?.Retention), firstAfterSeconds: SYSTEM_WORKFLOW_SCHEDULES.Retention.firstAfterSeconds, run: retention.run, start: retention.start },
|
|
66
|
-
] as const;
|
|
67
|
-
return { workflows, layer: Layer.mergeAll(retention.layer) };
|
|
68
|
-
};
|
|
69
|
-
|
|
70
|
-
export type SystemWorkflows = ReturnType<typeof makeSystemWorkflows<unknown>>;
|