@telora/daemon 0.22.144 → 0.22.160

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 (252) hide show
  1. package/build-info.json +8 -3
  2. package/dist/audit/audit-phase.d.ts +34 -1
  3. package/dist/audit/audit-phase.d.ts.map +1 -1
  4. package/dist/audit/audit-phase.js +77 -9
  5. package/dist/audit/audit-phase.js.map +1 -1
  6. package/dist/backends/codex/codex-mcp-proxy.d.ts +4 -6
  7. package/dist/backends/codex/codex-mcp-proxy.d.ts.map +1 -1
  8. package/dist/backends/codex/codex-mcp-proxy.js.map +1 -1
  9. package/dist/backends/codex/mcp-preflight.d.ts +2 -2
  10. package/dist/backends/codex/mcp-preflight.d.ts.map +1 -1
  11. package/dist/backends/codex/mcp-preflight.js.map +1 -1
  12. package/dist/completion/completion-phase-registry.d.ts +1 -0
  13. package/dist/completion/completion-phase-registry.d.ts.map +1 -1
  14. package/dist/completion/completion-phase-registry.js +7 -5
  15. package/dist/completion/completion-phase-registry.js.map +1 -1
  16. package/dist/completion/escalation-provenance.d.ts.map +1 -1
  17. package/dist/completion/escalation-provenance.js +5 -2
  18. package/dist/completion/escalation-provenance.js.map +1 -1
  19. package/dist/completion/exit-classification.d.ts +1 -1
  20. package/dist/completion/exit-classification.d.ts.map +1 -1
  21. package/dist/completion/exit-classification.js +7 -1
  22. package/dist/completion/exit-classification.js.map +1 -1
  23. package/dist/completion/review-cycle-cap.d.ts +81 -35
  24. package/dist/completion/review-cycle-cap.d.ts.map +1 -1
  25. package/dist/completion/review-cycle-cap.js +60 -132
  26. package/dist/completion/review-cycle-cap.js.map +1 -1
  27. package/dist/completion/review-exit-deps.d.ts +3 -1
  28. package/dist/completion/review-exit-deps.d.ts.map +1 -1
  29. package/dist/completion/review-exit-deps.js +3 -1
  30. package/dist/completion/review-exit-deps.js.map +1 -1
  31. package/dist/completion/review-exit-phase.d.ts.map +1 -1
  32. package/dist/completion/review-exit-phase.js +5 -4
  33. package/dist/completion/review-exit-phase.js.map +1 -1
  34. package/dist/completion/state-cascade.d.ts.map +1 -1
  35. package/dist/completion/state-cascade.js +3 -7
  36. package/dist/completion/state-cascade.js.map +1 -1
  37. package/dist/delivery/delivery-review-coverage.d.ts +16 -0
  38. package/dist/delivery/delivery-review-coverage.d.ts.map +1 -1
  39. package/dist/delivery/delivery-review-coverage.js +16 -0
  40. package/dist/delivery/delivery-review-coverage.js.map +1 -1
  41. package/dist/focus/focus-engine.d.ts +16 -0
  42. package/dist/focus/focus-engine.d.ts.map +1 -1
  43. package/dist/focus/focus-engine.js +37 -17
  44. package/dist/focus/focus-engine.js.map +1 -1
  45. package/dist/focus/focus-executor.d.ts.map +1 -1
  46. package/dist/focus/focus-executor.js +7 -0
  47. package/dist/focus/focus-executor.js.map +1 -1
  48. package/dist/focus/focus-spawn-decision.d.ts +5 -3
  49. package/dist/focus/focus-spawn-decision.d.ts.map +1 -1
  50. package/dist/focus/focus-spawn-decision.js.map +1 -1
  51. package/dist/focus/listener-spawn.d.ts.map +1 -1
  52. package/dist/focus/listener-spawn.js +4 -3
  53. package/dist/focus/listener-spawn.js.map +1 -1
  54. package/dist/focus/listener.d.ts +15 -0
  55. package/dist/focus/listener.d.ts.map +1 -1
  56. package/dist/focus/listener.js +58 -9
  57. package/dist/focus/listener.js.map +1 -1
  58. package/dist/focus/review-cycle-cap-hold.d.ts +15 -94
  59. package/dist/focus/review-cycle-cap-hold.d.ts.map +1 -1
  60. package/dist/focus/review-cycle-cap-hold.js +54 -112
  61. package/dist/focus/review-cycle-cap-hold.js.map +1 -1
  62. package/dist/focus/session-health.d.ts +22 -1
  63. package/dist/focus/session-health.d.ts.map +1 -1
  64. package/dist/focus/session-health.js +28 -3
  65. package/dist/focus/session-health.js.map +1 -1
  66. package/dist/focus/session-process-reap.d.ts +3 -1
  67. package/dist/focus/session-process-reap.d.ts.map +1 -1
  68. package/dist/focus/session-process-reap.js +20 -0
  69. package/dist/focus/session-process-reap.js.map +1 -1
  70. package/dist/focus-stage-lifecycle/index.d.ts.map +1 -1
  71. package/dist/focus-stage-lifecycle/index.js +1 -0
  72. package/dist/focus-stage-lifecycle/index.js.map +1 -1
  73. package/dist/focus-stage-lifecycle/wedge-watchdog.d.ts +10 -0
  74. package/dist/focus-stage-lifecycle/wedge-watchdog.d.ts.map +1 -1
  75. package/dist/focus-stage-lifecycle/wedge-watchdog.js +27 -3
  76. package/dist/focus-stage-lifecycle/wedge-watchdog.js.map +1 -1
  77. package/dist/git/focus-integration-sync.d.ts +42 -3
  78. package/dist/git/focus-integration-sync.d.ts.map +1 -1
  79. package/dist/git/focus-integration-sync.js +38 -2
  80. package/dist/git/focus-integration-sync.js.map +1 -1
  81. package/dist/merge/abandoned-merge-recovery.d.ts.map +1 -1
  82. package/dist/merge/abandoned-merge-recovery.js +10 -0
  83. package/dist/merge/abandoned-merge-recovery.js.map +1 -1
  84. package/dist/merge/merge-back-loop.d.ts +1 -0
  85. package/dist/merge/merge-back-loop.d.ts.map +1 -1
  86. package/dist/merge/merge-back-loop.js +3 -3
  87. package/dist/merge/merge-back-loop.js.map +1 -1
  88. package/dist/prompt/team-prompt-base.d.ts +2 -1
  89. package/dist/prompt/team-prompt-base.d.ts.map +1 -1
  90. package/dist/prompt/team-prompt-base.js +5 -19
  91. package/dist/prompt/team-prompt-base.js.map +1 -1
  92. package/dist/prompt-sections/integration-reconcile-section.d.ts +45 -0
  93. package/dist/prompt-sections/integration-reconcile-section.d.ts.map +1 -0
  94. package/dist/prompt-sections/integration-reconcile-section.js +69 -0
  95. package/dist/prompt-sections/integration-reconcile-section.js.map +1 -0
  96. package/dist/prompt-sections/persona-sections.d.ts +0 -20
  97. package/dist/prompt-sections/persona-sections.d.ts.map +1 -1
  98. package/dist/prompt-sections/persona-sections.js +4 -49
  99. package/dist/prompt-sections/persona-sections.js.map +1 -1
  100. package/dist/prompt-sections/testing-standard.d.ts +51 -0
  101. package/dist/prompt-sections/testing-standard.d.ts.map +1 -0
  102. package/dist/prompt-sections/testing-standard.js +132 -0
  103. package/dist/prompt-sections/testing-standard.js.map +1 -0
  104. package/dist/queries/agent-resolvable-promotion.d.ts.map +1 -1
  105. package/dist/queries/agent-resolvable-promotion.js +7 -5
  106. package/dist/queries/agent-resolvable-promotion.js.map +1 -1
  107. package/dist/queries/ended-arm.d.ts +47 -0
  108. package/dist/queries/ended-arm.d.ts.map +1 -0
  109. package/dist/queries/ended-arm.js +35 -0
  110. package/dist/queries/ended-arm.js.map +1 -0
  111. package/dist/queries/escalation-consumption.d.ts.map +1 -1
  112. package/dist/queries/escalation-consumption.js +0 -1
  113. package/dist/queries/escalation-consumption.js.map +1 -1
  114. package/dist/queries/focus-discovery.d.ts +14 -0
  115. package/dist/queries/focus-discovery.d.ts.map +1 -1
  116. package/dist/queries/focus-discovery.js +1 -0
  117. package/dist/queries/focus-discovery.js.map +1 -1
  118. package/dist/queries/focus-integration-conflict.d.ts +78 -0
  119. package/dist/queries/focus-integration-conflict.d.ts.map +1 -0
  120. package/dist/queries/focus-integration-conflict.js +136 -0
  121. package/dist/queries/focus-integration-conflict.js.map +1 -0
  122. package/dist/queries/focuses.d.ts +6 -3
  123. package/dist/queries/focuses.d.ts.map +1 -1
  124. package/dist/queries/focuses.js +13 -5
  125. package/dist/queries/focuses.js.map +1 -1
  126. package/dist/queries/incident-correlation.d.ts +1 -2
  127. package/dist/queries/incident-correlation.d.ts.map +1 -1
  128. package/dist/queries/incident-correlation.js +1 -3
  129. package/dist/queries/incident-correlation.js.map +1 -1
  130. package/dist/queries/local-models.js +1 -1
  131. package/dist/queries/local-models.js.map +1 -1
  132. package/dist/queries/schemas-local-model.d.ts +47 -0
  133. package/dist/queries/schemas-local-model.d.ts.map +1 -0
  134. package/dist/queries/schemas-local-model.js +57 -0
  135. package/dist/queries/schemas-local-model.js.map +1 -0
  136. package/dist/queries/schemas.d.ts +10 -32
  137. package/dist/queries/schemas.d.ts.map +1 -1
  138. package/dist/queries/schemas.js +10 -41
  139. package/dist/queries/schemas.js.map +1 -1
  140. package/dist/queries/sessions.d.ts +120 -12
  141. package/dist/queries/sessions.d.ts.map +1 -1
  142. package/dist/queries/sessions.js +104 -11
  143. package/dist/queries/sessions.js.map +1 -1
  144. package/dist/queries/shared.d.ts +1 -0
  145. package/dist/queries/shared.d.ts.map +1 -1
  146. package/dist/queries/shared.js +1 -1
  147. package/dist/queries/shared.js.map +1 -1
  148. package/dist/queries/system-session.d.ts.map +1 -1
  149. package/dist/queries/system-session.js +3 -1
  150. package/dist/queries/system-session.js.map +1 -1
  151. package/dist/resolvers/assembly-engine.d.ts +71 -1
  152. package/dist/resolvers/assembly-engine.d.ts.map +1 -1
  153. package/dist/resolvers/assembly-engine.js +82 -43
  154. package/dist/resolvers/assembly-engine.js.map +1 -1
  155. package/dist/resolvers/branch-work-arming.d.ts +133 -0
  156. package/dist/resolvers/branch-work-arming.d.ts.map +1 -0
  157. package/dist/resolvers/branch-work-arming.js +67 -0
  158. package/dist/resolvers/branch-work-arming.js.map +1 -0
  159. package/dist/resolvers/focus-review-coverage.d.ts.map +1 -1
  160. package/dist/resolvers/focus-review-coverage.js +31 -2
  161. package/dist/resolvers/focus-review-coverage.js.map +1 -1
  162. package/dist/resolvers/wiki-topic.d.ts +6 -5
  163. package/dist/resolvers/wiki-topic.d.ts.map +1 -1
  164. package/dist/resolvers/wiki-topic.js +43 -27
  165. package/dist/resolvers/wiki-topic.js.map +1 -1
  166. package/dist/session/session-lineage.d.ts.map +1 -1
  167. package/dist/session/session-lineage.js +1 -0
  168. package/dist/session/session-lineage.js.map +1 -1
  169. package/dist/shell/crash-recovery.d.ts +4 -2
  170. package/dist/shell/crash-recovery.d.ts.map +1 -1
  171. package/dist/shell/crash-recovery.js +15 -14
  172. package/dist/shell/crash-recovery.js.map +1 -1
  173. package/dist/shell/daemon-instance.d.ts +176 -0
  174. package/dist/shell/daemon-instance.d.ts.map +1 -0
  175. package/dist/shell/daemon-instance.js +281 -0
  176. package/dist/shell/daemon-instance.js.map +1 -0
  177. package/dist/shell/graceful-shutdown.d.ts +12 -1
  178. package/dist/shell/graceful-shutdown.d.ts.map +1 -1
  179. package/dist/shell/graceful-shutdown.js +7 -4
  180. package/dist/shell/graceful-shutdown.js.map +1 -1
  181. package/dist/shell/shutdown-ownership.d.ts +34 -0
  182. package/dist/shell/shutdown-ownership.d.ts.map +1 -0
  183. package/dist/shell/shutdown-ownership.js +51 -0
  184. package/dist/shell/shutdown-ownership.js.map +1 -0
  185. package/dist/shell/unified-shell.d.ts.map +1 -1
  186. package/dist/shell/unified-shell.js +12 -5
  187. package/dist/shell/unified-shell.js.map +1 -1
  188. package/dist/shell/worker-pidfile.d.ts +127 -11
  189. package/dist/shell/worker-pidfile.d.ts.map +1 -1
  190. package/dist/shell/worker-pidfile.js +349 -58
  191. package/dist/shell/worker-pidfile.js.map +1 -1
  192. package/dist/spawn/lead-launch.d.ts +17 -1
  193. package/dist/spawn/lead-launch.d.ts.map +1 -1
  194. package/dist/spawn/lead-launch.js +56 -7
  195. package/dist/spawn/lead-launch.js.map +1 -1
  196. package/dist/spawn/lead-process-ownership.d.ts +5 -4
  197. package/dist/spawn/lead-process-ownership.d.ts.map +1 -1
  198. package/dist/spawn/lead-process-ownership.js +7 -4
  199. package/dist/spawn/lead-process-ownership.js.map +1 -1
  200. package/dist/spawn/lifecycle.d.ts +0 -12
  201. package/dist/spawn/lifecycle.d.ts.map +1 -1
  202. package/dist/spawn/lifecycle.js +76 -19
  203. package/dist/spawn/lifecycle.js.map +1 -1
  204. package/dist/spawn/liveness.d.ts.map +1 -1
  205. package/dist/spawn/liveness.js +3 -1
  206. package/dist/spawn/liveness.js.map +1 -1
  207. package/dist/spawn/one-shot-process-ownership.d.ts +46 -2
  208. package/dist/spawn/one-shot-process-ownership.d.ts.map +1 -1
  209. package/dist/spawn/one-shot-process-ownership.js +78 -3
  210. package/dist/spawn/one-shot-process-ownership.js.map +1 -1
  211. package/dist/spawn/process-group-kill.d.ts.map +1 -1
  212. package/dist/spawn/process-group-kill.js +3 -1
  213. package/dist/spawn/process-group-kill.js.map +1 -1
  214. package/dist/spawn/process-spawn.d.ts +5 -15
  215. package/dist/spawn/process-spawn.d.ts.map +1 -1
  216. package/dist/spawn/process-spawn.js +2 -1
  217. package/dist/spawn/process-spawn.js.map +1 -1
  218. package/dist/spawn/prompt-assembly.d.ts +27 -2
  219. package/dist/spawn/prompt-assembly.d.ts.map +1 -1
  220. package/dist/spawn/prompt-assembly.js +65 -43
  221. package/dist/spawn/prompt-assembly.js.map +1 -1
  222. package/dist/spawn/worktree-session.d.ts +46 -2
  223. package/dist/spawn/worktree-session.d.ts.map +1 -1
  224. package/dist/spawn/worktree-session.js +57 -4
  225. package/dist/spawn/worktree-session.js.map +1 -1
  226. package/dist/testing/fixtures/conflicting-repo.d.ts +30 -0
  227. package/dist/testing/fixtures/conflicting-repo.d.ts.map +1 -0
  228. package/dist/testing/fixtures/conflicting-repo.js +89 -0
  229. package/dist/testing/fixtures/conflicting-repo.js.map +1 -0
  230. package/dist/testing/fixtures/index.d.ts.map +1 -1
  231. package/dist/testing/fixtures/index.js +2 -1
  232. package/dist/testing/fixtures/index.js.map +1 -1
  233. package/dist/testing/fixtures/pending-spawn-world.js +2 -2
  234. package/dist/testing/fixtures/pending-spawn-world.js.map +1 -1
  235. package/dist/types/exit-category.d.ts +59 -0
  236. package/dist/types/exit-category.d.ts.map +1 -0
  237. package/dist/types/exit-category.js +133 -0
  238. package/dist/types/exit-category.js.map +1 -0
  239. package/dist/types/index.js +1 -1
  240. package/dist/types/session.d.ts +5 -1
  241. package/dist/types/session.d.ts.map +1 -1
  242. package/dist/types/session.js +1 -1
  243. package/dist/types/session.js.map +1 -1
  244. package/dist/verify/stall-detector-config.d.ts +5 -1
  245. package/dist/verify/stall-detector-config.d.ts.map +1 -1
  246. package/dist/verify/stall-detector-config.js +5 -1
  247. package/dist/verify/stall-detector-config.js.map +1 -1
  248. package/dist/worktree/state.d.ts +75 -1
  249. package/dist/worktree/state.d.ts.map +1 -1
  250. package/dist/worktree/state.js +89 -17
  251. package/dist/worktree/state.js.map +1 -1
  252. package/package.json +3 -3
