@codetreker/daynight 0.37.2 → 0.38.0

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 (52) hide show
  1. package/README.md +112 -41
  2. package/dist/commands/cleanup-operation.d.ts +3 -0
  3. package/dist/commands/cleanup-operation.js +12 -0
  4. package/dist/commands/cleanup-operation.js.map +1 -0
  5. package/dist/commands/controller/provider-display.d.ts +2 -0
  6. package/dist/commands/controller/provider-display.js +63 -0
  7. package/dist/commands/controller/provider-display.js.map +1 -0
  8. package/dist/commands/controller/runtime.js +4 -2
  9. package/dist/commands/controller/runtime.js.map +1 -1
  10. package/dist/commands/skill/skills/using-daynight/SKILL.md +1 -1
  11. package/dist/commands/skill/skills/using-daynight/references/authorization.md +1 -1
  12. package/dist/commands/skill/skills/using-daynight/references/autopilot-managed-task.md +4 -3
  13. package/dist/commands/skill/skills/using-daynight/references/handoff.md +25 -15
  14. package/dist/commands/skill/skills/using-daynight/references/task-management.md +1 -1
  15. package/dist/commands/skill/usage.md +5 -3
  16. package/dist/commands/task/command.js +3 -1
  17. package/dist/commands/task/command.js.map +1 -1
  18. package/dist/commands/task/definition.js +1 -1
  19. package/dist/commands/task/definition.js.map +1 -1
  20. package/dist/commands/worker/backends/session-api.d.ts +1 -1
  21. package/dist/commands/worker/backends/session-api.js +4 -4
  22. package/dist/commands/worker/backends/session-api.js.map +1 -1
  23. package/dist/commands/worker/backends/web-store.d.ts +4 -0
  24. package/dist/commands/worker/backends/web-store.js +40 -6
  25. package/dist/commands/worker/backends/web-store.js.map +1 -1
  26. package/dist/commands/worker/backends/web.js +248 -127
  27. package/dist/commands/worker/backends/web.js.map +1 -1
  28. package/dist/commands/worker/cleanup-error.d.ts +5 -0
  29. package/dist/commands/worker/cleanup-error.js +9 -0
  30. package/dist/commands/worker/cleanup-error.js.map +1 -0
  31. package/dist/commands/worker/cleanup-schedule.d.ts +3 -0
  32. package/dist/commands/worker/cleanup-schedule.js +11 -0
  33. package/dist/commands/worker/cleanup-schedule.js.map +1 -0
  34. package/dist/commands/worker/cleanup.js +47 -31
  35. package/dist/commands/worker/cleanup.js.map +1 -1
  36. package/dist/commands/worker/coordinator.js +173 -64
  37. package/dist/commands/worker/coordinator.js.map +1 -1
  38. package/dist/commands/worker/execution.d.ts +1 -1
  39. package/dist/commands/worker/execution.js +2 -2
  40. package/dist/commands/worker/execution.js.map +1 -1
  41. package/dist/commands/worker/prompts.js +2 -2
  42. package/dist/commands/worker/prompts.js.map +1 -1
  43. package/dist/commands/worker/runtime.js +1 -1
  44. package/dist/commands/worker/runtime.js.map +1 -1
  45. package/dist/commands/worker/sqlite/006-cleanup-schedules.sql +14 -0
  46. package/dist/commands/worker/store.d.ts +5 -1
  47. package/dist/commands/worker/store.js +53 -0
  48. package/dist/commands/worker/store.js.map +1 -1
  49. package/dist/commands/worker/types.d.ts +10 -0
  50. package/dist/commands/worker/worktrees.js +1 -1
  51. package/dist/commands/worker/worktrees.js.map +1 -1
  52. package/package.json +2 -2
@@ -1,3 +1,4 @@
1
+ import { CLEANUP_OPERATION_MS, cleanupOperation } from "../../cleanup-operation.js";
1
2
  import path from "node:path";
2
3
  import { unlink } from "node:fs/promises";
3
4
  import { randomUUID } from "node:crypto";
