harnery 0.45.1 → 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.
Files changed (119) hide show
  1. package/dist/commands/workflow.d.ts.map +1 -1
  2. package/dist/commands/workflow.js +6 -45
  3. package/dist/core/agents/coord-client.d.ts.map +1 -1
  4. package/dist/core/agents/coord-client.js +0 -18
  5. package/dist/core/agents/state/pidmap.js +2 -2
  6. package/dist/core/agents/state/proc-start.d.ts +20 -31
  7. package/dist/core/agents/state/proc-start.d.ts.map +1 -1
  8. package/dist/core/agents/state/proc-start.js +37 -70
  9. package/dist/core/agents/state/service-process.d.ts +61 -0
  10. package/dist/core/agents/state/service-process.d.ts.map +1 -0
  11. package/dist/core/agents/state/service-process.js +143 -0
  12. package/dist/core/context/index.d.ts +6 -4
  13. package/dist/core/context/index.d.ts.map +1 -1
  14. package/dist/core/context/index.js +194 -256
  15. package/dist/core/context/observation.d.ts +9 -9
  16. package/dist/core/context/observation.d.ts.map +1 -1
  17. package/dist/core/context/observation.js +37 -6
  18. package/dist/core/events/v3/runtime-build.d.ts +14 -0
  19. package/dist/core/events/v3/runtime-build.d.ts.map +1 -1
  20. package/dist/core/events/v3/runtime-build.js +44 -0
  21. package/dist/core/governor/index.d.ts +2 -1
  22. package/dist/core/governor/index.d.ts.map +1 -1
  23. package/dist/core/governor/index.js +2 -1
  24. package/dist/core/governor/service-read.d.ts +3 -10
  25. package/dist/core/governor/service-read.d.ts.map +1 -1
  26. package/dist/core/governor/service-read.js +10 -94
  27. package/dist/core/governor/service.d.ts +3 -7
  28. package/dist/core/governor/service.d.ts.map +1 -1
  29. package/dist/core/governor/service.js +17 -182
  30. package/dist/core/hooks/resolve/owner.js +2 -2
  31. package/dist/core/resources/sampler.js +2 -2
  32. package/dist/core/resources/service-status.d.ts +2 -14
  33. package/dist/core/resources/service-status.d.ts.map +1 -1
  34. package/dist/core/resources/service-status.js +3 -23
  35. package/dist/core/resources/service.d.ts +3 -7
  36. package/dist/core/resources/service.d.ts.map +1 -1
  37. package/dist/core/resources/service.js +12 -101
  38. package/dist/core/resources/status.d.ts.map +1 -1
  39. package/dist/core/resources/status.js +3 -2
  40. package/dist/core/semantic/service.d.ts.map +1 -1
  41. package/dist/core/semantic/service.js +9 -2
  42. package/dist/core/servers/index.d.ts +0 -2
  43. package/dist/core/servers/index.d.ts.map +1 -1
  44. package/dist/core/servers/index.js +3 -18
  45. package/dist/core/supervisor/service.d.ts +4 -7
  46. package/dist/core/supervisor/service.d.ts.map +1 -1
  47. package/dist/core/supervisor/service.js +23 -122
  48. package/dist/core/supervisor/services.js +2 -2
  49. package/dist/core/supervisor/status.d.ts +3 -17
  50. package/dist/core/supervisor/status.d.ts.map +1 -1
  51. package/dist/core/supervisor/status.js +7 -70
  52. package/dist/core/workflow/engine.js +2 -1
  53. package/dist/core/workflow/index.d.ts +3 -4
  54. package/dist/core/workflow/index.d.ts.map +1 -1
  55. package/dist/core/workflow/index.js +2 -2
  56. package/dist/core/workflow/proof.d.ts.map +1 -1
  57. package/dist/core/workflow/proof.js +30 -74
  58. package/dist/core/workflow/resume-lock.d.ts +17 -0
  59. package/dist/core/workflow/resume-lock.d.ts.map +1 -0
  60. package/dist/core/workflow/resume-lock.js +158 -0
  61. package/dist/core/workflow/run-state.d.ts +0 -21
  62. package/dist/core/workflow/run-state.d.ts.map +1 -1
  63. package/dist/core/workflow/run-state.js +3 -174
  64. package/dist/core/workflow/workspaces/leases.d.ts +4 -0
  65. package/dist/core/workflow/workspaces/leases.d.ts.map +1 -1
  66. package/dist/core/workflow/workspaces/leases.js +1 -1
  67. package/dist/core/workflow/workspaces/local-git.js +91 -210
  68. package/dist/core/workflow/workspaces/ownership.d.ts +0 -7
  69. package/dist/core/workflow/workspaces/ownership.d.ts.map +1 -1
  70. package/dist/core/workflow/workspaces/ownership.js +3 -130
  71. package/dist/core/workflow/workspaces/reclaim.d.ts +4 -7
  72. package/dist/core/workflow/workspaces/reclaim.d.ts.map +1 -1
  73. package/dist/core/workflow/workspaces/reclaim.js +0 -4
  74. package/dist/core/workflow/workspaces/recovery.d.ts +1 -1
  75. package/dist/core/workflow/workspaces/recovery.d.ts.map +1 -1
  76. package/dist/core/workflow/workspaces/recovery.js +1 -1
  77. package/dist/core/workflow/workspaces/state.d.ts.map +1 -1
  78. package/dist/core/workflow/workspaces/state.js +1 -4
  79. package/package.json +1 -1
  80. package/src/commands/workflow.ts +8 -58
  81. package/src/core/agents/coord-client.ts +0 -20
  82. package/src/core/agents/state/pidmap.ts +2 -2
  83. package/src/core/agents/state/proc-start.ts +41 -69
  84. package/src/core/agents/state/service-process.ts +217 -0
  85. package/src/core/context/index.ts +207 -272
  86. package/src/core/context/observation.ts +40 -9
  87. package/src/core/events/v3/runtime-build.ts +62 -0
  88. package/src/core/governor/index.ts +1 -2
  89. package/src/core/governor/service-read.ts +15 -114
  90. package/src/core/governor/service.ts +36 -220
  91. package/src/core/hooks/resolve/owner.ts +2 -2
  92. package/src/core/resources/sampler.ts +3 -2
  93. package/src/core/resources/service-status.ts +6 -35
  94. package/src/core/resources/service.ts +23 -133
  95. package/src/core/resources/status.ts +3 -2
  96. package/src/core/semantic/service.ts +8 -2
  97. package/src/core/servers/index.ts +3 -23
  98. package/src/core/supervisor/service.ts +33 -155
  99. package/src/core/supervisor/services.ts +2 -2
  100. package/src/core/supervisor/status.ts +10 -85
  101. package/src/core/workflow/engine.ts +1 -1
  102. package/src/core/workflow/index.ts +2 -13
  103. package/src/core/workflow/proof.ts +35 -83
  104. package/src/core/workflow/resume-lock.ts +179 -0
  105. package/src/core/workflow/run-state.ts +3 -207
  106. package/src/core/workflow/workspaces/leases.ts +1 -1
  107. package/src/core/workflow/workspaces/local-git.ts +120 -239
  108. package/src/core/workflow/workspaces/ownership.ts +3 -158
  109. package/src/core/workflow/workspaces/reclaim.ts +3 -9
  110. package/src/core/workflow/workspaces/recovery.ts +1 -1
  111. package/src/core/workflow/workspaces/state.ts +1 -5
  112. package/dist/core/agents/state/process-handle.d.ts +0 -26
  113. package/dist/core/agents/state/process-handle.d.ts.map +0 -1
  114. package/dist/core/agents/state/process-handle.js +0 -121
  115. package/dist/core/workflow/recovery-audit.d.ts +0 -30
  116. package/dist/core/workflow/recovery-audit.d.ts.map +0 -1
  117. package/dist/core/workflow/recovery-audit.js +0 -116
  118. package/src/core/agents/state/process-handle.ts +0 -165
  119. package/src/core/workflow/recovery-audit.ts +0 -181
