harnery 0.44.0 → 0.45.1
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/dist/commands/workflow.d.ts.map +1 -1
- package/dist/commands/workflow.js +44 -0
- package/dist/core/agents/coord-client.d.ts.map +1 -1
- package/dist/core/agents/coord-client.js +18 -0
- package/dist/core/agents/live-authority-v3.d.ts +0 -1
- package/dist/core/agents/live-authority-v3.d.ts.map +1 -1
- package/dist/core/agents/live-authority-v3.js +0 -11
- package/dist/core/agents/live-lifecycle-v3.d.ts +2 -4
- package/dist/core/agents/live-lifecycle-v3.d.ts.map +1 -1
- package/dist/core/agents/live-lifecycle-v3.js +7 -28
- package/dist/core/agents/state/heartbeat-writer.d.ts.map +1 -1
- package/dist/core/agents/state/heartbeat-writer.js +14 -25
- package/dist/core/agents/state/live-coordination-writer.d.ts.map +1 -1
- package/dist/core/agents/state/live-coordination-writer.js +0 -5
- package/dist/core/agents/state/pidmap.d.ts.map +1 -1
- package/dist/core/agents/state/pidmap.js +0 -5
- package/dist/core/agents/state/proc-start.d.ts +5 -6
- package/dist/core/agents/state/proc-start.d.ts.map +1 -1
- package/dist/core/agents/state/proc-start.js +13 -9
- package/dist/core/agents/state/process-handle.d.ts +26 -0
- package/dist/core/agents/state/process-handle.d.ts.map +1 -0
- package/dist/core/agents/state/process-handle.js +121 -0
- package/dist/core/agents/state/stale-sweep.d.ts.map +1 -1
- package/dist/core/agents/state/stale-sweep.js +70 -180
- package/dist/core/artifacts/activity.d.ts +4 -1
- package/dist/core/artifacts/activity.d.ts.map +1 -1
- package/dist/core/artifacts/activity.js +8 -2
- package/dist/core/artifacts/index.d.ts.map +1 -1
- package/dist/core/artifacts/index.js +38 -12
- package/dist/core/events/v3/authority-outbox.d.ts.map +1 -1
- package/dist/core/events/v3/authority-outbox.js +0 -29
- package/dist/core/events/v3/producers/coordination-recorder.d.ts +0 -1
- package/dist/core/events/v3/producers/coordination-recorder.d.ts.map +1 -1
- package/dist/core/events/v3/producers/coordination-recorder.js +0 -7
- package/dist/core/events/v3/producers/recorder.d.ts.map +1 -1
- package/dist/core/events/v3/producers/recorder.js +64 -77
- package/dist/core/hooks/cli.js +78 -48
- package/dist/core/resources/service.d.ts +2 -16
- package/dist/core/resources/service.d.ts.map +1 -1
- package/dist/core/resources/service.js +1 -78
- package/dist/core/semantic/service.d.ts.map +1 -1
- package/dist/core/semantic/service.js +2 -9
- package/dist/core/servers/index.d.ts +4 -0
- package/dist/core/servers/index.d.ts.map +1 -1
- package/dist/core/servers/index.js +21 -3
- package/dist/core/storage/durable-history.js +56 -22
- package/dist/core/storage/segments.d.ts.map +1 -1
- package/dist/core/storage/segments.js +73 -17
- package/dist/core/supervisor/service.d.ts +2 -4
- package/dist/core/supervisor/service.d.ts.map +1 -1
- package/dist/core/work/state.js +7 -7
- package/dist/core/workflow/engine.d.ts.map +1 -1
- package/dist/core/workflow/engine.js +21 -65
- package/dist/core/workflow/index.d.ts +4 -2
- package/dist/core/workflow/index.d.ts.map +1 -1
- package/dist/core/workflow/index.js +2 -1
- package/dist/core/workflow/live-session-v3.d.ts +0 -6
- package/dist/core/workflow/live-session-v3.d.ts.map +1 -1
- package/dist/core/workflow/live-session-v3.js +5 -126
- package/dist/core/workflow/proof.d.ts +4 -4
- package/dist/core/workflow/proof.d.ts.map +1 -1
- package/dist/core/workflow/proof.js +4 -12
- package/dist/core/workflow/recovery-audit.d.ts +30 -0
- package/dist/core/workflow/recovery-audit.d.ts.map +1 -0
- package/dist/core/workflow/recovery-audit.js +116 -0
- package/dist/core/workflow/run-state.d.ts +19 -2
- package/dist/core/workflow/run-state.d.ts.map +1 -1
- package/dist/core/workflow/run-state.js +113 -8
- package/dist/core/workflow/spawn-claude.d.ts.map +1 -1
- package/dist/core/workflow/spawn-claude.js +0 -19
- package/dist/core/workflow/spawn-codex.d.ts.map +1 -1
- package/dist/core/workflow/spawn-codex.js +0 -13
- package/dist/core/workflow/spawn-cursor.d.ts.map +1 -1
- package/dist/core/workflow/spawn-cursor.js +0 -19
- package/dist/core/workflow/spawn-opencode.d.ts.map +1 -1
- package/dist/core/workflow/spawn-opencode.js +0 -14
- package/dist/core/workflow/types.d.ts +11 -54
- package/dist/core/workflow/types.d.ts.map +1 -1
- package/dist/core/workflow/workspaces/local-git.d.ts.map +1 -1
- package/dist/core/workflow/workspaces/local-git.js +70 -14
- package/dist/core/workflow/workspaces/reclaim.d.ts +6 -1
- package/dist/core/workflow/workspaces/reclaim.d.ts.map +1 -1
- package/dist/core/workflow/workspaces/recovery.d.ts +2 -0
- package/dist/core/workflow/workspaces/recovery.d.ts.map +1 -1
- package/dist/core/workflow/workspaces/recovery.js +24 -0
- package/dist/lib/identities/assume.d.ts.map +1 -1
- package/dist/lib/identities/assume.js +0 -4
- package/package.json +1 -1
- package/src/commands/workflow.ts +59 -0
- package/src/core/agents/coord-client.ts +20 -0
- package/src/core/agents/live-authority-v3.ts +0 -17
- package/src/core/agents/live-lifecycle-v3.ts +14 -52
- package/src/core/agents/state/heartbeat-writer.ts +12 -29
- package/src/core/agents/state/live-coordination-writer.ts +0 -29
- package/src/core/agents/state/pidmap.ts +0 -13
- package/src/core/agents/state/proc-start.ts +14 -11
- package/src/core/agents/state/process-handle.ts +165 -0
- package/src/core/agents/state/stale-sweep.ts +82 -247
- package/src/core/artifacts/activity.ts +9 -2
- package/src/core/artifacts/index.ts +45 -12
- package/src/core/events/v3/authority-outbox.ts +0 -56
- package/src/core/events/v3/producers/coordination-recorder.ts +0 -15
- package/src/core/events/v3/producers/recorder.ts +68 -94
- package/src/core/hooks/cli.ts +85 -47
- package/src/core/resources/service.ts +3 -88
- package/src/core/semantic/service.ts +2 -8
- package/src/core/servers/index.ts +30 -3
- package/src/core/storage/durable-history.ts +52 -20
- package/src/core/storage/segments.ts +79 -17
- package/src/core/supervisor/service.ts +2 -3
- package/src/core/work/state.ts +7 -7
- package/src/core/workflow/engine.ts +21 -73
- package/src/core/workflow/index.ts +12 -1
- package/src/core/workflow/live-session-v3.ts +5 -146
- package/src/core/workflow/proof.ts +5 -21
- package/src/core/workflow/recovery-audit.ts +181 -0
- package/src/core/workflow/run-state.ts +137 -8
- package/src/core/workflow/spawn-claude.ts +0 -18
- package/src/core/workflow/spawn-codex.ts +0 -13
- package/src/core/workflow/spawn-cursor.ts +0 -18
- package/src/core/workflow/spawn-opencode.ts +0 -14
- package/src/core/workflow/types.ts +11 -41
- package/src/core/workflow/workspaces/local-git.ts +86 -15
- package/src/core/workflow/workspaces/reclaim.ts +4 -0
- package/src/core/workflow/workspaces/recovery.ts +23 -0
- package/src/lib/identities/assume.ts +0 -4
- package/dist/core/agents/state/unchanged-file.d.ts +0 -44
- package/dist/core/agents/state/unchanged-file.d.ts.map +0 -1
- package/dist/core/agents/state/unchanged-file.js +0 -390
- package/dist/core/events/v3/generation-custody.d.ts +0 -5
- package/dist/core/events/v3/generation-custody.d.ts.map +0 -1
- package/dist/core/events/v3/generation-custody.js +0 -50
- package/dist/core/workflow/failure-evidence.d.ts +0 -16
- package/dist/core/workflow/failure-evidence.d.ts.map +0 -1
- package/dist/core/workflow/failure-evidence.js +0 -114
- package/src/core/agents/state/unchanged-file.ts +0 -456
- package/src/core/events/v3/generation-custody.ts +0 -59
- package/src/core/workflow/failure-evidence.ts +0 -141
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { spawn } from "node:child_process";
|
|
2
1
|
import { randomUUID } from "node:crypto";
|
|
3
2
|
import { closeSync, existsSync, mkdirSync, openSync, readFileSync, rmSync, unlinkSync, writeFileSync, } from "node:fs";
|
|
4
|
-
import { hostname
|
|
3
|
+
import { hostname } from "node:os";
|
|
5
4
|
import { resolve } from "node:path";
|
|
6
5
|
import { processStartToken, signalIfSameGeneration, } from "../agents/state/proc-start.js";
|
|
7
6
|
import { resolveBinName } from "../config.js";
|
|
@@ -14,72 +13,6 @@ import { resourcePaths, writePrivateJsonAtomic } from "./storage.js";
|
|
|
14
13
|
export const RESOURCE_SERVICE_DEFAULT_INTERVAL_MS = 2_000;
|
|
15
14
|
const RESOURCE_SERVICE_MIN_INTERVAL_MS = 500;
|
|
16
15
|
const RESOURCE_SERVICE_MAX_INTERVAL_MS = 60_000;
|
|
17
|
-
export async function spawnResourceService(coordRootRaw, options = {}) {
|
|
18
|
-
const coordRoot = resolve(coordRootRaw);
|
|
19
|
-
const current = readResourceServiceStatus(coordRoot);
|
|
20
|
-
if (current.liveness === "unknown")
|
|
21
|
-
throw unknownResourceOwnerError();
|
|
22
|
-
if (current.liveness === "running") {
|
|
23
|
-
throw new Error(`resource observer is already running under pid ${current.record?.pid}`);
|
|
24
|
-
}
|
|
25
|
-
const intervalMs = normalizeInterval(options.intervalMs);
|
|
26
|
-
const paths = resourcePaths(coordRoot);
|
|
27
|
-
assertResourceLeaseAvailable(paths.lease);
|
|
28
|
-
mkdirSync(paths.root, { recursive: true, mode: stateDirMode() });
|
|
29
|
-
const harnBin = new URL("../../../bin/harn", import.meta.url).pathname;
|
|
30
|
-
if (!existsSync(harnBin))
|
|
31
|
-
throw new Error(`cannot find harn executable at ${harnBin}`);
|
|
32
|
-
let spawnError;
|
|
33
|
-
const child = spawn(harnBin, ["resources", "service", "daemon", "--root", coordRoot, "--interval-ms", String(intervalMs)], {
|
|
34
|
-
cwd: coordRoot,
|
|
35
|
-
detached: true,
|
|
36
|
-
stdio: ["ignore", "ignore", "ignore"],
|
|
37
|
-
env: {
|
|
38
|
-
...process.env,
|
|
39
|
-
HARNERY_COORD_ROOT_OVERRIDE: coordRoot,
|
|
40
|
-
HARNERY_OUTPUT_SESSION_TEE: "0",
|
|
41
|
-
},
|
|
42
|
-
});
|
|
43
|
-
child.once("error", (error) => {
|
|
44
|
-
spawnError = error;
|
|
45
|
-
});
|
|
46
|
-
child.unref();
|
|
47
|
-
const deadline = Date.now() + 5_000;
|
|
48
|
-
while (Date.now() < deadline) {
|
|
49
|
-
await delay(50);
|
|
50
|
-
if (spawnError)
|
|
51
|
-
throw spawnError;
|
|
52
|
-
const status = readResourceServiceStatus(coordRoot);
|
|
53
|
-
if (status.running && status.record?.pid === child.pid)
|
|
54
|
-
return status;
|
|
55
|
-
if (child.exitCode !== null)
|
|
56
|
-
break;
|
|
57
|
-
}
|
|
58
|
-
throw new Error(`resource observer failed to start; inspect ${paths.service}`);
|
|
59
|
-
}
|
|
60
|
-
export async function ensureResourceServiceRunning(coordRoot) {
|
|
61
|
-
const status = readResourceServiceStatus(coordRoot);
|
|
62
|
-
if (status.running)
|
|
63
|
-
return { state: "running", status };
|
|
64
|
-
if (platform() !== "linux") {
|
|
65
|
-
return {
|
|
66
|
-
state: "unsupported",
|
|
67
|
-
status,
|
|
68
|
-
error: `resource observer does not yet support ${platform()}`,
|
|
69
|
-
};
|
|
70
|
-
}
|
|
71
|
-
try {
|
|
72
|
-
const started = await spawnResourceService(coordRoot);
|
|
73
|
-
return { state: "started", status: started };
|
|
74
|
-
}
|
|
75
|
-
catch (error) {
|
|
76
|
-
return {
|
|
77
|
-
state: "unavailable",
|
|
78
|
-
status: readResourceServiceStatus(coordRoot),
|
|
79
|
-
error: error instanceof Error ? error.message : String(error),
|
|
80
|
-
};
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
16
|
export function requestResourceServiceStop(coordRootRaw, dependencies = {}) {
|
|
84
17
|
const coordRoot = resolve(coordRootRaw);
|
|
85
18
|
const paths = resourcePaths(coordRoot);
|
|
@@ -266,16 +199,6 @@ function readLease(path) {
|
|
|
266
199
|
function leaseIsLive(lease) {
|
|
267
200
|
return resourceProcessLiveness(lease).liveness;
|
|
268
201
|
}
|
|
269
|
-
function assertResourceLeaseAvailable(path) {
|
|
270
|
-
if (!existsSync(path))
|
|
271
|
-
return;
|
|
272
|
-
const lease = readLease(path);
|
|
273
|
-
const liveness = lease ? leaseIsLive(lease) : "unknown";
|
|
274
|
-
if (liveness === "unknown")
|
|
275
|
-
throw unknownResourceOwnerError();
|
|
276
|
-
if (liveness === "running")
|
|
277
|
-
throw new Error(`resource observer lease is held by pid ${lease?.pid}`);
|
|
278
|
-
}
|
|
279
202
|
function unknownResourceOwnerError() {
|
|
280
203
|
return new Error(`resource observer process identity is unknown; run ${resolveBinName()} supervisor stop to write the durable stop request before starting again`);
|
|
281
204
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../../../src/core/semantic/service.ts"],"names":[],"mappings":"AAoBA,OAAO,EAGL,iBAAiB,EAClB,MAAM,uBAAuB,CAAC;AAU/B,OAAO,EAAmB,KAAK,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAErE,OAAO,EAIL,KAAK,qBAAqB,EAC1B,KAAK,2BAA2B,EACjC,MAAM,qBAAqB,CAAC;AAc7B,OAAO,EACL,yBAAyB,EACzB,sCAAsC,EACtC,KAAK,wBAAwB,EAC7B,KAAK,oBAAoB,EACzB,KAAK,qBAAqB,EAC1B,KAAK,2BAA2B,GACjC,MAAM,qBAAqB,CAAC;AAE7B,eAAO,MAAM,oCAAoC,OAAQ,CAAC;AAC1D,eAAO,MAAM,gCAAgC,OAAQ,CAAC;AACtD,eAAO,MAAM,qCAAqC,OAAQ,CAAC;AAK3D,eAAO,MAAM,yCAAyC,QAAS,CAAC;AA2BhE,MAAM,WAAW,6BAA6B;IAC5C,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,GAAG,CAAC,EAAE,MAAM,IAAI,CAAC;IACjB,SAAS,CAAC,EAAE,OAAO,iBAAiB,CAAC;IACrC,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE;QAChB,SAAS,EAAE,MAAM,CAAC;QAClB,YAAY,CAAC,EAAE,MAAM,CAAC;QACtB,UAA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,KAAK,EAAE,0BAA0B,CAAC;IAClC,MAAM,CAAC,EAAE,qBAAqB,CAAC;IAC/B,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,iCAAiC;IAChD,UAAU,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,qBAAqB,CAAC;IACzD,KAAK,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,OAAO,CAAC,qBAAqB,CAAC,CAAC;IAC7D,QAAQ,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,OAAO,CAAC;IACzC,QAAQ,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,OAAO,CAAC;CAC1C;AAED,wBAAsB,oBAAoB,CACxC,YAAY,EAAE,MAAM,EACpB,OAAO,GAAE;IAAE,YAAY,CAAC,EAAE,MAAM,CAAA;CAAO,GACtC,OAAO,CAAC,qBAAqB,CAAC,CAgDhC;AAED;;;;;;GAMG;AACH,wBAAsB,4BAA4B,CAChD,YAAY,EAAE,MAAM,EACpB,SAAS,GAAE,OAAO,CAAC,iCAAiC,CAAM,GACzD,OAAO,CAAC,2BAA2B,CAAC,CAsBtC;AAED,wBAAgB,0BAA0B,CAAC,YAAY,EAAE,MAAM,GAAG,qBAAqB,CAUtF;AAED,wBAAsB,wBAAwB,CAC5C,KAAK,EAAE,6BAA6B,GACnC,OAAO,CAAC,2BAA2B,CAAC,CA8MtC;AAED,wBAAgB,2BAA2B,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM,IAAI,CAuC5E;AAmID,wBAAgB,+BAA+B,CAC7C,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC7B,QAAQ,GAAG,QAAQ,CAerB"}
|
|
@@ -132,20 +132,13 @@ export async function ensureSemanticServiceRunning(coordRootRaw, overrides = {})
|
|
|
132
132
|
}
|
|
133
133
|
export function requestSemanticServiceStop(coordRootRaw) {
|
|
134
134
|
const coordRoot = resolve(coordRootRaw);
|
|
135
|
-
const status = readSemanticServiceStatus(coordRoot);
|
|
136
135
|
mkdirSync(semanticPaths(coordRoot).root, { recursive: true, mode: stateDirMode() });
|
|
137
136
|
writePrivateJsonAtomic(semanticPaths(coordRoot).stop, {
|
|
138
137
|
requested_at: new Date().toISOString(),
|
|
139
138
|
requested_by_pid: process.pid,
|
|
140
139
|
});
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
process.kill(status.record.pid, "SIGTERM");
|
|
144
|
-
}
|
|
145
|
-
catch {
|
|
146
|
-
// The durable stop request remains for a racing or restarted daemon.
|
|
147
|
-
}
|
|
148
|
-
}
|
|
140
|
+
// This record has no generation witness. The durable request is the stop
|
|
141
|
+
// authority; a numeric PID cannot authorize an additional signal.
|
|
149
142
|
return readSemanticServiceStatus(coordRoot);
|
|
150
143
|
}
|
|
151
144
|
export async function runSemanticServiceDaemon(input) {
|
|
@@ -21,6 +21,8 @@
|
|
|
21
21
|
*/
|
|
22
22
|
import { type ProcessGenerationSignalDependencies, type ProcessGenerationVerdict } from "../agents/state/proc-start.js";
|
|
23
23
|
import { type ScanSupport } from "./net.js";
|
|
24
|
+
export { processStartToken, signalIfSameGeneration, verifyProcessGeneration, } from "../agents/state/proc-start.js";
|
|
25
|
+
export { acquireNoClobberLease } from "../workflow/workspaces/leases.js";
|
|
24
26
|
export { ancestry, establishedConnectionCounts, listListeningPorts, listListeningSockets, lsofConnectionCounts, lsofListeningSockets, parseElapsed, parseLsofListen, parseProcNetTcp, processStartedAt, psProcessInfo, readProcessInfo, scanSupport, } from "./net.js";
|
|
25
27
|
export { tunnelServerId, tunnelServerInput } from "./tunnels.js";
|
|
26
28
|
export declare const SERVER_RECORD_SCHEMA_VERSION = 1;
|
|
@@ -183,6 +185,8 @@ export interface StopResult {
|
|
|
183
185
|
}
|
|
184
186
|
export interface ServerProcessDependencies extends ProcessGenerationSignalDependencies {
|
|
185
187
|
probePid?: (pid: number) => boolean;
|
|
188
|
+
/** Numeric signal, used for the process group and in tests. */
|
|
189
|
+
kill?: (pid: number, signal: NodeJS.Signals) => void;
|
|
186
190
|
}
|
|
187
191
|
/**
|
|
188
192
|
* Stop a verified server with SIGTERM, then SIGKILL after the grace period.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/core/servers/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAQH,OAAO,EACL,KAAK,mCAAmC,EACxC,KAAK,wBAAwB,EAI9B,MAAM,+BAA+B,CAAC;AASvC,OAAO,EAOL,KAAK,WAAW,EAEjB,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/core/servers/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAQH,OAAO,EACL,KAAK,mCAAmC,EACxC,KAAK,wBAAwB,EAI9B,MAAM,+BAA+B,CAAC;AASvC,OAAO,EAOL,KAAK,WAAW,EAEjB,MAAM,UAAU,CAAC;AAGlB,OAAO,EACL,iBAAiB,EACjB,sBAAsB,EACtB,uBAAuB,GACxB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,qBAAqB,EAAE,MAAM,kCAAkC,CAAC;AACzE,OAAO,EACL,QAAQ,EACR,2BAA2B,EAC3B,kBAAkB,EAClB,oBAAoB,EACpB,oBAAoB,EACpB,oBAAoB,EACpB,YAAY,EACZ,eAAe,EACf,eAAe,EACf,gBAAgB,EAChB,aAAa,EACb,eAAe,EACf,WAAW,GACZ,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAEjE,eAAO,MAAM,4BAA4B,IAAI,CAAC;AAC9C,eAAO,MAAM,yBAAyB,IAAI,CAAC;AAC3C,eAAO,MAAM,gCAAgC,KAAK,CAAC;AAGnD,MAAM,MAAM,UAAU,GAAG,SAAS,GAAG,SAAS,CAAC;AAE/C,MAAM,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
import { writePrivateJsonAtomic } from "../storage/atomic-json.js";
|
|
34
34
|
import { ancestry, establishedConnectionCounts, listListeningPorts, listListeningSockets, processStartedAt, readProcessInfo, scanSupport, } from "./net.js";
|
|
35
|
+
// Host supervisors verify and signal their own children with the same checks.
|
|
36
|
+
export { processStartToken, signalIfSameGeneration, verifyProcessGeneration, } from "../agents/state/proc-start.js";
|
|
37
|
+
export { acquireNoClobberLease } from "../workflow/workspaces/leases.js";
|
|
35
38
|
export { ancestry, establishedConnectionCounts, listListeningPorts, listListeningSockets, lsofConnectionCounts, lsofListeningSockets, parseElapsed, parseLsofListen, parseProcNetTcp, processStartedAt, psProcessInfo, readProcessInfo, scanSupport, } from "./net.js";
|
|
36
39
|
export { tunnelServerId, tunnelServerInput } from "./tunnels.js";
|
|
37
40
|
export const SERVER_RECORD_SCHEMA_VERSION = 1;
|
|
@@ -425,6 +428,21 @@ export function planServerGc(views, policy) {
|
|
|
425
428
|
};
|
|
426
429
|
});
|
|
427
430
|
}
|
|
431
|
+
/** Recheck the generation, then signal. A supplied `kill` replaces the handle path. */
|
|
432
|
+
function signalVerified(pid, token, name, dependencies) {
|
|
433
|
+
if (!dependencies.kill)
|
|
434
|
+
return signalIfSameGeneration(pid, token, name, dependencies);
|
|
435
|
+
const verdict = verifyProcessGeneration(pid, token, dependencies.readToken);
|
|
436
|
+
if (verdict !== "same")
|
|
437
|
+
return { sent: false, verdict };
|
|
438
|
+
try {
|
|
439
|
+
dependencies.kill(pid, name);
|
|
440
|
+
return { sent: true, verdict };
|
|
441
|
+
}
|
|
442
|
+
catch {
|
|
443
|
+
return { sent: false, verdict };
|
|
444
|
+
}
|
|
445
|
+
}
|
|
428
446
|
/**
|
|
429
447
|
* Stop a verified server with SIGTERM, then SIGKILL after the grace period.
|
|
430
448
|
* Each signal, including the process group and auxiliary processes, requires
|
|
@@ -480,7 +498,7 @@ export async function stopServer(record, options) {
|
|
|
480
498
|
return refuse(target.pid, "unknown");
|
|
481
499
|
const result = target.pid === record.pid
|
|
482
500
|
? signalServerLeader(target.pid, target.token, name, dependencies)
|
|
483
|
-
:
|
|
501
|
+
: signalVerified(target.pid, target.token, name, dependencies);
|
|
484
502
|
if (result.verdict !== "same")
|
|
485
503
|
return refuse(target.pid, result.verdict);
|
|
486
504
|
}
|
|
@@ -502,13 +520,13 @@ function signalServerLeader(pid, token, name, dependencies) {
|
|
|
502
520
|
// The leader's generation authorizes its group. A failed group signal must
|
|
503
521
|
// not reuse that observation for the direct-PID fallback.
|
|
504
522
|
const kill = dependencies.kill ?? process.kill;
|
|
505
|
-
const group =
|
|
523
|
+
const group = signalVerified(pid, token, name, {
|
|
506
524
|
readToken: dependencies.readToken,
|
|
507
525
|
kill: (leader, signal) => kill(-leader, signal),
|
|
508
526
|
});
|
|
509
527
|
return group.sent || group.verdict !== "same"
|
|
510
528
|
? group
|
|
511
|
-
:
|
|
529
|
+
: signalVerified(pid, token, name, dependencies);
|
|
512
530
|
}
|
|
513
531
|
async function waitForExit(targets, waitMs, dependencies) {
|
|
514
532
|
const deadline = Date.now() + waitMs;
|
|
@@ -394,31 +394,55 @@ function acquireLease(lease) {
|
|
|
394
394
|
pid: process.pid,
|
|
395
395
|
acquired_at: new Date().toISOString(),
|
|
396
396
|
};
|
|
397
|
-
|
|
398
|
-
try {
|
|
399
|
-
mkdirSync(lease, { mode: stateDirMode() });
|
|
400
|
-
assertDirectoryWithinParent(lease, parent);
|
|
401
|
-
claimed = captureDirectoryIdentity(lease);
|
|
402
|
-
writeOwner(join(lease, "owner.json"), owner);
|
|
403
|
-
syncDirectory(claimed);
|
|
397
|
+
if (claimLease(lease, parent, owner))
|
|
404
398
|
return owner;
|
|
399
|
+
if (recoverStaleLease(lease, DURABLE_HISTORY_LEASE_STALE_MS))
|
|
400
|
+
continue;
|
|
401
|
+
throw new Error(`durable history lease busy: ${lease}`);
|
|
402
|
+
}
|
|
403
|
+
throw new Error(`durable history lease busy: ${lease}`);
|
|
404
|
+
}
|
|
405
|
+
/**
|
|
406
|
+
* Publish a complete lease in one rename. The owner record is written and synced
|
|
407
|
+
* in a private claim directory first, so a writer stopped at any point leaves
|
|
408
|
+
* either no lease or one with an owner. A held lease always has an owner record,
|
|
409
|
+
* here and in the earlier create-then-write protocol, so a rename that replaces
|
|
410
|
+
* an empty lease directory never takes a held lease. A lease with any entry makes
|
|
411
|
+
* the rename fail and the caller reports it busy.
|
|
412
|
+
*/
|
|
413
|
+
function claimLease(lease, parent, owner) {
|
|
414
|
+
const claim = `${lease}.claim-${process.pid}-${owner.owner_id}`;
|
|
415
|
+
try {
|
|
416
|
+
mkdirSync(claim, { mode: stateDirMode() });
|
|
417
|
+
assertDirectoryWithinParent(claim, parent);
|
|
418
|
+
const claimed = captureDirectoryIdentity(claim);
|
|
419
|
+
writeOwner(join(claim, "owner.json"), owner);
|
|
420
|
+
syncDirectory(claimed);
|
|
421
|
+
renameSync(claim, lease);
|
|
422
|
+
}
|
|
423
|
+
catch {
|
|
424
|
+
return false;
|
|
425
|
+
}
|
|
426
|
+
finally {
|
|
427
|
+
try {
|
|
428
|
+
rmSync(claim, { recursive: true, force: true });
|
|
405
429
|
}
|
|
406
430
|
catch {
|
|
407
|
-
|
|
408
|
-
try {
|
|
409
|
-
assertDirectoryIdentity(claimed);
|
|
410
|
-
rmSync(lease, { recursive: true, force: false });
|
|
411
|
-
}
|
|
412
|
-
catch {
|
|
413
|
-
// Never remove a lease after its directory identity changes.
|
|
414
|
-
}
|
|
415
|
-
}
|
|
416
|
-
if (recoverStaleLease(lease, DURABLE_HISTORY_LEASE_STALE_MS))
|
|
417
|
-
continue;
|
|
418
|
-
throw new Error(`durable history lease busy: ${lease}`);
|
|
431
|
+
// A leftover claim directory never blocks a lease.
|
|
419
432
|
}
|
|
420
433
|
}
|
|
421
|
-
|
|
434
|
+
try {
|
|
435
|
+
assertDirectoryWithinParent(lease, parent);
|
|
436
|
+
const current = JSON.parse(completeJsonl(join(lease, "owner.json")));
|
|
437
|
+
if (current.owner_id !== owner.owner_id)
|
|
438
|
+
return false;
|
|
439
|
+
syncDirectory(parent);
|
|
440
|
+
return true;
|
|
441
|
+
}
|
|
442
|
+
catch {
|
|
443
|
+
releaseOwnedLease(lease, owner);
|
|
444
|
+
return false;
|
|
445
|
+
}
|
|
422
446
|
}
|
|
423
447
|
function writeOwner(path, owner) {
|
|
424
448
|
const parent = captureDirectoryIdentity(dirname(path));
|
|
@@ -468,7 +492,7 @@ function recoverStaleLease(lease, staleMs) {
|
|
|
468
492
|
assertDirectoryIdentity(leaseIdentity);
|
|
469
493
|
if (completeJsonl(ownerPath) !== raw)
|
|
470
494
|
return false;
|
|
471
|
-
|
|
495
|
+
retireLease(lease, randomUUID());
|
|
472
496
|
return true;
|
|
473
497
|
}
|
|
474
498
|
catch {
|
|
@@ -480,12 +504,22 @@ function releaseOwnedLease(lease, owner) {
|
|
|
480
504
|
const current = JSON.parse(completeJsonl(join(lease, "owner.json")));
|
|
481
505
|
if (current.owner_id !== owner.owner_id)
|
|
482
506
|
return;
|
|
483
|
-
|
|
507
|
+
retireLease(lease, owner.owner_id);
|
|
484
508
|
}
|
|
485
509
|
catch {
|
|
486
510
|
// A missing or replaced lease does not belong to this operation.
|
|
487
511
|
}
|
|
488
512
|
}
|
|
513
|
+
/**
|
|
514
|
+
* Move a lease aside before deleting it. Its path goes from held to absent in
|
|
515
|
+
* one rename and is never an empty directory that a concurrent claim could
|
|
516
|
+
* replace while a recursive removal is still running.
|
|
517
|
+
*/
|
|
518
|
+
function retireLease(lease, tag) {
|
|
519
|
+
const retired = `${lease}.retired-${process.pid}-${tag}`;
|
|
520
|
+
renameSync(lease, retired);
|
|
521
|
+
rmSync(retired, { recursive: true, force: true });
|
|
522
|
+
}
|
|
489
523
|
function processIsAlive(pid) {
|
|
490
524
|
try {
|
|
491
525
|
process.kill(pid, 0);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"segments.d.ts","sourceRoot":"","sources":["../../../src/core/storage/segments.ts"],"names":[],"mappings":"AAqB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e;gBAAlD,MAAM,EAAE,SAAS,GAAG,YAAY,GAAG,eAAe,EAC3D,OAAO,EAAE,MAAM;CAKlB;AAED,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,8BAA8B,GAAG,MAAM,CAMjF;AAED,qBAAa,eAAe;;gBAGd,OAAO,EAAE,oBAAoB;IAmBnC,MAAM,CACV,OAAO,EAAE,SAAS,MAAM,EAAE,EAC1B,OAAO,GAAE,sBAA2B,EACpC,OAAO,UAAQ,EACf,GAAG,OAAa,GACf,OAAO,CAAC,mBAAmB,CAAC;CA4ChC;AAED,wBAAgB,mBAAmB,CACjC,SAAS,EAAE,MAAM,EACjB,MAAM,CAAC,EAAE,8BAA8B,GACtC,oBAAoB,CAyCtB;AAED,wBAAgB,sBAAsB,CAAC,QAAQ,EAAE,oBAAoB,GAAG,MAAM,CAE7E;AAED;;;;GAIG;AACH,wBAAsB,qBAAqB,CACzC,OAAO,EAAE,4BAA4B,GACpC,OAAO,CAAC,SAAS,GAAG,iBAAiB,CAAC,CAuExC;AAED,wBAAsB,eAAe,CAAC,CAAC,EACrC,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE;IAAE,gBAAgB,EAAE,MAAM,CAAC;IAAC,cAAc,EAAE,MAAM,CAAC;IAAC,cAAc,EAAE,MAAM,CAAA;CAAE,EACpF,SAAS,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,GAC9B,OAAO,CAAC,CAAC,CAAC,CA+BZ"}
|
|
@@ -191,25 +191,19 @@ export async function withFamilyLease(directory, policy, operation) {
|
|
|
191
191
|
let owner;
|
|
192
192
|
while (true) {
|
|
193
193
|
try {
|
|
194
|
-
|
|
195
|
-
const leaseIdentity = captureDirectoryIdentity(lease);
|
|
196
|
-
owner = {
|
|
197
|
-
owner_id: randomUUID(),
|
|
198
|
-
pid: process.pid,
|
|
199
|
-
acquired_at: new Date().toISOString(),
|
|
200
|
-
};
|
|
201
|
-
writeNewFile(join(lease, "owner.json"), Buffer.from(`${JSON.stringify(owner)}\n`));
|
|
202
|
-
assertDirectoryIdentity(leaseIdentity);
|
|
194
|
+
owner = claimLease(lease);
|
|
203
195
|
break;
|
|
204
196
|
}
|
|
205
197
|
catch (error) {
|
|
206
|
-
if (
|
|
198
|
+
if (leaseHasWrongType(lease)) {
|
|
207
199
|
throw new HarneryLogLeaseError("wrong_type", `log lease is not a directory: ${lease}`);
|
|
208
200
|
}
|
|
209
201
|
if (recoverStaleLease(lease, policy.lease_stale_ms))
|
|
210
202
|
continue;
|
|
211
203
|
if (Date.now() - started >= policy.lease_timeout_ms) {
|
|
212
|
-
throw new HarneryLogLeaseError("timeout",
|
|
204
|
+
throw new HarneryLogLeaseError("timeout", leaseHasValidOwner(lease)
|
|
205
|
+
? `timed out acquiring log lease: ${lease}`
|
|
206
|
+
: `timed out acquiring log lease with no valid owner; an interrupted writer left it, and it is never recovered automatically: ${lease}`);
|
|
213
207
|
}
|
|
214
208
|
await new Promise((resolve) => setTimeout(resolve, policy.lease_retry_ms));
|
|
215
209
|
void error;
|
|
@@ -223,6 +217,42 @@ export async function withFamilyLease(directory, policy, operation) {
|
|
|
223
217
|
releaseOwnedLease(lease, owner);
|
|
224
218
|
}
|
|
225
219
|
}
|
|
220
|
+
/**
|
|
221
|
+
* Publish a complete lease in one rename. The owner record is written and synced
|
|
222
|
+
* in a private claim directory first, so a writer stopped at any point leaves
|
|
223
|
+
* either no lease or one with an owner. A held lease always has an owner record,
|
|
224
|
+
* here and in the earlier create-then-write protocol, so a rename that replaces
|
|
225
|
+
* an empty lease directory never takes a held lease. A lease with any entry makes
|
|
226
|
+
* the rename fail, and the caller waits or recovers as before.
|
|
227
|
+
*/
|
|
228
|
+
function claimLease(lease) {
|
|
229
|
+
const owner = {
|
|
230
|
+
owner_id: randomUUID(),
|
|
231
|
+
pid: process.pid,
|
|
232
|
+
acquired_at: new Date().toISOString(),
|
|
233
|
+
};
|
|
234
|
+
const content = `${JSON.stringify(owner)}\n`;
|
|
235
|
+
const claim = `${lease}.claim-${process.pid}-${owner.owner_id}`;
|
|
236
|
+
try {
|
|
237
|
+
mkdirSync(claim, { mode: stateDirMode() });
|
|
238
|
+
writeNewFile(join(claim, "owner.json"), Buffer.from(content));
|
|
239
|
+
renameSync(claim, lease);
|
|
240
|
+
}
|
|
241
|
+
finally {
|
|
242
|
+
rmSync(claim, { recursive: true, force: true });
|
|
243
|
+
}
|
|
244
|
+
try {
|
|
245
|
+
captureDirectoryIdentity(lease);
|
|
246
|
+
if (readRegularFile(join(lease, "owner.json"), 4_096).toString("utf8") !== content) {
|
|
247
|
+
throw new Error(`log lease owner changed during claim: ${lease}`);
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
catch (error) {
|
|
251
|
+
releaseOwnedLease(lease, owner);
|
|
252
|
+
throw error;
|
|
253
|
+
}
|
|
254
|
+
return owner;
|
|
255
|
+
}
|
|
226
256
|
function shouldRotate(active, incoming, options, now) {
|
|
227
257
|
const stat = regularFileStat(active);
|
|
228
258
|
const incomingBytes = incoming.reduce((sum, record) => sum + record.byteLength, 0);
|
|
@@ -315,6 +345,18 @@ function atomicJson(path, value) {
|
|
|
315
345
|
renameSync(temporary, path);
|
|
316
346
|
assertRegularPath(path, captureDirectoryIdentity(dirname(path)));
|
|
317
347
|
}
|
|
348
|
+
function leaseHasValidOwner(lease) {
|
|
349
|
+
try {
|
|
350
|
+
const owner = JSON.parse(readRegularFile(join(lease, "owner.json"), 4_096).toString("utf8"));
|
|
351
|
+
return (typeof owner?.owner_id === "string" &&
|
|
352
|
+
owner.owner_id.length > 0 &&
|
|
353
|
+
Number.isSafeInteger(owner.pid) &&
|
|
354
|
+
Number.isFinite(Date.parse(owner.acquired_at)));
|
|
355
|
+
}
|
|
356
|
+
catch {
|
|
357
|
+
return false;
|
|
358
|
+
}
|
|
359
|
+
}
|
|
318
360
|
function recoverStaleLease(lease, maximumAgeMs) {
|
|
319
361
|
let identity;
|
|
320
362
|
let raw;
|
|
@@ -344,7 +386,7 @@ function recoverStaleLease(lease, maximumAgeMs) {
|
|
|
344
386
|
assertDirectoryIdentity(identity);
|
|
345
387
|
if (readRegularFile(join(lease, "owner.json"), 4_096).toString("utf8") !== raw)
|
|
346
388
|
return false;
|
|
347
|
-
|
|
389
|
+
retireLease(lease, randomUUID());
|
|
348
390
|
return true;
|
|
349
391
|
}
|
|
350
392
|
catch {
|
|
@@ -356,12 +398,22 @@ function releaseOwnedLease(lease, owner) {
|
|
|
356
398
|
const current = JSON.parse(readRegularFile(join(lease, "owner.json"), 4_096).toString("utf8"));
|
|
357
399
|
if (current.owner_id !== owner.owner_id)
|
|
358
400
|
return;
|
|
359
|
-
|
|
401
|
+
retireLease(lease, owner.owner_id);
|
|
360
402
|
}
|
|
361
403
|
catch {
|
|
362
404
|
// A missing or replaced lease does not belong to this operation.
|
|
363
405
|
}
|
|
364
406
|
}
|
|
407
|
+
/**
|
|
408
|
+
* Move a lease aside before deleting it. Its path goes from held to absent in
|
|
409
|
+
* one rename and is never an empty directory that a concurrent claim could
|
|
410
|
+
* replace while a recursive removal is still running.
|
|
411
|
+
*/
|
|
412
|
+
function retireLease(lease, tag) {
|
|
413
|
+
const retired = `${lease}.retired-${process.pid}-${tag}`;
|
|
414
|
+
renameSync(lease, retired);
|
|
415
|
+
rmSync(retired, { recursive: true, force: true });
|
|
416
|
+
}
|
|
365
417
|
function processIsAlive(pid) {
|
|
366
418
|
try {
|
|
367
419
|
process.kill(pid, 0);
|
|
@@ -519,12 +571,16 @@ function writeAllSync(fd, buffer, writer) {
|
|
|
519
571
|
function nativeWriteSync(fd, buffer, offset, length) {
|
|
520
572
|
return writeSync(fd, buffer, offset, length);
|
|
521
573
|
}
|
|
522
|
-
|
|
574
|
+
/** One lstat, so a lease released between checks reads as absent, not as a wrong type. */
|
|
575
|
+
function leaseHasWrongType(path) {
|
|
523
576
|
try {
|
|
524
|
-
|
|
577
|
+
const stat = lstatSync(path);
|
|
578
|
+
return stat.isSymbolicLink() || !stat.isDirectory();
|
|
525
579
|
}
|
|
526
|
-
catch {
|
|
527
|
-
|
|
580
|
+
catch (error) {
|
|
581
|
+
if (error.code === "ENOENT")
|
|
582
|
+
return false;
|
|
583
|
+
throw error;
|
|
528
584
|
}
|
|
529
585
|
}
|
|
530
586
|
function pathExists(path) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type ProcessGenerationVerdict } from "../agents/state/proc-start.js";
|
|
1
|
+
import { type ProcessGenerationSignalDependencies, type ProcessGenerationVerdict } from "../agents/state/proc-start.js";
|
|
2
2
|
import { type SupervisorServiceStatusRecord, type SupervisorStatus } from "./contract.js";
|
|
3
3
|
import { type SupervisorProcessDependencies } from "./status.js";
|
|
4
4
|
export declare const SUPERVISOR_DEFAULT_INTERVAL_MS = 2000;
|
|
@@ -30,8 +30,6 @@ export interface SupervisorStopResult extends SupervisorStatus {
|
|
|
30
30
|
signal_sent: boolean;
|
|
31
31
|
signal_verdict: ProcessGenerationVerdict;
|
|
32
32
|
}
|
|
33
|
-
export declare function requestSupervisorStop(coordRootRaw: string, dependencies?: SupervisorProcessDependencies &
|
|
34
|
-
kill?: (pid: number, signal: NodeJS.Signals | number) => unknown;
|
|
35
|
-
}): SupervisorStopResult;
|
|
33
|
+
export declare function requestSupervisorStop(coordRootRaw: string, dependencies?: SupervisorProcessDependencies & ProcessGenerationSignalDependencies): SupervisorStopResult;
|
|
36
34
|
export declare function runSupervisor(input: RunSupervisorInput): Promise<SupervisorServiceStatusRecord>;
|
|
37
35
|
//# sourceMappingURL=service.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../../../src/core/supervisor/service.ts"],"names":[],"mappings":"AAkBA,OAAO,EACL,KAAK,wBAAwB,EAG9B,MAAM,+BAA+B,CAAC;AAevC,OAAO,EAML,KAAK,6BAA6B,EAElC,KAAK,gBAAgB,EACtB,MAAM,eAAe,CAAC;AAavB,OAAO,EAGL,KAAK,6BAA6B,EAEnC,MAAM,aAAa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AAE,wBAAwB,CAAC;CAC1C;AAED,wBAAgB,qBAAqB,CACnC,YAAY,EAAE,MAAM,EACpB,YAAY,GAAE,6BAA6B,GAAG,mCAAwC,GACrF,oBAAoB,CA8BtB;AAED,wBAAsB,aAAa,CACjC,KAAK,EAAE,kBAAkB,GACxB,OAAO,CAAC,6BAA6B,CAAC,CA+QxC"}
|
package/dist/core/work/state.js
CHANGED
|
@@ -6,7 +6,7 @@ import { appendSegmentedJsonlFile, readSegmentedJsonlFileSync, } from "../storag
|
|
|
6
6
|
import { stateDirMode, stateFileMode } from "../storage/modes.js";
|
|
7
7
|
import { readWorkflowApproval } from "../workflow/approvals.js";
|
|
8
8
|
import { stableDigest } from "../workflow/durable-record.js";
|
|
9
|
-
import {
|
|
9
|
+
import { readWorkflowProof } from "../workflow/proof.js";
|
|
10
10
|
import { readWorkflowRunManifest, workflowScriptDigest } from "../workflow/run-state.js";
|
|
11
11
|
import { WORKFLOW_TRANSCRIPT_EVENT_BYTES, workflowTranscriptPath } from "../workflow/transcript.js";
|
|
12
12
|
import { isWorkspaceBoundExecutionEvidence } from "../workflow/workspaces/validate.js";
|
|
@@ -464,13 +464,13 @@ function inspectAttempt(coordRoot, event, intent, priorRunId) {
|
|
|
464
464
|
proof.acceptance.summary.unknown === 0
|
|
465
465
|
? "succeeded"
|
|
466
466
|
: "failed";
|
|
467
|
-
//
|
|
468
|
-
//
|
|
469
|
-
//
|
|
467
|
+
// A failed attempt the run classified as uninformative about the work is
|
|
468
|
+
// uncharged (ADR 0046). Absent class ⇒ charged, as before. Read only for a
|
|
469
|
+
// failed attempt: a succeeded run never carries a class.
|
|
470
470
|
if (attempt.status === "failed" &&
|
|
471
|
-
(proof.run.class === "
|
|
472
|
-
|
|
473
|
-
|
|
471
|
+
(proof.run.class === "environment" ||
|
|
472
|
+
proof.run.class === "upstream" ||
|
|
473
|
+
proof.run.class === "decision")) {
|
|
474
474
|
attempt.uncharged = proof.run.class;
|
|
475
475
|
if (proof.run.class === "decision" && typeof proof.run.decision_id === "string") {
|
|
476
476
|
attempt.blocked_on = proof.run.decision_id;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"engine.d.ts","sourceRoot":"","sources":["../../../src/core/workflow/engine.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;
|
|
1
|
+
{"version":3,"file":"engine.d.ts","sourceRoot":"","sources":["../../../src/core/workflow/engine.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAiDH,OAAO,KAAK,EAIV,UAAU,EAGV,SAAS,EAeV,MAAM,YAAY,CAAC;AAuDpB,qBAAa,gBAAiB,SAAQ,KAAK;IACzC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;gBAEf,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,OAAO;CAM/E;AAED,qBAAa,mBAAoB,SAAQ,KAAK;IAC5C,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;gBAEpB,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM;CAOvF;AAED;;;;6EAI6E;AAC7E,qBAAa,oBAAqB,SAAQ,KAAK;IAC7C,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;gBAEjB,MAAM,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM;CAUhD;AAED,wBAAsB,WAAW,CAAC,UAAU,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,GAAG,OAAO,CAAC,SAAS,CAAC,CA6E1F"}
|