@jive-sh/workflow-platform 0.3.3 → 0.4.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 +64 -21
- package/dist/dashboard/agent-usage.js +25 -0
- package/dist/dashboard/agent-usage.js.map +1 -0
- package/dist/dashboard/drilldown.js +16 -0
- package/dist/dashboard/drilldown.js.map +1 -0
- package/dist/dashboard/queue-lines.js +44 -0
- package/dist/dashboard/queue-lines.js.map +1 -0
- package/dist/index.js +8 -7
- package/dist/index.js.map +1 -1
- package/dist/keep-running.js +1 -1
- package/dist/keep-running.js.map +1 -1
- package/dist/pick-wakes.js +4 -4
- package/dist/pick-wakes.js.map +1 -1
- package/dist/queue-counts.js +7 -9
- package/dist/queue-counts.js.map +1 -1
- package/dist/steps.js +133 -30
- package/dist/steps.js.map +1 -1
- package/dist/storage/sqlite-store.js +115 -40
- package/dist/storage/sqlite-store.js.map +1 -1
- package/dist/storage/task-store.js +14 -1
- package/dist/storage/task-store.js.map +1 -1
- package/dist/tasks.js +215 -267
- package/dist/tasks.js.map +1 -1
- package/dist/views/runs-now.js +2 -1
- package/dist/views/runs-now.js.map +1 -1
- package/dist/views/workflows-view.js +74 -15
- package/dist/views/workflows-view.js.map +1 -1
- package/package.json +1 -1
- package/src/dashboard/agent-usage-line.tsx +28 -0
- package/src/dashboard/agent-usage.ts +48 -0
- package/src/dashboard/dashboard.css +57 -28
- package/src/dashboard/drilldown.ts +44 -0
- package/src/dashboard/index.tsx +1 -0
- package/src/dashboard/machine-controls.tsx +53 -0
- package/src/dashboard/queue-bar.tsx +43 -0
- package/src/dashboard/queue-chart.tsx +89 -76
- package/src/dashboard/queue-lines.ts +87 -0
- package/src/dashboard/workflow-drilldown.tsx +89 -0
- package/src/dashboard/workflows-dashboard.tsx +103 -37
- package/src/index.ts +11 -10
- package/src/keep-running.ts +3 -3
- package/src/pick-wakes.ts +14 -9
- package/src/queue-counts.ts +10 -14
- package/src/steps.ts +179 -42
- package/src/storage/sqlite-store.ts +123 -46
- package/src/storage/step-records.ts +14 -3
- package/src/storage/task-store.ts +88 -36
- package/src/tasks.ts +235 -301
- package/src/views/runs-now.ts +3 -2
- package/src/views/workflows-view.ts +102 -32
- package/dist/views/workflow-flows.js +0 -53
- package/dist/views/workflow-flows.js.map +0 -1
- package/src/dashboard/workflow-dag.tsx +0 -276
- package/src/views/workflow-flows.ts +0 -97
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* WHERE WORK FLOWS BETWEEN WORKFLOWS: the edges of a project's DAG of workflows, and each workflow's place in its pipeline.
|
|
3
|
-
* Built from what the platform knows and nothing written for the page:
|
|
4
|
-
*
|
|
5
|
-
* feeds a workflow declares the other among those whose results it works on (`fedBy`);
|
|
6
|
-
* sends back a workflow gave new input (`giveNewInput`) to a task of one that is upstream of it, through feeds;
|
|
7
|
-
* gives input it gave new input to a task of one that is not upstream of it, and no feed is declared between them;
|
|
8
|
-
* waits on its list puts tasks on a wait that names another workflow (`PendingWork.waits`), not the one that feeds it:
|
|
9
|
-
* the list's own words say why (`why`).
|
|
10
|
-
*
|
|
11
|
-
* Its place: its stage (the project's phases, in order), then how many feeds lead into it within its stage. Pure.
|
|
12
|
-
*/
|
|
13
|
-
import type { ListedWait, NewInputFlow } from '../storage/task-store';
|
|
14
|
-
|
|
15
|
-
export type FlowKind = 'feeds' | 'sends back' | 'gives input' | 'waits on';
|
|
16
|
-
|
|
17
|
-
/** One edge: work going from one workflow to another. */
|
|
18
|
-
export interface WorkflowFlow {
|
|
19
|
-
readonly from: string;
|
|
20
|
-
readonly to: string;
|
|
21
|
-
readonly kind: FlowKind;
|
|
22
|
-
/** Whether a declaration says it (`fedBy`); a recorded one only is not declared. */
|
|
23
|
-
readonly declared: boolean;
|
|
24
|
-
/** The new-input notes recorded along it, and the last one's time; 0 and none where none was recorded. */
|
|
25
|
-
readonly notes: number;
|
|
26
|
-
readonly last: number | null;
|
|
27
|
-
/** Along a `waits on` edge: the tasks waiting, and the list's words for the wait; 0 and none on any other. */
|
|
28
|
-
readonly waiting: number;
|
|
29
|
-
readonly why: string | null;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
/** A workflow's place in its pipeline: its stage's index, then its depth within the stage through feeds. */
|
|
33
|
-
export interface PipelinePlace {
|
|
34
|
-
readonly workflow: string;
|
|
35
|
-
readonly stage: number;
|
|
36
|
-
readonly depth: number;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
/** Whether `to` reaches `from` through `feeds`: work goes from `to`, by way of others, to `from`. */
|
|
40
|
-
const reaches = (feeds: ReadonlyArray<{ readonly from: string; readonly to: string }>, start: string, target: string): boolean => {
|
|
41
|
-
const seen = new Set<string>([start]);
|
|
42
|
-
const next = [start];
|
|
43
|
-
while (next.length > 0) {
|
|
44
|
-
const at = next.pop()!;
|
|
45
|
-
for (const f of feeds) {
|
|
46
|
-
if (f.from !== at || seen.has(f.to)) continue;
|
|
47
|
-
if (f.to === target) return true;
|
|
48
|
-
seen.add(f.to);
|
|
49
|
-
next.push(f.to);
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
return false;
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
export const workflowFlows = (input: {
|
|
56
|
-
readonly declared: ReadonlyArray<{ readonly name: string; readonly fedBy?: ReadonlyArray<string> }>;
|
|
57
|
-
readonly newInputs: ReadonlyArray<NewInputFlow>;
|
|
58
|
-
readonly waits: ReadonlyArray<ListedWait>;
|
|
59
|
-
}): ReadonlyArray<WorkflowFlow> => {
|
|
60
|
-
const names = new Set(input.declared.map((d) => d.name));
|
|
61
|
-
const recorded = (from: string, to: string) => input.newInputs.find((n) => n.from === from && n.to === to);
|
|
62
|
-
const feeds = input.declared.flatMap((d) => (d.fedBy ?? []).filter((f) => names.has(f) && f !== d.name).map((f) => ({ from: f, to: d.name })));
|
|
63
|
-
const declaredFlows: ReadonlyArray<WorkflowFlow> = feeds.map((f) => {
|
|
64
|
-
const r = recorded(f.from, f.to);
|
|
65
|
-
return { from: f.from, to: f.to, kind: 'feeds', declared: true, notes: r?.notes ?? 0, last: r?.last ?? null, waiting: 0, why: null };
|
|
66
|
-
});
|
|
67
|
-
const recordedOnly: ReadonlyArray<WorkflowFlow> = input.newInputs
|
|
68
|
-
.filter((n) => names.has(n.from) && names.has(n.to) && !feeds.some((f) => f.from === n.from && f.to === n.to))
|
|
69
|
-
.map((n) => ({ from: n.from, to: n.to, kind: reaches(feeds, n.to, n.from) ? 'sends back' : 'gives input', declared: false, notes: n.notes, last: n.last, waiting: 0, why: null }));
|
|
70
|
-
// A wait on the workflow that feeds it is that feed's work still to come, drawn as the feed; one on another is an edge.
|
|
71
|
-
const waitedOn: ReadonlyArray<WorkflowFlow> = input.waits
|
|
72
|
-
.filter((w) => names.has(w.on) && w.on !== w.workflow && !feeds.some((f) => f.from === w.on && f.to === w.workflow))
|
|
73
|
-
.map((w) => ({ from: w.workflow, to: w.on, kind: 'waits on', declared: false, notes: 0, last: null, waiting: w.tasks, why: w.label }));
|
|
74
|
-
return [...declaredFlows, ...recordedOnly, ...waitedOn];
|
|
75
|
-
};
|
|
76
|
-
|
|
77
|
-
/** Each workflow's place: its stage by `stageOf` in `stages`' order (one not among them after them), then its depth there. */
|
|
78
|
-
export const pipelinePlaces = (input: {
|
|
79
|
-
readonly workflows: ReadonlyArray<{ readonly name: string; readonly stage: string }>;
|
|
80
|
-
readonly stages: ReadonlyArray<string>;
|
|
81
|
-
readonly flows: ReadonlyArray<WorkflowFlow>;
|
|
82
|
-
}): ReadonlyArray<PipelinePlace> => {
|
|
83
|
-
const stageIndex = (s: string) => (input.stages.includes(s) ? input.stages.indexOf(s) : input.stages.length);
|
|
84
|
-
const stageOf = new Map(input.workflows.map((w) => [w.name, stageIndex(w.stage)]));
|
|
85
|
-
// Forward work only: feeds, and input given to one not upstream. A send-back points against the pipeline.
|
|
86
|
-
const forward = input.flows.filter((f) => f.kind !== 'sends back');
|
|
87
|
-
const depth = new Map<string, number>();
|
|
88
|
-
const depthOf = (name: string, path: ReadonlySet<string>): number => {
|
|
89
|
-
const known = depth.get(name);
|
|
90
|
-
if (known !== undefined) return known;
|
|
91
|
-
const into = forward.filter((f) => f.to === name && !path.has(f.from) && stageOf.get(f.from) === stageOf.get(name));
|
|
92
|
-
const d = into.length === 0 ? 0 : Math.max(...into.map((f) => depthOf(f.from, new Set([...path, name])) + 1));
|
|
93
|
-
depth.set(name, d);
|
|
94
|
-
return d;
|
|
95
|
-
};
|
|
96
|
-
return input.workflows.map((w) => ({ workflow: w.name, stage: stageIndex(w.stage), depth: depthOf(w.name, new Set()) }));
|
|
97
|
-
};
|