@@ -5,7 +5,7 @@ import { basename, join } from "node:path";
5
5
  import { performance } from "node:perf_hooks";
6
6
  import { readLiveCoordinationRows } from "../agents/state/live-coordination-view.ts";
7
7
  import { parsePidmapRow } from "../agents/state/pidmap.ts";
8
- import { checkPidToken } from "../agents/state/proc-start.ts";
8
+ import { verifyProcessGeneration } from "../agents/state/proc-start.ts";
9
9
  import {
10
10
  RESOURCE_SNAPSHOT_SCHEMA_VERSION,
11
11
  type ResourceProcessGroup,
@@ -386,7 +386,8 @@ function readOwnershipAnchors(
386
386
  if (!byPid.has(pid)) continue;
387
387
  try {
388
388
  const row = parsePidmapRow(readFileSync(join(directory, entry), "utf8"));
389
- if (!row.instanceId || checkPidToken(pid, row.startToken) === "mismatch") continue;
389
+ if (!row.instanceId || verifyProcessGeneration(pid, row.startToken) === "different")
390
+ continue;
390
391
  anchors.set(pid, { kind: "agent", id: row.instanceId, source: "pid-map" });
391
392
  } catch {
392
393
  // An unreadable or racing row cannot prove ownership.
@@ -1,9 +1,8 @@
1
1
  import { existsSync } from "node:fs";
2
- import { hostname } from "node:os";
3
2
  import {
4
- type ProcessGenerationVerdict,
5
- verifyProcessGeneration,
6
- } from "../agents/state/proc-start.ts";
3
+ observeServiceProcess,
4
+ type ServiceProcessDependencies,
5
+ } from "../agents/state/service-process.ts";
7
6
  import {
8
7
  RESOURCE_SERVICE_STATUS_SCHEMA_VERSION,
9
8
  type ResourceServiceStatus,
@@ -13,15 +12,10 @@ import { readResourceServiceRecord, resourcePaths } from "./storage.ts";
13
12
 
14
13
  const STALE_HEARTBEAT_MS = 15_000;
15
14
 
16
- export interface ResourceProcessDependencies {
17
- readToken?: (pid: number) => string | null;
18
- probePid?: (pid: number) => unknown;
19
- }
20
-
21
15
  export function readResourceServiceStatus(
22
16
  coordRoot: string,
23
17
  nowMs = Date.now(),
24
- dependencies: ResourceProcessDependencies = {},
18
+ dependencies: ServiceProcessDependencies = {},
25
19
  ): ResourceServiceStatus {
26
20
  const paths = resourcePaths(coordRoot);
27
21
  const record = readResourceServiceRecord(coordRoot);
@@ -37,13 +31,11 @@ export function readResourceServiceStatus(
37
31
  }
38
32
  const heartbeatAt = Date.parse(record.heartbeat_at);
39
33
  const stale = !Number.isFinite(heartbeatAt) || nowMs - heartbeatAt > STALE_HEARTBEAT_MS;
40
- const owner = resourceProcessLiveness(record, dependencies);
41
- const liveness =
42
- owner.generation === "same" && record.state === "stopped" ? "stopped" : owner.liveness;
34
+ const { generation, liveness } = observeServiceProcess(record, dependencies);
43
35
  return {
44
36
  running: liveness === "running" && !stale,
45
37
  stale,
46
- generation: owner.generation,
38
+ generation,
47
39
  liveness,
48
40
  record,
49
41
  status_path: paths.service,
@@ -62,24 +54,3 @@ function validRecord(
62
54
  typeof value.heartbeat_at === "string"
63
55
  );
64
56
  }
65
-
66
- export function resourceProcessLiveness(
67
- owner: { pid: number; host: string; start_token?: string },
68
- dependencies: ResourceProcessDependencies = {},
69
- ): { generation: ProcessGenerationVerdict; liveness: ResourceServiceStatus["liveness"] } {
70
- if (owner.host !== hostname()) return { generation: "unknown", liveness: "unknown" };
71
- try {
72
- (dependencies.probePid ?? ((pid) => process.kill(pid, 0)))(owner.pid);
73
- } catch (error) {
74
- return {
75
- generation: "unknown",
76
- liveness: (error as NodeJS.ErrnoException).code === "ESRCH" ? "stopped" : "unknown",
77
- };
78
- }
79
- const generation = verifyProcessGeneration(owner.pid, owner.start_token, dependencies.readToken);
80
- return {
81
- generation,
82
- liveness:
83
- generation === "same" ? "running" : generation === "different" ? "stopped" : "unknown",
84
- };
85
- }
@@ -1,25 +1,17 @@
1
- import { randomUUID } from "node:crypto";
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
- type ProcessGenerationSignalDependencies,
16
- type ProcessGenerationVerdict,
17
- processStartToken,
18
- signalIfSameGeneration,
19
- } from "../agents/state/proc-start.ts";
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 interface ResourceServiceStopResult extends ResourceServiceStatus {
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: ResourceProcessDependencies & ProcessGenerationSignalDependencies = {},
42
+ dependencies: ServiceProcessDependencies = {},
66
43
  ): ResourceServiceStopResult {
67
44
  const coordRoot = resolve(coordRootRaw);
68
- const paths = resourcePaths(coordRoot);
69
- const status = readResourceServiceStatus(coordRoot, Date.now(), dependencies);
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 === "unknown") throw unknownResourceOwnerError();
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 = acquireLease(coordRoot, now());
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
- releaseLease(paths.lease, lease.nonce);
137
+ lease.release();
182
138
  }
183
139
  }
184
140
  return status;
185
141
  }