@@ -17,31 +17,89 @@ export interface WorkerPidEntry {
17
17
  startIdentity?: string;
18
18
  /** Epoch ms the entry was recorded. */
19
19
  recordedAt?: number;
20
+ /**
21
+ * A RESERVATION: a lead this daemon is about to spawn, written BEFORE the
22
+ * child exists so the window between `spawn()` and the pid write is not a
23
+ * hole in the record. `pid` is PENDING_PID until the real one lands.
24
+ *
25
+ * A reservation is never signalled (there is no pid to signal) and never
26
+ * discarded by a reap: it is the one state that means "a process may exist
27
+ * and we cannot name it", which every reader must treat as unprovable.
28
+ */
29
+ pending?: true;
30
+ /**
31
+ * The daemon instance that made a reservation (shell/daemon-instance.ts
32
+ * `daemonInstanceId`). Only meaningful with `pending`.
33
+ */
34
+ reservedBy?: string;
20
35
  }
36
+ /** The placeholder pid a reservation carries until the real one is recorded. */
37
+ export declare const PENDING_PID = 0;
21
38
  /** Resolve the worker pidfile path in the global state dir (~/.telora/). */
22
39
  export declare function resolveWorkerPidfilePath(): string;
23
40
  /**
24
- * Read the persisted worker fleet. Tolerant: a missing, unreadable, or
25
- * malformed file returns []. Only well-formed { pid, label } entries with a
26
- * real pid (> 1) survive parsing.
41
+ * Read the persisted fleet, DISTINGUISHING an absent record from an unreadable
42
+ * one. Returns null when the file exists but could not be read or parsed as a
43
+ * fleet -- an EACCES, a truncated write, a hand-edit, anything that is not an
44
+ * array of entries.
45
+ *
46
+ * That distinction is the whole point. The tolerant read below collapses both
47
+ * into [], and a caller asking "was a lead recorded for this session?" then
48
+ * reads a corrupt file as PROOF that nothing was spawned -- which is how a live
49
+ * team's session row gets closed. An absent file is real evidence (no lead was
50
+ * reserved); an unreadable one is not evidence at all.
51
+ *
52
+ * A malformed ELEMENT inside a well-formed array is still dropped: that is one
53
+ * unusable record, not an unreadable file.
54
+ */
55
+ export declare function readWorkerPidfileStrict(path?: string): WorkerPidEntry[] | null;
56
+ /**
57
+ * Read the persisted worker fleet, tolerantly: a missing, unreadable, or
58
+ * malformed file returns []. Kept for the REAP callers, whose worst case on an
59
+ * unreadable file is that they signal nothing. A caller that would treat [] as
60
+ * proof of absence must use {@link readWorkerPidfileStrict} instead.
27
61
  */
