@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
@@ -1,11 +1,14 @@
1
1
  // PINNED-BY-BEGIN (generated by gen:pinned-by -- do not hand-edit; checked by lint:pinned-by)
2
2
  // Pinned by: packages/daemon/src/focus/session-health-passes.test.ts,
3
3
  // packages/daemon/src/focus/session-health-poll-sweep.test.ts,
4
- // packages/daemon/src/focus/session-process-reap.test.ts, packages/daemon/src/shell/worker-pidfile.test.ts,
5
- // packages/daemon/src/spawn/lead-launch.test.ts, packages/daemon/src/spawn/lead-process-ownership.test.ts,
4
+ // packages/daemon/src/focus/session-process-reap.test.ts,
5
+ // packages/daemon/src/shell/shutdown-ownership-wiring.test.ts,
6
+ // packages/daemon/src/shell/worker-pidfile.test.ts, packages/daemon/src/spawn/lead-launch.test.ts,
7
+ // packages/daemon/src/spawn/lead-process-ownership.test.ts,
6
8
  // packages/daemon/src/spawn/one-shot-process-ownership.test.ts,
7
9
  // packages/daemon/src/spawn/spawn-team-process-ownership.test.ts,
8
- // packages/daemon/src/spawn/untracked-lead-sweep.test.ts
10
+ // packages/daemon/src/spawn/untracked-lead-sweep.test.ts,
11
+ // packages/daemon/src/worktree/worktree-state.test.ts
9
12
  // PINNED-BY-END
10
13
  /**
11
14
  * Persisted team-lead pid registry -- closes the hard-kill orphan gap.
@@ -28,17 +31,22 @@
28
31
  * (the only closure available for a bare external `kill -9 <daemon>`, which
29
32
  * no in-process handler can intercept).
30
33
  *
31
- * All file ops are best-effort and never throw: a missing/corrupt file yields
32
- * an empty fleet, and a write failure is swallowed (orphan prevention is a
33
- * backstop, never a blocker on the spawn/exit hot path). One daemon per host
34
- * (PID lock) makes read-modify-write races a non-issue.
34
+ * No file op throws. But "never throws" is not "always empty": the REAP paths
35
+ * read tolerantly (their worst case is signalling nothing), while a reader that
36
+ * would treat an empty fleet as PROOF that nothing is running reads through
37
+ * `readWorkerPidfileStrict`, which answers null for a file it could not read.
38
+ * Writes report whether they landed, because the spawn path refuses to create a
39
+ * lead it cannot record. One daemon per host (PID lock) makes read-modify-write
40
+ * races a non-issue.
35
41
  */
36
42
  import { existsSync, readFileSync, writeFileSync, unlinkSync } from 'node:fs';
37
43
  import { resolve } from 'node:path';
38
44
  import { resolveGlobalStateDir } from './daemon-process.js';
39
- import { readProcessStartIdentity } from '../spawn/process-group-kill.js';
45
+ import { readProcessStartIdentity, isProcessGroupAlive } from '../spawn/process-group-kill.js';
40
46
  import { createLogger } from './log.js';
41
47
  const log = createLogger({ module: 'worker-pidfile' });
48
+ /** The placeholder pid a reservation carries until the real one is recorded. */
49
+ export const PENDING_PID = 0;
42
50
  function optionalString(value) {
43
51
  return typeof value === 'string' && value.length > 0 ? value : undefined;
44
52
  }