186
142
 
187
- function acquireLease(coordRoot: string, now: Date): ResourceServiceLease {
188
- const paths = resourcePaths(coordRoot);
189
- mkdirSync(paths.root, { recursive: true, mode: stateDirMode() });
190
- for (let attempt = 0; attempt < 2; attempt++) {
191
- const daemonStartToken = processStartToken(process.pid);
192
- const lease: ResourceServiceLease = {
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 { installedSupervisorBuild, readSupervisorStatus } from "../supervisor/status.ts";
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: installedSupervisorBuild(),
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
- // This record has no generation witness. The durable request is the stop
234
- // authority; a numeric PID cannot authorize an additional signal.
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
 
@@ -598,26 +598,6 @@ export interface StopResult {
598
598
 
599
599
  export interface ServerProcessDependencies extends ProcessGenerationSignalDependencies {
600
600
  probePid?: (pid: number) => boolean;
601
- /** Numeric signal, used for the process group and in tests. */
602
- kill?: (pid: number, signal: NodeJS.Signals) => void;
603
- }
604
-
605
- /** Recheck the generation, then signal. A supplied `kill` replaces the handle path. */
606
- function signalVerified(
607
- pid: number,
608
- token: string | undefined,
609
- name: NodeJS.Signals,
610
- dependencies: ServerProcessDependencies,
611
- ): { sent: boolean; verdict: ProcessGenerationVerdict } {
612
- if (!dependencies.kill) return signalIfSameGeneration(pid, token, name, dependencies);
613
- const verdict = verifyProcessGeneration(pid, token, dependencies.readToken);
614
- if (verdict !== "same") return { sent: false, verdict };
615
- try {
616
- dependencies.kill(pid, name);
617
- return { sent: true, verdict };
618
- } catch {
619
- return { sent: false, verdict };
620
- }
621
601
  }
622
602
 
623
603
  /**
@@ -680,7 +660,7 @@ export async function stopServer(
680
660
  const result =
681
661
  target.pid === record.pid
682
662
  ? signalServerLeader(target.pid, target.token, name, dependencies)
683
- : signalVerified(target.pid, target.token, name, dependencies);
663
+ : signalIfSameGeneration(target.pid, target.token, name, dependencies);
684
664
  if (result.verdict !== "same") return refuse(target.pid, result.verdict);
685
665
  }
686
666
  const observed = await waitForExit(targets, name === "SIGTERM" ? graceMs : 2_000, dependencies);
@@ -706,13 +686,13 @@ function signalServerLeader(
706
686
  // The leader's generation authorizes its group. A failed group signal must
707
687
  // not reuse that observation for the direct-PID fallback.
708
688
  const kill = dependencies.kill ?? process.kill;
709
- const group = signalVerified(pid, token, name, {
689
+ const group = signalIfSameGeneration(pid, token, name, {
710
690
  readToken: dependencies.readToken,
711
691
  kill: (leader, signal) => kill(-leader, signal),
712
692
  });
713
693
  return group.sent || group.verdict !== "same"
714
694
  ? group
715
- : signalVerified(pid, token, name, dependencies);
695
+ : signalIfSameGeneration(pid, token, name, dependencies);
716
696
  }
717
697
 
718
698
  async function waitForExit(