harnery 0.45.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.
Files changed (128) hide show
  1. package/dist/commander.js +0 -1
  2. package/dist/commands/files.d.ts +2 -2
  3. package/dist/commands/files.d.ts.map +1 -1
  4. package/dist/commands/files.js +4 -7
  5. package/dist/commands/servers.d.ts.map +1 -1
  6. package/dist/commands/servers.js +17 -11
  7. package/dist/commands/tunnel.d.ts +0 -15
  8. package/dist/commands/tunnel.d.ts.map +1 -1
  9. package/dist/commands/tunnel.js +153 -453
  10. package/dist/core/agents/live-authority-v3.d.ts +0 -1
  11. package/dist/core/agents/live-authority-v3.d.ts.map +1 -1
  12. package/dist/core/agents/live-authority-v3.js +0 -11
  13. package/dist/core/agents/live-lifecycle-v3.d.ts +2 -4
  14. package/dist/core/agents/live-lifecycle-v3.d.ts.map +1 -1
  15. package/dist/core/agents/live-lifecycle-v3.js +7 -28
  16. package/dist/core/agents/state/heartbeat-writer.d.ts.map +1 -1
  17. package/dist/core/agents/state/heartbeat-writer.js +14 -25
  18. package/dist/core/agents/state/live-coordination-writer.d.ts.map +1 -1
  19. package/dist/core/agents/state/live-coordination-writer.js +0 -5
  20. package/dist/core/agents/state/pidmap.d.ts.map +1 -1
  21. package/dist/core/agents/state/pidmap.js +0 -5
  22. package/dist/core/agents/state/stale-sweep.d.ts.map +1 -1
  23. package/dist/core/agents/state/stale-sweep.js +70 -180
  24. package/dist/core/artifacts/activity.d.ts +4 -1
  25. package/dist/core/artifacts/activity.d.ts.map +1 -1
  26. package/dist/core/artifacts/activity.js +8 -2
  27. package/dist/core/artifacts/delivery-card.d.ts.map +1 -1
  28. package/dist/core/artifacts/delivery-card.js +1 -2
  29. package/dist/core/artifacts/index.d.ts.map +1 -1
  30. package/dist/core/artifacts/index.js +38 -12
  31. package/dist/core/events/v3/authority-outbox.d.ts.map +1 -1
  32. package/dist/core/events/v3/authority-outbox.js +0 -29
  33. package/dist/core/events/v3/producers/coordination-recorder.d.ts +0 -1
  34. package/dist/core/events/v3/producers/coordination-recorder.d.ts.map +1 -1
  35. package/dist/core/events/v3/producers/coordination-recorder.js +0 -7
  36. package/dist/core/events/v3/producers/recorder.d.ts.map +1 -1
  37. package/dist/core/events/v3/producers/recorder.js +64 -77
  38. package/dist/core/hooks/cli.js +78 -48
  39. package/dist/core/servers/index.d.ts +13 -10
  40. package/dist/core/servers/index.d.ts.map +1 -1
  41. package/dist/core/servers/index.js +97 -192
  42. package/dist/core/servers/tunnels.d.ts +3 -5
  43. package/dist/core/servers/tunnels.d.ts.map +1 -1
  44. package/dist/core/servers/tunnels.js +2 -45
  45. package/dist/core/storage/durable-history.js +56 -22
  46. package/dist/core/storage/segments.d.ts.map +1 -1
  47. package/dist/core/storage/segments.js +73 -17
  48. package/dist/core/work/state.js +7 -7
  49. package/dist/core/workflow/engine.d.ts.map +1 -1
  50. package/dist/core/workflow/engine.js +21 -65
  51. package/dist/core/workflow/live-session-v3.d.ts +0 -6
  52. package/dist/core/workflow/live-session-v3.d.ts.map +1 -1
  53. package/dist/core/workflow/live-session-v3.js +5 -126
  54. package/dist/core/workflow/proof.d.ts +4 -4
  55. package/dist/core/workflow/proof.d.ts.map +1 -1
  56. package/dist/core/workflow/proof.js +4 -12
  57. package/dist/core/workflow/spawn-claude.d.ts.map +1 -1
  58. package/dist/core/workflow/spawn-claude.js +0 -19
  59. package/dist/core/workflow/spawn-codex.d.ts.map +1 -1
  60. package/dist/core/workflow/spawn-codex.js +0 -13
  61. package/dist/core/workflow/spawn-cursor.d.ts.map +1 -1
  62. package/dist/core/workflow/spawn-cursor.js +0 -19
  63. package/dist/core/workflow/spawn-opencode.d.ts.map +1 -1
  64. package/dist/core/workflow/spawn-opencode.js +0 -14
  65. package/dist/core/workflow/types.d.ts +11 -54
  66. package/dist/core/workflow/types.d.ts.map +1 -1
  67. package/dist/lib/identities/assume.d.ts.map +1 -1
  68. package/dist/lib/identities/assume.js +0 -4
  69. package/dist/lib/tunnel/state.d.ts +6 -13
  70. package/dist/lib/tunnel/state.d.ts.map +1 -1
  71. package/dist/lib/tunnel/state.js +12 -58
  72. package/package.json +1 -6
  73. package/src/commander.ts +0 -10
  74. package/src/commands/files.ts +5 -13
  75. package/src/commands/servers.ts +23 -12
  76. package/src/commands/tunnel.ts +166 -533
  77. package/src/core/agents/live-authority-v3.ts +0 -17
  78. package/src/core/agents/live-lifecycle-v3.ts +14 -52
  79. package/src/core/agents/state/heartbeat-writer.ts +12 -29
  80. package/src/core/agents/state/live-coordination-writer.ts +0 -29
  81. package/src/core/agents/state/pidmap.ts +0 -13
  82. package/src/core/agents/state/stale-sweep.ts +82 -247
  83. package/src/core/artifacts/activity.ts +9 -2
  84. package/src/core/artifacts/delivery-card.ts +1 -7
  85. package/src/core/artifacts/index.ts +45 -12
  86. package/src/core/events/v3/authority-outbox.ts +0 -56
  87. package/src/core/events/v3/producers/coordination-recorder.ts +0 -15
  88. package/src/core/events/v3/producers/recorder.ts +68 -94
  89. package/src/core/hooks/cli.ts +85 -47
  90. package/src/core/servers/index.ts +106 -228
  91. package/src/core/servers/tunnels.ts +3 -55
  92. package/src/core/storage/durable-history.ts +52 -20
  93. package/src/core/storage/segments.ts +79 -17
  94. package/src/core/work/state.ts +7 -7
  95. package/src/core/workflow/engine.ts +21 -73
  96. package/src/core/workflow/live-session-v3.ts +5 -146
  97. package/src/core/workflow/proof.ts +5 -21
  98. package/src/core/workflow/spawn-claude.ts +0 -18
  99. package/src/core/workflow/spawn-codex.ts +0 -13
  100. package/src/core/workflow/spawn-cursor.ts +0 -18
  101. package/src/core/workflow/spawn-opencode.ts +0 -14
  102. package/src/core/workflow/types.ts +11 -41
  103. package/src/lib/identities/assume.ts +0 -4
  104. package/src/lib/tunnel/state.ts +15 -70
  105. package/dist/commands/turn-rollback.d.ts +0 -5
  106. package/dist/commands/turn-rollback.d.ts.map +0 -1
  107. package/dist/commands/turn-rollback.js +0 -76
  108. package/dist/core/agents/state/unchanged-file.d.ts +0 -44
  109. package/dist/core/agents/state/unchanged-file.d.ts.map +0 -1
  110. package/dist/core/agents/state/unchanged-file.js +0 -390
  111. package/dist/core/events/v3/generation-custody.d.ts +0 -5
  112. package/dist/core/events/v3/generation-custody.d.ts.map +0 -1
  113. package/dist/core/events/v3/generation-custody.js +0 -50
  114. package/dist/core/turn-rollback/content.d.ts +0 -53
  115. package/dist/core/turn-rollback/content.d.ts.map +0 -1
  116. package/dist/core/turn-rollback/content.js +0 -396
  117. package/dist/core/turn-rollback/index.d.ts +0 -72
  118. package/dist/core/turn-rollback/index.d.ts.map +0 -1
  119. package/dist/core/turn-rollback/index.js +0 -443
  120. package/dist/core/workflow/failure-evidence.d.ts +0 -16
  121. package/dist/core/workflow/failure-evidence.d.ts.map +0 -1
  122. package/dist/core/workflow/failure-evidence.js +0 -114
  123. package/src/commands/turn-rollback.ts +0 -111
  124. package/src/core/agents/state/unchanged-file.ts +0 -456
  125. package/src/core/events/v3/generation-custody.ts +0 -59
  126. package/src/core/turn-rollback/content.ts +0 -499
  127. package/src/core/turn-rollback/index.ts +0 -580
  128. package/src/core/workflow/failure-evidence.ts +0 -141