28
62
  export declare function readWorkerPidfile(path?: string): WorkerPidEntry[];
63
+ /**
64
+ * The whole file, reservations included. Only for readers that reason ABOUT
65
+ * reservations -- the retention pass and the by-session index. A caller that
66
+ * wants pids wants {@link readWorkerPidfile}.
67
+ */
68
+ export declare function readWorkerPidfileWithReservations(path?: string): WorkerPidEntry[];
29
69
  /**
30
70
  * Record a live team lead with its ownership record (focus, session, start
31
71
  * identity). Idempotent per pid (a re-record replaces the entry). No-op for an
32
72
  * invalid/init pid (<= 1).
33
73
  */
34
- export declare function recordWorkerProcess(entry: WorkerPidEntry, path?: string): void;
74
+ export declare function recordWorkerProcess(entry: WorkerPidEntry, path?: string): boolean;
75
+ /**
76
+ * Reserve a lead record BEFORE the process is spawned.
77
+ *
78
+ * `launchLeadProcess` used to spawn first and record after, so a hard kill (or
79
+ * a failed write) in between left a LIVE detached lead with no record anywhere
80
+ * -- and a reader that takes "no record" for "nothing spawned" then closes that
81
+ * team's session row. Reserving first removes the window: the record exists
82
+ * before the process can, and the caller REFUSES the spawn when this returns
83
+ * false, so a live lead this host cannot name is never created.
84
+ */
85
+ export declare function reserveLeadRecord(reservation: {
86
+ label: string;
87
+ sessionId: string;
88
+ focusId?: string;
89
+ reservedBy: string;
90
+ }, path?: string): boolean;
91
+ /** Drop a reservation whose spawn never produced a process. */
92
+ export declare function releaseLeadReservation(sessionId: string, path?: string): void;
35
93
  /** Remove a lead pid on its exit. No-op when absent. */
