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.
Files changed (235) 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/commands/workflow.d.ts.map +1 -1
  11. package/dist/commands/workflow.js +6 -45
  12. package/dist/core/agents/coord-client.d.ts.map +1 -1
  13. package/dist/core/agents/coord-client.js +0 -18
  14. package/dist/core/agents/live-authority-v3.d.ts +0 -1
  15. package/dist/core/agents/live-authority-v3.d.ts.map +1 -1
  16. package/dist/core/agents/live-authority-v3.js +0 -11
  17. package/dist/core/agents/live-lifecycle-v3.d.ts +2 -4
  18. package/dist/core/agents/live-lifecycle-v3.d.ts.map +1 -1
  19. package/dist/core/agents/live-lifecycle-v3.js +7 -28
  20. package/dist/core/agents/state/heartbeat-writer.d.ts.map +1 -1
  21. package/dist/core/agents/state/heartbeat-writer.js +14 -25
  22. package/dist/core/agents/state/live-coordination-writer.d.ts.map +1 -1
  23. package/dist/core/agents/state/live-coordination-writer.js +0 -5
  24. package/dist/core/agents/state/pidmap.d.ts.map +1 -1
  25. package/dist/core/agents/state/pidmap.js +2 -7
  26. package/dist/core/agents/state/proc-start.d.ts +20 -31
  27. package/dist/core/agents/state/proc-start.d.ts.map +1 -1
  28. package/dist/core/agents/state/proc-start.js +37 -70
  29. package/dist/core/agents/state/service-process.d.ts +61 -0
  30. package/dist/core/agents/state/service-process.d.ts.map +1 -0
  31. package/dist/core/agents/state/service-process.js +143 -0
  32. package/dist/core/agents/state/stale-sweep.d.ts.map +1 -1
  33. package/dist/core/agents/state/stale-sweep.js +70 -180
  34. package/dist/core/artifacts/activity.d.ts +4 -1
  35. package/dist/core/artifacts/activity.d.ts.map +1 -1
  36. package/dist/core/artifacts/activity.js +8 -2
  37. package/dist/core/artifacts/delivery-card.d.ts.map +1 -1
  38. package/dist/core/artifacts/delivery-card.js +1 -2
  39. package/dist/core/artifacts/index.d.ts.map +1 -1
  40. package/dist/core/artifacts/index.js +38 -12
  41. package/dist/core/context/index.d.ts +6 -4
  42. package/dist/core/context/index.d.ts.map +1 -1
  43. package/dist/core/context/index.js +194 -256
  44. package/dist/core/context/observation.d.ts +9 -9
  45. package/dist/core/context/observation.d.ts.map +1 -1
  46. package/dist/core/context/observation.js +37 -6
  47. package/dist/core/events/v3/authority-outbox.d.ts.map +1 -1
  48. package/dist/core/events/v3/authority-outbox.js +0 -29
  49. package/dist/core/events/v3/producers/coordination-recorder.d.ts +0 -1
  50. package/dist/core/events/v3/producers/coordination-recorder.d.ts.map +1 -1
  51. package/dist/core/events/v3/producers/coordination-recorder.js +0 -7
  52. package/dist/core/events/v3/producers/recorder.d.ts.map +1 -1
  53. package/dist/core/events/v3/producers/recorder.js +64 -77
  54. package/dist/core/events/v3/runtime-build.d.ts +14 -0
  55. package/dist/core/events/v3/runtime-build.d.ts.map +1 -1
  56. package/dist/core/events/v3/runtime-build.js +44 -0
  57. package/dist/core/governor/index.d.ts +2 -1
  58. package/dist/core/governor/index.d.ts.map +1 -1
  59. package/dist/core/governor/index.js +2 -1
  60. package/dist/core/governor/service-read.d.ts +3 -10
  61. package/dist/core/governor/service-read.d.ts.map +1 -1
  62. package/dist/core/governor/service-read.js +10 -94
  63. package/dist/core/governor/service.d.ts +3 -7
  64. package/dist/core/governor/service.d.ts.map +1 -1
  65. package/dist/core/governor/service.js +17 -182
  66. package/dist/core/hooks/cli.js +78 -48
  67. package/dist/core/hooks/resolve/owner.js +2 -2
  68. package/dist/core/resources/sampler.js +2 -2
  69. package/dist/core/resources/service-status.d.ts +2 -14
  70. package/dist/core/resources/service-status.d.ts.map +1 -1
  71. package/dist/core/resources/service-status.js +3 -23
  72. package/dist/core/resources/service.d.ts +3 -7
  73. package/dist/core/resources/service.d.ts.map +1 -1
  74. package/dist/core/resources/service.js +12 -101
  75. package/dist/core/resources/status.d.ts.map +1 -1
  76. package/dist/core/resources/status.js +3 -2
  77. package/dist/core/semantic/service.d.ts.map +1 -1
  78. package/dist/core/semantic/service.js +9 -2
  79. package/dist/core/servers/index.d.ts +11 -10
  80. package/dist/core/servers/index.d.ts.map +1 -1
  81. package/dist/core/servers/index.js +82 -192
  82. package/dist/core/servers/tunnels.d.ts +3 -5
  83. package/dist/core/servers/tunnels.d.ts.map +1 -1
  84. package/dist/core/servers/tunnels.js +2 -45
  85. package/dist/core/storage/durable-history.js +56 -22
  86. package/dist/core/storage/segments.d.ts.map +1 -1
  87. package/dist/core/storage/segments.js +73 -17
  88. package/dist/core/supervisor/service.d.ts +4 -7
  89. package/dist/core/supervisor/service.d.ts.map +1 -1
  90. package/dist/core/supervisor/service.js +23 -122
  91. package/dist/core/supervisor/services.js +2 -2
  92. package/dist/core/supervisor/status.d.ts +3 -17
  93. package/dist/core/supervisor/status.d.ts.map +1 -1
  94. package/dist/core/supervisor/status.js +7 -70
  95. package/dist/core/work/state.js +7 -7
  96. package/dist/core/workflow/engine.d.ts.map +1 -1
  97. package/dist/core/workflow/engine.js +23 -66
  98. package/dist/core/workflow/index.d.ts +3 -4
  99. package/dist/core/workflow/index.d.ts.map +1 -1
  100. package/dist/core/workflow/index.js +2 -2
  101. package/dist/core/workflow/live-session-v3.d.ts +0 -6
  102. package/dist/core/workflow/live-session-v3.d.ts.map +1 -1
  103. package/dist/core/workflow/live-session-v3.js +5 -126
  104. package/dist/core/workflow/proof.d.ts +4 -4
  105. package/dist/core/workflow/proof.d.ts.map +1 -1
  106. package/dist/core/workflow/proof.js +34 -86
  107. package/dist/core/workflow/resume-lock.d.ts +17 -0
  108. package/dist/core/workflow/resume-lock.d.ts.map +1 -0
  109. package/dist/core/workflow/resume-lock.js +158 -0
  110. package/dist/core/workflow/run-state.d.ts +0 -21
  111. package/dist/core/workflow/run-state.d.ts.map +1 -1
  112. package/dist/core/workflow/run-state.js +3 -174
  113. package/dist/core/workflow/spawn-claude.d.ts.map +1 -1
  114. package/dist/core/workflow/spawn-claude.js +0 -19
  115. package/dist/core/workflow/spawn-codex.d.ts.map +1 -1
  116. package/dist/core/workflow/spawn-codex.js +0 -13
  117. package/dist/core/workflow/spawn-cursor.d.ts.map +1 -1
  118. package/dist/core/workflow/spawn-cursor.js +0 -19
  119. package/dist/core/workflow/spawn-opencode.d.ts.map +1 -1
  120. package/dist/core/workflow/spawn-opencode.js +0 -14
  121. package/dist/core/workflow/types.d.ts +11 -54
  122. package/dist/core/workflow/types.d.ts.map +1 -1
  123. package/dist/core/workflow/workspaces/leases.d.ts +4 -0
  124. package/dist/core/workflow/workspaces/leases.d.ts.map +1 -1
  125. package/dist/core/workflow/workspaces/leases.js +1 -1
  126. package/dist/core/workflow/workspaces/local-git.js +91 -210
  127. package/dist/core/workflow/workspaces/ownership.d.ts +0 -7
  128. package/dist/core/workflow/workspaces/ownership.d.ts.map +1 -1
  129. package/dist/core/workflow/workspaces/ownership.js +3 -130
  130. package/dist/core/workflow/workspaces/reclaim.d.ts +4 -7
  131. package/dist/core/workflow/workspaces/reclaim.d.ts.map +1 -1
  132. package/dist/core/workflow/workspaces/reclaim.js +0 -4
  133. package/dist/core/workflow/workspaces/recovery.d.ts +1 -1
  134. package/dist/core/workflow/workspaces/recovery.d.ts.map +1 -1
  135. package/dist/core/workflow/workspaces/recovery.js +1 -1
  136. package/dist/core/workflow/workspaces/state.d.ts.map +1 -1
  137. package/dist/core/workflow/workspaces/state.js +1 -4
  138. package/dist/lib/identities/assume.d.ts.map +1 -1
  139. package/dist/lib/identities/assume.js +0 -4
  140. package/dist/lib/tunnel/state.d.ts +6 -13
  141. package/dist/lib/tunnel/state.d.ts.map +1 -1
  142. package/dist/lib/tunnel/state.js +12 -58
  143. package/package.json +1 -6
  144. package/src/commander.ts +0 -10
  145. package/src/commands/files.ts +5 -13
  146. package/src/commands/servers.ts +23 -12
  147. package/src/commands/tunnel.ts +166 -533
  148. package/src/commands/workflow.ts +8 -58
  149. package/src/core/agents/coord-client.ts +0 -20
  150. package/src/core/agents/live-authority-v3.ts +0 -17
  151. package/src/core/agents/live-lifecycle-v3.ts +14 -52
  152. package/src/core/agents/state/heartbeat-writer.ts +12 -29
  153. package/src/core/agents/state/live-coordination-writer.ts +0 -29
  154. package/src/core/agents/state/pidmap.ts +2 -15
  155. package/src/core/agents/state/proc-start.ts +41 -69
  156. package/src/core/agents/state/service-process.ts +217 -0
  157. package/src/core/agents/state/stale-sweep.ts +82 -247
  158. package/src/core/artifacts/activity.ts +9 -2
  159. package/src/core/artifacts/delivery-card.ts +1 -7
  160. package/src/core/artifacts/index.ts +45 -12
  161. package/src/core/context/index.ts +207 -272
  162. package/src/core/context/observation.ts +40 -9
  163. package/src/core/events/v3/authority-outbox.ts +0 -56
  164. package/src/core/events/v3/producers/coordination-recorder.ts +0 -15
  165. package/src/core/events/v3/producers/recorder.ts +68 -94
  166. package/src/core/events/v3/runtime-build.ts +62 -0
  167. package/src/core/governor/index.ts +1 -2
  168. package/src/core/governor/service-read.ts +15 -114
  169. package/src/core/governor/service.ts +36 -220
  170. package/src/core/hooks/cli.ts +85 -47
  171. package/src/core/hooks/resolve/owner.ts +2 -2
  172. package/src/core/resources/sampler.ts +3 -2
  173. package/src/core/resources/service-status.ts +6 -35
  174. package/src/core/resources/service.ts +23 -133
  175. package/src/core/resources/status.ts +3 -2
  176. package/src/core/semantic/service.ts +8 -2
  177. package/src/core/servers/index.ts +86 -228
  178. package/src/core/servers/tunnels.ts +3 -55
  179. package/src/core/storage/durable-history.ts +52 -20
  180. package/src/core/storage/segments.ts +79 -17
  181. package/src/core/supervisor/service.ts +33 -155
  182. package/src/core/supervisor/services.ts +2 -2
  183. package/src/core/supervisor/status.ts +10 -85
  184. package/src/core/work/state.ts +7 -7
  185. package/src/core/workflow/engine.ts +22 -74
  186. package/src/core/workflow/index.ts +2 -13
  187. package/src/core/workflow/live-session-v3.ts +5 -146
  188. package/src/core/workflow/proof.ts +40 -104
  189. package/src/core/workflow/resume-lock.ts +179 -0
  190. package/src/core/workflow/run-state.ts +3 -207
  191. package/src/core/workflow/spawn-claude.ts +0 -18
  192. package/src/core/workflow/spawn-codex.ts +0 -13
  193. package/src/core/workflow/spawn-cursor.ts +0 -18
  194. package/src/core/workflow/spawn-opencode.ts +0 -14
  195. package/src/core/workflow/types.ts +11 -41
  196. package/src/core/workflow/workspaces/leases.ts +1 -1
  197. package/src/core/workflow/workspaces/local-git.ts +120 -239
  198. package/src/core/workflow/workspaces/ownership.ts +3 -158
  199. package/src/core/workflow/workspaces/reclaim.ts +3 -9
  200. package/src/core/workflow/workspaces/recovery.ts +1 -1
  201. package/src/core/workflow/workspaces/state.ts +1 -5
  202. package/src/lib/identities/assume.ts +0 -4
  203. package/src/lib/tunnel/state.ts +15 -70
  204. package/dist/commands/turn-rollback.d.ts +0 -5
  205. package/dist/commands/turn-rollback.d.ts.map +0 -1
  206. package/dist/commands/turn-rollback.js +0 -76
  207. package/dist/core/agents/state/process-handle.d.ts +0 -26
  208. package/dist/core/agents/state/process-handle.d.ts.map +0 -1
  209. package/dist/core/agents/state/process-handle.js +0 -121
  210. package/dist/core/agents/state/unchanged-file.d.ts +0 -44
  211. package/dist/core/agents/state/unchanged-file.d.ts.map +0 -1
  212. package/dist/core/agents/state/unchanged-file.js +0 -390
  213. package/dist/core/events/v3/generation-custody.d.ts +0 -5
  214. package/dist/core/events/v3/generation-custody.d.ts.map +0 -1
  215. package/dist/core/events/v3/generation-custody.js +0 -50
  216. package/dist/core/turn-rollback/content.d.ts +0 -53
  217. package/dist/core/turn-rollback/content.d.ts.map +0 -1
  218. package/dist/core/turn-rollback/content.js +0 -396
  219. package/dist/core/turn-rollback/index.d.ts +0 -72
  220. package/dist/core/turn-rollback/index.d.ts.map +0 -1
  221. package/dist/core/turn-rollback/index.js +0 -443
  222. package/dist/core/workflow/failure-evidence.d.ts +0 -16
  223. package/dist/core/workflow/failure-evidence.d.ts.map +0 -1
  224. package/dist/core/workflow/failure-evidence.js +0 -114
  225. package/dist/core/workflow/recovery-audit.d.ts +0 -30
  226. package/dist/core/workflow/recovery-audit.d.ts.map +0 -1
  227. package/dist/core/workflow/recovery-audit.js +0 -116
  228. package/src/commands/turn-rollback.ts +0 -111
  229. package/src/core/agents/state/process-handle.ts +0 -165
  230. package/src/core/agents/state/unchanged-file.ts +0 -456
  231. package/src/core/events/v3/generation-custody.ts +0 -59
  232. package/src/core/turn-rollback/content.ts +0 -499
  233. package/src/core/turn-rollback/index.ts +0 -580
  234. package/src/core/workflow/failure-evidence.ts +0 -141
  235. package/src/core/workflow/recovery-audit.ts +0 -181
