@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/dist/spending-limit.js
DELETED
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* THE SPENDING LIMIT: ONE SETTING FOR THE WHOLE ACCOUNT, "AGENTS STOP AT X% OF THE WEEK". Alex, 2026-11-20: "ideally the
|
|
3
|
-
* workflow platform offers a configurable spending limit", and, of this design, "yes to building the spending limit".
|
|
4
|
-
*
|
|
5
|
-
* While the project's newest good reading of its week (`WorkflowProject.weekUsage`) is at or past X, no run of any workflow
|
|
6
|
-
* is given an agent claim (`steps.ts` `claimAgentsOrEnd`), and a run already holding one ends before its next agent call
|
|
7
|
-
* (`beforeAgentCall`), as at an agents' limit of 0: its task goes to the back of its queue, marked as needing an agent,
|
|
8
|
-
* with why in words. Nothing waits, and an agent call already going is never cut off. Runs take claims again once a reading
|
|
9
|
-
* is below X, which the week's reset brings: the project tells the platform of each reading it takes (`readingTaken`), and
|
|
10
|
-
* a verdict that changed has the run planner plan again and wakes every Pick. None is set: X is 95
|
|
11
|
-
* (`DEFAULT_SPENDING_LIMIT_PERCENT`).
|
|
12
|
-
*
|
|
13
|
-
* IT JUDGES THE ACCOUNT'S WEEK, NOT A COUNT OF TOKENS, because the week is the one figure that also counts spending the
|
|
14
|
-
* platform cannot see: agent threads run by hand, outside any workflow, which no step record holds. They were 73% of the
|
|
15
|
-
* spending of the week that ran out on 2026-11-01, 57 hours before its reset (the first project's `usage/pace.ts`).
|
|
16
|
-
*
|
|
17
|
-
* A READING THAT FAILS OR GROWS OLD NEVER LIFTS IT. The rule judges the newest good reading, however old, so a hold stands
|
|
18
|
-
* until a good reading below X, and a page says the reading is stale and why. That holds past the reset the reading named
|
|
19
|
-
* too: with every read failing, no agent is given until one succeeds, rather than spend on a week nobody can see. A week that
|
|
20
|
-
* cannot be read at all holds the same way. With no good reading yet there is nothing to judge, and nothing is held. A
|
|
21
|
-
* project that reads no week has no spending limit.
|
|
22
|
-
*/
|
|
23
|
-
import { Effect, pipe, Result } from 'effect';
|
|
24
|
-
import { SET_SPENDING_LIMIT_SQL } from './storage/budgets';
|
|
25
|
-
import { percentCut } from './views/format';
|
|
26
|
-
/** The percent of the week at which agents stop where none is set. */
|
|
27
|
-
export const DEFAULT_SPENDING_LIMIT_PERCENT = 95;
|
|
28
|
-
/** The limit against the week now. Pure. */
|
|
29
|
-
export const judgeSpending = (input) => {
|
|
30
|
-
const limitPercent = input.limit === null ? DEFAULT_SPENDING_LIMIT_PERCENT : input.limit.weekPercent;
|
|
31
|
-
const good = input.usage.good;
|
|
32
|
-
return {
|
|
33
|
-
limitPercent,
|
|
34
|
-
setAt: input.limit === null ? null : input.limit.changedAt,
|
|
35
|
-
reading: good,
|
|
36
|
-
failedSince: input.usage.failedSince,
|
|
37
|
-
stale: good !== null && (input.usage.failedSince !== null || input.now - good.readAt > input.staleAfterSeconds),
|
|
38
|
-
holds: good !== null && good.usedPercent >= limitPercent,
|
|
39
|
-
};
|
|
40
|
-
};
|
|
41
|
-
export const makeSpendingLimit = (deps) => {
|
|
42
|
-
const { usage } = deps;
|
|
43
|
-
const state = (now) => usage === null ? Effect.succeed(null) : Effect.map(Effect.all({ limit: deps.store.spendingLimit(), week: usage.now() }), ({ limit, week }) => judgeSpending({ limit, usage: week, staleAfterSeconds: usage.staleAfterSeconds, now }));
|
|
44
|
-
/** What the last reading told held, in this process; none before the first. */
|
|
45
|
-
let heldAtLastReading = null;
|
|
46
|
-
/** A run found the week unreadable since the last reading, so the next reading wakes every Pick, whatever its verdict. */
|
|
47
|
-
let unreadSinceLastReading = false;
|
|
48
|
-
return {
|
|
49
|
-
holdsAgents: () => pipe(state(Date.now() / 1000), Effect.map((s) => (s === null || !s.holds || s.reading === null ? null
|
|
50
|
-
: `the week's use is ${percentCut(s.reading.usedPercent)}, at or past the spending limit of ${s.limitPercent}%`)), Effect.catchTag('StorageError', (e) => Effect.sync(() => {
|
|
51
|
-
unreadSinceLastReading = true;
|
|
52
|
-
return `the week's use could not be read (${e.reason}), so the spending limit holds`;
|
|
53
|
-
}))),
|
|
54
|
-
state,
|
|
55
|
-
readingTaken: () => Effect.gen(function* () {
|
|
56
|
-
const judged = yield* Effect.result(state(Date.now() / 1000));
|
|
57
|
-
if (Result.isFailure(judged))
|
|
58
|
-
return yield* Effect.logError(`[spending limit] a reading was taken and could not be judged: ${judged.failure.reason}`);
|
|
59
|
-
const holds = judged.success !== null && judged.success.holds;
|
|
60
|
-
if (holds === heldAtLastReading && !unreadSinceLastReading)
|
|
61
|
-
return;
|
|
62
|
-
if (holds !== heldAtLastReading && judged.success !== null) {
|
|
63
|
-
yield* Effect.log(`[spending limit] ${holds ? 'withholds every agent' : 'holds nothing'}: the week's use is ${judged.success.reading === null ? 'not read yet' : percentCut(judged.success.reading.usedPercent)}, the limit ${judged.success.limitPercent}%`);
|
|
64
|
-
}
|
|
65
|
-
heldAtLastReading = holds;
|
|
66
|
-
unreadSinceLastReading = false;
|
|
67
|
-
// It changes whether any run can take work (`steps.ts` `whyNoRunCanTakeWork`): the run planner plans again too.
|
|
68
|
-
deps.wakes.runPlanChanged({ workflow: null, source: holds ? 'a reading at or past the spending limit' : 'a reading below the spending limit' });
|
|
69
|
-
}),
|
|
70
|
-
set: (r) => Effect.gen(function* () {
|
|
71
|
-
const weekPercent = r.weekPercent;
|
|
72
|
-
if (typeof weekPercent !== 'number' || !Number.isInteger(weekPercent) || weekPercent < 0 || weekPercent > 100) {
|
|
73
|
-
return { ok: false, error: 'weekPercent must be a whole number from 0 to 100' };
|
|
74
|
-
}
|
|
75
|
-
yield* r.write({ sql: SET_SPENDING_LIMIT_SQL, params: [weekPercent, Date.now() / 1000] });
|
|
76
|
-
deps.wakes.runPlanChanged({ workflow: null, source: 'the spending limit set' });
|
|
77
|
-
yield* Effect.log(`[spending limit] ${weekPercent}%, from ${r.from}`);
|
|
78
|
-
return { ok: true, weekPercent };
|
|
79
|
-
}),
|
|
80
|
-
};
|
|
81
|
-
};
|
|
82
|
-
//# sourceMappingURL=spending-limit.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"spending-limit.js","sourceRoot":"","s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CAAC,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC;YAC9B,MAAM,WAAW,GAAG,CAAC,CAAC,WAAW,CAAC;YAClC,IAAI,OAAO,WAAW,KAAK,QAAQ,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,WAAW,CAAC,IAAI,WAAW,GAAG,CAAC,IAAI,WAAW,GAAG,GAAG,EAAE,CAAC;gBAC9G,OAAO,EAAE,EAAE,EAAE,KAAc,EAAE,KAAK,EAAE,kDAAkD,EAAE,CAAC;YAC3F,CAAC;YACD,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,EAAE,GAAG,EAAE,sBAAsB,EAAE,MAAM,EAAE,CAAC,WAAW,EAAE,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,EAAE,CAAC,CAAC;YAC1F,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAE,wBAAwB,EAAE,CAAC,CAAC;YAChF,KAAK,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,oBAAoB,WAAW,WAAW,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;YACtE,OAAO,EAAE,EAAE,EAAE,IAAa,EAAE,WAAW,EAAE,CAAC;QAC5C,CAAC,CAAC;KACH,CAAC;AACJ,CAAC,CAAC"}
|
package/dist/step-files.js
DELETED
|
@@ -1,200 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* WHAT AN AGENT STEP CHANGED, read from the tree and not from what the agent said.
|
|
3
|
-
*
|
|
4
|
-
* A step with tools declares where it may write (`mayWrite`), and the definer hashes the project's tree before and after
|
|
5
|
-
* it. Other sessions edit the same checkout, so a change outside those paths is refused when the agent's own tool calls name
|
|
6
|
-
* the file, and recorded as not attributable when they do not: the record says which, and never guesses. (The first
|
|
7
|
-
* project's Fix browser stop agents ran with no transcript kept, so what they edited was stored nowhere: 2026-11-04.)
|
|
8
|
-
*/
|
|
9
|
-
import { createHash } from 'node:crypto';
|
|
10
|
-
import fs from 'node:fs';
|
|
11
|
-
import path from 'node:path';
|
|
12
|
-
const SKIPPED_NAMES = new Set(['node_modules', '.next', '.git', '.DS_Store']);
|
|
13
|
-
/** Files read at once: read one after another on the runner's thread, the walk held it up to 6.5 s (2026-11-04). */
|
|
14
|
-
const READS_AT_ONCE = 64;
|
|
15
|
-
/** What changed between two readings of the tree, and which of it a step may have written. Pure. */
|
|
16
|
-
export const filesChanged = (before, after, mayWrite, toolInputs) => {
|
|
17
|
-
const changed = [...new Set([...before.keys(), ...after.keys()])].filter((f) => before.get(f) !== after.get(f)).sort();
|
|
18
|
-
const outside = changed.filter((f) => !mayWrite.some((p) => f === p || f.startsWith(`${p}/`)));
|
|
19
|
-
const named = (f) => toolInputs.some((input) => input.includes(path.basename(f)));
|
|
20
|
-
return { changed, refused: outside.filter(named), notAttributable: outside.filter((f) => !named(f)), attributed: changed.filter(named) };
|
|
21
|
-
};
|
|
22
|
-
const AFTER = '.after';
|
|
23
|
-
const MANIFEST = 'hashes.json';
|
|
24
|
-
const SNAPSHOT_KEPT_MS = 86_400_000;
|
|
25
|
-
const blobOf = (dir, hash) => path.join(path.dirname(dir), 'blobs', hash.slice(0, 2), hash);
|
|
26
|
-
/** A step's snapshots of the project's tree, and taking back what it changed. */
|
|
27
|
-
export const makeStepFiles = (options) => {
|
|
28
|
-
const root = options.tree.root;
|
|
29
|
-
const snapshots = options.tree.snapshots;
|
|
30
|
-
const treeHashes = async () => {
|
|
31
|
-
const files = [];
|
|
32
|
-
const walk = async (dir) => {
|
|
33
|
-
for (const entry of await fs.promises.readdir(path.join(root, dir), { withFileTypes: true })) {
|
|
34
|
-
const rel = dir === '' ? entry.name : `${dir}/${entry.name}`;
|
|
35
|
-
if (SKIPPED_NAMES.has(entry.name) || options.tree.notTree.includes(rel))
|
|
36
|
-
continue;
|
|
37
|
-
if (entry.isDirectory())
|
|
38
|
-
await walk(rel);
|
|
39
|
-
else if (entry.isFile())
|
|
40
|
-
files.push(rel);
|
|
41
|
-
}
|
|
42
|
-
};
|
|
43
|
-
await walk('');
|
|
44
|
-
const hashes = new Map();
|
|
45
|
-
let next = 0;
|
|
46
|
-
const reader = async () => {
|
|
47
|
-
while (next < files.length) {
|
|
48
|
-
const rel = files[next++];
|
|
49
|
-
// Others edit this checkout: a file gone since the walk is simply not there.
|
|
50
|
-
const content = await fs.promises.readFile(path.join(root, rel)).catch(() => null);
|
|
51
|
-
if (content !== null)
|
|
52
|
-
hashes.set(rel, createHash('sha1').update(content).digest('hex'));
|
|
53
|
-
}
|
|
54
|
-
};
|
|
55
|
-
await Promise.all(Array.from({ length: READS_AT_ONCE }, reader));
|
|
56
|
-
return hashes;
|
|
57
|
-
};
|
|
58
|
-
/**
|
|
59
|
-
* Where a step's record of the tree goes: its file hashes, and `.after` for what it changed. A file's content is kept
|
|
60
|
-
* once, by its hash, in `blobs` beside the steps, so a step stores only what no earlier step has. Copying the whole tree
|
|
61
|
-
* per step wrote about 39,000 files in 5 minutes (2026-11-04).
|
|
62
|
-
*/
|
|
63
|
-
const snapshotOf = (stepRun) => path.join(snapshots, String(stepRun));
|
|
64
|
-
/**
|
|
65
|
-
* One snapshot at a time in this process: a blob dropped as unused while another step's record was being written could be
|
|
66
|
-
* one that record names, and an undo with its blob gone deletes the file it should restore.
|
|
67
|
-
*/
|
|
68
|
-
let snapshotting = Promise.resolve();
|
|
69
|
-
/**
|
|
70
|
-
* BLOBS NO STEP RECORD NAMES ARE DROPPED: a record a day old goes, and nothing else reads a blob, so one no remaining
|
|
71
|
-
* `hashes.json` names can never be restored from. Before this the blobs were never dropped (984 MB on 2026-11-11).
|
|
72
|
-
*/
|
|
73
|
-
const dropUnusedBlobs = async () => {
|
|
74
|
-
const named = new Set();
|
|
75
|
-
for (const record of await fs.promises.readdir(snapshots)) {
|
|
76
|
-
if (record === 'blobs')
|
|
77
|
-
continue;
|
|
78
|
-
const manifest = await fs.promises.readFile(path.join(snapshots, record, MANIFEST), 'utf8').catch(() => null);
|
|
79
|
-
if (manifest === null)
|
|
80
|
-
continue;
|
|
81
|
-
let hashes;
|
|
82
|
-
try {
|
|
83
|
-
hashes = JSON.parse(manifest);
|
|
84
|
-
}
|
|
85
|
-
catch {
|
|
86
|
-
// A record whose names cannot be read may name any blob: none is dropped.
|
|
87
|
-
return { dropped: 0, bytes: 0 };
|
|
88
|
-
}
|
|
89
|
-
for (const hash of Object.values(hashes))
|
|
90
|
-
named.add(hash);
|
|
91
|
-
}
|
|
92
|
-
const blobs = path.join(snapshots, 'blobs');
|
|
93
|
-
let dropped = 0, bytes = 0;
|
|
94
|
-
for (const prefix of await fs.promises.readdir(blobs).catch(() => [])) {
|
|
95
|
-
for (const hash of await fs.promises.readdir(path.join(blobs, prefix))) {
|
|
96
|
-
if (named.has(hash))
|
|
97
|
-
continue;
|
|
98
|
-
const at = path.join(blobs, prefix, hash);
|
|
99
|
-
bytes += (await fs.promises.stat(at)).blocks * 512;
|
|
100
|
-
await fs.promises.rm(at, { force: true });
|
|
101
|
-
dropped += 1;
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
return { dropped, bytes };
|
|
105
|
-
};
|
|
106
|
-
const snapshotTreeNow = async (dir, hashes) => {
|
|
107
|
-
if (fs.existsSync(snapshots) && dir.startsWith(snapshots)) {
|
|
108
|
-
for (const old of await fs.promises.readdir(snapshots)) {
|
|
109
|
-
if (old === 'blobs')
|
|
110
|
-
continue;
|
|
111
|
-
const at = path.join(snapshots, old);
|
|
112
|
-
if (Date.now() - (await fs.promises.stat(at)).mtimeMs > SNAPSHOT_KEPT_MS)
|
|
113
|
-
await fs.promises.rm(at, { recursive: true, force: true });
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
await fs.promises.mkdir(dir, { recursive: true });
|
|
117
|
-
await fs.promises.writeFile(path.join(dir, MANIFEST), JSON.stringify(Object.fromEntries(hashes)));
|
|
118
|
-
if (dir.startsWith(snapshots)) {
|
|
119
|
-
const unused = await dropUnusedBlobs();
|
|
120
|
-
if (unused.dropped > 0)
|
|
121
|
-
console.log(`[step files] dropped ${unused.dropped} blobs no step record names, ${Math.round(unused.bytes / 1e6)} MB`);
|
|
122
|
-
}
|
|
123
|
-
const missing = [...hashes].filter(([, hash]) => !fs.existsSync(blobOf(dir, hash)));
|
|
124
|
-
let next = 0;
|
|
125
|
-
await Promise.all(Array.from({ length: READS_AT_ONCE }, async () => {
|
|
126
|
-
while (next < missing.length) {
|
|
127
|
-
const [rel, hash] = missing[next++];
|
|
128
|
-
const to = blobOf(dir, hash);
|
|
129
|
-
await fs.promises.mkdir(path.dirname(to), { recursive: true });
|
|
130
|
-
await fs.promises.copyFile(path.join(root, rel), to, fs.constants.COPYFILE_FICLONE).catch(() => undefined);
|
|
131
|
-
}
|
|
132
|
-
}));
|
|
133
|
-
};
|
|
134
|
-
/** The tree as a step starts: its hashes, and the content of any file not stored yet. Older step records are dropped. */
|
|
135
|
-
const snapshotTree = (dir, hashes) => {
|
|
136
|
-
const run = snapshotting.then(() => snapshotTreeNow(dir, hashes));
|
|
137
|
-
snapshotting = run.catch(() => undefined);
|
|
138
|
-
return run;
|
|
139
|
-
};
|
|
140
|
-
/** What the step left in the files it changed, so a later undo can tell its change from anyone's after it. */
|
|
141
|
-
const keepWhatItChanged = (dir, files) => {
|
|
142
|
-
for (const rel of files) {
|
|
143
|
-
if (!fs.existsSync(path.join(root, rel)))
|
|
144
|
-
continue;
|
|
145
|
-
const to = path.join(dir, AFTER, rel);
|
|
146
|
-
fs.mkdirSync(path.dirname(to), { recursive: true });
|
|
147
|
-
fs.copyFileSync(path.join(root, rel), to);
|
|
148
|
-
}
|
|
149
|
-
};
|
|
150
|
-
/**
|
|
151
|
-
* TAKES BACK WHAT A REFUSED STEP CHANGED, from the copy of the tree it started with. Others edit this checkout, so a file
|
|
152
|
-
* changed again since the step ended has only the step's change taken out of it (`diff3`), and one where the two overlap is
|
|
153
|
-
* left and named rather than overwritten. A change another session made to the same file while the step ran cannot be told
|
|
154
|
-
* from the step's, and goes with it: the record names the file either way.
|
|
155
|
-
*/
|
|
156
|
-
const undoFiles = (dir, files) => {
|
|
157
|
-
const restored = [];
|
|
158
|
-
const conflicts = [];
|
|
159
|
-
const read = (at) => (fs.existsSync(at) ? fs.readFileSync(at) : null);
|
|
160
|
-
const same = (a, b) => (a === null || b === null ? a === b : a.equals(b));
|
|
161
|
-
// A record from before hashes were kept has nothing to restore from: named, never guessed.
|
|
162
|
-
const manifest = read(path.join(dir, MANIFEST));
|
|
163
|
-
if (manifest === null)
|
|
164
|
-
return { restored, conflicts: [...files] };
|
|
165
|
-
const hashes = JSON.parse(manifest.toString());
|
|
166
|
-
for (const rel of files) {
|
|
167
|
-
const here = path.join(root, rel);
|
|
168
|
-
const hash = hashes[rel];
|
|
169
|
-
const beforeAt = hash === undefined ? path.join(dir, '.none') : blobOf(dir, hash);
|
|
170
|
-
const afterAt = path.join(dir, AFTER, rel);
|
|
171
|
-
const [now, before, after] = [read(here), read(beforeAt), read(afterAt)];
|
|
172
|
-
if (same(now, before))
|
|
173
|
-
continue;
|
|
174
|
-
if (same(now, after)) {
|
|
175
|
-
if (before === null)
|
|
176
|
-
fs.rmSync(here, { force: true });
|
|
177
|
-
else {
|
|
178
|
-
fs.mkdirSync(path.dirname(here), { recursive: true });
|
|
179
|
-
fs.writeFileSync(here, before);
|
|
180
|
-
}
|
|
181
|
-
restored.push(rel);
|
|
182
|
-
continue;
|
|
183
|
-
}
|
|
184
|
-
if (now === null || before === null || after === null) {
|
|
185
|
-
conflicts.push(rel);
|
|
186
|
-
continue;
|
|
187
|
-
}
|
|
188
|
-
const merged = options.runLightNow(['diff3', '-m', here, afterAt, beforeAt]);
|
|
189
|
-
if (merged.code === 0) {
|
|
190
|
-
fs.writeFileSync(here, merged.stdoutBytes);
|
|
191
|
-
restored.push(rel);
|
|
192
|
-
}
|
|
193
|
-
else
|
|
194
|
-
conflicts.push(rel);
|
|
195
|
-
}
|
|
196
|
-
return { restored, conflicts };
|
|
197
|
-
};
|
|
198
|
-
return { treeHashes, snapshotOf, snapshotTree, dropUnusedBlobs, keepWhatItChanged, undoFiles };
|
|
199
|
-
};
|
|
200
|
-
//# sourceMappingURL=step-files.js.map
|
package/dist/step-files.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"step-files.js","sourceRoot":"","sources":["../../../src/step-files.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAG7B,MAAM,aAAa,GAAG,IAAI,GAAG,CAAC,CAAC,cAAc,EAAE,OAAO,EAAE,MAAM,EAAE,WAAW,CAAC,CAAC,CAAC;AAI9E,oHAAoH;AACpH,MAAM,aAAa,GAAG,EAAE,CAAC;AAmBzB,oGAAoG;AACpG,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,MAAkB,EAAE,KAAiB,EAAE,QAA+B,EAAE,UAAiC,EAAgB,EAAE;IACtJ,MAAM,OAAO,GAAG,CAAC,GAAG,IAAI,GAAG,CAAC,CAAC,GAAG,MAAM,CAAC,IAAI,EAAE,EAAE,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,KAAK,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;IACvH,MAAM,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,UAAU,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;IAC/F,MAAM,KAAK,GAAG,CAAC,CAAS,EAA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AAC,SAAS;YAAC,CAAC;YACzF,MAAM,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAC,CAAC;YAC7E,IAAI,MAAM,CAAC,IAAI,KAAK,CAAC,EAAE,CAAC;gBAAC,EAAE,CAAC,aAAa,CAAC,IAAI,EAAE,MAAM,CAAC,WAAW,CAAC,CAAC;gBAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;YAAC,CAAC;;gBAAM,SAAS,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QACtH,CAAC;QACD,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,CAAC;IACjC,CAAC,CAAC;IAEF,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,YAAY,EAAE,eAAe,EAAE,iBAAiB,EAAE,SAAS,EAAE,CAAC;AACjG,CAAC,CAAC"}
|
package/dist/step-meter.js
DELETED
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
/** What makes a process a compile on its step's record: its label, in one place. */
|
|
2
|
-
export const isCompile = (usage) => usage.label.startsWith('compile');
|
|
3
|
-
const MB = 1024 * 1024;
|
|
4
|
-
export class StepMeter {
|
|
5
|
-
record;
|
|
6
|
-
agent;
|
|
7
|
-
writes;
|
|
8
|
-
parent;
|
|
9
|
-
childCpuSeconds = 0;
|
|
10
|
-
ownCpuSeconds = 0;
|
|
11
|
-
peakBytes = 0;
|
|
12
|
-
compiles = 0;
|
|
13
|
-
filesWritten = 0;
|
|
14
|
-
/** Items recorded under it, and how many are going now. */
|
|
15
|
-
items = 0;
|
|
16
|
-
itemsOpen = 0;
|
|
17
|
-
constructor(record,
|
|
18
|
-
/** An agent step's own work is in its agent's process, and only its declared paths are its files. */
|
|
19
|
-
agent, writes, parent) {
|
|
20
|
-
this.record = record;
|
|
21
|
-
this.agent = agent;
|
|
22
|
-
this.writes = writes;
|
|
23
|
-
this.parent = parent;
|
|
24
|
-
}
|
|
25
|
-
add = (u) => {
|
|
26
|
-
this.childCpuSeconds += u.cpuSeconds;
|
|
27
|
-
this.peakBytes = Math.max(this.peakBytes, u.peakBytes);
|
|
28
|
-
if (isCompile(u))
|
|
29
|
-
this.compiles += 1;
|
|
30
|
-
};
|
|
31
|
-
used() {
|
|
32
|
-
return {
|
|
33
|
-
childCpuSeconds: this.childCpuSeconds,
|
|
34
|
-
ownCpuSeconds: this.ownCpuSeconds,
|
|
35
|
-
peakMemoryMb: Math.round((this.peakBytes / MB) * 10) / 10,
|
|
36
|
-
filesWritten: Math.round(this.filesWritten),
|
|
37
|
-
compiles: this.compiles,
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
const open = new Set();
|
|
42
|
-
let cpuAt = process.cpuUsage();
|
|
43
|
-
/** The meters taking a share now: a step with an item going has it in that item's meter. */
|
|
44
|
-
const sharing = () => [...open].filter((m) => !m.agent && m.itemsOpen === 0);
|
|
45
|
-
/** Shares out the runner's CPU since the last look. */
|
|
46
|
-
const settle = () => {
|
|
47
|
-
const since = process.cpuUsage(cpuAt);
|
|
48
|
-
cpuAt = process.cpuUsage();
|
|
49
|
-
const rss = process.memoryUsage().rss;
|
|
50
|
-
const those = sharing();
|
|
51
|
-
for (const m of those) {
|
|
52
|
-
m.ownCpuSeconds += (since.user + since.system) / 1e6 / those.length;
|
|
53
|
-
m.peakBytes = Math.max(m.peakBytes, rss);
|
|
54
|
-
}
|
|
55
|
-
};
|
|
56
|
-
export const meterOpened = (meter) => {
|
|
57
|
-
settle();
|
|
58
|
-
open.add(meter);
|
|
59
|
-
if (meter.parent !== null) {
|
|
60
|
-
meter.parent.items += 1;
|
|
61
|
-
meter.parent.itemsOpen += 1;
|
|
62
|
-
}
|
|
63
|
-
};
|
|
64
|
-
/** Closes a meter: an item's figures go into its step's as well. */
|
|
65
|
-
export const meterClosed = (meter) => {
|
|
66
|
-
settle();
|
|
67
|
-
open.delete(meter);
|
|
68
|
-
const parent = meter.parent;
|
|
69
|
-
if (parent === null)
|
|
70
|
-
return;
|
|
71
|
-
parent.itemsOpen -= 1;
|
|
72
|
-
parent.childCpuSeconds += meter.childCpuSeconds;
|
|
73
|
-
parent.ownCpuSeconds += meter.ownCpuSeconds;
|
|
74
|
-
parent.peakBytes = Math.max(parent.peakBytes, meter.peakBytes);
|
|
75
|
-
parent.compiles += meter.compiles;
|
|
76
|
-
parent.filesWritten += meter.filesWritten;
|
|
77
|
-
};
|
|
78
|
-
/** Writes no open step declared, by folder (the path's first two parts), until they are stored (`takeUndeclaredWrites`). */
|
|
79
|
-
const undeclared = new Map();
|
|
80
|
-
/** A file changed: `relative` is its path from the package's root. Counted to the open steps that declared its path, if any. */
|
|
81
|
-
export const fileWritten = (relative) => {
|
|
82
|
-
const declared = [...open].filter((m) => m.writes.some((w) => relative === w || relative.startsWith(w.endsWith('/') ? w : `${w}/`)));
|
|
83
|
-
if (declared.length > 0) {
|
|
84
|
-
for (const m of declared)
|
|
85
|
-
m.filesWritten += 1 / declared.length;
|
|
86
|
-
return;
|
|
87
|
-
}
|
|
88
|
-
const folder = relative.split('/').slice(0, 2).join('/');
|
|
89
|
-
undeclared.set(folder, (undeclared.get(folder) ?? 0) + 1);
|
|
90
|
-
};
|
|
91
|
-
/** The undeclared writes since the last call, by folder. */
|
|
92
|
-
export const takeUndeclaredWrites = () => {
|
|
93
|
-
const taken = new Map(undeclared);
|
|
94
|
-
undeclared.clear();
|
|
95
|
-
return taken;
|
|
96
|
-
};
|
|
97
|
-
//# sourceMappingURL=step-meter.js.map
|
package/dist/step-meter.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"step-meter.js","sourceRoot":"","sources":["../../../src/step-meter.ts"],"names":[],"mappings":"AAmBA,oFAAoF;AACpF,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,KAAmB,EAAW,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,UAAU,CAAC,SAAS,CAAC,CA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MAAM,GAAG,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACzD,UAAU,CAAC,GAAG,CAAC,MAAM,EAAE,CAAC,UAAU,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;AAC5D,CAAC,CAAC;AAEF,4DAA4D;AAC5D,MAAM,CAAC,MAAM,oBAAoB,GAAG,GAAgC,EAAE;IACpE,MAAM,KAAK,GAAG,IAAI,GAAG,CAAC,UAAU,CAAC,CAAC;IAClC,UAAU,CAAC,KAAK,EAAE,CAAC;IACnB,OAAO,KAAK,CAAC;AACf,CAAC,CAAC"}
|
package/dist/step-times.js
DELETED
|
@@ -1,114 +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
|
-
/**
|
|
17
|
-
* 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
|
|
18
|
-
* none of its calls is open. `unfinished` is the runs still going. Pure, so it is tested alone.
|
|
19
|
-
*/
|
|
20
|
-
export const taskTimes = (input) => {
|
|
21
|
-
const newest = new Map();
|
|
22
|
-
for (const r of input.records)
|
|
23
|
-
if ((newest.get(r.run)?.id ?? -1) < r.id)
|
|
24
|
-
newest.set(r.run, r);
|
|
25
|
-
const partsOf = new Map();
|
|
26
|
-
for (const p of input.parts)
|
|
27
|
-
partsOf.set(p.stepRun, [...(partsOf.get(p.stepRun) ?? []), p]);
|
|
28
|
-
const groups = new Map();
|
|
29
|
-
const add = (r, task, started, ended) => {
|
|
30
|
-
const key = `${r.run}\u0000${r.step}\u0000${task.toLowerCase()}`;
|
|
31
|
-
const g = groups.get(key) ?? { run: r.run, step: r.step, seconds: 0, open: false };
|
|
32
|
-
if (ended === null)
|
|
33
|
-
g.open = true;
|
|
34
|
-
else
|
|
35
|
-
g.seconds += Math.max(0, ended - started);
|
|
36
|
-
groups.set(key, g);
|
|
37
|
-
};
|
|
38
|
-
for (const r of input.records) {
|
|
39
|
-
const parts = r.scope === 'functions' ? partsOf.get(r.id) : undefined;
|
|
40
|
-
if (parts !== undefined && parts.length > 0)
|
|
41
|
-
for (const p of parts)
|
|
42
|
-
add(r, p.subject, p.started, p.ended);
|
|
43
|
-
else
|
|
44
|
-
add(r, r.subject ?? r.run, r.started, r.ended);
|
|
45
|
-
}
|
|
46
|
-
const values = new Map();
|
|
47
|
-
for (const g of groups.values()) {
|
|
48
|
-
const left = !input.unfinished.has(g.run) || newest.get(g.run)?.step !== g.step;
|
|
49
|
-
if (g.open || !left)
|
|
50
|
-
continue;
|
|
51
|
-
values.set(g.step, [...(values.get(g.step) ?? []), Math.round(g.seconds * 10) / 10]);
|
|
52
|
-
}
|
|
53
|
-
for (const v of values.values())
|
|
54
|
-
v.sort((a, b) => a - b);
|
|
55
|
-
return values;
|
|
56
|
-
};
|
|
57
|
-
export const makeStepTimes = (deps) => {
|
|
58
|
-
const held = new Map();
|
|
59
|
-
const previous = new Map();
|
|
60
|
-
const hold = (r) => Effect.map(deps.records.versionRecords(r), (read) => ({
|
|
61
|
-
version: r.version,
|
|
62
|
-
records: new Map(read.records.map((x) => [x.id, x])),
|
|
63
|
-
parts: groupParts(read.parts),
|
|
64
|
-
newestId: read.newestId,
|
|
65
|
-
}));
|
|
66
|
-
/** Reads the records written since, and those still open again, into what is held. */
|
|
67
|
-
const refresh = (workflow, h) => Effect.gen(function* () {
|
|
68
|
-
const open = [...h.records.values()].filter((x) => x.ended === null).map((x) => x.id);
|
|
69
|
-
const read = yield* deps.records.recordsSince({ after: h.newestId, again: open });
|
|
70
|
-
for (const x of read.records) {
|
|
71
|
-
h.newestId = Math.max(h.newestId, x.id);
|
|
72
|
-
if (x.workflow === workflow && x.version === h.version)
|
|
73
|
-
h.records.set(x.id, x);
|
|
74
|
-
}
|
|
75
|
-
for (const [id, parts] of groupParts(read.parts))
|
|
76
|
-
h.parts.set(id, parts);
|
|
77
|
-
});
|
|
78
|
-
const valuesOf = (workflow, h, unfinished) => {
|
|
79
|
-
const byStep = taskTimes({ records: [...h.records.values()], parts: [...h.parts.values()].flat(), unfinished });
|
|
80
|
-
const declared = deps.stepsOf(workflow);
|
|
81
|
-
return [...declared, ...[...byStep.keys()].filter((s) => !declared.includes(s))].map((step) => ({ step, values: byStep.get(step) ?? [] }));
|
|
82
|
-
};
|
|
83
|
-
/** A workflow's step times now: its current version's values, and the previous version's where the current has none. */
|
|
84
|
-
const timesOf = (workflow) => Effect.gen(function* () {
|
|
85
|
-
const current = deps.versionOf(workflow);
|
|
86
|
-
const known = held.get(workflow);
|
|
87
|
-
const h = known !== undefined && known.version === current.version ? known : yield* hold({ workflow, version: current.version });
|
|
88
|
-
if (h !== known)
|
|
89
|
-
held.set(workflow, h);
|
|
90
|
-
else
|
|
91
|
-
yield* refresh(workflow, h);
|
|
92
|
-
const unfinished = new Set((yield* deps.engine.unfinishedRuns()).map((u) => u.run));
|
|
93
|
-
const steps = valuesOf(workflow, h, unfinished);
|
|
94
|
-
if (steps.some((s) => s.values.length > 0))
|
|
95
|
-
return { workflow, version: current.version, since: current.since, steps, previous: null };
|
|
96
|
-
if (!previous.has(workflow)) {
|
|
97
|
-
const before = yield* deps.records.previousVersion({ workflow, version: current.version });
|
|
98
|
-
previous.set(workflow, before === null ? null : { ...before, held: yield* hold({ workflow, version: before.version }) });
|
|
99
|
-
}
|
|
100
|
-
const before = previous.get(workflow) ?? null;
|
|
101
|
-
return {
|
|
102
|
-
workflow, version: current.version, since: current.since, steps,
|
|
103
|
-
previous: before === null ? null : { version: before.version, at: before.at, steps: valuesOf(workflow, before.held, unfinished) },
|
|
104
|
-
};
|
|
105
|
-
});
|
|
106
|
-
return { timesOf };
|
|
107
|
-
};
|
|
108
|
-
const groupParts = (parts) => {
|
|
109
|
-
const out = new Map();
|
|
110
|
-
for (const p of parts)
|
|
111
|
-
out.set(p.stepRun, [...(out.get(p.stepRun) ?? []), p]);
|
|
112
|
-
return out;
|
|
113
|
-
};
|
|
114
|
-
//# sourceMappingURL=step-times.js.map
|
package/dist/step-times.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"step-times.js","sourceRoot":"","sources":["../../../src/step-times.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AA2BhC;;;GAGG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,KAIzB,EAA8C,EAAE;IAC/C,MAAM,MAAM,GAAG,IAAI,GAAG,EAAuB,CAAC;IAC9C,KAAK,MAAM,CAAC,IAAI,KAAK,CAAC,OAAO;QAAE,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,EAAE,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,C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|
package/dist/step-usage.js
DELETED
|
@@ -1,19 +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 { isCompile } from './step-meter';
|
|
8
|
-
export const makeStepUsage = (options) => {
|
|
9
|
-
const startedFor = Number(process.env[options.variable]);
|
|
10
|
-
const processSink = Number.isInteger(startedFor) && startedFor > 0
|
|
11
|
-
? { record: startedFor, add: (u) => { if (isCompile(u))
|
|
12
|
-
options.addStepCompile(startedFor); } }
|
|
13
|
-
: null;
|
|
14
|
-
const CurrentStepUsage = Context.Reference('CurrentStepUsage', { defaultValue: () => processSink });
|
|
15
|
-
/** `go` given where its processes' usage goes; for code that starts one from a Promise. */
|
|
16
|
-
const withStepUsage = (go) => Effect.flatMap(CurrentStepUsage, go);
|
|
17
|
-
return { CurrentStepUsage, withStepUsage };
|
|
18
|
-
};
|
|
19
|
-
//# sourceMappingURL=step-usage.js.map
|
package/dist/step-usage.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"step-usage.js","sourceRoot":"","sources":["../../../src/step-usage.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEzC,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzC,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,OAAyF,EAAE,EAAE;IACzH,MAAM,UAAU,GAAG,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC;IACzD,MAAM,WAAW,GAAqB,MAAM,CAAC,SAAS,CAAC,UAAU,CAAC,IAAI,UAAU,GAAG,CAAC;QAClF,CAAC,CAAC,EAAE,MAAM,EAAE,UAAU,EAAE,GAAG,EAAE,CAAC,CAAC,EAAE,EAAE,GAAG,IAAI,SAAS,CAAC,CAAC,CAAC;gBAAE,OAAO,CAAC,cAAc,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,EAAE;QAC/F,CAAC,CAAC,IAAI,CAAC;IAET,MAAM,gBAAgB,GAAG,OAAO,CAAC,SAAS,CAAmB,kBAAkB,EAAE,EAAE,YAAY,EAAE,GAAG,EAAE,CAAC,WAAW,EAAE,CAAC,CAAC;IAEtH,2FAA2F;IAC3F,MAAM,aAAa,GAAG,CAAU,EAAuD,EAA0B,EAAE,CACjH,MAAM,CAAC,OAAO,CAAC,gBAAgB,EAAE,EAAE,CAAC,CAAC;IAEvC,OAAO,EAAE,gBAAgB,EAAE,aAAa,EAAE,CAAC;AAC7C,CAAC,CAAC"}
|