36
94
  export declare function removeWorkerPid(pid: number, path?: string): void;
37
- /** Delete the pidfile entirely (graceful shutdown clears it after reaping). */
38
- export declare function clearWorkerPidfile(path?: string): void;
39
95
  /** Injectable seams for {@link reapPersistedWorkerGroups} (test without procs). */
40
96
  export interface ReapPersistedDeps {
41
97
  /** Signal sender. Defaults to process.kill. */
42
98
  kill?: (pid: number, signal: NodeJS.Signals) => void;
43
- /** Liveness probe. Defaults to a kill(pid, 0) existence check. */
99
+ /** Liveness probe. Defaults to a kill(pid, 0) existence check (EPERM counts as alive). */
44
100
  isAlive?: (pid: number) => boolean;
101
+ /** True while any non-zombie member of the lead's process GROUP is alive. */
102
+ isGroupAlive?: (pgid: number) => boolean;
45
103
  /** Live process start identity. Defaults to /proc (null off Linux or for a gone pid). */
46
104
  readStartIdentity?: (pid: number) => string | null;
47
105
  }
@@ -49,8 +107,21 @@ export interface ReapPersistedDeps {
49
107
  export interface ReapPersistedResult {
50
108
  /** Pids that were alive and got a group SIGKILL. */
51
109
  reaped: number[];
52
- /** Pids skipped because they were already dead (or invalid). */
110
+ /** Pids skipped because they were already dead, reserved, or identity-mismatched. */
53
111
  skipped: number[];
112
+ /**
113
+ * Pids that were ALIVE and could not be signalled (EPERM -- another user's
114
+ * process holding our recorded number, or a group we may not touch). They
115
+ * were not reaped, and saying so is the difference between a record that is
116
+ * safe to drop and one that is not.
117
+ */
118
+ unsignalled: number[];
119
+ /**
120
+ * Pids that were ALIVE and whose identity could not be VERIFIED as the lead we
121
+ * recorded (no identity recorded, or none readable now). They are not signalled
122
+ * -- a SIGKILL there could end an unrelated process -- and their records are kept.
123
+ */
124
+ unverified: number[];
54
125
  }
55
126
  /**
56
127
  * Group-SIGKILL every still-alive persisted lead. Because leads are spawned
@@ -61,9 +132,54 @@ export interface ReapPersistedResult {
61
132
  */
62
133
  export declare function reapPersistedWorkerGroups(entries: WorkerPidEntry[], deps?: ReapPersistedDeps): ReapPersistedResult;
63
134
  /**
64
- * Read + reap the persisted fleet, then clear the file. Used by the CLI hard
65
- * stop (after SIGKILLing the daemon) and by the next daemon boot (to reap leads
66
- * a prior hard kill orphaned). Returns the reap result for logging.
135
+ * True when this recorded lead is STILL RUNNING and still the process that was
136
+ * recorded -- alive, and with a start identity that has not changed under it.
137
+ *
138
+ * A pid whose start identity no longer matches was recycled: the recorded lead
139
+ * is gone and an unrelated process now holds its number.
140
+ */
141
+ export declare function recordedLeadStillRunning(entry: WorkerPidEntry, deps?: ReapPersistedDeps): boolean;
142
+ /**
143
+ * Read + reap the persisted fleet, then RETAIN whatever it could not confirm
144
+ * gone. Used by the CLI hard stop (after SIGKILLing the daemon) and by the next
145
+ * daemon boot (to reap leads a prior hard kill orphaned).
146
+ *
147
+ * It used to clear the file unconditionally, which threw away the record of
148
+ * exactly the processes the reap FAILED to end -- a kill that raised EPERM, or
149
+ * a group that outlived SIGKILL. Those survivors are precisely what the next
150
+ * reader needs to know about: crash recovery runs after this and must not close
151
+ * a session row whose team is still running, and with the file cleared it had no
152
+ * way to tell. Retaining until CONFIRMED GONE is also the rule the one-shot
153
+ * ownership records already follow.
154
+ *
155
+ * Returns the reap result for logging.
67
156
  */
68
157
  export declare function reapAndClearWorkerPidfile(path?: string, deps?: ReapPersistedDeps): ReapPersistedResult;
158
+ /**
159
+ * Clear the pidfile ONLY when nothing it records survives.
160
+ *
161
+ * The graceful-stop and auto-update paths cleared it unconditionally, on the
162
+ * reasoning that `reapWorkerFleet` had just ended everything. It has not
163
+ * necessarily: that reap is bounded and best-effort, so a worker that outlived
164
+ * SIGKILL, one that could not be signalled, and a reservation whose spawn is in
165
+ * flight all survive it -- and clearing here erases the record of exactly those,
166
+ * right before a re-exec'd daemon's boot reap would have acted on them.
167
+ *
168
+ * Same rule as {@link reapAndClearWorkerPidfile}: retain until CONFIRMED GONE.
169
+ * Returns the survivors it kept.
170
+ */
171
+ export declare function clearWorkerPidfileIfAllGone(path?: string, deps?: ReapPersistedDeps): WorkerPidEntry[];
172
+ /**
173
+ * The leads this host has a durable record of, by the agent_sessions row each
174
+ * was spawned for. Null when the record cannot be read at all -- which is NOT
175
+ * the same as "no leads": a caller must treat an unreadable record as unknown
176
+ * rather than as proof that nothing is running.
177
+ *
178
+ * This is the correlation crash recovery needs. `launchLeadProcess` writes the
179
+ * record BEFORE `spawnTeamProcess` persists the row's `running` status and pid,
180
+ * so a row still reading `starting` with no pid -- the window a hard kill or a
181
+ * failed API write leaves behind -- is exactly the case where the DB knows
182
+ * nothing and this file knows everything.
183
+ */
184
+ export declare function readLeadRecordsBySession(path?: string): Map<string, WorkerPidEntry> | null;
69
185
  //# sourceMappingURL=worker-pidfile.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"worker-pidfile.d.ts","sourceRoot":"","sources":["../../src/shell/worker-pidfile.ts"],"names":[],"mappings":"AA8CA;;;;;;;GAOG;AACH,MAAM,WAAW,cAAc;IAC7B,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,sCAAsC;IACtC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,yCAAyC;IACzC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,oGAAoG;IACpG,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,uCAAuC;IACvC,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAsBD,4EAA4E;AAC5E,wBAAgB,wBAAwB,IAAI,MAAM,CAEjD;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,GAAE,MAAmC,GAAG,cAAc,EAAE,CAc7F;AAYD;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,cAAc,EAAE,IAAI,GAAE,MAAmC,GAAG,IAAI,CAK1G;AAED,wDAAwD;AACxD,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,GAAE,MAAmC,GAAG,IAAI,CAS5F;AAED,+EAA+E;AAC/E,wBAAgB,kBAAkB,CAAC,IAAI,GAAE,MAAmC,GAAG,IAAI,CAOlF;AAED,mFAAmF;AACnF,MAAM,WAAW,iBAAiB;IAChC,+CAA+C;IAC/C,IAAI,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,OAAO,KAAK,IAAI,CAAC;IACrD,kEAAkE;IAClE,OAAO,C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