@@ -47,9 +55,19 @@ function parseWorkerPidEntry(e) {
47
55
  if (typeof e !== 'object' || e === null)
48
56
  return null;
49
57
  const raw = e;
50
- if (typeof raw.pid !== 'number' || raw.pid <= 1)
58
+ const pending = raw.pending === true;
59
+ if (typeof raw.pid !== 'number')
60
+ return null;
61
+ if (!pending && raw.pid <= 1)
62
+ return null;
63
+ if (pending && raw.pid !== PENDING_PID)
51
64
  return null;
52
65
  const entry = { pid: raw.pid, label: typeof raw.label === 'string' ? raw.label : 'unknown' };
66
+ if (pending)
67
+ entry.pending = true;
68
+ const reservedBy = optionalString(raw.reservedBy);
69
+ if (reservedBy)
70
+ entry.reservedBy = reservedBy;
53
71
  const focusId = optionalString(raw.focusId);
54
72
  const sessionId = optionalString(raw.sessionId);
55
73
  const startIdentity = optionalString(raw.startIdentity);
@@ -68,37 +86,96 @@ export function resolveWorkerPidfilePath() {
68
86
  return resolve(resolveGlobalStateDir(), 'daemon.workers.json');
69
87
  }
70
88
  /**
71
- * Read the persisted worker fleet. Tolerant: a missing, unreadable, or
72
- * malformed file returns []. Only well-formed { pid, label } entries with a
73
- * real pid (> 1) survive parsing.
89
+ * Read the persisted fleet, DISTINGUISHING an absent record from an unreadable
90
+ * one. Returns null when the file exists but could not be read or parsed as a
91
+ * fleet -- an EACCES, a truncated write, a hand-edit, anything that is not an
92
+ * array of entries.
93
+ *
94
+ * That distinction is the whole point. The tolerant read below collapses both
95
+ * into [], and a caller asking "was a lead recorded for this session?" then
96
+ * reads a corrupt file as PROOF that nothing was spawned -- which is how a live
97
+ * team's session row gets closed. An absent file is real evidence (no lead was
98
+ * reserved); an unreadable one is not evidence at all.
99
+ *
100
+ * A malformed ELEMENT inside a well-formed array is still dropped: that is one
101
+ * unusable record, not an unreadable file.
74
102
  */
75
- export function readWorkerPidfile(path = resolveWorkerPidfilePath()) {
103
+ export function readWorkerPidfileStrict(path = resolveWorkerPidfilePath()) {
76
104
  if (!existsSync(path))
77
105
  return [];
106
+ let raw;
78
107
  try {
79
- const raw = JSON.parse(readFileSync(path, 'utf-8'));
80
- if (!Array.isArray(raw))
81
- return [];
82
- const out = [];
83
- for (const e of raw) {
84
- const entry = parseWorkerPidEntry(e);
85
- if (entry)
86
- out.push(entry);
87
- }
88
- return out;
108
+ raw = JSON.parse(readFileSync(path, 'utf-8'));
89
109
  }
90
- catch {
91
- return [];
110
+ catch (err) {
111
+ log.warn(`[worker-pidfile] ${path} exists but could not be read/parsed -- treating the fleet as UNKNOWN, not empty`, { error: String(err?.message ?? err) });
112
+ return null;
113
+ }
114
+ if (!Array.isArray(raw)) {
115
+ log.warn(`[worker-pidfile] ${path} is not a fleet array -- treating the fleet as UNKNOWN, not empty`);
116
+ return null;
117
+ }
118
+ const out = [];
119
+ for (const e of raw) {
120
+ const entry = parseWorkerPidEntry(e);
121
+ if (!entry) {
122
+ // A record we cannot parse may be a LIVE lead this host can no longer
123
+ // name. Dropping it silently -- and then writing the survivors back --
124
+ // converts "one unreadable record" into "that lead does not exist".
125
+ log.warn(`[worker-pidfile] ${path} holds an unparseable record -- treating the fleet as UNKNOWN, not partial`);
126
+ return null;
127
+ }
128
+ out.push(entry);
92
129
  }
130
+ return out;
93
131
  }
94
- /** Best-effort write of the fleet. Swallows all errors. */
132
+ /**
133
+ * Read for a MUTATION. Every writer goes through here, because a write-back is
134
+ * what makes an unknown read permanent: the tolerant read answers [], the writer
135
+ * appends its own entry, and the file now DEFINITELY records one lead where a
136
+ * moment ago it recorded an unreadable number of them. Every other live lead has
137
+ * just become `no_process_recorded`, which is reapable.
138
+ *
139
+ * So a mutation reads strictly and REFUSES when the state is unknown. The caller
140
+ * learns the write did not land (and, on the spawn path, declines to leave a
141
+ * process it cannot name).
142
+ */
143
+ function readForMutation(path) {
144
+ return readWorkerPidfileStrict(path);
145
+ }
146
+ /**
147
+ * Read the persisted worker fleet, tolerantly: a missing, unreadable, or
148
+ * malformed file returns []. Kept for the REAP callers, whose worst case on an
149
+ * unreadable file is that they signal nothing. A caller that would treat [] as
150
+ * proof of absence must use {@link readWorkerPidfileStrict} instead.
151
+ */
152
+ export function readWorkerPidfile(path = resolveWorkerPidfilePath()) {
153
+ // RESOLVED entries only. A reservation carries PENDING_PID (0) instead of a
154
+ // pid, and every consumer of this reader treats an entry as a pid it may
155
+ // probe, remove, or SIGNAL -- and `kill(-0, ...)` signals the caller's OWN
156
+ // process group, which here is the daemon. The reservation shape was added to
157
+ // the file without being taught to those passes; keeping it out of this reader
158
+ // is the source-level fix, rather than a pid guard in each of them.
159
+ return (readWorkerPidfileStrict(path) ?? []).filter((e) => !e.pending);
160
+ }
161
+ /**
162
+ * The whole file, reservations included. Only for readers that reason ABOUT
163
+ * reservations -- the retention pass and the by-session index. A caller that
164
+ * wants pids wants {@link readWorkerPidfile}.
165
+ */
166
+ export function readWorkerPidfileWithReservations(path = resolveWorkerPidfilePath()) {
167
+ return readWorkerPidfileStrict(path) ?? [];
168
+ }
169
+ /** Write the fleet. Never throws; returns whether the bytes actually landed. */
95
170
  function writeWorkerPidfile(entries, path) {
96
171
  try {
97
172
  writeFileSync(path, JSON.stringify(entries), { mode: 0o600 });
173
+ return true;
98
174
  }
99
175
  catch (err) {
100
176
  // Orphan prevention is a backstop -- never fail a spawn/exit on this.
101
177
  log.debug('Orphan prevention is a backstop -- never fail a spawn/exit on this', { error: String(err?.message ?? err) });
178
+ return false;
102
179
  }
103
180
  }
104
181
  /**
@@ -107,15 +184,65 @@ function writeWorkerPidfile(entries, path) {
107
184
  * invalid/init pid (<= 1).
108
185
  */
109
186
  export function recordWorkerProcess(entry, path = resolveWorkerPidfilePath()) {
110
- if (!Number.isInteger(entry.pid) || entry.pid <= 1)
111
- return;
112
- const entries = readWorkerPidfile(path).filter((e) => e.pid !== entry.pid);
187
+ if (!Number.isInteger(entry.pid) || entry.pid <= PENDING_PID)
188
+ return false;
189
+ const current = readForMutation(path);
190
+ if (current === null)
191
+ return false; // never overwrite unknown state
192
+ const entries = current.filter((e) => e.pid !== entry.pid && !(e.pending && e.sessionId !== undefined && e.sessionId === entry.sessionId));
193
+ entries.push(entry);
194
+ return writeWorkerPidfile(entries, path);
195
+ }
196
+ /**
197
+ * Reserve a lead record BEFORE the process is spawned.
198
+ *
199
+ * `launchLeadProcess` used to spawn first and record after, so a hard kill (or
200
+ * a failed write) in between left a LIVE detached lead with no record anywhere
201
+ * -- and a reader that takes "no record" for "nothing spawned" then closes that
202
+ * team's session row. Reserving first removes the window: the record exists
203
+ * before the process can, and the caller REFUSES the spawn when this returns
204
+ * false, so a live lead this host cannot name is never created.
205
+ */
206
+ export function reserveLeadRecord(reservation, path = resolveWorkerPidfilePath()) {
207
+ const current = readForMutation(path);
208
+ if (current === null)
209
+ return false; // never overwrite unknown state
210
+ const entries = current.filter((e) => !(e.pending && e.sessionId === reservation.sessionId));
211
+ const entry = {
212
+ pid: PENDING_PID,
213
+ label: reservation.label,
214
+ sessionId: reservation.sessionId,
215
+ pending: true,
216
+ // WHO reserved it. A reservation is "in flight" only while the instance that
217
+ // made it is still running; once that instance is provably gone nothing will
218
+ // ever resolve it, and it must not hold a worktree open forever.
219
+ reservedBy: reservation.reservedBy,
220
+ recordedAt: Date.now(),
221
+ };
222
+ if (reservation.focusId)
223
+ entry.focusId = reservation.focusId;
113
224
  entries.push(entry);
114
- writeWorkerPidfile(entries, path);
225
+ return writeWorkerPidfile(entries, path);
226
+ }
227
+ /** Drop a reservation whose spawn never produced a process. */
228
+ export function releaseLeadReservation(sessionId, path = resolveWorkerPidfilePath()) {
229
+ const entries = readForMutation(path);
230
+ if (entries === null)
231
+ return; // never overwrite unknown state
232
+ const next = entries.filter((e) => !(e.pending && e.sessionId === sessionId));
233
+ if (next.length === entries.length)
234
+ return;
235
+ if (next.length === 0) {
236
+ clearWorkerPidfile(path);
237
+ return;
238
+ }
239
+ writeWorkerPidfile(next, path);
115
240
  }
116
241
  /** Remove a lead pid on its exit. No-op when absent. */
117
242
  export function removeWorkerPid(pid, path = resolveWorkerPidfilePath()) {
118
- const entries = readWorkerPidfile(path);
243
+ const entries = readForMutation(path);
244
+ if (entries === null)
245
+ return; // never overwrite unknown state
119
246
  const next = entries.filter((e) => e.pid !== pid);
120
247
  if (next.length === entries.length)
121
248
  return;
@@ -125,8 +252,18 @@ export function removeWorkerPid(pid, path = resolveWorkerPidfilePath()) {
125
252
  }
126
253
  writeWorkerPidfile(next, path);
127
254
  }
128
- /** Delete the pidfile entirely (graceful shutdown clears it after reaping). */
129
- export function clearWorkerPidfile(path = resolveWorkerPidfilePath()) {
255
+ /**
256
+ * Delete the pidfile entirely. MODULE-PRIVATE, deliberately.
257
+ *
258
+ * This used to be exported, and both shutdown paths called it -- erasing the
259
+ * record of every worker that outlived a bounded reap. The survivor-safe
260
+ * {@link clearWorkerPidfileIfAllGone} replaced those calls, but while this was
261
+ * exported, reverting one of them was a one-word edit that no run could observe.
262
+ * Inside this module it is reached only where the caller has already established
263
+ * that nothing is left to record: an empty remainder after a removal, or a
264
+ * survivor set of zero.
265
+ */
266
+ function clearWorkerPidfile(path = resolveWorkerPidfilePath()) {
130
267
  try {
131
268
  if (existsSync(path))
132
269
  unlinkSync(path);
@@ -136,14 +273,19 @@ export function clearWorkerPidfile(path = resolveWorkerPidfilePath()) {
136
273
  log.debug('Best effort', { error: String(err?.message ?? err) });
137
274
  }
138
275
  }
139
- /** Default liveness: kill(pid, 0) throws iff the process does not exist. */
276
+ /**
277
+ * Default liveness: kill(pid, 0) succeeds iff the process exists and we may
278
+ * signal it. EPERM means it EXISTS and we may not -- the one error that must
279
+ * not read as "gone", because a record dropped there is a live process this
280
+ * host can no longer name.
281
+ */
140
282
  function defaultIsAlive(pid) {
141
283
  try {
142
284
  process.kill(pid, 0);
143
285
  return true;
144
286
  }
145
- catch {
146
- return false;
287
+ catch (err) {
288
+ return err?.code === 'EPERM';
147
289
  }
148
290
  }
149
291
  /**
@@ -157,10 +299,12 @@ export function reapPersistedWorkerGroups(entries, deps = {}) {
157
299
  const kill = deps.kill ?? ((pid, signal) => { process.kill(pid, signal); });
158
300
  const isAlive = deps.isAlive ?? defaultIsAlive;
159
301
  const readStartIdentity = deps.readStartIdentity ?? readProcessStartIdentity;
160
- const result = { reaped: [], skipped: [] };
302
+ const result = { reaped: [], skipped: [], unsignalled: [], unverified: [] };
161
303
  for (const entry of entries) {
162
304
  const { pid } = entry;
163
- if (!Number.isInteger(pid) || pid <= 1) {
305
+ // A reservation names no process yet: there is nothing to signal, and it is
306
+ // not evidence of absence either. The retention pass keeps it.
307
+ if (entry.pending || !Number.isInteger(pid) || pid <= 1) {
164
308
  result.skipped.push(pid);
165
309
  continue;
166
310
  }
@@ -169,39 +313,186 @@ export function reapPersistedWorkerGroups(entries, deps = {}) {
169
313
  continue;
170
314
  }
171
315
  // A record now outlives its lead until the lead's whole group is confirmed
172
- // gone, so its pid may have been reused: never SIGKILL a live process whose
173
- // start identity no longer matches the one recorded at spawn.
174
- const live = entry.startIdentity ? readStartIdentity(pid) : null;
175
- if (live !== null && live !== entry.startIdentity) {
316
+ // gone, so its pid may have been reused. SIGKILL requires the identity to be
317
+ // VERIFIED -- recorded AND matching what the pid reads now. The old rule only
318
+ // refused a positive MISMATCH, which signalled two unverified cases anyway: a
319
+ // record carrying no identity (written by an older daemon), and one whose live
320
+ // identity cannot be read. In both the pid may belong to something that has
321
+ // nothing to do with us, and we would be SIGKILLing a stranger's process.
322
+ if (!entry.startIdentity) {
323
+ log.warn(`[worker-pidfile] recorded lead ${pid} carries no start identity -- not signalled, record kept`);
324
+ result.unverified.push(pid);
325
+ continue;
326
+ }
327
+ const live = readStartIdentity(pid);
328
+ if (live === null) {
329
+ log.warn(`[worker-pidfile] could not read the live start identity of ${pid} -- not signalled, record kept`);
330
+ result.unverified.push(pid);
331
+ continue;
332
+ }
333
+ if (live !== entry.startIdentity) {
176
334
  result.skipped.push(pid);
177
335
  continue;
178
336
  }
179
- // Group-first (detached lead => pgid == pid), bare-pid fallback.
337
+ // Group-first (detached lead => pgid == pid), bare-pid fallback. A signal
338
+ // that LANDED is a reap; one that raised EPERM at both is not, and must not
339
+ // be reported as one -- the caller decides what to keep from this list.
340
+ if (signalOrReport(kill, pid))
341
+ result.reaped.push(pid);
342
+ else
343
+ result.unsignalled.push(pid);
344
+ }
345
+ return result;
346
+ }
347
+ /** SIGKILL the group, then the bare pid. True iff either signal actually landed. */
348
+ function signalOrReport(kill, pid) {
349
+ try {
350
+ kill(-pid, 'SIGKILL');
351
+ return true;
352
+ }
353
+ catch (groupErr) {
180
354
  try {
181
- kill(-pid, 'SIGKILL');
355
+ kill(pid, 'SIGKILL');
356
+ return true;
182
357
  }
183
- catch {
184
- try {
185
- kill(pid, 'SIGKILL');
186
- }
187
- catch (err) {
188
- // Already gone.
189
- log.debug('Already gone', { error: String(err?.message ?? err) });
358
+ catch (pidErr) {
359
+ // ESRCH at both is success by another name (it is gone). Anything else --
360
+ // EPERM above all -- means a live process we could not end.
361
+ const gone = pidErr?.code === 'ESRCH';
362
+ if (!gone) {
363
+ log.warn(`[worker-pidfile] could not signal recorded lead ${pid}; its record is kept`, {
364
+ groupError: String(groupErr?.message ?? groupErr),
365
+ pidError: String(pidErr?.message ?? pidErr),
366
+ });
190
367
  }
368
+ return gone;
191
369
  }
192
- result.reaped.push(pid);
193
370
  }
194
- return result;
195
371
  }
196
372
  /**
197
- * Read + reap the persisted fleet, then clear the file. Used by the CLI hard
198
- * stop (after SIGKILLing the daemon) and by the next daemon boot (to reap leads
199
- * a prior hard kill orphaned). Returns the reap result for logging.
373
+ * True when this recorded lead is STILL RUNNING and still the process that was
374
+ * recorded -- alive, and with a start identity that has not changed under it.
375
+ *
376
+ * A pid whose start identity no longer matches was recycled: the recorded lead
377
+ * is gone and an unrelated process now holds its number.
378
+ */
379
+ export function recordedLeadStillRunning(entry, deps = {}) {
380
+ const isAlive = deps.isAlive ?? defaultIsAlive;
381
+ const isGroupAlive = deps.isGroupAlive ?? isProcessGroupAlive;
382
+ const readStartIdentity = deps.readStartIdentity ?? readProcessStartIdentity;
383
+ // A reservation cannot be confirmed gone -- the process it names may not have
384
+ // been spawned yet, or may be running under a pid we never got to write.
385
+ if (entry.pending)
386
+ return true;
387
+ if (!Number.isInteger(entry.pid) || entry.pid <= 1)
388
+ return false;
389
+ // Ask the GROUP as well as the pid. A detached lead is a group leader, and its
390
+ // children outlive it: once the leader exits, the bare-pid probe reads dead
391
+ // while the group is still writing the worktree. Dropping the record there is
392
+ // exactly how a live writer loses the only evidence that it exists.
393
+ if (isGroupAlive(entry.pid))
394
+ return true;
395
+ if (!isAlive(entry.pid))
396
+ return false;
397
+ if (!entry.startIdentity)
398
+ return true; // nothing to contradict it
399
+ const live = readStartIdentity(entry.pid);
400
+ return live === null || live === entry.startIdentity;
401
+ }
402
+ /**
403
+ * Read + reap the persisted fleet, then RETAIN whatever it could not confirm
404
+ * gone. Used by the CLI hard stop (after SIGKILLing the daemon) and by the next
405
+ * daemon boot (to reap leads a prior hard kill orphaned).
406
+ *
407
+ * It used to clear the file unconditionally, which threw away the record of
408
+ * exactly the processes the reap FAILED to end -- a kill that raised EPERM, or
409
+ * a group that outlived SIGKILL. Those survivors are precisely what the next
410
+ * reader needs to know about: crash recovery runs after this and must not close
411
+ * a session row whose team is still running, and with the file cleared it had no
412
+ * way to tell. Retaining until CONFIRMED GONE is also the rule the one-shot
413
+ * ownership records already follow.
414
+ *
415
+ * Returns the reap result for logging.
200
416
  */
201
417
  export function reapAndClearWorkerPidfile(path = resolveWorkerPidfilePath(), deps = {}) {
202
- const entries = readWorkerPidfile(path);
418
+ const entries = readForMutation(path);
419
+ if (entries === null) {
420
+ // We cannot read the fleet, so we cannot reap it and we certainly cannot
421
+ // declare it empty. Deleting the file here would turn "unknown" into a
422
+ // permanent, confident "nothing was running".
423
+ log.warn(`[worker-pidfile] ${path} is unreadable -- reaping nothing and KEEPING the file`);
424
+ return { reaped: [], skipped: [], unsignalled: [], unverified: [] };
425
+ }
203
426
  const result = reapPersistedWorkerGroups(entries, deps);
204
- clearWorkerPidfile(path);
427
+ const survivors = entries.filter((e) => recordedLeadStillRunning(e, deps));
428
+ if (survivors.length === 0) {
429
+ clearWorkerPidfile(path);
430
+ }
431
+ else {
432
+ log.warn(`[worker-pidfile] ${survivors.length} recorded lead(s) survived the reap and stay recorded: ` +
433
+ survivors.map((e) => e.pid).join(', '));
434
+ writeWorkerPidfile(survivors, path);
435
+ }
205
436
  return result;
206
437
  }
438
+ /**
439
+ * Clear the pidfile ONLY when nothing it records survives.
440
+ *
441
+ * The graceful-stop and auto-update paths cleared it unconditionally, on the
442
+ * reasoning that `reapWorkerFleet` had just ended everything. It has not
443
+ * necessarily: that reap is bounded and best-effort, so a worker that outlived
444
+ * SIGKILL, one that could not be signalled, and a reservation whose spawn is in
445
+ * flight all survive it -- and clearing here erases the record of exactly those,
446
+ * right before a re-exec'd daemon's boot reap would have acted on them.
447
+ *
448
+ * Same rule as {@link reapAndClearWorkerPidfile}: retain until CONFIRMED GONE.
449
+ * Returns the survivors it kept.
450
+ */
451
+ export function clearWorkerPidfileIfAllGone(path = resolveWorkerPidfilePath(), deps = {}) {
452
+ const entries = readForMutation(path);
453
+ if (entries === null) {
454
+ log.warn(`[worker-pidfile] ${path} is unreadable at shutdown -- KEEPING it rather than declaring it empty`);
455
+ return [];
456
+ }
457
+ const survivors = entries.filter((e) => recordedLeadStillRunning(e, deps));
458
+ if (survivors.length === 0) {
459
+ clearWorkerPidfile(path);
460
+ return [];
461
+ }
462
+ log.warn(`[worker-pidfile] ${survivors.length} recorded worker(s) survived shutdown and stay recorded ` +
463
+ `for the next boot reap: ${survivors.map((e) => (e.pending ? `${e.label} (reservation)` : String(e.pid))).join(', ')}`);
464
+ writeWorkerPidfile(survivors, path);
465
+ return survivors;
466
+ }
467
+ /**
468
+ * The leads this host has a durable record of, by the agent_sessions row each
469
+ * was spawned for. Null when the record cannot be read at all -- which is NOT
470
+ * the same as "no leads": a caller must treat an unreadable record as unknown
471
+ * rather than as proof that nothing is running.
472
+ *
473
+ * This is the correlation crash recovery needs. `launchLeadProcess` writes the
474
+ * record BEFORE `spawnTeamProcess` persists the row's `running` status and pid,
475
+ * so a row still reading `starting` with no pid -- the window a hard kill or a
476
+ * failed API write leaves behind -- is exactly the case where the DB knows
477
+ * nothing and this file knows everything.
478
+ */
479
+ export function readLeadRecordsBySession(path = resolveWorkerPidfilePath()) {
480
+ // STRICT, and reservations included: this reader's null is what makes an
481
+ // unreadable record `unprovable` rather than `no_process_recorded`, and its
482
+ // reservations are what make the pre-spawn window decidable.
483
+ const entries = readWorkerPidfileStrict(path);
484
+ if (entries === null)
485
+ return null;
486
+ const bySession = new Map();
487
+ for (const entry of entries) {
488
+ if (!entry.sessionId)
489
+ continue;
490
+ // A resolved record wins over a stale reservation for the same session.
491
+ const existing = bySession.get(entry.sessionId);
492
+ if (existing && !existing.pending && entry.pending)
493
+ continue;
494
+ bySession.set(entry.sessionId, entry);
495
+ }
496
+ return bySession;
497
+ }
207
498
  //# sourceMappingURL=worker-pidfile.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"worker-pidfile.js","sourceRoot":"","sources":["../../src/shell/worker-pidfile.ts"],"names":[],"mappings":"AAAA,8FAA8F;AAC9F,sEAAsE;AACtE,iEAAiE;AACjE,8GAA8G;AAC9G,6GAA6G;AAC7G,kEAAkE;AAClE,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,SAAS,CAAC;AACnB,CAAC;AAED;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,wBAAwB,CACtC,OAAe,wBAAwB,EAAE;IAEzC,yEAAyE;IACzE,4EAA4E;IAC5E,6DAA6D;IAC7D,MAAM,OAAO,GAAG,uBAAuB,CAAC,IAAI,CAAC,CAAC;IAC9C,IAAI,OAAO,KAAK,IAAI;QAAE,OAAO,IAAI,CAAC;IAClC,MAAM,SAAS,GAAG,IAAI,GAAG,EAA0B,CAAC;IACpD,KAAK,MAAM,KAAK,IAAI,OAAO,EAAE,CAAC;QAC5B,IAAI,CAAC,KAAK,CAAC,SAAS;YAAE,SAAS;QAC/B,wEAAwE;QACxE,MAAM,QAAQ,GAAG,SAAS,CAAC,GAAG,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;QAChD,IAAI,QAAQ,IAAI,CAAC,QAAQ,CAAC,OAAO,IAAI,KAAK,CAAC,OAAO;YAAE,SAAS;QAC7D,SAAS,CAAC,GAAG,CAAC,KAAK,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC;IACxC,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC"}
@@ -25,10 +25,26 @@ export interface LaunchLeadProcessArgs {
25
25
  /** Starts the lead. Called only once every previous lead of the focus is confirmed ended. */
26
26
  spawn: () => ChildProcessWithoutNullStreams;
27
27
  }
28
+ /** The record seams of the launch, injectable so the refusals are testable. */
29
+ export interface LeadRecordDeps {
30
+ /** Write the pre-spawn reservation. False when the bytes did not land. */
31
+ reserve?: (r: {
32
+ label: string;
33
+ sessionId: string;
34
+ focusId?: string;
35
+ reservedBy: string;
36
+ }) => boolean;
37
+ /** Drop a reservation whose spawn produced nothing. */
38
+ release?: (sessionId: string) => void;
39
+ /** End a lead we spawned but could not record. */
40
+ terminate?: (pgid: number) => Promise<{
41
+ outcome: string;
42
+ }>;
43
+ }
28
44
  /**
29
45
  * End the focus's untracked previous leads, then spawn and record the new lead.
30
46
  * Returns the lead, or null when the spawn was refused because a previous lead
31
47
  * could not be ended (the caller fails the session and releases the team).
32
48
  */
33
- export declare function launchLeadProcess(args: LaunchLeadProcessArgs, ownership?: LeadOwnershipDeps): Promise<ChildProcessWithoutNullStreams | null>;
49
+ export declare function launchLeadProcess(args: LaunchLeadProcessArgs, ownership?: LeadOwnershipDeps, records?: LeadRecordDeps): Promise<ChildProcessWithoutNullStreams | null>;
34
50
  //# sourceMappingURL=lead-launch.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"lead-launch.d.ts","sourceRoot":"","sources":["../../src/spawn/lead-launch.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,oBAAoB,CAAC;AACzE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,EAAqB,KAAK,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAOxF,MAAM,WAAW,qBAAqB;IACpC,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,cAAc,CAAC;IAC1B,SAAS,EAAE,MAAM,CAAC;IAClB,6FAA6F;IAC7F,KAAK,EAAE,MAAM,8BAA8B,CAAC;CAC7C;AAED;;;;GAIG;AACH,wBAAsB,iBAAiB,CACrC,IAAI,EAAE,qBAAqB,EAC3B,SAAS,GAAE,iBAAsB,GAChC,OAAO,CAAC,8BAA8B,GAAG,IAAI,CAAC,CAsBhD"}
1
+ {"version":3,"file":"lead-launch.d.ts","sourceRoot":"","sources":["../../src/spawn/lead-launch.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,oBAAoB,CAAC;AACzE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,EAAqB,KAAK,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAcxF,MAAM,WAAW,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