@@ -1 +1 @@
1
- {"version":3,"file":"workflow.d.ts","sourceRoot":"","sources":["../../src/commands/workflow.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAmFnD,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,WAAW,GAAG,IAAI,CAqyBjF"}
1
+ {"version":3,"file":"workflow.d.ts","sourceRoot":"","sources":["../../src/commands/workflow.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AA2EnD,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,WAAW,GAAG,IAAI,CA2vBjF"}
@@ -475,9 +475,7 @@ export function registerWorkflowCommand(program, emit) {
475
475
  .description("Preview reclaim of an inactive owned workspace, or confirm salvage or discard and release.")
476
476
  .option("--yes", "Confirm that this commits or discards uncommitted work, then releases")
477
477
  .option("--discard", "Throw the uncommitted work away instead of salvaging it")
478
- .option("--unknown-liveness <sha256>", "Recover unknown evidence pinned by the preview digest; active evidence still refuses")
479
- .option("--actor <id>", "Actor responsible for an audited recovery")
480
- .option("--reason <text>", "Reason for an audited recovery")
478
+ .option("--force", "With --yes, admit missing or corrupt liveness evidence (active evidence still refuses) and record it")
481
479
  .option("--json", "Emit the reclaim preview or confirmed result as JSON")
482
480
  .action(async (runId, opts) => {
483
481
  const coordRoot = resolveCoordRoot();
@@ -502,13 +500,7 @@ export function registerWorkflowCommand(program, emit) {
502
500
  const result = await provider.reclaim(binding, {
503
501
  mode: opts.discard ? "discard" : "salvage",
504
502
  yes: opts.yes,
505
- unknownLiveness: opts.unknownLiveness
506
- ? {
507
- evidenceSha256: opts.unknownLiveness,
508
- actor: opts.actor,
509
- reason: opts.reason,
510
- }
511
- : undefined,
503
+ force: opts.force,
512
504
  });
513
505
  if (opts.json) {
514
506
  emit.config({ format: "json" });
@@ -519,11 +511,13 @@ export function registerWorkflowCommand(program, emit) {
519
511
  const holders = result.lease_holder.map((holder) => `${holder.scope}: ${holder.owner_id ?? "unknown"}${holder.pid ? ` (pid ${holder.pid})` : ""}${holder.detail ? `; ${holder.detail}` : ""}`);
520
512
  emit.text(`reclaim preview: ${result.run_id}\n` +
521
513
  `mode: ${result.mode}\nliveness: ${result.liveness}\nownership: ${result.ownership}\n` +
522
- `evidence sha256: ${result.evidence_sha256}\n` +
523
514
  `lease holder: ${holders.length > 0 ? holders.join(", ") : "none observed"}\n` +
524
515
  `dirty paths: ${result.dirty_paths === null ? "unknown" : result.dirty_paths.length > 0 ? result.dirty_paths.join(", ") : "none"}\n` +
525
516
  (result.ownership_detail ? `ownership detail: ${result.ownership_detail}\n` : "") +
526
- `Pass --yes to confirm ${result.mode} and release after all checks pass.\n`);
517
+ `Pass --yes to confirm ${result.mode} and release after all checks pass.\n` +
518
+ (result.liveness === "unknown"
519
+ ? "Liveness is unknown; add --force with --yes only if the run is known to be stopped.\n"
520
+ : ""));
527
521
  return;
528
522
  }
529
523
  emit.text(`reclaim ${result.preparation.action}: ${result.preparation.detail}\n` +
@@ -539,39 +533,6 @@ export function registerWorkflowCommand(program, emit) {
539
533
  process.exit(1);
540
534
  }
541
535
  });
542
- workflow
543
- .command("unlock <run-id>")
544
- .description("Preview or explicitly retire one exact resume lock whose local owner is proven dead.")
545
- .option("--lock-sha256 <sha256>", "Exact lock identity digest returned by the preview")
546
- .option("--actor <id>", "Actor responsible for the recovery")
547
- .option("--reason <text>", "Reason for the recovery")
548
- .option("--yes", "Confirm removal after dead-owner and exact-lock checks")
549
- .option("--json", "Emit the recovery preview or result as JSON")
550
- .action(async (runId, opts) => {
551
- try {
552
- const coordRoot = resolveCoordRoot();
553
- if (!coordRoot)
554
- throw new Error("no .harnery/ coordination root found");
555
- const { recoverWorkflowResumeLease } = await import("../core/workflow/index.js");
556
- const result = recoverWorkflowResumeLease(coordRoot, runId, opts);
557
- if (opts.json) {
558
- emit.config({ format: "json" });
559
- emit.data(result);
560
- return;
561
- }
562
- emit.text(`resume lock ${result.action}: ${runId}\nowner: ${result.owner_state}\nlock sha256: ${result.lock_sha256 ?? "absent"}\n` +
563
- (result.action === "preview"
564
- ? "Pass --lock-sha256, --actor, --reason and --yes to confirm exact dead-owner recovery.\n"
565
- : `recovery: ${result.recovery_id}\n`));
566
- }
567
- catch (error) {
568
- emit.error({
569
- code: "workflow_resume_unlock_failed",
570
- message: error instanceof Error ? error.message : String(error),
571
- });
572
- process.exit(1);
573
- }
574
- });
575
536
  const approvals = program
576
537
  .command("approval")
577
538
  .description("Inspect and resolve durable run-policy approvals.");
@@ -1 +1 @@
1
- {"version":3,"file":"coord-client.d.ts","sourceRoot":"","sources":["../../../src/core/agents/coord-client.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAeH;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAWhE;AAED,wBA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yBA;AAyBD,sFAAsF;AACtF;;;;;;;GAOG;AACH,wBAAgB,sBAAsB,IAAI,MAAM,GAAG,IAAI,CAEtD;AAuCD;;;;;;;GAOG;AACH,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAEpE;AAED;;;;;;GAMG;AACH,wBAAgB,gCAAgC,CAC9C,IAAI,EAAE,MAAM,GACX;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,EAAE,CAAA;CAAE,GAAG,IAAI,CAmB9C;AAED;;;;;;GAMG;AACH,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAOpE"}
@@ -251,25 +251,7 @@ export function parsePidmapRowStartToken(row) {
251
251
  * a test can hold this one against `processStartToken` and fail on drift.
252
252
  */
253
253
  export function pidStartToken(pid) {
254
- if (!Number.isInteger(pid) || pid <= 0)
255
- return null;
256
254
  const forced = process.env.HARNERY_PID_PROBE;
257
- if (process.platform === "win32" && forced !== "procfs" && forced !== "ps") {
258
- try {
259
- const out = spawnSync("powershell.exe", [
260
- "-NoLogo",
261
- "-NoProfile",
262
- "-NonInteractive",
263
- "-Command",
264
- `$process = [Diagnostics.Process]::GetProcessById(${pid}); try { 'w' + $process.StartTime.ToFileTimeUtc().ToString([Globalization.CultureInfo]::InvariantCulture) } finally { $process.Dispose() }`,
265
- ], { encoding: "utf8", timeout: 10_000, windowsHide: true });
266
- const token = String(out.stdout ?? "").trim();
267
- return out.status === 0 && /^w\d+$/.test(token) ? token : null;
268
- }
269
- catch {
270
- return null;
271
- }
272
- }
273
255
  const useProcfs = forced === "procfs" || (forced !== "ps" && existsSync("/proc/self/stat"));
274
256
  // One machine, one probe. Falling back to the other on a read failure would
275
257
  // answer in the wrong dialect and read as a recycled pid.
@@ -38,7 +38,6 @@ interface LiveAuthorityBaseV3 {
38
38
  nativeSessionId: string;
39
39
  adapter: Adapter;
40
40
  observationId?: string;
41
- expectedGenerationId?: `gen_${string}`;
42
41
  }
43
42
  /**
44
43
  * Establish the missing generation authority for one adapter-native session,
@@ -1 +1 @@
1
- {"version":3,"file":"live-authority-v3.d.ts","sourceRoot":"","sources":["../../../src/core/agents/live-authority-v3.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAI7C,OAAO,EAAE,KAAK,gBAAgB,EAA2B,MAAM,yBAAyB,CAAC;AAgBzF,OAAO,EACL,KAAK,mCAAmC,EAEzC,MAAM,iDAAiD,CAAC;AASzD,OAAO,EAEL,KAAK,SAAS,EAMf,MAAM,6BAA6B,CAAC;AAQrC,eAAO,MAAM,gCAAgC,EAAG,iBAA0B,CAAC;AAE3E,qBAAa,gCAAiC,SAAQ,KAAK;aAC7B,MAAM,EAAE,MAAM;gBAAd,MAAM,EAAE,MAAM;CAI3C;AAED,MAAM,MAAM,iCAAiC,GACzC;IAAE,KAAK,EAAE,WAAW,CAAA;CAAE,GACtB;IAAE,KAAK,EAAE,UAAU,CAAC;IAAC,MAAM,EAAE,mCAAmC,CAAA;CAAE,CAAC;AAEvE,MAAM,WAAW,oCAAoC;IACnD,KAAK,EAAE,UAAU,CAAC;IAClB,OAAO,EAAE,OAAO,CAAC;IACjB,mBAAmB,EAAE,OAAO,MAAM,EAAE,CAAC;IACrC,aAAa,EAAE,OAAO,MAAM,EAAE,CAAC;CAChC;AAED,MAAM,WAAW,uCAAuC;IACtD,KAAK,EAAE,SAAS,GAAG,QAAQ,CAAC;IAC5B,OAAO,EAAE,OAAO,CAAC;IACjB,aAAa,EAAE,OAAO,MAAM,EAAE,CAAC;IAC/B,SAAS,EAAE,SAAS,CAAC;CACtB;AAED,MAAM,WAAW,+BAA+B;IAC9C,KAAK,EAAE,WAAW,GAAG,UAAU,CAAC;IAChC,IAAI,EAAE,OAAO,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,OAAO,CAAC;CACpB;AAED,UA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AAkC,CAAC,KAAK,EAAE;IACxD,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,eAAe,EAAE,MAAM,CAAC;CACzB,GAAG,oCAAoC,CAqDvC;AAED,wBAAgB,sBAAsB,CACpC,KAAK,EAAE,mBAAmB,GAAG;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,GAC5C,iCAAiC,CAiCnC;AAED,wBAAgB,2BAA2B,CACzC,KAAK,EAAE,mBAAmB,GAAG;IAC3B,KAAK,EAAE,QAAQ,GAAG,SAAS,GAAG,MAAM,CAAC;IACrC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,GACA,iCAAiC,CAoCnC;AAED,wBAAgB,uBAAuB,CACrC,KAAK,EAAE,mBAAmB,GAAG;IAC3B,SAAS,EAAE,UAAU,GAAG,UAAU,CAAC;IACnC,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;CAC3B,GACA,iCAAiC,CAwCnC;AAED,wBAAgB,0BAA0B,CACxC,KAAK,EAAE,mBAAmB,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAAE,GAChE,iCAAiC,CAwBnC;AAuDD,wBAAgB,2BAA2B,CAAC,SAAS,EAAE,MAAM,GAAG,gBAAgB,CAI/E;AAaD,wBAAgB,kCAAkC,CAAC,SAAS,EAAE,SAAS,GAAG,UAAU,MAAM,EAAE,CAa3F"}
@@ -419,10 +419,6 @@ function recordLiveAuthority(input, signal, observation, expected, desired, appl
419
419
  platform: livePlatformV3(),
420
420
  expected_prior_state_digest: coordinationAuthorityStateDigestV3(expected),
421
421
  desired_state_digest: coordinationAuthorityStateDigestV3(desired),
422
- expected_generation_id: input.expectedGenerationId ??
423
- (subject === input.owner
424
- ? expected.v3_generation_id
425
- : readLiveCoordinationRow(input.coordRoot, input.owner)?.v3_generation_id),
426
422
  reconciler: {
427
423
  readStateDigest: () => {
428
424
  const heartbeat = readHeartbeat(input.coordRoot, subject);
@@ -452,16 +448,9 @@ export function liveCoordinationWriteModeV3(coordRoot) {
452
448
  return route.mode;
453
449
  }
454
450
  function requireHeartbeat(input, owner) {
455
- if (input.expectedGenerationId &&
456
- readLiveCoordinationRow(input.coordRoot, owner)?.v3_generation_id !== input.expectedGenerationId) {
457
- throw new LiveCoordinationAuthorityV3Error("expected_generation_changed");
458
- }
459
451
  const heartbeat = ensureLiveCoordinationHeartbeat(input.coordRoot, owner, owner === input.owner ? input.nativeSessionId : owner, input.adapter);
460
452
  if (!heartbeat)
461
453
  throw new LiveCoordinationAuthorityV3Error(`heartbeat_missing:${owner}`);
462
- if (input.expectedGenerationId && heartbeat.v3_generation_id !== input.expectedGenerationId) {
463
- throw new LiveCoordinationAuthorityV3Error("expected_generation_changed");
464
- }
465
454
  return heartbeat;
466
455
  }
467
456
  export function coordinationAuthorityStateDigestV3(heartbeat) {
@@ -11,12 +11,10 @@ interface LiveLifecycleObservationBaseV3 {
11
11
  adapter: EventAdapterIdV3;
12
12
  observedAt?: string;
13
13
  }
14
- interface LiveSweepObservationV3Input extends LiveLifecycleObservationBaseV3 {
15
- expectedGenerationId: `gen_${string}` | null;
14
+ export declare function recordLiveSweepObservationV3(input: LiveLifecycleObservationBaseV3 & {
16
15
  observation: "stale_heartbeat" | "killed" | "unparseable_heartbeat" | "missing_timestamp";
17
16
  ageMs: number;
18
- }
19
- export declare function recordLiveSweepObservationV3(input: LiveSweepObservationV3Input): LiveLifecycleObservationV3Result;
17
+ }): LiveLifecycleObservationV3Result;
20
18
  export declare function recordLiveResumeObservationV3(input: LiveLifecycleObservationBaseV3): LiveLifecycleObservationV3Result;
21
19
  export {};
22
20
  //# sourceMappingURL=live-lifecycle-v3.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"live-lifecycle-v3.d.ts","sourceRoot":"","sources":["../../../src/core/agents/live-lifecycle-v3.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAGnE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAC;AAcxD,MAAM,MAAM,gCAAgC,GAAG;IAAE,KAAK,EAAE,UAAU,CAAC;IAAC,KAAK,EAAE,OAAO,CAAA;CAAE,CAAC;AAErF,UAAU,8BAA8B;IACtC,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,eAAe,EAAE,MAAM,CAAC;IACxB,OAAO,EAAE,gBAAgB,CAAC;IAC1B,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,UAAU,2BAA4B,SAAQ,8BAA8B;IAC1E,oBAAoB,EAAE,OAAO,MAAM,EAAE,GAAG,IAAI,CAAC;IAC7C,WAAW,EAAE,iBAAiB,GAAG,QAAQ,GAAG,uBAAuB,GAAG,mBAAmB,CAAC;IAC1F,KAAK,EAAE,MAAM,CAAC;CACf;AAED,wBAAgB,4BAA4B,CAC1C,KAAK,EAAE,2BAA2B,GACjC,gCAAgC,CAqBlC;AAED,wBAAgB,6BAA6B,CAC3C,KAAK,EAAE,8BAA8B,GACpC,gCAAgC,CAalC"}
1
+ {"version":3,"file":"live-lifecycle-v3.d.ts","sourceRoot":"","sources":["../../../src/core/agents/live-lifecycle-v3.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAGnE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAC;AAaxD,MAAM,MAAM,gCAAgC,GAAG;IAAE,KAAK,EAAE,UAAU,CAAC;IAAC,KAAK,EAAE,OAAO,CAAA;CAAE,CAAC;AAErF,UAAU,8BAA8B;IACtC,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,eAAe,EAAE,MAAM,CAAC;IACxB,OAAO,EAAE,gBAAgB,CAAC;IAC1B,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,wBAAgB,4BAA4B,CAC1C,KAAK,EAAE,8BAA8B,GAAG;IACtC,WAAW,EAAE,iBAAiB,GAAG,QAAQ,GAAG,uBAAuB,GAAG,mBAAmB,CAAC;IAC1F,KAAK,EAAE,MAAM,CAAC;CACf,GACA,gCAAgC,CAOlC;AAED,wBAAgB,6BAA6B,CAC3C,KAAK,EAAE,8BAA8B,GACpC,gCAAgC,CAQlC"}
@@ -3,27 +3,17 @@ import { buildEventV3 } from "../events/v3/builder.js";
3
3
  import { normalizeNativeIdV3 } from "../events/v3/canonical.js";
4
4
  import { readEventV3ControlState } from "../events/v3/control.js";
5
5
  import { fingerprintContextV3 } from "../events/v3/fingerprint-keys.js";
6
- import { withGenerationCustodyV3 } from "../events/v3/generation-custody.js";
7
6
  import { liveInstanceIdV3, livePlatformV3, resolveLiveEventLedgerRouteV3, } from "../events/v3/live-routing.js";
8
7
  import { readJoinableHookProducerStateV3 } from "../events/v3/producers/recorder.js";
9
8
  import { writeEventV3 } from "../events/v3/writer.js";
10
9
  import { LiveCoordinationAuthorityV3Error } from "./live-authority-v3.js";
11
10
  import { liveCoordinationAdapterV3 } from "./state/live-coordination-view.js";
12
11
  export function recordLiveSweepObservationV3(input) {
13
- input = { ...input };
14
- // Reject stale observations before preparing durable custody state. The
15
- // in-custody checks cover replacement while acquiring custody and reentry.
16
- requireSweepHookState(input);
17
- return withGenerationCustodyV3(input.coordRoot, [liveInstanceIdV3(input.owner)], () => {
18
- requireSweepHookState(input);
19
- return recordObservation(input, "lifecycle.sweep_observed", {
20
- subject_instance_id: liveInstanceIdV3(input.owner),
21
- observation: input.observation,
22
- provisional: true,
23
- age_ms: Math.max(0, Math.floor(input.ageMs)),
24
- }, () => {
25
- requireSweepHookState(input);
26
- });
12
+ return recordObservation(input, "lifecycle.sweep_observed", {
13
+ subject_instance_id: liveInstanceIdV3(input.owner),
14
+ observation: input.observation,
15
+ provisional: true,
16
+ age_ms: Math.max(0, Math.floor(input.ageMs)),
27
17
  });
28
18
  }
29
19
  export function recordLiveResumeObservationV3(input) {
@@ -33,9 +23,9 @@ export function recordLiveResumeObservationV3(input) {
33
23
  prior_generation_id: hook.generation_id,
34
24
  continuity: "native",
35
25
  evidence_reference: "heartbeat_recreated",
36
- }, () => { });
26
+ });
37
27
  }
38
- function recordObservation(input, eventType, payload, beforeWrite) {
28
+ function recordObservation(input, eventType, payload) {
39
29
  const route = resolveLiveEventLedgerRouteV3(input.coordRoot);
40
30
  if (route.state === "blocked")
41
31
  throw new LiveCoordinationAuthorityV3Error(route.reason);
@@ -83,7 +73,6 @@ function recordObservation(input, eventType, payload, beforeWrite) {
83
73
  monotonic_ns: process.hrtime.bigint().toString(),
84
74
  };
85
75
  const event = buildEventV3(eventType, { ...common, payload });
86
- beforeWrite();
87
76
  const durability = writeEventV3(input.coordRoot, event, {
88
77
  expectedGenesisId: control.genesis.event.payload.genesis_id,
89
78
  });
@@ -92,16 +81,6 @@ function recordObservation(input, eventType, payload, beforeWrite) {
92
81
  }
93
82
  return { state: "recorded", event };
94
83
  }
95
- function requireSweepHookState(input) {
96
- if (typeof input.expectedGenerationId !== "string" ||
97
- !/^gen_[a-zA-Z0-9._-]+$/.test(input.expectedGenerationId)) {
98
- throw new LiveCoordinationAuthorityV3Error("hook_generation_not_joinable");
99
- }
100
- const hook = requireHookState(withAttestedAdapter(input));
101
- if (hook.generation_id !== input.expectedGenerationId) {
102
- throw new LiveCoordinationAuthorityV3Error("expected_generation_changed");
103
- }
104
- }
105
84
  function withAttestedAdapter(input) {
106
85
  const adapter = liveCoordinationAdapterV3(input.coordRoot, input.owner);
107
86
  if (!adapter)
@@ -1 +1 @@
1
- {"version":3,"file":"heartbeat-writer.d.ts","sourceRoot":"","sources":["../../../../src/core/agents/state/heartbeat-writer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAkBH,OAAO,EAAE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,EACjB,UAAU,EAAE,MAAM,EAClB,IAAI,CAAC,EAAE,MAAM,GACZ,SAAS,GAAG,IAAI,CAMlB;AAED;;;;;;;;;GASG;AACH,wBAAgB,yBAAyB,CACvC,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,MAAM,EAClB,IAAI,EAAE,MAAM,GACX,SAAS,GAAG,IAAI,CAOlB;AAED;;;;;;;;GAQG;AACH,wBAAgB,wBAAwB,CACtC,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,MAAM,EAClB,IAAI,EAAE,MAAM,GACX,SAAS,GAAG,IAAI,CAOlB;AAED,wBAAgB,YAAY,CAC1B,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,MAAM,EAClB,IAAI,EAAE,MAAM,GACX,SAAS,GAAG,IAAI,CAQlB;AAED,oFAAoF;AACpF,wBAAgB,YAAY,CAC1B,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,MAAM,EAClB,IAAI,EAAE,MAAM,GACX,SAAS,GAAG,IAAI,CAWlB;AAED,uEAAuE;AACvE,MAAM,WAAW,eAAe;IAC9B,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,eAAe,CAC7B,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,MAAM,GACX,eAAe,EAAE,CA6BnB;AAED,wBAAgB,sBAAsB,CAAC,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CASrF;AAED,wBAAgB,UAAU,CAAC,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,IAAI,CAInF"}
1
+ {"version":3,"file":"heartbeat-writer.d.ts","sourceRoot":"","sources":["../../../../src/core/agents/state/heartbeat-writer.ts"],"names":[],"mappings":"AAAA;;;;;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, unlinkSync, writeFileSync, } from "node:fs";
17
17
  import { dirname, join } from "node:path";
18
- import { assertCurrentGenerationV3, withGenerationCustodyV3, } from "../../events/v3/generation-custody.js";
19
- import { liveInstanceIdV3 } from "../../events/v3/live-routing.js";
20
18
  import { canonicalClaimPath } from "../claim-path.js";
21
19
  import { heartbeatPath, readHeartbeat } from "./heartbeat-reader.js";
22
20
  export { readHeartbeat } from "./heartbeat-reader.js";
@@ -40,16 +38,13 @@ export function setLifecycleCache(coordRoot, instanceId, state, reason, suggeste
40
38
  }));
41
39
  }
42
40
  function mutate(coordRoot, instanceId, fn) {
43
- return withGenerationCustodyV3(coordRoot, [liveInstanceIdV3(instanceId)], () => {
44
- const hb = readHeartbeat(coordRoot, instanceId);
45
- if (!hb)
46
- return null;
47
- const next = fn(hb);
48
- next.last_heartbeat = nowIsoSeconds();
49
- assertCurrentGenerationV3(coordRoot, liveInstanceIdV3(instanceId), hb.v3_generation_id);
50
- atomicWrite(heartbeatPath(coordRoot, instanceId), JSON.stringify(next, null, 2));
51
- return next;
52
- });
41
+ const hb = readHeartbeat(coordRoot, instanceId);
42
+ if (!hb)
43
+ return null;
44
+ const next = fn(hb);
45
+ next.last_heartbeat = nowIsoSeconds();
46
+ atomicWrite(heartbeatPath(coordRoot, instanceId), JSON.stringify(next, null, 2));
47
+ return next;
53
48
  }
54
49
  export function setTask(coordRoot, instanceId, task) {
55
50
  return mutate(coordRoot, instanceId, (hb) => {
@@ -73,16 +68,13 @@ export function setTask(coordRoot, instanceId, task) {
73
68
  }
74
69
  /** Update the disposable identity cache after a canonical V3 attestation. */
75
70
  export function setIdentityCache(coordRoot, instanceId, name, agentId) {
76
- return withGenerationCustodyV3(coordRoot, [liveInstanceIdV3(instanceId)], () => {
77
- const heartbeat = readHeartbeat(coordRoot, instanceId);
78
- if (!heartbeat)
79
- return null;
80
- heartbeat.name = name;
81
- heartbeat.agent_id = agentId;
82
- assertCurrentGenerationV3(coordRoot, liveInstanceIdV3(instanceId), heartbeat.v3_generation_id);
83
- atomicWrite(heartbeatPath(coordRoot, instanceId), JSON.stringify(heartbeat, null, 2));
84
- return heartbeat;
85
- });
71
+ const heartbeat = readHeartbeat(coordRoot, instanceId);
72
+ if (!heartbeat)
73
+ return null;
74
+ heartbeat.name = name;
75
+ heartbeat.agent_id = agentId;
76
+ atomicWrite(heartbeatPath(coordRoot, instanceId), JSON.stringify(heartbeat, null, 2));
77
+ return heartbeat;
86
78
  }
87
79
  /** Restore the pool-assigned display name on a generation that was
88
80
  * materialized before the adapter's normal SessionStart naming path ran.
@@ -256,9 +248,6 @@ export function clearCoordinationCache(coordRoot, instanceId) {
256
248
  }
257
249
  }
258
250
  export function healPidmap(coordRoot, instanceId, pid) {
259
- withGenerationCustodyV3(coordRoot, [liveInstanceIdV3(instanceId)], () => healPidmapUnderCustody(coordRoot, instanceId, pid));
260
- }
261
- function healPidmapUnderCustody(coordRoot, instanceId, pid) {
262
251
  const dir = join(coordRoot, ".harnery", "pid-map");
263
252
  mkdirSync(dir, { recursive: true });
264
253
  const hb = readHeartbeat(coordRoot, instanceId);
@@ -1 +1 @@
1
- {"version":3,"file":"live-coordination-writer.d.ts","sourceRoot":"","sources":["../../../../src/core/agents/state/live-coordination-writer.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAUhD,OAAO,EAAE,KAAK,SAAS,EAAiB,MAAM,uBAAuB,CAAC;AAUtE;;;;;GAKG;AACH,wBAAgB,+BAA+B,CAC7C,SAAS,EAAE,MAAM,EACjB,gBAAgB,EAAE,MAAM,EACxB,eAAe,EAAE,MAAM,EACvB,QAAQ,EAAE,OAAO,EACjB,KAAK,CAAC,EAAE,MAAM,GACb,SAAS,GAAG,IAAI,CASlB;AAED,wFAAwF;AACxF,wBAAgB,+BAA+B,CAC7C,SAAS,EAAE,MAAM,EACjB,gBAAgB,EAAE,MAAM,EACxB,eAAe,EAAE,MAAM,EACvB,OAAO,EAAE,OAAO,EAChB,KAAK,CAAC,EAAE,MAAM,GACb,SAAS,GAAG,IAAI,CASlB"}
1
+ {"version":3,"file":"live-coordination-writer.d.ts","sourceRoot":"","sources":["../../../../src/core/agents/state/live-coordination-writer.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAMhD,OAAO,EAAE,KAAK,SAAS,EAAiB,MAAM,uBAAuB,CAAC;AAUtE;;;;;GAKG;AACH,wBAAgB,+BAA+B,CAC7C,SAAS,EAAE,MAAM,EACjB,gBAAgB,EAAE,MAAM,EACxB,eAAe,EAAE,MAAM,EACvB,QAAQ,EAAE,OAAO,EACjB,KAAK,CAAC,EAAE,MAAM,GACb,SAAS,GAAG,IAAI,CASlB;AAED,wFAAwF;AACxF,wBAAgB,+BAA+B,CAC7C,SAAS,EAAE,MAAM,EACjB,gBAAgB,EAAE,MAAM,EACxB,eAAe,EAAE,MAAM,EACvB,OAAO,EAAE,OAAO,EAChB,KAAK,CAAC,EAAE,MAAM,GACb,SAAS,GAAG,IAAI,CASlB"}
@@ -1,7 +1,6 @@
1
1
  import { mkdirSync, renameSync, writeFileSync } from "node:fs";
2
2
  import { dirname, join } from "node:path";
3
3
  import { readCoordinationViewV3, requireAuthoritySafeCoordinationViewV3, } from "../../events/v3/coordination-view.js";
4
- import { assertCurrentGenerationV3, withGenerationCustodyV3, } from "../../events/v3/generation-custody.js";
5
4
  import { liveInstanceIdV3, resolveLiveEventLedgerRouteV3 } from "../../events/v3/live-routing.js";
6
5
  import { readHeartbeat } from "./heartbeat-reader.js";
7
6
  import { isAdapterV3, isCurrentV3HeartbeatCache, observedAdapterV3, projectHeartbeatV3, } from "./live-coordination-view.js";
@@ -20,9 +19,6 @@ export function repairLiveCoordinationHeartbeat(coordRoot, nativeInstanceId, nat
20
19
  return materializeLiveCoordinationHeartbeat(coordRoot, nativeInstanceId, nativeSessionId, adapter, model, true);
21
20
  }
22
21
  function materializeLiveCoordinationHeartbeat(coordRoot, nativeInstanceId, nativeSessionId, _adapter, model, force) {
23
- return withGenerationCustodyV3(coordRoot, [liveInstanceIdV3(nativeInstanceId)], () => materializeHeartbeatUnderCustody(coordRoot, nativeInstanceId, nativeSessionId, _adapter, model, force));
24
- }
25
- function materializeHeartbeatUnderCustody(coordRoot, nativeInstanceId, nativeSessionId, _adapter, model, force) {
26
22
  const route = resolveLiveEventLedgerRouteV3(coordRoot);
27
23
  if (route.state === "blocked")
28
24
  throw new Error(`event_v3_coordination_view:${route.reason}`);
@@ -89,7 +85,6 @@ function materializeHeartbeatUnderCustody(coordRoot, nativeInstanceId, nativeSes
89
85
  v3_projection_event_id: generation.last_event_id,
90
86
  v3_task_state: generation.task_state === "set" ? "set" : "cleared",
91
87
  };
92
- assertCurrentGenerationV3(coordRoot, liveInstanceIdV3(nativeInstanceId), generation.generation_id);
93
88
  writeHeartbeatCache(coordRoot, nativeInstanceId, materialized);
94
89
  return materialized;
95
90
  }
@@ -1 +1 @@
1
- {"version":3,"file":"pidmap.d.ts","sourceRoot":"","sources":["../../../../src/core/agents/state/pidmap.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AA2BH,6EAA6E;AAC7E,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG;IAC3C,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,GAAG,SAAS,CAAC;CAChC,CAGA;AAwCD;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CA8B7D;AAED,wBAAgB,cAAc,CAC5B,SAAS,EAAE,MAAM,EACjB,GAAG,EAAE,MAAM,EACX,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,MAAM,GACf,IAAI,CAIN;AAsCD;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAAC,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAmBjF;AAED,yFAAyF;AACzF,wBAAgB,2BAA2B,CAAC,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM,CAoBzF"}
1
+ {"version":3,"file":"pidmap.d.ts","sourceRoot":"","sources":["../../../../src/core/agents/state/pidmap.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAyBH,6EAA6E;AAC7E,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG;IAC3C,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,GAAG,SAAS,CAAC;CAChC,CAGA;AAwCD;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CA8B7D;AAED,wBAAgB,cAAc,CAC5B,SAAS,EAAE,MAAM,EACjB,GAAG,EAAE,MAAM,EACX,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,MAAM,GACf,IAAI,CA6BN;AAED;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAAC,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAmBjF;AAED,yFAAyF;AACzF,wBAAgB,2BAA2B,CAAC,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM,CAoBzF"}
@@ -15,9 +15,7 @@
15
15
  */
16
16
  import { existsSync, mkdirSync, readdirSync, readFileSync, renameSync, unlinkSync, writeFileSync, } from "node:fs";
17
17
  import { dirname, join } from "node:path";
18
- import { withGenerationCustodyV3 } from "../../events/v3/generation-custody.js";
19
- import { liveInstanceIdV3 } from "../../events/v3/live-routing.js";
20
- import { checkPidToken, processStartToken } from "./proc-start.js";
18
+ import { processStartToken, verifyProcessGeneration } from "./proc-start.js";
21
19
  /**
22
20
  * Row count that triggers a dead-row sweep on the next write.
23
21
  *
@@ -46,7 +44,7 @@ export function parsePidmapRow(row) {
46
44
  function rowStillNamesItsProcess(pid, startToken) {
47
45
  if (!pidIsAlive(pid))
48
46
  return false;
49
- return checkPidToken(pid, startToken) !== "mismatch";
47
+ return verifyProcessGeneration(pid, startToken) !== "different";
50
48
  }
51
49
  function atomicWrite(path, content) {
52
50
  mkdirSync(dirname(path), { recursive: true });
@@ -112,9 +110,6 @@ export function prunePidmapDeadRows(coordRoot) {
112
110
  return removed;
113
111
  }
114
112
  export function writePidmapRow(coordRoot, pid, instanceId, platform) {
115
- withGenerationCustodyV3(coordRoot, [liveInstanceIdV3(instanceId)], () => writePidmapRowUnderCustody(coordRoot, pid, instanceId, platform));
116
- }
117
- function writePidmapRowUnderCustody(coordRoot, pid, instanceId, platform) {
118
113
  const dir = join(coordRoot, ".harnery", "pid-map");
119
114
  const path = join(dir, String(pid));
120
115
  // Stamped at write time, when the pid provably belongs to the process we
@@ -30,9 +30,8 @@
30
30
  * through the caller's locale and timezone, so both are pinned; without that,
31
31
  * two callers reading the same live process disagree.
32
32
  */
33
- import { signalProcessWithHandle } from "./process-handle.js";
34
33
  /** Which probe answers "when did this process start?" on this machine. */
35
- export type StartTokenProbe = "procfs" | "ps" | "windows";
34
+ export type StartTokenProbe = "procfs" | "ps";
36
35
  /**
37
36
  * Which probe this machine uses, decided once.
38
37
  *
@@ -50,7 +49,7 @@ export declare function resetStartTokenCaches(): void;
50
49
  * than by splitting the whole line, because comm is the executable name in
51
50
  * parentheses and may itself contain spaces and parens. The boot segment is
52
51
  * dropped rather than faked when the kernel will not name its boot, which
53
- * yields the pre-boot-id shape that `tokensAgree` still accepts.
52
+ * yields the pre-boot-id shape that `verifyProcessGeneration` compares by ticks.
54
53
  */
55
54
  export declare function procfsStartToken(pid: number): string | null;
56
55
  /**
@@ -71,43 +70,33 @@ export declare function psStartToken(pid: number, run?: (pid: number) => {
71
70
  export declare function processStartToken(pid: number): string | null;
72
71
  export type ProcessGenerationVerdict = "same" | "different" | "unknown";
73
72
  type ReadProcessStartToken = (pid: number) => string | null;
74
- /** A missing or unreadable token never establishes process identity. */
73
+ /**
74
+ * Does `pid` still name the run that wrote `recordedToken`?
75
+ *
76
+ * - `"same"`: both tokens present and equal.
77
+ * - `"different"`: the pid was recycled. A liveness check cannot see this,
78
+ * because a recycled pid is alive.
79
+ * - `"unknown"`: a token is missing, malformed, or unreadable. Never treat
80
+ * this as proof of identity.
81
+ *
82
+ * A Linux token written without a boot segment cannot identify a run across
83
+ * reboots, so it is compared on its tick count: a different count proves a
84
+ * different run, and an equal count stays unknown.
85
+ */
75
86
  export declare function verifyProcessGeneration(pid: number, recordedToken: string | null | undefined, readToken?: ReadProcessStartToken): ProcessGenerationVerdict;
76
87
  export interface ProcessGenerationSignalDependencies {
77
88
  readToken?: ReadProcessStartToken;
78
- signalProcess?: typeof signalProcessWithHandle;
89
+ kill?: (pid: number, signal: NodeJS.Signals | number) => unknown;
79
90
  }
80
91
  /**
81
- * Observations may refuse a signal, but only the retained native process handle
82
- * can authorize it. No numeric-PID effect follows the preliminary token read.
92
+ * Recheck the process generation immediately before sending the signal.
93
+ *
94
+ * The process can still exit and its PID can be reused between the token read
95
+ * and the signal. Eliminating that race requires a generation-bound OS handle.
83
96
  */
84
97
  export declare function signalIfSameGeneration(pid: number, recordedToken: string | null | undefined, signal: NodeJS.Signals | number, dependencies?: ProcessGenerationSignalDependencies): {
85
98
  sent: boolean;
86
99
  verdict: ProcessGenerationVerdict;
87
100
  };
88
- /**
89
- * Do two tokens describe the same run?
90
- *
91
- * Equality, plus one concession: a row written before tokens carried a boot
92
- * segment recorded the tick count alone, so it is compared on the part it
93
- * actually recorded. Refusing that would call every pre-upgrade row a recycled
94
- * pid and prune a working machine's live rows the first time the new code ran.
95
- * Such a row loses its reboot protection until the next write rewrites it,
96
- * which is a strictly better position than the one it came from.
97
- */
98
- export declare function tokensAgree(recorded: string, current: string): boolean;
99
- /**
100
- * Does `pid` still name the process a row recorded?
101
- *
102
- * Three answers, and the difference between the last two matters:
103
- *
104
- * - `"match"` — recorded token, current token, same run. The row is trustworthy.
105
- * - `"mismatch"` — both present and different. The pid was recycled. This is
106
- * the case a liveness check cannot see, because a recycled pid is alive.
107
- * - `"unverified"` — no recorded token (a row written before tokens existed) or
108
- * no current one (an unsupported platform). Callers treat this the way they
109
- * treated every row previously: trust it if the pid is alive.
110
- */
111
- export declare function checkPidToken(pid: number, recorded: string | undefined): "match" | "mismatch" | "unverified";
112
101
  export {};
113
102
  //# sourceMappingURL=proc-start.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"proc-start.d.ts","sourceRoot":"","sources":["../../../../src/core/agents/state/proc-start.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAKH,OAAO,EAAE,uBAAuB,EAA4B,MAAM,qBAAqB,CAAC;AAExF,0EAA0E;AAC1E,MAAM,MAAM,eAAe,GAAG,QAAQ,GAAG,IAAI,GAAG,SAAS,CAAC;AAc1D;;;;;;GAMG;AACH,wBAAgB,eAAe,IAAI,eAAe,CAQjD;AAyBD,uDAAuD;AACvD,wBAAgB,qBAAqB,IAAI,IAAI,CAG5C;AAED;;;;;;;;GAQG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAc3D;AAED;;;;;;GAMG;AACH,wBAAgB,YAAY,CAC1B,GAAG,EAAE,MAAM,EACX,GAAG,GAAE,CAAC,GAAG,EAAE,MAAM,KAAK;IAAE,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAiB,GAC7E,MAAM,GAAG,IAAI,CAUf;AAWD;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAQ5D;AAED,MAAM,MAAM,wBAAwB,GAAG,MAAM,GAAG,WAAW,GAAG,SAAS,CAAC;AAExE,KAAK,qBAAqB,GAAG,CAAC,GAAG,EAAE,MAAM,KAAK,MAAM,GAAG,IAAI,CAAC;AAE5D,wEAAwE;AAC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