harnery 0.45.0 → 0.45.2
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/commander.js +0 -1
- package/dist/commands/files.d.ts +2 -2
- package/dist/commands/files.d.ts.map +1 -1
- package/dist/commands/files.js +4 -7
- package/dist/commands/servers.d.ts.map +1 -1
- package/dist/commands/servers.js +17 -11
- package/dist/commands/tunnel.d.ts +0 -15
- package/dist/commands/tunnel.d.ts.map +1 -1
- package/dist/commands/tunnel.js +153 -453
- package/dist/commands/workflow.d.ts.map +1 -1
- package/dist/commands/workflow.js +6 -45
- package/dist/core/agents/coord-client.d.ts.map +1 -1
- package/dist/core/agents/coord-client.js +0 -18
- 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 +2 -7
- package/dist/core/agents/state/proc-start.d.ts +20 -31
- package/dist/core/agents/state/proc-start.d.ts.map +1 -1
- package/dist/core/agents/state/proc-start.js +37 -70
- package/dist/core/agents/state/service-process.d.ts +61 -0
- package/dist/core/agents/state/service-process.d.ts.map +1 -0
- package/dist/core/agents/state/service-process.js +143 -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/delivery-card.d.ts.map +1 -1
- package/dist/core/artifacts/delivery-card.js +1 -2
- package/dist/core/artifacts/index.d.ts.map +1 -1
- package/dist/core/artifacts/index.js +38 -12
- package/dist/core/context/index.d.ts +6 -4
- package/dist/core/context/index.d.ts.map +1 -1
- package/dist/core/context/index.js +194 -256
- package/dist/core/context/observation.d.ts +9 -9
- package/dist/core/context/observation.d.ts.map +1 -1
- package/dist/core/context/observation.js +37 -6
- 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/events/v3/runtime-build.d.ts +14 -0
- package/dist/core/events/v3/runtime-build.d.ts.map +1 -1
- package/dist/core/events/v3/runtime-build.js +44 -0
- package/dist/core/governor/index.d.ts +2 -1
- package/dist/core/governor/index.d.ts.map +1 -1
- package/dist/core/governor/index.js +2 -1
- package/dist/core/governor/service-read.d.ts +3 -10
- package/dist/core/governor/service-read.d.ts.map +1 -1
- package/dist/core/governor/service-read.js +10 -94
- package/dist/core/governor/service.d.ts +3 -7
- package/dist/core/governor/service.d.ts.map +1 -1
- package/dist/core/governor/service.js +17 -182
- package/dist/core/hooks/cli.js +78 -48
- package/dist/core/hooks/resolve/owner.js +2 -2
- package/dist/core/resources/sampler.js +2 -2
- package/dist/core/resources/service-status.d.ts +2 -14
- package/dist/core/resources/service-status.d.ts.map +1 -1
- package/dist/core/resources/service-status.js +3 -23
- package/dist/core/resources/service.d.ts +3 -7
- package/dist/core/resources/service.d.ts.map +1 -1
- package/dist/core/resources/service.js +12 -101
- package/dist/core/resources/status.d.ts.map +1 -1
- package/dist/core/resources/status.js +3 -2
- package/dist/core/semantic/service.d.ts.map +1 -1
- package/dist/core/semantic/service.js +9 -2
- package/dist/core/servers/index.d.ts +11 -10
- package/dist/core/servers/index.d.ts.map +1 -1
- package/dist/core/servers/index.js +82 -192
- package/dist/core/servers/tunnels.d.ts +3 -5
- package/dist/core/servers/tunnels.d.ts.map +1 -1
- package/dist/core/servers/tunnels.js +2 -45
- 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 +4 -7
- package/dist/core/supervisor/service.d.ts.map +1 -1
- package/dist/core/supervisor/service.js +23 -122
- package/dist/core/supervisor/services.js +2 -2
- package/dist/core/supervisor/status.d.ts +3 -17
- package/dist/core/supervisor/status.d.ts.map +1 -1
- package/dist/core/supervisor/status.js +7 -70
- package/dist/core/work/state.js +7 -7
- package/dist/core/workflow/engine.d.ts.map +1 -1
- package/dist/core/workflow/engine.js +23 -66
- package/dist/core/workflow/index.d.ts +3 -4
- package/dist/core/workflow/index.d.ts.map +1 -1
- package/dist/core/workflow/index.js +2 -2
- 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 +34 -86
- package/dist/core/workflow/resume-lock.d.ts +17 -0
- package/dist/core/workflow/resume-lock.d.ts.map +1 -0
- package/dist/core/workflow/resume-lock.js +158 -0
- package/dist/core/workflow/run-state.d.ts +0 -21
- package/dist/core/workflow/run-state.d.ts.map +1 -1
- package/dist/core/workflow/run-state.js +3 -174
- 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/leases.d.ts +4 -0
- package/dist/core/workflow/workspaces/leases.d.ts.map +1 -1
- package/dist/core/workflow/workspaces/leases.js +1 -1
- package/dist/core/workflow/workspaces/local-git.js +91 -210
- package/dist/core/workflow/workspaces/ownership.d.ts +0 -7
- package/dist/core/workflow/workspaces/ownership.d.ts.map +1 -1
- package/dist/core/workflow/workspaces/ownership.js +3 -130
- package/dist/core/workflow/workspaces/reclaim.d.ts +4 -7
- package/dist/core/workflow/workspaces/reclaim.d.ts.map +1 -1
- package/dist/core/workflow/workspaces/reclaim.js +0 -4
- package/dist/core/workflow/workspaces/recovery.d.ts +1 -1
- package/dist/core/workflow/workspaces/recovery.d.ts.map +1 -1
- package/dist/core/workflow/workspaces/recovery.js +1 -1
- package/dist/core/workflow/workspaces/state.d.ts.map +1 -1
- package/dist/core/workflow/workspaces/state.js +1 -4
- package/dist/lib/identities/assume.d.ts.map +1 -1
- package/dist/lib/identities/assume.js +0 -4
- package/dist/lib/tunnel/state.d.ts +6 -13
- package/dist/lib/tunnel/state.d.ts.map +1 -1
- package/dist/lib/tunnel/state.js +12 -58
- package/package.json +1 -6
- package/src/commander.ts +0 -10
- package/src/commands/files.ts +5 -13
- package/src/commands/servers.ts +23 -12
- package/src/commands/tunnel.ts +166 -533
- package/src/commands/workflow.ts +8 -58
- package/src/core/agents/coord-client.ts +0 -20
- 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 +2 -15
- package/src/core/agents/state/proc-start.ts +41 -69
- package/src/core/agents/state/service-process.ts +217 -0
- package/src/core/agents/state/stale-sweep.ts +82 -247
- package/src/core/artifacts/activity.ts +9 -2
- package/src/core/artifacts/delivery-card.ts +1 -7
- package/src/core/artifacts/index.ts +45 -12
- package/src/core/context/index.ts +207 -272
- package/src/core/context/observation.ts +40 -9
- 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/events/v3/runtime-build.ts +62 -0
- package/src/core/governor/index.ts +1 -2
- package/src/core/governor/service-read.ts +15 -114
- package/src/core/governor/service.ts +36 -220
- package/src/core/hooks/cli.ts +85 -47
- package/src/core/hooks/resolve/owner.ts +2 -2
- package/src/core/resources/sampler.ts +3 -2
- package/src/core/resources/service-status.ts +6 -35
- package/src/core/resources/service.ts +23 -133
- package/src/core/resources/status.ts +3 -2
- package/src/core/semantic/service.ts +8 -2
- package/src/core/servers/index.ts +86 -228
- package/src/core/servers/tunnels.ts +3 -55
- package/src/core/storage/durable-history.ts +52 -20
- package/src/core/storage/segments.ts +79 -17
- package/src/core/supervisor/service.ts +33 -155
- package/src/core/supervisor/services.ts +2 -2
- package/src/core/supervisor/status.ts +10 -85
- package/src/core/work/state.ts +7 -7
- package/src/core/workflow/engine.ts +22 -74
- package/src/core/workflow/index.ts +2 -13
- package/src/core/workflow/live-session-v3.ts +5 -146
- package/src/core/workflow/proof.ts +40 -104
- package/src/core/workflow/resume-lock.ts +179 -0
- package/src/core/workflow/run-state.ts +3 -207
- 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/leases.ts +1 -1
- package/src/core/workflow/workspaces/local-git.ts +120 -239
- package/src/core/workflow/workspaces/ownership.ts +3 -158
- package/src/core/workflow/workspaces/reclaim.ts +3 -9
- package/src/core/workflow/workspaces/recovery.ts +1 -1
- package/src/core/workflow/workspaces/state.ts +1 -5
- package/src/lib/identities/assume.ts +0 -4
- package/src/lib/tunnel/state.ts +15 -70
- package/dist/commands/turn-rollback.d.ts +0 -5
- package/dist/commands/turn-rollback.d.ts.map +0 -1
- package/dist/commands/turn-rollback.js +0 -76
- package/dist/core/agents/state/process-handle.d.ts +0 -26
- package/dist/core/agents/state/process-handle.d.ts.map +0 -1
- package/dist/core/agents/state/process-handle.js +0 -121
- 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/turn-rollback/content.d.ts +0 -53
- package/dist/core/turn-rollback/content.d.ts.map +0 -1
- package/dist/core/turn-rollback/content.js +0 -396
- package/dist/core/turn-rollback/index.d.ts +0 -72
- package/dist/core/turn-rollback/index.d.ts.map +0 -1
- package/dist/core/turn-rollback/index.js +0 -443
- 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/dist/core/workflow/recovery-audit.d.ts +0 -30
- package/dist/core/workflow/recovery-audit.d.ts.map +0 -1
- package/dist/core/workflow/recovery-audit.js +0 -116
- package/src/commands/turn-rollback.ts +0 -111
- package/src/core/agents/state/process-handle.ts +0 -165
- package/src/core/agents/state/unchanged-file.ts +0 -456
- package/src/core/events/v3/generation-custody.ts +0 -59
- package/src/core/turn-rollback/content.ts +0 -499
- package/src/core/turn-rollback/index.ts +0 -580
- package/src/core/workflow/failure-evidence.ts +0 -141
- package/src/core/workflow/recovery-audit.ts +0 -181
|
@@ -1,25 +1,17 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
closeSync,
|
|
4
|
-
existsSync,
|
|
5
|
-
mkdirSync,
|
|
6
|
-
openSync,
|
|
7
|
-
readFileSync,
|
|
8
|
-
rmSync,
|
|
9
|
-
unlinkSync,
|
|
10
|
-
writeFileSync,
|
|
11
|
-
} from "node:fs";
|
|
1
|
+
import { existsSync, rmSync } from "node:fs";
|
|
12
2
|
import { hostname } from "node:os";
|
|
13
3
|
import { resolve } from "node:path";
|
|
4
|
+
import { processStartToken } from "../agents/state/proc-start.ts";
|
|
14
5
|
import {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
6
|
+
acquireServiceLease,
|
|
7
|
+
requestServiceStop,
|
|
8
|
+
type ServiceLiveness,
|
|
9
|
+
type ServiceProcessDependencies,
|
|
10
|
+
type ServiceStopFields,
|
|
11
|
+
serviceStartRefusal,
|
|
12
|
+
} from "../agents/state/service-process.ts";
|
|
20
13
|
import { resolveBinName } from "../config.ts";
|
|
21
14
|
import { closeProcessLoggers, legacyLogFields, processLogger } from "../storage/logger.ts";
|
|
22
|
-
import { stateDirMode, stateFileMode } from "../storage/modes.ts";
|
|
23
15
|
import {
|
|
24
16
|
RESOURCE_SERVICE_STATUS_SCHEMA_VERSION,
|
|
25
17
|
type ResourceSamplerState,
|
|
@@ -27,25 +19,13 @@ import {
|
|
|
27
19
|
type ResourceServiceStatusRecord,
|
|
28
20
|
} from "./contract.ts";
|
|
29
21
|
import { sampleResources } from "./sampler.ts";
|
|
30
|
-
import {
|
|
31
|
-
type ResourceProcessDependencies,
|
|
32
|
-
readResourceServiceStatus,
|
|
33
|
-
resourceProcessLiveness,
|
|
34
|
-
} from "./service-status.ts";
|
|
22
|
+
import { readResourceServiceStatus } from "./service-status.ts";
|
|
35
23
|
import { resourcePaths, writePrivateJsonAtomic } from "./storage.ts";
|
|
36
24
|
|
|
37
25
|
export const RESOURCE_SERVICE_DEFAULT_INTERVAL_MS = 2_000;
|
|
38
26
|
const RESOURCE_SERVICE_MIN_INTERVAL_MS = 500;
|
|
39
27
|
const RESOURCE_SERVICE_MAX_INTERVAL_MS = 60_000;
|
|
40
28
|
|
|
41
|
-
interface ResourceServiceLease {
|
|
42
|
-
pid: number;
|
|
43
|
-
start_token?: string;
|
|
44
|
-
host: string;
|
|
45
|
-
nonce: string;
|
|
46
|
-
created_at: string;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
29
|
export interface RunResourceServiceInput {
|
|
50
30
|
coordRoot: string;
|
|
51
31
|
intervalMs?: number;
|
|
@@ -55,37 +35,15 @@ export interface RunResourceServiceInput {
|
|
|
55
35
|
wait?: (milliseconds: number) => Promise<void>;
|
|
56
36
|
}
|
|
57
37
|
|
|
58
|
-
export
|
|
59
|
-
signal_sent: boolean;
|
|
60
|
-
signal_verdict: ProcessGenerationVerdict;
|
|
61
|
-
}
|
|
38
|
+
export type ResourceServiceStopResult = ResourceServiceStatus & ServiceStopFields;
|
|
62
39
|
|
|
63
40
|
export function requestResourceServiceStop(
|
|
64
41
|
coordRootRaw: string,
|
|
65
|
-
dependencies:
|
|
42
|
+
dependencies: ServiceProcessDependencies = {},
|
|
66
43
|
): ResourceServiceStopResult {
|
|
67
44
|
const coordRoot = resolve(coordRootRaw);
|
|
68
|
-
const
|
|
69
|
-
|
|
70
|
-
mkdirSync(paths.root, { recursive: true, mode: stateDirMode() });
|
|
71
|
-
writePrivateJsonAtomic(paths.stop, {
|
|
72
|
-
requested_at: new Date().toISOString(),
|
|
73
|
-
requested_by_pid: process.pid,
|
|
74
|
-
});
|
|
75
|
-
const signal =
|
|
76
|
-
status.liveness === "running" && status.record?.host === hostname()
|
|
77
|
-
? signalIfSameGeneration(
|
|
78
|
-
status.record.pid,
|
|
79
|
-
status.record.start_token,
|
|
80
|
-
"SIGTERM",
|
|
81
|
-
dependencies,
|
|
82
|
-
)
|
|
83
|
-
: { sent: false, verdict: status.generation };
|
|
84
|
-
return {
|
|
85
|
-
...readResourceServiceStatus(coordRoot, Date.now(), dependencies),
|
|
86
|
-
signal_sent: signal.sent,
|
|
87
|
-
signal_verdict: signal.verdict,
|
|
88
|
-
};
|
|
45
|
+
const read = () => readResourceServiceStatus(coordRoot, Date.now(), dependencies);
|
|
46
|
+
return requestServiceStop(read(), read, resourcePaths(coordRoot).stop, dependencies);
|
|
89
47
|
}
|
|
90
48
|
|
|
91
49
|
export async function runResourceService(
|
|
@@ -93,15 +51,13 @@ export async function runResourceService(
|
|
|
93
51
|
): Promise<ResourceServiceStatusRecord> {
|
|
94
52
|
const coordRoot = resolve(input.coordRoot);
|
|
95
53
|
const current = readResourceServiceStatus(coordRoot);
|
|
96
|
-
if (current.liveness
|
|
97
|
-
if (current.liveness === "running")
|
|
98
|
-
throw new Error(`resource observer is already running under pid ${current.record?.pid}`);
|
|
54
|
+
if (current.liveness !== "stopped") throw startRefusal(current.record?.pid, current.liveness);
|
|
99
55
|
const paths = resourcePaths(coordRoot);
|
|
100
56
|
const intervalMs = normalizeInterval(input.intervalMs);
|
|
101
57
|
const now = input.now ?? (() => new Date());
|
|
102
58
|
const sample = input.sample ?? sampleResources;
|
|
103
59
|
const wait = input.wait ?? delay;
|
|
104
|
-
const lease =
|
|
60
|
+
const lease = acquireServiceLease(paths.lease, startRefusal);
|
|
105
61
|
rmSync(paths.stop, { force: true });
|
|
106
62
|
const startedAt = now().toISOString();
|
|
107
63
|
const daemonStartToken = processStartToken(process.pid);
|
|
@@ -178,84 +134,18 @@ export async function runResourceService(
|
|
|
178
134
|
try {
|
|
179
135
|
await closeProcessLoggers();
|
|
180
136
|
} finally {
|
|
181
|
-
|
|
137
|
+
lease.release();
|
|
182
138
|
}
|
|
183
139
|
}
|
|
184
140
|
return status;
|
|
185
141
|
}
|
|
186
142
|
|
|
187
|
-
function
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
pid: process.pid,
|
|
194
|
-
...(daemonStartToken ? { start_token: daemonStartToken } : {}),
|
|
195
|
-
host: hostname(),
|
|
196
|
-
nonce: randomUUID(),
|
|
197
|
-
created_at: now.toISOString(),
|
|
198
|
-
};
|
|
199
|
-
try {
|
|
200
|
-
const fd = openSync(paths.lease, "wx", stateFileMode());
|
|
201
|
-
try {
|
|
202
|
-
writeFileSync(fd, `${JSON.stringify(lease)}\n`, "utf8");
|
|
203
|
-
} finally {
|
|
204
|
-
closeSync(fd);
|
|
205
|
-
}
|
|
206
|
-
return lease;
|
|
207
|
-
} catch (error) {
|
|
208
|
-
if ((error as NodeJS.ErrnoException).code !== "EEXIST") throw error;
|
|
209
|
-
const existing = readLease(paths.lease);
|
|
210
|
-
const liveness = existing ? leaseIsLive(existing) : "unknown";
|
|
211
|
-
if (liveness === "unknown") throw unknownResourceOwnerError();
|
|
212
|
-
if (existing && liveness === "running") {
|
|
213
|
-
throw new Error(`resource observer lease is held by pid ${existing.pid}`);
|
|
214
|
-
}
|
|
215
|
-
try {
|
|
216
|
-
unlinkSync(paths.lease);
|
|
217
|
-
} catch {
|
|
218
|
-
// A concurrent starter may have replaced or removed the stale lease.
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
}
|
|
222
|
-
throw new Error("resource observer could not acquire its singleton lease");
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
function releaseLease(path: string, nonce: string): void {
|
|
226
|
-
const current = readLease(path);
|
|
227
|
-
if (current?.nonce !== nonce) return;
|
|
228
|
-
try {
|
|
229
|
-
unlinkSync(path);
|
|
230
|
-
} catch {
|
|
231
|
-
// A missing lease is already released.
|
|
232
|
-
}
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
function readLease(path: string): ResourceServiceLease | undefined {
|
|
236
|
-
try {
|
|
237
|
-
const value = JSON.parse(readFileSync(path, "utf8")) as ResourceServiceLease;
|
|
238
|
-
return value &&
|
|
239
|
-
Number.isSafeInteger(value.pid) &&
|
|
240
|
-
value.pid > 0 &&
|
|
241
|
-
typeof value.host === "string" &&
|
|
242
|
-
value.host.length > 0 &&
|
|
243
|
-
typeof value.nonce === "string" &&
|
|
244
|
-
value.nonce.length > 0
|
|
245
|
-
? value
|
|
246
|
-
: undefined;
|
|
247
|
-
} catch {
|
|
248
|
-
return undefined;
|
|
249
|
-
}
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
function leaseIsLive(lease: ResourceServiceLease): ResourceServiceStatus["liveness"] {
|
|
253
|
-
return resourceProcessLiveness(lease).liveness;
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
function unknownResourceOwnerError(): Error {
|
|
257
|
-
return new Error(
|
|
258
|
-
`resource observer process identity is unknown; run ${resolveBinName()} supervisor stop to write the durable stop request before starting again`,
|
|
143
|
+
function startRefusal(pid: number | undefined, liveness: ServiceLiveness): Error {
|
|
144
|
+
return serviceStartRefusal(
|
|
145
|
+
"resource observer",
|
|
146
|
+
`${resolveBinName()} supervisor stop`,
|
|
147
|
+
pid,
|
|
148
|
+
liveness,
|
|
259
149
|
);
|
|
260
150
|
}
|
|
261
151
|
|
|
@@ -6,13 +6,14 @@ import {
|
|
|
6
6
|
type PressureAssessment,
|
|
7
7
|
type PressureHysteresisState,
|
|
8
8
|
} from "../diagnostics/contract.ts";
|
|
9
|
+
import { installedHarneryBuild } from "../events/v3/runtime-build.ts";
|
|
9
10
|
import {
|
|
10
11
|
SUPERVISOR_PRESSURE_SCHEMA_VERSION,
|
|
11
12
|
type SupervisorCapability,
|
|
12
13
|
type SupervisorPressureRecord,
|
|
13
14
|
type SupervisorStatus,
|
|
14
15
|
} from "../supervisor/contract.ts";
|
|
15
|
-
import {
|
|
16
|
+
import { readSupervisorStatus } from "../supervisor/status.ts";
|
|
16
17
|
import { supervisorPaths } from "../supervisor/storage.ts";
|
|
17
18
|
import {
|
|
18
19
|
RESOURCE_SNAPSHOT_SCHEMA_VERSION,
|
|
@@ -465,7 +466,7 @@ function unknownWriterState(): ResourceStatus["writer"] {
|
|
|
465
466
|
generation: "unknown",
|
|
466
467
|
liveness: "unknown",
|
|
467
468
|
running_build: null,
|
|
468
|
-
installed_build:
|
|
469
|
+
installed_build: installedHarneryBuild(),
|
|
469
470
|
restart_needed: true,
|
|
470
471
|
build_status: "running build unknown; restart needed",
|
|
471
472
|
};
|
|
@@ -225,13 +225,19 @@ export async function ensureSemanticServiceRunning(
|
|
|
225
225
|
|
|
226
226
|
export function requestSemanticServiceStop(coordRootRaw: string): SemanticServiceStatus {
|
|
227
227
|
const coordRoot = resolve(coordRootRaw);
|
|
228
|
+
const status = readSemanticServiceStatus(coordRoot);
|
|
228
229
|
mkdirSync(semanticPaths(coordRoot).root, { recursive: true, mode: stateDirMode() });
|
|
229
230
|
writePrivateJsonAtomic(semanticPaths(coordRoot).stop, {
|
|
230
231
|
requested_at: new Date().toISOString(),
|
|
231
232
|
requested_by_pid: process.pid,
|
|
232
233
|
});
|
|
233
|
-
|
|
234
|
-
|
|
234
|
+
if (status.running && status.record?.host === hostname()) {
|
|
235
|
+
try {
|
|
236
|
+
process.kill(status.record.pid, "SIGTERM");
|
|
237
|
+
} catch {
|
|
238
|
+
// The durable stop request remains for a racing or restarted daemon.
|
|
239
|
+
}
|
|
240
|
+
}
|
|
235
241
|
return readSemanticServiceStatus(coordRoot);
|
|
236
242
|
}
|
|
237
243
|
|