@@ -7,6 +8,7 @@ import { readControllerOperation, readControllerSnapshot, recordStoppedControlle
7
8
  import { confirmControllerProcessesStopped, stopControllerProcesses } from "../../controller/process-proof.js";
8
9
  import { workerOperation } from "../execution.js";
9
10
  import { workerCleanupPrompt } from "../prompts.js";
11
+ import { WorkerCleanupError } from "../cleanup-error.js";
10
12
  import { backendResourcesClosed, taskAgentControlMode } from "./web-types.js";
11
13
  export const createWebExecutionBackend = (options) => {
12
14
  const request = options.request ?? requestController;
@@ -34,153 +36,272 @@ export const createWebExecutionBackend = (options) => {
34
36
  return {
35
37
  advance: async (input, signal) => {
36
38
  let task = current(input);
39
+ if (task.recovery.pauseReason !== null && !task.recovery.retryAuthorized)
40
+ return task;
37
41
  if (task.cleanup !== null || task.control !== null || task.configuration === null)
38
42
  throw new Error("Ordinary Web execution is fenced by cleanup or management.");
39
- if (task.resources.worktree === null)
40
- task = options.store.bindWorktree(task, await workerOperation(operation => options.git.prepareWorktree({ projectId: task.projectId, repoUrl: task.repoUrl, localPath: task.repositoryPath }, task, operation), signal), options.now());
41
- else
42
- await workerOperation(operation => options.git.verifyWorktree({ projectId: task.projectId, repoUrl: task.repoUrl, localPath: task.repositoryPath }, task, operation), signal);
43
- task = options.store.initializeWebExecution(task, options.now());
44
- let ticket = await options.launcher.prepare(task, task.webExecution.initialPrompt ?? options.buildPrompt(task, options.platform), signal);
45
- task = current(task);
46
- await options.launcher.launch(task, ticket, signal);
47
- task = current(task);
48
- let snapshot;
49
- let orderlyRestart = false;
43
+ const retryAttempt = task.recovery.retryAuthorized;
44
+ let recovering = retryAttempt;
45
+ const pause = (error) => options.store.pauseRecovery(task, error instanceof Error ? error.message : String(error), options.now());
46
+ const originalSnapshot = () => {
47
+ const saved = readControllerSnapshot(journal(task)), execution = task.webExecution;
48
+ if (saved === null || saved.executionId !== execution.executionId || saved.claimId !== task.claimId || saved.sessionId !== execution.sessionId || saved.executionGeneration !== execution.executionGeneration || saved.controllerInstanceId !== execution.controllerInstanceId)
49
+ throw new Error("The original controller generation evidence is unavailable.");
50
+ return saved;
51
+ };
50
52
  try {
51
- snapshot = (await request(ticket, { kind: "observe" }, { signal, timeoutMs: 2000 })).snapshot;
52
- }
53
- catch (error) {
54
- const saved = readControllerSnapshot(journal(task));
55
- if (saved !== null)
53
+ if (retryAttempt && task.recovery.pauseReason !== null) {
54
+ // Authorization permits one replacement generation only after proving the old writer stopped.
55
+ if (task.webExecution === null || task.resources.nativeSession === null)
56
+ throw new Error("Web retry requires the original native session identity.");
57
+ if (task.webExecution.launchSubmission === "not-submitted" && BigInt(task.webExecution.executionGeneration) > 1n) {
58
+ // Preparation may fail after allocating a generation but before any writer is launched.
59
+ const previous = readControllerSnapshot(journal(task));
60
+ if (previous === null || previous.controllerProcess === null || previous.lifecycle !== "stopped" || !previous.nativeStopped || previous.stoppedAt === null)
61
+ throw new Error("Unsubmitted recovery requires the original complete stopped generation evidence.");
62
+ if (!await confirmControllerProcessesStopped(previous.controllerProcess, previous.nativeProcesses))
63
+ throw new Error("Unsubmitted recovery requires complete original controller and native process stop.");
64
+ signal.throwIfAborted();
65
+ if (JSON.stringify(readControllerSnapshot(journal(task))) !== JSON.stringify(previous))
66
+ throw new Error("The original stopped generation changed during unsubmitted recovery verification.");
67
+ task = options.store.retryUnsubmittedWebGeneration(task, previous, options.now());
68
+ }
69
+ else {
70
+ const saved = originalSnapshot();
71
+ if (saved.nativeSessionId === null || saved.nativeSessionId !== task.resources.nativeSession.sessionId)
72
+ throw new Error("Web retry requires the original native session identity.");
73
+ task = remember(task, saved);
74
+ const proof = task.webExecution.controllerProcess;
75
+ if (proof === null || !await confirmControllerProcessesStopped(proof, task.webExecution.nativeProcesses))
76
+ throw new Error("Web retry requires complete original controller and native process stop.");
77
+ const ticket = await readLaunchTicket(options.homeDirectory, task.webExecution.launchId);
78
+ const stopped = await recordStoppedControllerGeneration(journal(task), ticket);
79
+ task = options.store.beginWebGeneration(task, stopped, options.now());
80
+ }
81
+ }
82
+ else if (!retryAttempt && task.webExecution !== null && task.webExecution.launchSubmission !== "not-submitted" && task.recovery.count >= task.configuration.recoveryLimit) {
83
+ // Older versions recorded exhaustion without a pause. Inspect before any launch preparation.
84
+ try {
85
+ const saved = originalSnapshot();
86
+ task = remember(task, saved);
87
+ const proof = task.webExecution.controllerProcess;
88
+ if (proof === null)
89
+ throw new Error("The exhausted execution has no complete original process stop evidence.");
90
+ const stopped = await confirmControllerProcessesStopped(proof, task.webExecution.nativeProcesses);
91
+ if (stopped) {
92
+ if (!task.webExecution.restartAfterShutdown || saved.error !== null)
93
+ return pause(new Error("The execution recovery budget is exhausted."));
94
+ }
95
+ else {
96
+ if (["stopped", "stopping", "failed", "paused"].includes(saved.lifecycle))
97
+ throw new Error("The exhausted execution is stopped or failed, but complete original process stop is unproven.");
98
+ const ticket = await readLaunchTicket(options.homeDirectory, task.webExecution.launchId);
99
+ const observed = (await request(ticket, { kind: "observe" }, { signal, timeoutMs: 2000 })).snapshot;
100
+ if (observed.lifecycle !== "ready" && observed.lifecycle !== "working" && observed.lifecycle !== "starting")
101
+ throw new Error(observed.error ?? "The exhausted controller is not healthy.");
102
+ task = remember(task, observed);
103
+ }
104
+ }
105
+ catch (error) {
106
+ signal.throwIfAborted();
107
+ return pause(error);
108
+ }
109
+ }
110
+ if (task.resources.worktree === null)
111
+ task = options.store.bindWorktree(task, await workerOperation(operation => options.git.prepareWorktree({ projectId: task.projectId, repoUrl: task.repoUrl, localPath: task.repositoryPath }, task, operation), signal), options.now());
112
+ else
113
+ await workerOperation(operation => options.git.verifyWorktree({ projectId: task.projectId, repoUrl: task.repoUrl, localPath: task.repositoryPath }, task, operation), signal);
114
+ task = options.store.initializeWebExecution(task, options.now());
115
+ let ticket = await options.launcher.prepare(task, task.webExecution.initialPrompt ?? options.buildPrompt(task, options.platform), signal);
116
+ task = current(task);
117
+ await options.launcher.launch(task, ticket, signal);
118
+ task = current(task);
119
+ let snapshot;
120
+ try {
121
+ snapshot = (await request(ticket, { kind: "observe" }, { signal, timeoutMs: 2000 })).snapshot;
122
+ }
123
+ catch (error) {
124
+ signal.throwIfAborted();
125
+ // A retry never grants a second generation when its first observation fails.
126
+ if (retryAttempt)
127
+ throw error;
128
+ const saved = originalSnapshot();
56
129
  task = remember(task, saved);
57
- const proof = task.webExecution.controllerProcess;
58
- if (proof === null || !await confirmControllerProcessesStopped(proof, task.webExecution.nativeProcesses))
59
- throw new Error("The original controller is unreachable; its native writer may still be alive and will not be replaced.", { cause: error });
60
- if (saved?.nativeSessionId == null)
61
- throw new Error("The stopped native launch has no proven session identity; recovery cannot create another conversation.");
62
- const stopped = await recordStoppedControllerGeneration(journal(task), ticket);
63
- if (task.recovery.pauseReason !== null && !task.recovery.retryAuthorized)
64
- return task;
65
- orderlyRestart = task.webExecution.restartAfterShutdown;
66
- if (!orderlyRestart)
67
- task = options.store.beginRecovery(task, options.now());
68
- task = options.store.beginWebGeneration(task, stopped, options.now());
69
- ticket = await options.launcher.prepare(task, task.webExecution.initialPrompt, signal);
70
- await options.launcher.launch(current(task), ticket, signal);
71
- snapshot = (await request(ticket, { kind: "observe" }, { signal, timeoutMs: 2000 })).snapshot;
130
+ const proof = task.webExecution.controllerProcess;
131
+ if (proof === null || !await confirmControllerProcessesStopped(proof, task.webExecution.nativeProcesses))
132
+ throw new Error("The original controller is unreachable; its native writer may still be alive and will not be replaced.", { cause: error });
133
+ if (saved.nativeSessionId === null)
134
+ throw new Error("The stopped native launch has no proven session identity; recovery cannot create another conversation.");
135
+ const stopped = await recordStoppedControllerGeneration(journal(task), ticket);
136
+ if (!task.webExecution.restartAfterShutdown)
137
+ task = options.store.beginRecovery(task, options.now());
138
+ if (task.recovery.pauseReason !== null)
139
+ return task;
140
+ recovering = true;
141
+ task = options.store.beginWebGeneration(task, stopped, options.now());
142
+ ticket = await options.launcher.prepare(task, task.webExecution.initialPrompt, signal);
143
+ await options.launcher.launch(current(task), ticket, signal);
144
+ snapshot = (await request(ticket, { kind: "observe" }, { signal, timeoutMs: 2000 })).snapshot;
145
+ }
146
+ task = remember(current(task), snapshot);
147
+ if (snapshot.lifecycle === "failed" || snapshot.lifecycle === "paused" || snapshot.lifecycle === "stopped" || snapshot.lifecycle === "stopping") {
148
+ recovering = true;
149
+ throw new Error(snapshot.error ?? "The native controller is paused or stopped.");
150
+ }
151
+ if ((snapshot.lifecycle === "ready" || snapshot.lifecycle === "working") && snapshot.initialInputState === "not_submitted" && BigInt(task.webExecution.executionGeneration) > 1n) {
152
+ recovering = true;
153
+ throw new Error("Recovery cannot resubmit the original managed assignment.");
154
+ }
155
+ if (snapshot.lifecycle === "ready" || snapshot.lifecycle === "working") {
156
+ if (task.recovery.retryAuthorized)
157
+ task = options.store.completeRecoveryRetry(task, snapshot, options.now());
158
+ recovering = false;
159
+ }
160
+ await options.launcher.refreshGrant(task, ticket, signal);
161
+ if (snapshot.lifecycle === "starting")
162
+ return options.store.updateWebExecution(task, { activity: "initializing" }, options.now());
163
+ if (snapshot.initialInputState === "not_submitted") {
164
+ const response = await request(ticket, { kind: "submit_initial", operationId: task.webExecution.initialOperationId }, { signal, timeoutMs: 30000 });
165
+ task = remember(task, response.snapshot);
166
+ }
167
+ options.emit({ kind: "web-observed", task, message: `Original ${ticket.provider} controller generation ${ticket.executionGeneration} is bound to session ${ticket.sessionId}.` });
168
+ return current(task);
72
169
  }
73
- task = remember(current(task), snapshot);
74
- await options.launcher.refreshGrant(task, ticket, signal);
75
- if (snapshot.lifecycle === "starting")
76
- return task;
77
- if (snapshot.lifecycle === "failed" || snapshot.lifecycle === "paused")
78
- throw new Error(snapshot.error ?? "The native controller is paused.");
79
- if (task.recovery.pauseReason !== null && !task.recovery.retryAuthorized)
80
- return task;
81
- if (task.recovery.retryAuthorized && !orderlyRestart)
82
- task = options.store.beginRecovery(task, options.now());
83
- if (snapshot.initialInputState === "not_submitted") {
84
- const response = await request(ticket, { kind: "submit_initial", operationId: task.webExecution.initialOperationId }, { signal, timeoutMs: 30000 });
85
- task = remember(task, response.snapshot);
170
+ catch (error) {
171
+ if (!signal.aborted && (recovering && (retryAttempt || current(task).recovery.count >= task.configuration.recoveryLimit)))
172
+ pause(error);
173
+ throw error;
86
174
  }
87
- options.emit({ kind: "web-observed", task, message: `Original ${ticket.provider} controller generation ${ticket.executionGeneration} is bound to session ${ticket.sessionId}.` });
88
- return current(task);
89
175
  },
90
176
  cleanup: async (input, kind, deadline, signal = new AbortController().signal, immediateStop = false) => {
91
- const startedAt = options.now();
92
- // An elapsed caller deadline has zero remaining budget, including immediate shutdown.
93
- let task = options.store.beginCleanup(current(input), { kind, deadline: Math.max(startedAt, deadline) }, startedAt);
94
- if (task.resources.worktree === null) {
95
- const found = await workerOperation(operation => options.git.findWorktree({ projectId: task.projectId, repoUrl: task.repoUrl, localPath: task.repositoryPath }, task, operation), signal);
96
- if (found !== null)
97
- task = options.store.bindWorktree(task, found, options.now());
98
- }
99
- const execution = task.webExecution;
100
- if (execution == null && task.configuration === null)
101
- throw new Error("The recovered Web claim has no original launch provenance; its native writer and worktree are retained.");
102
- if (!task.cleanup.agentStopped) {
103
- if (execution == null || execution.launchSubmission === "not-submitted") {
104
- task = options.store.recordCleanupInputOutcome(task, "unavailable", options.now());
105
- task = options.store.recordCleanupResult(task, "unavailable", "No controller launch was submitted.", options.now());
106
- task = options.store.confirmAgentStopped(task, { agentStopped: true }, options.now());
107
- task = options.store.confirmBackendResourcesClosed(task, { controllerStopped: true, endpointClosed: true }, options.now());
108
- }
109
- else {
110
- if (execution.ticketPath === null)
111
- throw new Error("The original launch ticket is missing; cleanup retains its unknown native writer.");
112
- const ticket = await readLaunchTicket(options.homeDirectory, execution.launchId);
113
- let response;
177
+ let stage = "observation";
178
+ try {
179
+ const startedAt = options.now();
180
+ let original = current(input);
181
+ if (kind === "shutdown" && original.cleanup === null && original.recovery.retryAuthorized && original.recovery.pauseReason === null)
182
+ original = options.store.pauseRecovery(original, "The explicit recovery attempt stopped before a successful observation.", options.now());
183
+ if (kind === "shutdown" && original.cleanup === null && original.recovery.pauseReason === null && original.configuration !== null && original.recovery.count >= original.configuration.recoveryLimit && original.webExecution !== null && original.webExecution.launchSubmission !== "not-submitted") {
184
+ // Shutdown provenance must not turn an already exhausted writer into a healthy orderly restart.
114
185
  try {
115
- response = await request(ticket, { kind: "observe" }, { signal, timeoutMs: 1000 });
186
+ const saved = readControllerSnapshot(journal(original)), execution = original.webExecution;
187
+ if (saved === null || saved.executionId !== execution.executionId || saved.claimId !== original.claimId || saved.executionGeneration !== execution.executionGeneration || saved.controllerInstanceId !== execution.controllerInstanceId)
188
+ throw new Error("The exhausted execution has no original generation evidence before shutdown.");
189
+ original = remember(original, saved);
190
+ const proof = original.webExecution.controllerProcess;
191
+ if (proof === null)
192
+ throw new Error("The exhausted execution has no complete original process stop evidence before shutdown.");
193
+ if (["failed", "paused", "stopped", "stopping"].includes(saved.lifecycle) || await confirmControllerProcessesStopped(proof, original.webExecution.nativeProcesses))
194
+ original = options.store.pauseRecovery(original, "The execution recovery budget is exhausted.", options.now());
116
195
  }
117
- catch {
118
- const saved = readControllerSnapshot(journal(task));
119
- if (saved !== null)
120
- task = remember(task, saved);
196
+ catch (error) {
197
+ signal.throwIfAborted();
198
+ original = options.store.pauseRecovery(original, error instanceof Error ? error.message : String(error), options.now());
121
199
  }
122
- const reachable = response !== undefined;
123
- if (response !== undefined)
124
- task = remember(task, response.snapshot);
125
- const proof = task.webExecution.controllerProcess;
126
- if (proof === null)
127
- throw new Error("The original controller process proof is missing; cleanup cannot infer stop.");
128
- let stopped = await confirmControllerProcessesStopped(proof, task.webExecution.nativeProcesses);
129
- if (!immediateStop && !stopped && task.cleanup.result === null && options.now() < task.cleanup.deadline) {
130
- if (!reachable)
131
- throw new Error("The original controller is unavailable; cleanup retains its fixed deadline and process proof.");
132
- if (task.webExecution.cleanupOperationId === null)
133
- task = options.store.updateWebExecution(task, { cleanupOperationId: randomUUID() }, options.now());
134
- if (task.cleanup.input === "not-submitted") {
135
- task = options.store.markCleanupInputSubmitting(task, options.now());
136
- await request(ticket, { kind: "cleanup", operationId: task.webExecution.cleanupOperationId, prompt: workerCleanupPrompt(task, task.cleanup.deadline), deadline: task.cleanup.deadline }, { signal, timeoutMs: 30000 });
200
+ }
201
+ // An elapsed caller deadline has zero remaining budget, including immediate shutdown.
202
+ let task = options.store.beginCleanup(original, { kind, deadline: Math.max(startedAt, deadline) }, startedAt);
203
+ stage = "agent-stop";
204
+ const execution = task.webExecution;
205
+ if (execution == null && task.configuration === null)
206
+ throw new Error("The recovered Web claim has no original launch provenance; its native writer and worktree are retained.");
207
+ if (!task.cleanup.agentStopped) {
208
+ if (execution == null || execution.launchSubmission === "not-submitted") {
209
+ task = options.store.recordCleanupInputOutcome(task, "unavailable", options.now());
210
+ task = options.store.recordCleanupResult(task, "unavailable", "No controller launch was submitted.", options.now());
211
+ task = options.store.confirmAgentStopped(task, { agentStopped: true }, options.now());
212
+ task = options.store.confirmBackendResourcesClosed(task, { controllerStopped: true, endpointClosed: true }, options.now());
213
+ }
214
+ else {
215
+ if (execution.ticketPath === null)
216
+ throw new Error("The original launch ticket is missing; cleanup retains its unknown native writer.");
217
+ const ticket = await readLaunchTicket(options.homeDirectory, execution.launchId);
218
+ let response;
219
+ try {
220
+ response = await request(ticket, { kind: "observe" }, { signal, timeoutMs: CLEANUP_OPERATION_MS });
137
221
  }
138
- const operation = readControllerOperation(journal(task), task.webExecution.cleanupOperationId);
139
- if (operation?.state === "provider_accepted" || operation?.state === "confirmed") {
140
- if (task.cleanup.input === "unknown")
141
- task = options.store.recordCleanupInputOutcome(task, "submitted", options.now());
142
- if (operation.state === "confirmed")
143
- task = options.store.recordCleanupResult(task, "completed", null, options.now());
222
+ catch {
223
+ const saved = readControllerSnapshot(journal(task));
224
+ if (saved !== null)
225
+ task = remember(task, saved);
144
226
  }
145
- else if (operation !== null && ["failed", "rejected", "expired"].includes(operation.state))
146
- task = options.store.recordCleanupResult(task, "failed", operation.error, options.now());
147
- if (task.cleanup.result === null)
148
- return task;
149
- }
150
- if (task.cleanup.result === null)
151
- task = options.store.recordCleanupResult(task, stopped || immediateStop ? "unavailable" : "timed-out", stopped || immediateStop ? "Original processes stopped before cleanup completion was established." : "The original cleanup deadline elapsed.", options.now());
152
- if (!stopped) {
153
- if (reachable)
154
- try {
155
- await request(ticket, { kind: "stop", deadline: options.now() + 5000 }, { signal, timeoutMs: 5000 });
227
+ const reachable = response !== undefined;
228
+ if (response !== undefined)
229
+ task = remember(task, response.snapshot);
230
+ const proof = task.webExecution.controllerProcess;
231
+ if (proof === null)
232
+ throw new Error("The original controller process proof is missing; cleanup cannot infer stop.");
233
+ let stopped = await confirmControllerProcessesStopped(proof, task.webExecution.nativeProcesses);
234
+ if (!immediateStop && !stopped && task.cleanup.result === null && options.now() < task.cleanup.deadline) {
235
+ if (!reachable)
236
+ throw new Error("The original controller is unavailable; cleanup retains its fixed deadline and process proof.");
237
+ if (task.webExecution.cleanupOperationId === null)
238
+ task = options.store.updateWebExecution(task, { cleanupOperationId: randomUUID() }, options.now());
239
+ if (task.cleanup.input === "not-submitted") {
240
+ task = options.store.markCleanupInputSubmitting(task, options.now());
241
+ await request(ticket, { kind: "cleanup", operationId: task.webExecution.cleanupOperationId, prompt: workerCleanupPrompt(task, task.cleanup.deadline), deadline: task.cleanup.deadline }, { signal, timeoutMs: Math.max(1, Math.min(CLEANUP_OPERATION_MS, task.cleanup.deadline - options.now())) });
242
+ }
243
+ const operation = readControllerOperation(journal(task), task.webExecution.cleanupOperationId);
244
+ if (operation?.state === "provider_accepted" || operation?.state === "confirmed") {
245
+ if (task.cleanup.input === "unknown")
246
+ task = options.store.recordCleanupInputOutcome(task, "submitted", options.now());
247
+ if (operation.state === "confirmed")
248
+ task = options.store.recordCleanupResult(task, "completed", null, options.now());
156
249
  }
157
- catch { /* OS process proof remains authoritative after an IPC loss. */ }
158
- await stopControllerProcesses(proof, task.webExecution.nativeProcesses, Date.now() + 5000);
159
- stopped = await confirmControllerProcessesStopped(proof, task.webExecution.nativeProcesses);
250
+ else if (operation !== null && ["failed", "rejected", "expired"].includes(operation.state))
251
+ task = options.store.recordCleanupResult(task, "failed", operation.error, options.now());
252
+ if (task.cleanup.result === null)
253
+ return task;
254
+ }
255
+ if (task.cleanup.result === null)
256
+ task = options.store.recordCleanupResult(task, stopped || immediateStop ? "unavailable" : "timed-out", stopped || immediateStop ? "Original processes stopped before cleanup completion was established." : "The original cleanup deadline elapsed.", options.now());
257
+ if (!stopped) {
258
+ if (reachable)
259
+ try {
260
+ await request(ticket, { kind: "stop", deadline: options.now() + CLEANUP_OPERATION_MS }, { signal, timeoutMs: CLEANUP_OPERATION_MS });
261
+ }
262
+ catch { /* OS process proof remains authoritative after an IPC loss. */ }
263
+ await stopControllerProcesses(proof, task.webExecution.nativeProcesses, Date.now() + CLEANUP_OPERATION_MS);
264
+ stopped = await confirmControllerProcessesStopped(proof, task.webExecution.nativeProcesses);
265
+ }
266
+ if (!stopped)
267
+ throw new Error("Complete original controller process stop is not proven.");
268
+ await recordStoppedControllerGeneration(journal(task), ticket);
269
+ task = options.store.confirmAgentStopped(task, { agentStopped: true }, options.now());
160
270
  }
161
- if (!stopped)
162
- throw new Error("Complete original controller process stop is not proven.");
163
- await recordStoppedControllerGeneration(journal(task), ticket);
164
- task = options.store.confirmAgentStopped(task, { agentStopped: true }, options.now());
271
+ }
272
+ stage = "backend-close";
273
+ if (!backendResourcesClosed(task.cleanup)) {
274
+ if (!task.cleanup.agentStopped || execution?.ticketPath == null)
275
+ throw new Error("The original Web backend closure has no stopped controller and launch ticket.");
276
+ const ticket = await readLaunchTicket(options.homeDirectory, execution.launchId);
165
277
  await removeEndpoint(ticket.ipcEndpoint);
166
278
  task = options.store.confirmBackendResourcesClosed(task, { controllerStopped: true, endpointClosed: true }, options.now());
167
279
  }
168
- }
169
- if (!backendResourcesClosed(task.cleanup))
170
- throw new Error("The original Web backend resources are not closed.");
171
- // Shutdown proves stop but leaves any terminal finalization for normal reconciliation.
172
- if (kind === "shutdown")
173
- return task;
174
- if (task.cleanup.kind === "terminal" && !task.cleanup.worktreeDeleted) {
175
- if (execution && execution.launchSubmission !== "not-submitted") {
176
- if (!options.archive)
177
- throw new Error("Session archive uploader is unavailable; the original worktree is retained.");
178
- await options.archive(task, journal(task), signal);
280
+ // Shutdown proves stop but leaves any terminal finalization for normal reconciliation.
281
+ if (kind === "shutdown")
282
+ return task;
283
+ stage = "observation";
284
+ if (task.resources.worktree === null) {
285
+ const found = await cleanupOperation(operation => options.git.findWorktree({ projectId: task.projectId, repoUrl: task.repoUrl, localPath: task.repositoryPath }, task, operation), signal);
286
+ if (found !== null)
287
+ task = options.store.bindWorktree(task, found, options.now());
288
+ }
289
+ if (task.cleanup.kind === "terminal" && !task.cleanup.worktreeDeleted) {
290
+ if (execution && execution.launchSubmission !== "not-submitted") {
291
+ stage = "archive";
292
+ if (!options.archive)
293
+ throw new Error("Session archive uploader is unavailable; the original worktree is retained.");
294
+ await options.archive(task, journal(task), signal);
295
+ }
296
+ stage = "worktree-removal";
297
+ await cleanupOperation(operation => options.git.removeWorktree({ projectId: task.projectId, repoUrl: task.repoUrl, localPath: task.repositoryPath }, task, operation), signal);
298
+ task = options.store.confirmWorktreeDeleted(task, { worktreeDeleted: true }, options.now());
179
299
  }
180
- await workerOperation(operation => options.git.removeWorktree({ projectId: task.projectId, repoUrl: task.repoUrl, localPath: task.repositoryPath }, task, operation), signal);
181
- task = options.store.confirmWorktreeDeleted(task, { worktreeDeleted: true }, options.now());
300
+ return task;
301
+ }
302
+ catch (error) {
303
+ throw new WorkerCleanupError(stage, error);
182
304
  }
183
- return task;
184
305
  },
185
306
  };
186
307
  };
@@ -1 +1 @@
1
- {"version":3,"file":"web.js","sourceRoot":"","sources":["../../../../src/commands/worker/backends/web.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,4BAA4B,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AACnG,OAAO,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;AACrE,OAAO,EAAE,uBAAuB,EAAE,sBAAsB,EAAE,iCAAiC,EAA2B,MAAM,qCAAqC,CAAC;AAClK,OAAO,EAAE,iCAAiC,EAAE,uBAAuB,EAAE,MAAM,mCAAmC,CAAC;AAC/G,OAAO,EAAE,eAAe,EAAyB,MAAM,iBAAiB,CAAC;AACzE,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,EAAE,sBAAsB,EAAE,oBAAoB,EAAqC,MAAM,gBAAgB,CAAC;AAUjH,MAAM,CAAC,MAAM,yBAAyB,G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type WorkerCleanupStage = "observation" | "agent-stop" | "backend-close" | "archive" | "worktree-removal";
2
+ export declare class WorkerCleanupError extends Error {
3
+ readonly stage: WorkerCleanupStage;
4
+ constructor(stage: WorkerCleanupStage, cause: unknown);
5
+ }
@@ -0,0 +1,9 @@
1
+ export class WorkerCleanupError extends Error {
2
+ stage;
3
+ constructor(stage, cause) {
4
+ super(`Worker cleanup ${stage} failed: ${cause instanceof Error ? cause.message : String(cause)}`, { cause });
5
+ this.stage = stage;
6
+ this.name = "WorkerCleanupError";
7
+ }
8
+ }
9
+ //# sourceMappingURL=cleanup-error.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cleanup-error.js","sourceRoot":"","sources":["../../../src/commands/worker/cleanup-error.ts"],"names":[],"mappings":"AAEA,MAAM,OAAO,kBAAmB,SAAQ,KAAK;IACtB,KAAK;IAA1B,YAAqB,KAAyB,EAAE,KAAc;QAC5D,KAAK,CAAC,kBAAkB,KAAK,YAAY,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;qBAD3F,KAAK;QAExB,IAAI,CAAC,IAAI,GAAG,oBAAoB,CAAC;IACnC,CAAC;CACF"}
@@ -0,0 +1,3 @@
1
+ import type { WorkerStore } from "./store.js";
2
+ import type { CleanupScheduleRecord, ResourceOwner } from "./types.js";
3
+ export declare const ensureCleanupSchedule: (store: WorkerStore, owner: ResourceOwner, now: number) => CleanupScheduleRecord;
@@ -0,0 +1,11 @@
1
+ // Persist responsibility before any cleanup side effect; a restart must not replay input.
2
+ export const ensureCleanupSchedule = (store, owner, now) => {
3
+ const previous = store.getCleanupSchedule(owner);
4
+ if (previous !== null) {
5
+ if (previous.worktreeId !== owner.worktreeId)
6
+ throw new Error("The cleanup claim has conflicting worktree identities.");
7
+ return previous;
8
+ }
9
+ return store.saveCleanupSchedule(owner, { deadline: now + 600_000, notified: false, submitted: false, failures: 0, nextAttemptAt: now, stage: "observation", lastError: null });
10
+ };
11
+ //# sourceMappingURL=cleanup-schedule.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cleanup-schedule.js","sourceRoot":"","sources":["../../../src/commands/worker/cleanup-schedule.ts"],"names":[],"mappings":"AAGA,0FAA0F;AAC1F,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,KAAkB,EAAE,KAAoB,EAAE,GAAW,EAAyB,EAAE;IACpH,MAAM,QAAQ,GAAG,KAAK,CAAC,kBAAkB,CAAC,KAAK,CAAC,CAAC;IACjD,IAAI,QAAQ,KAAK,IAAI,EAAE,CAAC;QACtB,IAAI,QAAQ,CAAC,UAAU,KAAK,KAAK,CAAC,UAAU;YAAE,MAAM,IAAI,KAAK,CAAC,wDAAwD,CAAC,CAAC;QACxH,OAAO,QAAQ,CAAC;IAClB,CAAC;IACD,OAAO,KAAK,CAAC,mBAAmB,CAAC,KAAK,EAAE,EAAE,QAAQ,EAAE,GAAG,GAAG,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC,EAAE,aAAa,EAAE,GAAG,EAAE,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;AAClL,CAAC,CAAC"}