@@ -631,6 +631,9 @@ async function main() {
631
631
  if (eventName === "runtime-context-retry") {
632
632
  return runRuntimeContextRetryWorker(coordRoot, adapter, extra);
633
633
  }
634
+ if (eventName === SESSION_MAINTENANCE_EVENT) {
635
+ return runSessionMaintenanceWorker(coordRoot, adapter);
636
+ }
634
637
  const ledgerRoute = resolveLiveEventLedgerRouteV3(coordRoot);
635
638
  // Always log a breadcrumb, useful when an event_type maps to null or owner
636
639
  // resolution fails. Stays cheap (one append) and self-prunes via repo log
@@ -1007,7 +1010,7 @@ function recordContextTelemetry(run) {
1007
1010
  }
1008
1011
  }
1009
1012
  async function handleSessionStarted(run) {
1010
- const { coordRoot, adapter, behavior, payload, owner, sessionId, data } = run;
1013
+ const { coordRoot, adapter, payload, owner, sessionId, data } = run;
1011
1014
  // A configured backup runs out of process and is freshness-gated per host.
1012
1015
  // Startup never waits for restic or a remote provider; the child owns no
1013
1016
  // hook stdio, so the harness is not held open until it finishes. A failed
@@ -1019,53 +1022,10 @@ async function handleSessionStarted(run) {
1019
1022
  catch (err) {
1020
1023
  logError(coordRoot, err, { phase: "backup-schedule" });
1021
1024
  }
1022
- // Effect (journal-maintaining adapters): prune stale journal archives +
1023
- // sweep orphans. The recovery-cue is merged into the session-start
1024
- // additionalContext inside emitSessionStartSystemMessage.
1025
- if (behavior.journalMaintenance)
1026
- journalJanitor(coordRoot);
1027
- imageJanitor(coordRoot);
1028
- // Session start is the only caller of the artifact janitor and the storage
1029
- // maintenance pass, so both load here instead of on every tool call.
1030
- const { autoCleanArtifacts } = await import("../artifacts/index.js");
1031
- const { autoCleanEventV3Archives } = await import("../events/v3/archive-retention.js");
1032
- const { createAutomaticMaintenanceComposition, runAutomaticMaintenancePass } = await import("../storage/maintenance-providers.js");
1033
- // Effect: throttled hourly artifact sweep (see autoCleanArtifacts). It
1034
- // deletes expired workspaces, plus unheld workspaces over the per-bundle
1035
- // ceiling or repository budget once they have been idle past
1036
- // artifacts.idle_grace_hours. Each deletion is rechecked first and recorded
1037
- // in .harnery/artifact-deletions.jsonl. Best-effort like every janitor
1038
- // here: a failure logs and never blocks session start.
1039
- try {
1040
- autoCleanArtifacts(coordRoot);
1041
- }
1042
- catch (err) {
1043
- logError(coordRoot, err, { phase: "artifact-auto-clean" });
1044
- }
1045
- // Effect: apply the same daily throttle to closed V3 epochs. The newest
1046
- // recovery epochs remain protected by the archive retention policy.
1047
- try {
1048
- autoCleanEventV3Archives(coordRoot);
1049
- }
1050
- catch (err) {
1051
- logError(coordRoot, err, { phase: "event-v3-archive-auto-clean" });
1052
- }
1053
- // Plan one bounded, claim-first global slice from cached pressure only.
1054
- // Existing owner janitors above remain the only active executors until
1055
- // each provider receives a separate production activation.
1056
- try {
1057
- await runAutomaticMaintenancePass(createAutomaticMaintenanceComposition(coordRoot, {
1058
- journal: () => {
1059
- if (behavior.journalMaintenance)
1060
- journalJanitor(coordRoot);
1061
- },
1062
- images: () => imageJanitor(coordRoot),
1063
- artifacts: () => autoCleanArtifacts(coordRoot),
1064
- }));
1065
- }
1066
- catch (err) {
1067
- logError(coordRoot, err, { phase: "storage-maintenance-auto" });
1068
- }
1025
+ // Storage maintenance can walk large stores. It runs in a detached worker so
1026
+ // session start emits its context without waiting for it; an adapter that
1027
+ // stops a slow hook would otherwise drop that context entirely.
1028
+ scheduleSessionMaintenance(coordRoot, adapter);
1069
1029
  let recovery = null;
1070
1030
  if (payload?.source === "compact") {
1071
1031
  try {
@@ -1518,6 +1478,76 @@ async function handleCompletedResponse(run) {
1518
1478
  });
1519
1479
  return 0;
1520
1480
  }
1481
+ const SESSION_MAINTENANCE_EVENT = "session-maintenance";
1482
+ function scheduleSessionMaintenance(coordRoot, adapter) {
1483
+ const modulePath = process.argv[1];
1484
+ if (!modulePath)
1485
+ return;
1486
+ try {
1487
+ const child = spawn(process.execPath, [modulePath, SESSION_MAINTENANCE_EVENT, "--adapter", adapter], {
1488
+ cwd: coordRoot,
1489
+ detached: true,
1490
+ stdio: "ignore",
1491
+ env: childEnv(coordRoot),
1492
+ });
1493
+ child.unref();
1494
+ }
1495
+ catch (err) {
1496
+ logError(coordRoot, err, { phase: "session-maintenance-spawn" });
1497
+ }
1498
+ }
1499
+ /**
1500
+ * Session-start storage maintenance, run out of the hook's process. Every step
1501
+ * is best-effort and throttled by its own stamp: a failure logs and never
1502
+ * reaches the session.
1503
+ */
1504
+ async function runSessionMaintenanceWorker(coordRoot, adapter) {
1505
+ const journalMaintenance = adapter ? adapterBehavior(adapter).journalMaintenance : false;
1506
+ // Effect (journal-maintaining adapters): prune stale journal archives +
1507
+ // sweep orphans. The recovery cue is read separately at session start.
1508
+ if (journalMaintenance)
1509
+ journalJanitor(coordRoot);
1510
+ imageJanitor(coordRoot);
1511
+ const { autoCleanArtifacts } = await import("../artifacts/index.js");
1512
+ const { autoCleanEventV3Archives } = await import("../events/v3/archive-retention.js");
1513
+ const { createAutomaticMaintenanceComposition, runAutomaticMaintenancePass } = await import("../storage/maintenance-providers.js");
1514
+ // Effect: throttled hourly artifact sweep (see autoCleanArtifacts). It
1515
+ // deletes expired workspaces, plus unheld workspaces over the per-bundle
1516
+ // ceiling or repository budget once they have been idle past
1517
+ // artifacts.idle_grace_hours. Each deletion is rechecked first and recorded
1518
+ // in .harnery/artifact-deletions.jsonl.
1519
+ try {
1520
+ autoCleanArtifacts(coordRoot);
1521
+ }
1522
+ catch (err) {
1523
+ logError(coordRoot, err, { phase: "artifact-auto-clean" });
1524
+ }
1525
+ // Effect: apply the same daily throttle to closed V3 epochs. The newest
1526
+ // recovery epochs remain protected by the archive retention policy.
1527
+ try {
1528
+ autoCleanEventV3Archives(coordRoot);
1529
+ }
1530
+ catch (err) {
1531
+ logError(coordRoot, err, { phase: "event-v3-archive-auto-clean" });
1532
+ }
1533
+ // Plan one bounded, claim-first global slice from cached pressure only.
1534
+ // Existing owner janitors above remain the only active executors until
1535
+ // each provider receives a separate production activation.
1536
+ try {
1537
+ await runAutomaticMaintenancePass(createAutomaticMaintenanceComposition(coordRoot, {
1538
+ journal: () => {
1539
+ if (journalMaintenance)
1540
+ journalJanitor(coordRoot);
1541
+ },
1542
+ images: () => imageJanitor(coordRoot),
1543
+ artifacts: () => autoCleanArtifacts(coordRoot),
1544
+ }));
1545
+ }
1546
+ catch (err) {
1547
+ logError(coordRoot, err, { phase: "storage-maintenance-auto" });
1548
+ }
1549
+ return 0;
1550
+ }
1521
1551
  function scheduleRuntimeContextRetry(coordRoot, adapter, nativeSessionId) {
1522
1552
  const modulePath = process.argv[1];
1523
1553
  if (!modulePath)
@@ -24,15 +24,14 @@ import { type ScanSupport } from "./net.js";
24
24
  export { processStartToken, signalIfSameGeneration, verifyProcessGeneration, } from "../agents/state/proc-start.js";
25
25
  export { acquireNoClobberLease } from "../workflow/workspaces/leases.js";
26
26
  export { ancestry, establishedConnectionCounts, listListeningPorts, listListeningSockets, lsofConnectionCounts, lsofListeningSockets, parseElapsed, parseLsofListen, parseProcNetTcp, processStartedAt, psProcessInfo, readProcessInfo, scanSupport, } from "./net.js";
27
- export { createTunnelReadinessVerifier, tunnelServerId, tunnelServerInput } from "./tunnels.js";
28
- export declare const SERVER_RECORD_SCHEMA_VERSION = 2;
27
+ export { tunnelServerId, tunnelServerInput } from "./tunnels.js";
28
+ export declare const SERVER_RECORD_SCHEMA_VERSION = 1;
29
29
  export declare const SERVER_DEFAULT_IDLE_HOURS = 2;
30
30
  export declare const SERVER_DEFAULT_OWNER_STALE_HOURS = 24;
31
31
  export type ServerKind = "service" | "session";
32
32
  export interface ServerRecord {
33
33
  schema_version: typeof SERVER_RECORD_SCHEMA_VERSION;
34
34
  id: string;
35
- registration_id: string;
36
35
  kind: ServerKind;
37
36
  /** Free-form family name: `preview`, `tunnel`, `dashboard`, ... */
38
37
  type: string;
@@ -122,11 +121,13 @@ export declare function isValidServerId(id: string): boolean;
122
121
  export declare function registerServer(input: RegisterServerInput, options?: ServerOptions): ServerRecord | null;
123
122
  /** Best-effort registration that never throws (for server start paths). */
124
123
  export declare function tryRegisterServer(input: RegisterServerInput, options?: ServerOptions): ServerRecord | null;
125
- /** Remove only the exact registration receipt observed by the caller. */
126
- export declare function unregisterServer(record: ServerRecord, options?: ServerOptions): boolean;
127
- /** Hold the exact registration receipt until a synchronous or asynchronous effect settles. */
128
- export declare function withServerRegistrationCustody<T>(record: ServerRecord, options: ServerOptions, effect: () => PromiseLike<T>): Promise<T>;
129
- export declare function withServerRegistrationCustody<T>(record: ServerRecord, options: ServerOptions, effect: () => T): T;
124
+ /**
125
+ * Remove a server's record. With `pid`, only a record still naming that pid
126
+ * is removed, so a replacement that re-registered the same id survives.
127
+ */
128
+ export declare function unregisterServer(id: string, options?: ServerOptions & {
129
+ pid?: number;
130
+ }): boolean;
130
131
  export declare function readServer(id: string, options?: ServerOptions): ServerRecord | null;
131
132
  /** Mark a server as used now. */
132
133
  export declare function touchServer(id: string, options?: ServerOptions & {
@@ -184,11 +185,13 @@ export interface StopResult {
184
185
  }
185
186
  export interface ServerProcessDependencies extends ProcessGenerationSignalDependencies {
186
187
  probePid?: (pid: number) => boolean;
188
+ /** Numeric signal, used for the process group and in tests. */
189
+ kill?: (pid: number, signal: NodeJS.Signals) => void;
187
190
  }
188
191
  /**
189
192
  * Stop a verified server with SIGTERM, then SIGKILL after the grace period.
190
- * Every signal targets one retained process handle, including auxiliary processes.
191
- * Each target requires a fresh generation check. Unknown or different generations retain the record.
193
+ * Each signal, including the process group and auxiliary processes, requires
194
+ * a fresh generation check. Unknown or different generations retain the record.
192
195
  */
193
196
  export declare function stopServer(record: ServerRecord, options?: ServerOptions & {
194
197
  graceMs?: number;
@@ -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;AAUvC,OAAO,EAOL,KAAK,WAAW,EAEjB,MAAM,UAAU,CAAC;AAElB,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,6BAA6B,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAEhG,eAAO,MAAM,4BAA4B,IAAI,CAAC;AAC9C,eAAO,MAAM,yBAAyB,IAAI,CAAC;AAC3C,eAAO,MAAM,gCAAgC,KAA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C,EAAE,aAAa,GAAG;IACxB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,kBAAkB,CAAC,EAAE,yBAAyB,CAAC;CAChD,GACA,OAAO,CAAC,UAAU,CAAC,CAgErB;AA8CD;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,aAAa,GAAG,MAAM,GAAG,IAAI,CAWvF;AAED,MAAM,WAAW,YAAa,SAAQ,aAAa;IACjD,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,UAAU,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,qFAAqF;IACrF,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACxB,YAAY,CAAC,EAAE;QACb,WAAW,CAAC,EAAE,OAAO,WAAW,CAAC;QACjC,SAAS,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,MAAM,GAAG,IAAI,CAAC;KAC5C,CAAC;CACH;AAED;;;GAGG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,YAAY,CAsC7E;AAED,oFAAoF;AACpF,wBAAgB,gBAAgB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAI1D"}
@@ -19,7 +19,7 @@
19
19
  * which `gc` never stops; a record without an owner is never stopped
20
20
  * automatically.
21
21
  */
22
- import { createHash, randomUUID } from "node:crypto";
22
+ import { createHash } from "node:crypto";
23
23
  import { existsSync, mkdirSync, readdirSync, readFileSync, rmSync, statSync } from "node:fs";
24
24
  import { hostname } from "node:os";
25
25
  import { basename, isAbsolute, join, relative, resolve } from "node:path";
@@ -31,13 +31,13 @@ import { readCoordinationViewV3, requireAuthoritySafeCoordinationViewV3, } from
31
31
  import { liveInstanceIdV3 } from "../events/v3/live-route-observer.js";
32
32
  import { resolveOwner } from "../hooks/resolve/owner.js";
33
33
  import { writePrivateJsonAtomic } from "../storage/atomic-json.js";
34
- import { acquireNoClobberLease } from "../workflow/workspaces/leases.js";
35
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
36
  export { processStartToken, signalIfSameGeneration, verifyProcessGeneration, } from "../agents/state/proc-start.js";
37
37
  export { acquireNoClobberLease } from "../workflow/workspaces/leases.js";
38
38
  export { ancestry, establishedConnectionCounts, listListeningPorts, listListeningSockets, lsofConnectionCounts, lsofListeningSockets, parseElapsed, parseLsofListen, parseProcNetTcp, processStartedAt, psProcessInfo, readProcessInfo, scanSupport, } from "./net.js";
39
- export { createTunnelReadinessVerifier, tunnelServerId, tunnelServerInput } from "./tunnels.js";
40
- export const SERVER_RECORD_SCHEMA_VERSION = 2;
39
+ export { tunnelServerId, tunnelServerInput } from "./tunnels.js";
40
+ export const SERVER_RECORD_SCHEMA_VERSION = 1;
41
41
  export const SERVER_DEFAULT_IDLE_HOURS = 2;
42
42
  export const SERVER_DEFAULT_OWNER_STALE_HOURS = 24;
43
43
  const TOUCH_INTERVAL_MS = 60_000;
@@ -86,54 +86,40 @@ export function registerServer(input, options) {
86
86
  !(Number.isInteger(input.port) && input.port > 0 && input.port < 65536))
87
87
  throw new Error(`invalid server port: ${input.port}`);
88
88
  const id = input.id ?? serverId(input.type, input.scope);
89
- return withServerMutation(coordRoot, id, () => {
90
- const path = recordPath(coordRoot, id);
91
- const now = new Date().toISOString();
92
- const startToken = input.start_token ?? processStartToken(pid);
93
- const pids = [...new Set(input.pids?.filter((p) => Number.isSafeInteger(p) && p > 0))];
94
- const pidsStartTokens = {};
95
- for (const auxiliaryPid of pids) {
96
- const token = processStartToken(auxiliaryPid);
97
- if (token)
98
- pidsStartTokens[auxiliaryPid] = token;
99
- }
100
- const owner = input.owner === undefined ? callingOwner(coordRoot) : (input.owner ?? undefined);
101
- const record = {
102
- schema_version: SERVER_RECORD_SCHEMA_VERSION,
103
- id,
104
- registration_id: randomUUID(),
105
- kind: input.kind,
106
- type: input.type,
107
- label: input.label ?? id,
108
- ...(input.url ? { url: input.url } : {}),
109
- ...(input.port ? { port: input.port } : {}),
110
- pid,
111
- ...(startToken ? { start_token: startToken } : {}),
112
- ...(pids.length ? { pids, pids_start_tokens: pidsStartTokens } : {}),
113
- host: hostname(),
114
- ...(input.scope ? { scope: resolve(input.scope) } : {}),
115
- ...(input.cwd ? { cwd: resolve(input.cwd) } : {}),
116
- ...(input.log ? { log: resolve(input.log) } : {}),
117
- ...(owner ? { owner } : {}),
118
- started_at: input.started_at ?? now,
119
- registered_at: now,
120
- last_active_at: now,
121
- };
122
- if (input.start_token !== undefined &&
123
- verifyProcessGeneration(pid, input.start_token) !== "same")
124
- throw new Error(`pid ${pid} generation could not be verified before registration`);
125
- if (existsSync(path)) {
126
- const existing = readRecord(path);
127
- if (!existing)
128
- throw new Error(`registration ${id} custody is unknown: invalid or older server record retained`);
129
- if (sameProcessCustody(existing, record) && serverState(existing) === "running")
130
- return existing;
131
- if (existing.host !== hostname() || !allProcessesAbsent(existing))
132
- throw new Error(`registration ${id} custody is held by a live or unverifiable server`);
133
- }
134
- writePrivateJsonAtomic(path, record);
135
- return record;
136
- });
89
+ const now = new Date().toISOString();
90
+ const startToken = input.start_token ?? processStartToken(pid);
91
+ const pids = [...new Set(input.pids?.filter((p) => Number.isSafeInteger(p) && p > 0))];
92
+ const pidsStartTokens = {};
93
+ for (const auxiliaryPid of pids) {
94
+ const token = processStartToken(auxiliaryPid);
95
+ if (token)
96
+ pidsStartTokens[auxiliaryPid] = token;
97
+ }
98
+ const owner = input.owner === undefined ? callingOwner(coordRoot) : (input.owner ?? undefined);
99
+ const record = {
100
+ schema_version: SERVER_RECORD_SCHEMA_VERSION,
101
+ id,
102
+ kind: input.kind,
103
+ type: input.type,
104
+ label: input.label ?? id,
105
+ ...(input.url ? { url: input.url } : {}),
106
+ ...(input.port ? { port: input.port } : {}),
107
+ pid,
108
+ ...(startToken ? { start_token: startToken } : {}),
109
+ ...(pids.length ? { pids, pids_start_tokens: pidsStartTokens } : {}),
110
+ host: hostname(),
111
+ ...(input.scope ? { scope: resolve(input.scope) } : {}),
112
+ ...(input.cwd ? { cwd: resolve(input.cwd) } : {}),
113
+ ...(input.log ? { log: resolve(input.log) } : {}),
114
+ ...(owner ? { owner } : {}),
115
+ started_at: input.started_at ?? now,
116
+ registered_at: now,
117
+ last_active_at: now,
118
+ };
119
+ if (input.start_token !== undefined && verifyProcessGeneration(pid, input.start_token) !== "same")
120
+ throw new Error(`pid ${pid} generation could not be verified before registration`);
121
+ writePrivateJsonAtomic(recordPath(coordRoot, id), record);
122
+ return record;
137
123
  }
138
124
  /** Best-effort registration that never throws (for server start paths). */
139
125
  export function tryRegisterServer(input, options) {
@@ -156,106 +142,43 @@ function callingOwner(coordRoot) {
156
142
  return undefined;
157
143
  }
158
144
  }
159
- /** Remove only the exact registration receipt observed by the caller. */
160
- export function unregisterServer(record, options) {
145
+ /**
146
+ * Remove a server's record. With `pid`, only a record still naming that pid
147
+ * is removed, so a replacement that re-registered the same id survives.
148
+ */
149
+ export function unregisterServer(id, options) {
161
150
  const coordRoot = rootOf(options);
162
- if (!coordRoot || !record || !isValidServerId(record.id))
151
+ if (!coordRoot || !isValidServerId(id))
163
152
  return false;
164
- return withServerMutation(coordRoot, record.id, () => removeServerReceipt(coordRoot, record));
165
- }
166
- export function withServerRegistrationCustody(record, options, effect) {
167
- const coordRoot = rootOf(options);
168
- if (!coordRoot)
169
- throw new Error("registration custody root is unavailable");
170
- const lease = serverMutationLease(coordRoot, record.id);
171
- try {
172
- const current = readServer(record.id, { coordRoot });
173
- if (!current ||
174
- current.registration_id !== record.registration_id ||
175
- !sameProcessCustody(current, record))
176
- throw new Error(`registration ${record.id} custody changed`);
177
- const result = effect();
178
- if (result !== null &&
179
- (typeof result === "object" || typeof result === "function") &&
180
- typeof result.then === "function")
181
- return Promise.resolve(result).finally(() => lease.release());
182
- lease.release();
183
- return result;
184
- }
185
- catch (error) {
186
- lease.release();
187
- throw error;
153
+ const path = recordPath(coordRoot, id);
154
+ if (options?.pid !== undefined) {
155
+ const record = readRecord(path);
156
+ if (record && record.pid !== options.pid)
157
+ return false;
188
158
  }
189
- }
190
- function removeServerReceipt(coordRoot, record) {
191
- const path = recordPath(coordRoot, record.id);
192
- const current = readRecord(path);
193
- if (!current ||
194
- current.registration_id !== record.registration_id ||
195
- !sameProcessCustody(current, record))
159
+ if (!existsSync(path))
196
160
  return false;
197
- rmSync(path);
161
+ rmSync(path, { force: true });
198
162
  return true;
199
163
  }
200
- function serverMutationLease(coordRoot, id) {
201
- recordPath(coordRoot, id);
202
- const scope = `server-registration-${id}`;
203
- return acquireNoClobberLease({
204
- path: join(serversDir(coordRoot), ".custody", id),
205
- scope,
206
- authoritySha256: createHash("sha256").update(scope).digest("hex"),
207
- staleAfterMs: 1,
208
- });
209
- }
210
- function withServerMutation(coordRoot, id, operation) {
211
- const lease = serverMutationLease(coordRoot, id);
212
- try {
213
- return operation();
214
- }
215
- finally {
216
- lease.release();
217
- }
218
- }
219
- function sameProcessCustody(a, b) {
220
- const helpers = (record) => [...new Set(record.pids ?? [])]
221
- .sort((x, y) => x - y)
222
- .map((pid) => [pid, record.pids_start_tokens?.[pid] ?? null]);
223
- return (a.schema_version === SERVER_RECORD_SCHEMA_VERSION &&
224
- b.schema_version === SERVER_RECORD_SCHEMA_VERSION &&
225
- a.id === b.id &&
226
- a.pid === b.pid &&
227
- a.start_token === b.start_token &&
228
- a.host === b.host &&
229
- a.kind === b.kind &&
230
- a.type === b.type &&
231
- a.scope === b.scope &&
232
- a.owner?.instance_id === b.owner?.instance_id &&
233
- JSON.stringify(helpers(a)) === JSON.stringify(helpers(b)));
234
- }
235
164
  export function readServer(id, options) {
236
165
  const coordRoot = rootOf(options);
237
166
  if (!coordRoot || !isValidServerId(id))
238
167
  return null;
239
- const path = recordPath(coordRoot, id);
240
- const record = readRecord(path);
241
- if (!record && existsSync(path))
242
- throw new Error(`server record ${id} is invalid or uses an older schema; retained without custody`);
243
- return record;
168
+ return readRecord(recordPath(coordRoot, id));
244
169
  }
245
170
  /** Mark a server as used now. */
246
171
  export function touchServer(id, options) {
247
172
  const coordRoot = rootOf(options);
248
173
  if (!coordRoot || !isValidServerId(id))
249
174
  return;
250
- withServerMutation(coordRoot, id, () => {
251
- const path = recordPath(coordRoot, id);
252
- const record = readRecord(path);
253
- if (!record)
254
- return;
255
- writePrivateJsonAtomic(path, {
256
- ...record,
257
- last_active_at: (options?.now ?? new Date()).toISOString(),
258
- });
175
+ const path = recordPath(coordRoot, id);
176
+ const record = readRecord(path);
177
+ if (!record)
178
+ return;
179
+ writePrivateJsonAtomic(path, {
180
+ ...record,
181
+ last_active_at: (options?.now ?? new Date()).toISOString(),
259
182
  });
260
183
  }
261
184
  /**
@@ -284,8 +207,6 @@ function readRecord(path) {
284
207
  const value = JSON.parse(readFileSync(path, "utf8"));
285
208
  if (value?.schema_version !== SERVER_RECORD_SCHEMA_VERSION ||
286
209
  typeof value.id !== "string" ||
287
- typeof value.registration_id !== "string" ||
288
- !/^[0-9a-f-]{36}$/.test(value.registration_id) ||
289
210
  !Number.isSafeInteger(value.pid) ||
290
211
  (value.kind !== "service" && value.kind !== "session"))
291
212
  return null;
@@ -304,12 +225,8 @@ export function readServerRecords(options) {
304
225
  return [];
305
226
  return readdirSync(dir)
306
227
  .filter((name) => name.endsWith(".json"))
307
- .map((name) => {
308
- const record = readRecord(join(dir, name));
309
- if (!record)
310
- throw new Error(`server record ${name} is invalid or uses an older schema; retained without custody`);
311
- return record;
312
- })
228
+ .map((name) => readRecord(join(dir, name)))
229
+ .filter((record) => record !== null)
313
230
  .sort((a, b) => a.kind.localeCompare(b.kind) || a.type.localeCompare(b.type) || a.id.localeCompare(b.id));
314
231
  }
315
232
  export function pidAlive(pid) {
@@ -380,7 +297,7 @@ export function listServers(options) {
380
297
  records.forEach((record, i) => {
381
298
  const state = states[i];
382
299
  if (state === "dead" && allProcessesAbsent(record) && options?.prune !== false) {
383
- unregisterServer(record, { coordRoot });
300
+ unregisterServer(record.id, { coordRoot, pid: record.pid });
384
301
  pruned.push(record.id);
385
302
  return;
386
303
  }
@@ -511,51 +428,28 @@ export function planServerGc(views, policy) {
511
428
  };
512
429
  });
513
430
  }
514
- /**
515
- * Stop a verified server with SIGTERM, then SIGKILL after the grace period.
516
- * Every signal targets one retained process handle, including auxiliary processes.
517
- * Each target requires a fresh generation check. Unknown or different generations retain the record.
518
- */
519
- export async function stopServer(record, options) {
520
- const coordRoot = rootOf(options);
521
- if (!coordRoot)
522
- return {
523
- id: record.id,
524
- stopped: false,
525
- method: "refused",
526
- generation: "unknown",
527
- detail: "registration custody root is unavailable",
528
- };
529
- let lease;
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 };
530
438
  try {
531
- lease = serverMutationLease(coordRoot, record.id);
439
+ dependencies.kill(pid, name);
440
+ return { sent: true, verdict };
532
441
  }
533
442
  catch {
534
- return {
535
- id: record.id,
536
- stopped: false,
537
- method: "refused",
538
- generation: "unknown",
539
- detail: "registration custody is unavailable",
540
- };
541
- }
542
- try {
543
- const current = readServer(record.id, { coordRoot });
544
- if (!current || current.registration_id !== record.registration_id)
545
- return {
546
- id: record.id,
547
- stopped: false,
548
- method: "refused",
549
- generation: "unknown",
550
- detail: "registration custody changed; retained current server",
551
- };
552
- return await stopServerWithCustody(record, coordRoot, options);
553
- }
554
- finally {
555
- lease.release();
443
+ return { sent: false, verdict };
556
444
  }
557
445
  }
558
- async function stopServerWithCustody(record, coordRoot, options) {
446
+ /**
447
+ * Stop a verified server with SIGTERM, then SIGKILL after the grace period.
448
+ * Each signal, including the process group and auxiliary processes, requires
449
+ * a fresh generation check. Unknown or different generations retain the record.
450
+ */
451
+ export async function stopServer(record, options) {
452
+ const coordRoot = rootOf(options);
559
453
  const graceMs = options?.graceMs ?? 5_000;
560
454
  const dependencies = options?.signalDependencies ?? {};
561
455
  const targets = [
@@ -573,7 +467,7 @@ async function stopServerWithCustody(record, coordRoot, options) {
573
467
  });
574
468
  const finish = (result) => {
575
469
  if (result.stopped || result.method === "not-running")
576
- removeServerReceipt(coordRoot, record);
470
+ unregisterServer(record.id, { coordRoot, pid: record.pid });
577
471
  return result;
578
472
  };
579
473
  if (record.host !== hostname())
@@ -595,9 +489,6 @@ async function stopServerWithCustody(record, coordRoot, options) {
595
489
  }
596
490
  if (targets.every((target) => processPresence(target.pid, dependencies.probePid) === "absent"))
597
491
  return finish({ id: record.id, stopped: false, method: "not-running" });
598
- const current = readServer(record.id, { coordRoot });
599
- if (!current || !sameProcessCustody(current, record))
600
- return refuse(record.pid, "unknown");
601
492
  for (const name of ["SIGTERM", "SIGKILL"]) {
602
493
  for (const target of targets) {
603
494
  const presence = processPresence(target.pid, dependencies.probePid);
@@ -605,9 +496,11 @@ async function stopServerWithCustody(record, coordRoot, options) {
605
496
  continue;
606
497
  if (presence === "unknown")
607
498
  return refuse(target.pid, "unknown");
608
- const result = signalIfSameGeneration(target.pid, target.token, name, dependencies);
609
- if (!result.sent || result.verdict !== "same")
610
- return refuse(target.pid, result.verdict === "same" ? "unknown" : result.verdict);
499
+ const result = target.pid === record.pid
500
+ ? signalServerLeader(target.pid, target.token, name, dependencies)
501
+ : signalVerified(target.pid, target.token, name, dependencies);
502
+ if (result.verdict !== "same")
503
+ return refuse(target.pid, result.verdict);
611
504
  }
612
505
  const observed = await waitForExit(targets, name === "SIGTERM" ? graceMs : 2_000, dependencies);
613
506
  if (observed.refused)
@@ -623,6 +516,18 @@ async function stopServerWithCustody(record, coordRoot, options) {
623
516
  detail: "process survived SIGKILL",
624
517
  };
625
518
  }
519
+ function signalServerLeader(pid, token, name, dependencies) {
520
+ // The leader's generation authorizes its group. A failed group signal must
521
+ // not reuse that observation for the direct-PID fallback.
522
+ const kill = dependencies.kill ?? process.kill;
523
+ const group = signalVerified(pid, token, name, {
524
+ readToken: dependencies.readToken,
525
+ kill: (leader, signal) => kill(-leader, signal),
526
+ });
527
+ return group.sent || group.verdict !== "same"
528
+ ? group
529
+ : signalVerified(pid, token, name, dependencies);
530
+ }
626
531
  async function waitForExit(targets, waitMs, dependencies) {
627
532
  const deadline = Date.now() + waitMs;
628
533
  while (true) {
@@ -2,12 +2,10 @@
2
2
  * Tunnels as registry services.
3
3
  *
4
4
  * `tunnel up` and `tunnel reload` register the new gate; `tunnel down` removes
5
- * its record. Missing original witnesses remain unknown and cannot authorize actions.
5
+ * its record. Older tunnels need an explicit adoption of an observed listener.
6
6
  */
7
- import { type TunnelReadinessVerifier, type TunnelState } from "../../lib/tunnel/state.js";
8
- import { type RegisterServerInput, type ServerOptions } from "./index.js";
9
- /** Verify only witnesses saved by the original tunnel registration. */
10
- export declare function createTunnelReadinessVerifier(options: ServerOptions): TunnelReadinessVerifier;
7
+ import { type TunnelState } from "../../lib/tunnel/state.js";
8
+ import type { RegisterServerInput } from "./index.js";
11
9
  export declare function tunnelServerId(name: string): string;
12
10
  /** Register the new gate; saved helper PIDs have no generation witnesses. */
13
11
  export declare function tunnelServerInput(state: TunnelState, coordRoot: string): RegisterServerInput;