@usine/executor 0.2.0 → 0.3.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 (177) hide show
  1. package/README.md +115 -37
  2. package/dist/child-command.d.ts +4 -7
  3. package/dist/child-command.d.ts.map +1 -1
  4. package/dist/child-command.js +6 -12
  5. package/dist/child-command.js.map +1 -1
  6. package/dist/claude-login-lock.d.ts +8 -0
  7. package/dist/claude-login-lock.d.ts.map +1 -0
  8. package/dist/claude-login-lock.js +9 -0
  9. package/dist/claude-login-lock.js.map +1 -0
  10. package/dist/credential-environment.d.ts +20 -0
  11. package/dist/credential-environment.d.ts.map +1 -0
  12. package/dist/credential-environment.js +20 -0
  13. package/dist/credential-environment.js.map +1 -0
  14. package/dist/durable-session.d.ts +63 -0
  15. package/dist/durable-session.d.ts.map +1 -0
  16. package/dist/durable-session.js +491 -0
  17. package/dist/durable-session.js.map +1 -0
  18. package/dist/exe-dev/commands.d.ts +23 -13
  19. package/dist/exe-dev/commands.d.ts.map +1 -1
  20. package/dist/exe-dev/commands.js +11 -57
  21. package/dist/exe-dev/commands.js.map +1 -1
  22. package/dist/exe-dev/exe-dev.d.ts +9 -3
  23. package/dist/exe-dev/exe-dev.d.ts.map +1 -1
  24. package/dist/exe-dev/exe-dev.js +53 -127
  25. package/dist/exe-dev/exe-dev.js.map +1 -1
  26. package/dist/exe-dev/grants.d.ts.map +1 -1
  27. package/dist/exe-dev/grants.js +35 -15
  28. package/dist/exe-dev/grants.js.map +1 -1
  29. package/dist/exe-dev/model.d.ts +15 -19
  30. package/dist/exe-dev/model.d.ts.map +1 -1
  31. package/dist/exe-dev/model.js +9 -12
  32. package/dist/exe-dev/model.js.map +1 -1
  33. package/dist/exe-dev/preflight.d.ts +8 -4
  34. package/dist/exe-dev/preflight.d.ts.map +1 -1
  35. package/dist/exe-dev/preflight.js +23 -33
  36. package/dist/exe-dev/preflight.js.map +1 -1
  37. package/dist/executor.d.ts +141 -38
  38. package/dist/executor.d.ts.map +1 -1
  39. package/dist/executor.js +90 -17
  40. package/dist/executor.js.map +1 -1
  41. package/dist/guard.d.ts +61 -0
  42. package/dist/guard.d.ts.map +1 -0
  43. package/dist/guard.js +288 -0
  44. package/dist/guard.js.map +1 -0
  45. package/dist/harness-preflight.d.ts +25 -4
  46. package/dist/harness-preflight.d.ts.map +1 -1
  47. package/dist/harness-preflight.js +25 -29
  48. package/dist/harness-preflight.js.map +1 -1
  49. package/dist/keyed-lock.d.ts +2 -3
  50. package/dist/keyed-lock.d.ts.map +1 -1
  51. package/dist/keyed-lock.js +2 -3
  52. package/dist/keyed-lock.js.map +1 -1
  53. package/dist/leftovers.d.ts +9 -0
  54. package/dist/leftovers.d.ts.map +1 -0
  55. package/dist/leftovers.js +14 -0
  56. package/dist/leftovers.js.map +1 -0
  57. package/dist/local/credentials.d.ts +21 -0
  58. package/dist/local/credentials.d.ts.map +1 -0
  59. package/dist/local/credentials.js +39 -0
  60. package/dist/local/credentials.js.map +1 -0
  61. package/dist/local/leftovers.d.ts +8 -0
  62. package/dist/local/leftovers.d.ts.map +1 -0
  63. package/dist/local/leftovers.js +23 -0
  64. package/dist/local/leftovers.js.map +1 -0
  65. package/dist/local/local.d.ts +16 -10
  66. package/dist/local/local.d.ts.map +1 -1
  67. package/dist/local/local.js +164 -129
  68. package/dist/local/local.js.map +1 -1
  69. package/dist/memory-preflight.d.ts +25 -0
  70. package/dist/memory-preflight.d.ts.map +1 -0
  71. package/dist/memory-preflight.js +83 -0
  72. package/dist/memory-preflight.js.map +1 -0
  73. package/dist/pre-push-hook.d.ts +20 -0
  74. package/dist/pre-push-hook.d.ts.map +1 -0
  75. package/dist/pre-push-hook.js +33 -0
  76. package/dist/pre-push-hook.js.map +1 -0
  77. package/dist/prepared-attempt.d.ts +33 -3
  78. package/dist/prepared-attempt.d.ts.map +1 -1
  79. package/dist/prepared-attempt.js +109 -39
  80. package/dist/prepared-attempt.js.map +1 -1
  81. package/dist/provision.d.ts +77 -14
  82. package/dist/provision.d.ts.map +1 -1
  83. package/dist/provision.js +357 -55
  84. package/dist/provision.js.map +1 -1
  85. package/dist/remote/commands.d.ts +51 -0
  86. package/dist/remote/commands.d.ts.map +1 -0
  87. package/dist/remote/commands.js +94 -0
  88. package/dist/remote/commands.js.map +1 -0
  89. package/dist/remote/leftovers.d.ts +14 -0
  90. package/dist/remote/leftovers.d.ts.map +1 -0
  91. package/dist/remote/leftovers.js +22 -0
  92. package/dist/remote/leftovers.js.map +1 -0
  93. package/dist/remote/liveness.d.ts +33 -0
  94. package/dist/remote/liveness.d.ts.map +1 -0
  95. package/dist/remote/liveness.js +194 -0
  96. package/dist/remote/liveness.js.map +1 -0
  97. package/dist/remote/machine.d.ts +64 -0
  98. package/dist/remote/machine.d.ts.map +1 -0
  99. package/dist/remote/machine.js +2 -0
  100. package/dist/remote/machine.js.map +1 -0
  101. package/dist/remote/remote.d.ts +24 -0
  102. package/dist/remote/remote.d.ts.map +1 -0
  103. package/dist/remote/remote.js +308 -0
  104. package/dist/remote/remote.js.map +1 -0
  105. package/dist/remote/sweep.d.ts +15 -0
  106. package/dist/remote/sweep.d.ts.map +1 -0
  107. package/dist/remote/sweep.js +116 -0
  108. package/dist/remote/sweep.js.map +1 -0
  109. package/dist/renewable-credential.d.ts +17 -0
  110. package/dist/renewable-credential.d.ts.map +1 -0
  111. package/dist/renewable-credential.js +58 -0
  112. package/dist/renewable-credential.js.map +1 -0
  113. package/dist/salvage.d.ts +30 -0
  114. package/dist/salvage.d.ts.map +1 -0
  115. package/dist/salvage.js +104 -0
  116. package/dist/salvage.js.map +1 -0
  117. package/dist/ssh/credentials.d.ts +40 -0
  118. package/dist/ssh/credentials.d.ts.map +1 -0
  119. package/dist/ssh/credentials.js +83 -0
  120. package/dist/ssh/credentials.js.map +1 -0
  121. package/dist/ssh/gateway/admin.d.ts +45 -0
  122. package/dist/ssh/gateway/admin.d.ts.map +1 -0
  123. package/dist/ssh/gateway/admin.js +129 -0
  124. package/dist/ssh/gateway/admin.js.map +1 -0
  125. package/dist/ssh/gateway/attachments.d.ts +22 -0
  126. package/dist/ssh/gateway/attachments.d.ts.map +1 -0
  127. package/dist/ssh/gateway/attachments.js +154 -0
  128. package/dist/ssh/gateway/attachments.js.map +1 -0
  129. package/dist/ssh/gateway/environment.d.ts +52 -0
  130. package/dist/ssh/gateway/environment.d.ts.map +1 -0
  131. package/dist/ssh/gateway/environment.js +78 -0
  132. package/dist/ssh/gateway/environment.js.map +1 -0
  133. package/dist/ssh/gateway/forward.d.ts +74 -0
  134. package/dist/ssh/gateway/forward.d.ts.map +1 -0
  135. package/dist/ssh/gateway/forward.js +247 -0
  136. package/dist/ssh/gateway/forward.js.map +1 -0
  137. package/dist/ssh/gateway/preflight.d.ts +28 -0
  138. package/dist/ssh/gateway/preflight.d.ts.map +1 -0
  139. package/dist/ssh/gateway/preflight.js +234 -0
  140. package/dist/ssh/gateway/preflight.js.map +1 -0
  141. package/dist/ssh/model.d.ts +65 -0
  142. package/dist/ssh/model.d.ts.map +1 -0
  143. package/dist/ssh/model.js +2 -0
  144. package/dist/ssh/model.js.map +1 -0
  145. package/dist/ssh/preflight.d.ts +16 -0
  146. package/dist/ssh/preflight.d.ts.map +1 -0
  147. package/dist/ssh/preflight.js +47 -0
  148. package/dist/ssh/preflight.js.map +1 -0
  149. package/dist/ssh/ssh.d.ts +20 -0
  150. package/dist/ssh/ssh.d.ts.map +1 -0
  151. package/dist/ssh/ssh.js +78 -0
  152. package/dist/ssh/ssh.js.map +1 -0
  153. package/dist/ssh/workers.d.ts +53 -0
  154. package/dist/ssh/workers.d.ts.map +1 -0
  155. package/dist/ssh/workers.js +173 -0
  156. package/dist/ssh/workers.js.map +1 -0
  157. package/package.json +12 -4
  158. package/dist/exe-dev/channel.d.ts +0 -11
  159. package/dist/exe-dev/channel.d.ts.map +0 -1
  160. package/dist/exe-dev/channel.js +0 -41
  161. package/dist/exe-dev/channel.js.map +0 -1
  162. package/dist/exe-dev/shell.d.ts +0 -12
  163. package/dist/exe-dev/shell.d.ts.map +0 -1
  164. package/dist/exe-dev/shell.js +0 -31
  165. package/dist/exe-dev/shell.js.map +0 -1
  166. package/dist/exe-dev/sweep.d.ts +0 -10
  167. package/dist/exe-dev/sweep.d.ts.map +0 -1
  168. package/dist/exe-dev/sweep.js +0 -117
  169. package/dist/exe-dev/sweep.js.map +0 -1
  170. package/dist/invalid-frame.d.ts +0 -17
  171. package/dist/invalid-frame.d.ts.map +0 -1
  172. package/dist/invalid-frame.js +0 -111
  173. package/dist/invalid-frame.js.map +0 -1
  174. package/dist/run-host-session.d.ts +0 -26
  175. package/dist/run-host-session.d.ts.map +0 -1
  176. package/dist/run-host-session.js +0 -241
  177. package/dist/run-host-session.js.map +0 -1
@@ -0,0 +1,491 @@
1
+ import * as AttemptChannel from "@usine/core/attempt/channel";
2
+ import { AgentFailure, InfraFailure, RunawayFailure, } from "@usine/core/attempt/failure";
3
+ import { AttemptRequest, AttemptRuntime, harvestedResult, } from "@usine/durable/attempt-runtime";
4
+ import { Cause, Deferred, Duration, Effect, Exit, Fiber, Match, Option, Ref, Result, } from "effect";
5
+ import { ExecutorOperationError, } from "./executor.js";
6
+ import { guardSeed } from "./guard.js";
7
+ import { preparedAttemptsFor } from "./prepared-attempt.js";
8
+ const cancelError = (attemptId, cause) => new ExecutorOperationError({
9
+ operation: "cancel",
10
+ message: `Can't cancel attempt ${attemptId}`,
11
+ cause,
12
+ });
13
+ /**
14
+ * Returns the session that runs Attempts whose Pi parent is a durable task in this process
15
+ * (`AttemptRuntime`), for every Worker kind. If a launch is interrupted without a stop, the
16
+ * parent task stays live and the checkout stays on disk for reattachment after restart; every
17
+ * other ending stops the parent task.
18
+ */
19
+ export const durableSessionFor = Effect.fn("DurableSession.for")(function* (options) {
20
+ const runtime = yield* AttemptRuntime;
21
+ const attempts = new Map();
22
+ /** Completed by each launch after it adds its Attempt to `attempts`. */
23
+ const registrations = new Map();
24
+ const registration = (attemptId) => {
25
+ const existing = registrations.get(attemptId);
26
+ if (existing !== undefined)
27
+ return existing;
28
+ const created = Deferred.makeUnsafe();
29
+ registrations.set(attemptId, created);
30
+ return created;
31
+ };
32
+ /**
33
+ * Cancels the Attempt's parent task if durable storage reports it live. Fails with a `cancel`
34
+ * `ExecutorOperationError` if liveness can't be read, or the cancel fails or exceeds
35
+ * `interruptGrace`.
36
+ */
37
+ const stopTask = Effect.fn("DurableSession.stopTask")(function* (attemptId, reason) {
38
+ yield* Effect.annotateCurrentSpan({ attemptId, reason });
39
+ const live = yield* runtime.isLive(attemptId).pipe(Effect.result);
40
+ if (Result.isFailure(live)) {
41
+ yield* Effect.logWarning("Could not read whether the Attempt's parent task is live", {
42
+ attemptId,
43
+ reason,
44
+ errorTag: live.failure._tag,
45
+ message: live.failure.message,
46
+ });
47
+ return yield* cancelError(attemptId, live.failure);
48
+ }
49
+ if (!live.success) {
50
+ yield* Effect.logDebug("The Attempt's parent task is not live; nothing to stop", {
51
+ attemptId,
52
+ reason,
53
+ });
54
+ return;
55
+ }
56
+ yield* Effect.logInfo("Canceling the Attempt's parent task", { attemptId, reason });
57
+ const canceled = yield* runtime
58
+ .cancel(attemptId)
59
+ .pipe(Effect.timeoutOption(options.interruptGrace), Effect.result);
60
+ if (Result.isFailure(canceled)) {
61
+ yield* Effect.logWarning("The Attempt's parent task could not be canceled", {
62
+ attemptId,
63
+ reason,
64
+ errorTag: canceled.failure._tag,
65
+ message: canceled.failure.message,
66
+ });
67
+ return yield* cancelError(attemptId, canceled.failure);
68
+ }
69
+ if (Option.isNone(canceled.success)) {
70
+ yield* Effect.logWarning("Canceling the Attempt's parent task exceeded the interrupt grace", {
71
+ attemptId,
72
+ reason,
73
+ });
74
+ return yield* cancelError(attemptId, new Error("canceling the parent task exceeded the interrupt grace"));
75
+ }
76
+ });
77
+ /** Calls `record` with `comments`; failures are logged, not raised. */
78
+ const recordComments = Effect.fn("DurableSession.recordComments")(function* (attemptId, comments, record) {
79
+ yield* Effect.annotateCurrentSpan({ attemptId, comments: comments.length });
80
+ if (comments.length === 0) {
81
+ yield* Effect.logDebug("The Attempt posted no comment on its Item before it ended", {
82
+ attemptId,
83
+ });
84
+ return;
85
+ }
86
+ yield* record(comments).pipe(Effect.tapError((error) => Effect.logWarning("Could not record the comments the Attempt posted before it ended", {
87
+ attemptId,
88
+ comments: comments.length,
89
+ message: String(error),
90
+ })), Effect.ignore);
91
+ });
92
+ /**
93
+ * Records the comments and reviews an unsuccessful Attempt posted on its Run's Item, after its
94
+ * parent task stops. A canceled Attempt's window ends when the orchestrator closes it, so later
95
+ * comments are excluded. Failures are logged without changing the Attempt's result.
96
+ */
97
+ const recordPostedComments = Effect.fn("DurableSession.recordPostedComments")(function* (attemptId, checkout, io) {
98
+ yield* Effect.annotateCurrentSpan({ attemptId });
99
+ yield* recordComments(attemptId, yield* checkout.harvestComments(io.windows), io.comments);
100
+ });
101
+ const launch = Effect.fn("DurableSession.launch")(function* (prepared, io, checkout) {
102
+ const spec = prepared.spec;
103
+ const attemptId = spec.attemptId;
104
+ yield* Effect.annotateCurrentSpan({ attemptId, worker: prepared.worker });
105
+ const stopping = yield* Ref.make(Option.none());
106
+ const execution = yield* Ref.make(Option.none());
107
+ const settled = yield* Deferred.make();
108
+ const run = Effect.gen(function* () {
109
+ attempts.set(attemptId, {
110
+ worker: prepared.worker,
111
+ scope: yield* Effect.scope,
112
+ stopping,
113
+ execution,
114
+ settled,
115
+ });
116
+ yield* Deferred.succeed(registration(attemptId), undefined);
117
+ yield* Effect.logInfo("Running the Attempt's parent task", {
118
+ attemptId,
119
+ worker: prepared.worker,
120
+ worktree: prepared.worktree,
121
+ childHost: checkout.host._tag,
122
+ gatewayCredential: Option.getOrElse(yield* checkout.gatewayCredential, () => "none"),
123
+ });
124
+ const running = yield* runtime
125
+ .execute(new AttemptRequest({
126
+ spec,
127
+ worker: prepared.worker,
128
+ cwd: prepared.worktree,
129
+ host: checkout.host,
130
+ environment: checkout.environment,
131
+ gatewayCredential: checkout.gatewayCredential,
132
+ }), io)
133
+ .pipe(Effect.forkScoped);
134
+ yield* Ref.set(execution, Option.some(running));
135
+ const executed = yield* Fiber.await(running);
136
+ const stop = yield* Ref.get(stopping);
137
+ if (Option.isSome(stop) && stop.value._tag === "Runaway")
138
+ return yield* new RunawayFailure({ ceiling: stop.value.ceiling });
139
+ if (Option.isSome(stop) &&
140
+ Exit.isFailure(executed) &&
141
+ Cause.hasInterruptsOnly(executed.cause))
142
+ return yield* new AgentFailure({ message: "The attempt's parent task was canceled" });
143
+ const report = yield* executed;
144
+ // Reads the windows after GitHub lists the comments, because a later Attempt of the same Agent
145
+ // can overlap this one and a cancel can close this window first (#429). A failed read fails
146
+ // the Attempt.
147
+ const facts = yield* checkout.harvest(io.windows);
148
+ const harvested = harvestedResult(report, facts);
149
+ if (Result.isFailure(harvested)) {
150
+ yield* Effect.logWarning("The parent's last turn answered the operator and the checkout holds no facts; the Attempt fails", { attemptId });
151
+ return yield* harvested.failure;
152
+ }
153
+ const result = harvested.success;
154
+ yield* Effect.logInfo("The Attempt's parent task finished", {
155
+ attemptId,
156
+ facts: result.facts.length,
157
+ answeredOperator: report.answeredOperator,
158
+ });
159
+ yield* runtime.recordResult(attemptId, result).pipe(Effect.tapError((error) => Effect.logWarning("Could not record the Attempt's result in durable storage; preserving the checkout for reattachment", { attemptId, errorTag: error._tag, message: error.message }).pipe(Effect.andThen(checkout.keepForReattach))), Effect.ignore);
160
+ return result;
161
+ });
162
+ return yield* Effect.scoped(run).pipe(Effect.onExit((exit) => Effect.gen(function* () {
163
+ // Complete `settled` first so `stopping` cannot change while the branches below read it.
164
+ yield* Deferred.succeed(settled, undefined);
165
+ if (Exit.isFailure(exit)) {
166
+ const stop = yield* Ref.get(stopping);
167
+ if (Option.isNone(stop) && Cause.hasInterruptsOnly(exit.cause)) {
168
+ yield* Effect.logInfo("This process is stopping; the Attempt's parent task stays live for reattachment", { attemptId, worker: prepared.worker });
169
+ yield* checkout.keepForReattach;
170
+ }
171
+ else {
172
+ // stopTask logs its own failure; the Attempt's result is unchanged.
173
+ yield* stopTask(attemptId, Option.match(stop, {
174
+ onNone: () => "the Attempt failed",
175
+ onSome: (reason) => reason._tag === "Cancel" ? "the Attempt was canceled" : "a ceiling tripped",
176
+ })).pipe(Effect.ignore);
177
+ yield* recordPostedComments(attemptId, checkout, io);
178
+ }
179
+ }
180
+ })));
181
+ });
182
+ /**
183
+ * Stops a launched Attempt for `reason` and returns whether one was running here. Cancels the
184
+ * parent task, then waits up to `interruptGrace` before interrupting the Attempt; the launch
185
+ * fails with the first reason. For a run that already ended, does nothing, and the caller waits
186
+ * for its resources to be released.
187
+ */
188
+ const stop = Effect.fn("DurableSession.stop")(function* (attemptId, reason) {
189
+ const active = attempts.get(attemptId);
190
+ if (active === undefined)
191
+ return false;
192
+ return yield* Effect.uninterruptible(Effect.gen(function* () {
193
+ yield* Effect.annotateCurrentSpan({ attemptId, worker: active.worker, stop: reason._tag });
194
+ if (yield* Deferred.isDone(active.settled)) {
195
+ yield* Effect.logDebug("The Attempt's run has ended; nothing to stop before its release", {
196
+ attemptId,
197
+ worker: active.worker,
198
+ stop: reason,
199
+ });
200
+ return true;
201
+ }
202
+ const first = yield* Ref.modify(active.stopping, (stopping) => Option.isNone(stopping)
203
+ ? [true, Option.some(reason)]
204
+ : [false, stopping]);
205
+ if (!first) {
206
+ yield* Effect.logDebug("The Attempt is already stopping", {
207
+ attemptId,
208
+ worker: active.worker,
209
+ stop: reason,
210
+ });
211
+ return true;
212
+ }
213
+ yield* Effect.logInfo("Canceling the Attempt's parent task", {
214
+ attemptId,
215
+ worker: active.worker,
216
+ stop: reason,
217
+ });
218
+ const canceled = yield* runtime
219
+ .cancel(attemptId)
220
+ .pipe(Effect.timeoutOption(options.interruptGrace), Effect.result);
221
+ const settledInGrace = yield* Deferred.await(active.settled).pipe(Effect.timeoutOption(options.interruptGrace));
222
+ if (Option.isNone(settledInGrace)) {
223
+ yield* Effect.logWarning("The Attempt did not stop within the interrupt grace", {
224
+ attemptId,
225
+ worker: active.worker,
226
+ });
227
+ const running = yield* Ref.get(active.execution);
228
+ if (Option.isSome(running)) {
229
+ const stopped = yield* Fiber.interrupt(running.value).pipe(Effect.timeoutOption(options.interruptGrace));
230
+ if (Option.isNone(stopped))
231
+ yield* Effect.logWarning("The Attempt's execution did not stop when interrupted", {
232
+ attemptId,
233
+ worker: active.worker,
234
+ });
235
+ }
236
+ }
237
+ else {
238
+ yield* Effect.logInfo("The Attempt stopped within the interrupt grace", {
239
+ attemptId,
240
+ worker: active.worker,
241
+ });
242
+ }
243
+ if (Result.isFailure(canceled)) {
244
+ yield* Effect.logWarning("The Attempt's parent task could not be canceled", {
245
+ attemptId,
246
+ worker: active.worker,
247
+ errorTag: canceled.failure._tag,
248
+ message: canceled.failure.message,
249
+ });
250
+ return yield* cancelError(attemptId, canceled.failure);
251
+ }
252
+ if (Option.isNone(canceled.success)) {
253
+ yield* Effect.logWarning("Canceling the parent task exceeded the interrupt grace", {
254
+ attemptId,
255
+ worker: active.worker,
256
+ });
257
+ return yield* cancelError(attemptId, new Error("canceling the parent task exceeded the interrupt grace"));
258
+ }
259
+ return true;
260
+ }));
261
+ });
262
+ const intervene = Effect.fn("DurableSession.intervene")(function* (attemptId, intervention) {
263
+ yield* Effect.annotateCurrentSpan({
264
+ attemptId,
265
+ target: intervention.target._tag,
266
+ action: intervention.action._tag,
267
+ });
268
+ const active = attempts.get(attemptId);
269
+ if (active === undefined ||
270
+ (yield* Deferred.isDone(active.settled)) ||
271
+ Option.isSome(yield* Ref.get(active.stopping)))
272
+ return yield* new AgentFailure({
273
+ message: "This attempt has no live session in this orchestrator",
274
+ });
275
+ yield* runtime.intervene(attemptId, intervention).pipe(Effect.tap(() => Effect.logInfo("Operator input delivered to the Attempt's parent task", {
276
+ attemptId,
277
+ action: intervention.action._tag,
278
+ })), Effect.tapError((error) => Effect.logWarning("Operator input delivery failed", {
279
+ attemptId,
280
+ action: intervention.action._tag,
281
+ errorTag: error._tag,
282
+ })),
283
+ // Forks into the Attempt's scope so a disconnected HTTP caller doesn't interrupt delivery.
284
+ Effect.forkIn(active.scope), Effect.flatMap(Fiber.join));
285
+ });
286
+ /**
287
+ * Sends the runaway guard's warning steer through `intervene` after `execute` attaches to the
288
+ * Attempt's channel. The guard starts before `execute` reads durable storage, so sending
289
+ * immediately would drop a warning restored on reattachment (#178).
290
+ */
291
+ const warnParent = Effect.fn("DurableSession.warnParent")(function* (attemptId, intervention) {
292
+ yield* Effect.annotateCurrentSpan({ attemptId });
293
+ yield* runtime.attached(attemptId);
294
+ yield* intervene(attemptId, intervention);
295
+ });
296
+ /**
297
+ * Wraps `read`, one `part` of the guard's restored state. If `read` fails after the store's
298
+ * retries, stops the parent task and fails the reattachment with an `InfraFailure` for `part`,
299
+ * because restarting that part would reset the Attempt's allowance (#178).
300
+ */
301
+ const seedPart = (attemptId, part) => (read) => read.pipe(Effect.catch((error) => Effect.gen(function* () {
302
+ yield* Effect.logError(`Could not read the reattached Attempt's ${part}; the reattachment fails instead of starting its runaway guard over`, { attemptId, part, errorTag: error._tag, message: error.message });
303
+ yield* stopTask(attemptId, `its runaway guard cannot read the Attempt's ${part}`).pipe(Effect.ignore);
304
+ return yield* new InfraFailure({
305
+ message: `Can't read the ${part} of the reattached attempt, which the runaway guard needs to resume`,
306
+ cause: error,
307
+ });
308
+ })));
309
+ /**
310
+ * Returns the initial runaway guard state for `request`, empty for a new Attempt. On
311
+ * reattachment, reads the transcript if any ceiling is set and the unsupervised time if
312
+ * `maxAttemptMinutes` is set. Fails with an `InfraFailure` after stopping the parent task if a
313
+ * read fails.
314
+ */
315
+ const guardSeedFor = Effect.fn("DurableSession.guardSeed")(function* (request, io) {
316
+ const attemptId = request.attemptId;
317
+ const wallClock = Option.isSome(request.maxAttemptMinutes);
318
+ const armed = wallClock || Option.isSome(request.maxAttemptTokens);
319
+ yield* Effect.annotateCurrentSpan({ attemptId, reattach: request.reattach, armed });
320
+ if (!request.reattach)
321
+ return guardSeed([], Duration.zero);
322
+ if (!armed) {
323
+ yield* Effect.logDebug("The reattached Attempt arms no ceiling; its guard resumes nothing", {
324
+ attemptId,
325
+ });
326
+ return guardSeed([], Duration.zero);
327
+ }
328
+ const transcript = yield* io.transcript.pipe(seedPart(attemptId, "transcript"));
329
+ const recorded = wallClock
330
+ ? yield* runtime.unsupervised(attemptId).pipe(seedPart(attemptId, "unsupervised time"))
331
+ : Option.none();
332
+ const seed = guardSeed(transcript, Option.getOrElse(recorded, () => Duration.zero));
333
+ yield* Effect.logInfo("Resuming the reattached Attempt's ceilings", {
334
+ attemptId,
335
+ envelopes: transcript.length,
336
+ tokens: [...seed.tokens.values()].reduce((sum, value) => sum + value, 0),
337
+ unsupervisedRecorded: Option.isSome(recorded),
338
+ unsupervisedMinutes: Math.round(Duration.toMillis(seed.unsupervised) / 6_000) / 10,
339
+ parentHeld: seed.parentHeld,
340
+ warned: [...seed.warned],
341
+ });
342
+ return seed;
343
+ });
344
+ const prepared = yield* preparedAttemptsFor(stop, warnParent, (attemptId) => Deferred.await(registration(attemptId)), guardSeedFor, runtime.recordUnsupervised);
345
+ /**
346
+ * Wraps an executor's `acquire` with `preparedAttemptsFor`. If a reattachment can't be prepared,
347
+ * cancels its parent task so the engine retries on a new Attempt.
348
+ */
349
+ const prepare = (acquire, request) => prepared
350
+ .prepare(
351
+ // Added first so it runs last: the session stays registered until checkout and credential
352
+ // cleanup finish (#197).
353
+ Effect.addFinalizer(() => Effect.sync(() => {
354
+ attempts.delete(request.attemptId);
355
+ registrations.delete(request.attemptId);
356
+ })).pipe(Effect.andThen(acquire)), request)
357
+ .pipe(Effect.tapError(() => request.reattach
358
+ ? // stopTask logs its own failure; the preparation error is returned.
359
+ stopTask(request.attemptId, "its reattachment could not be prepared").pipe(Effect.ignore)
360
+ : Effect.void));
361
+ /**
362
+ * Cancels the Attempt at any stage, then stops a live parent task this process didn't launch,
363
+ * for example one awaiting reattachment. Fails if that task can't be confirmed stopped.
364
+ */
365
+ const cancel = Effect.fn("DurableSession.cancel")(function* (attemptId) {
366
+ yield* Effect.annotateCurrentSpan({ attemptId });
367
+ yield* prepared.cancel(attemptId);
368
+ yield* stopTask(attemptId, "the Attempt was canceled");
369
+ });
370
+ /**
371
+ * Returns whether the open Attempt's parent task is running or reported success without a
372
+ * recorded harvest. If true, a restart reattaches it.
373
+ */
374
+ const isLive = Effect.fn("DurableSession.isLive")(function* (attemptId) {
375
+ yield* Effect.annotateCurrentSpan({ attemptId });
376
+ if (yield* runtime.isLive(attemptId)) {
377
+ yield* Effect.logDebug("The Attempt's parent task is live", { attemptId });
378
+ return true;
379
+ }
380
+ const finished = yield* runtime.finished(attemptId);
381
+ const unharvested = Option.exists(finished, ({ _tag }) => _tag === "ParentReported");
382
+ yield* Effect.logDebug(unharvested
383
+ ? "The Attempt's parent task finished before its checkout was harvested; it is reattached"
384
+ : "The Attempt's parent task is not live", { attemptId });
385
+ return unharvested;
386
+ });
387
+ /** Returns the stored result of a finished parent task: the recorded harvest or the parent's failure. */
388
+ const outcome = Effect.fn("DurableSession.outcome")(function* (attemptId) {
389
+ yield* Effect.annotateCurrentSpan({ attemptId });
390
+ const finished = yield* runtime.finished(attemptId);
391
+ const stored = Option.flatMap(finished, (found) => Match.valueTags(found, {
392
+ ParentReported: () => Option.none(),
393
+ ResultRecorded: ({ result }) => Option.some(Result.succeed(result)),
394
+ ParentFailed: ({ failure }) => Option.some(Result.fail(failure)),
395
+ }));
396
+ yield* Effect.logDebug("Read the Attempt's stored outcome", {
397
+ attemptId,
398
+ stored: Option.match(stored, {
399
+ onNone: () => "none",
400
+ onSome: Result.match({ onSuccess: () => "Succeeded", onFailure: ({ _tag }) => _tag }),
401
+ }),
402
+ });
403
+ return stored;
404
+ });
405
+ /**
406
+ * Stops `attempt`'s parent task before recovery reconciles its checkout, even if `isLive` returns
407
+ * true. An unharvested report stays unharvested while the checkout is salvaged (#180). Fails if
408
+ * the task can't be confirmed stopped.
409
+ */
410
+ const stopForRecovery = Effect.fn("DurableSession.stopForRecovery")(function* (attempt) {
411
+ yield* Effect.annotateCurrentSpan({ attemptId: attempt.attemptId, worker: attempt.worker });
412
+ yield* stopTask(attempt.attemptId, attempt.open ? "its Run does not reattach the Attempt" : "its Attempt is closed");
413
+ });
414
+ /**
415
+ * During startup reconciliation, records the comments and reviews an open Attempt posted on its
416
+ * Run's Item if durable storage has its parent's failure. `harvest` is `None` if the checkout is
417
+ * gone. Does nothing for other Attempts; failures are logged, not raised.
418
+ */
419
+ const recoverPostedComments = Effect.fn("DurableSession.recoverPostedComments")(function* (attempt, harvest, record) {
420
+ if (!attempt.open)
421
+ return;
422
+ const { attemptId, worker } = attempt;
423
+ yield* Effect.annotateCurrentSpan({ attemptId, worker });
424
+ const finished = yield* runtime.finished(attemptId).pipe(Effect.result);
425
+ if (Result.isFailure(finished)) {
426
+ yield* Effect.logWarning("Could not read how the open Attempt's parent task ended; the comments it posted are not recorded", { attemptId, worker, errorTag: finished.failure._tag, message: finished.failure.message });
427
+ return;
428
+ }
429
+ if (!Option.exists(finished.success, ({ _tag }) => _tag === "ParentFailed")) {
430
+ yield* Effect.logDebug("Durable storage holds no failure of the open Attempt's parent task; reconciliation records no comment", {
431
+ attemptId,
432
+ worker,
433
+ finished: Option.match(finished.success, {
434
+ onNone: () => "none",
435
+ onSome: ({ _tag }) => _tag,
436
+ }),
437
+ });
438
+ return;
439
+ }
440
+ if (Option.isNone(harvest)) {
441
+ yield* Effect.logWarning("The open Attempt's parent task failed and its checkout is gone; the comments it posted are not recorded", { attemptId, worker });
442
+ return;
443
+ }
444
+ const stored = yield* runtime.request(attemptId).pipe(Effect.result);
445
+ if (Result.isFailure(stored) || Option.isNone(stored.success)) {
446
+ yield* Effect.logWarning("The open Attempt's parent task failed and its durable request cannot be read; the comments it posted are not recorded", {
447
+ attemptId,
448
+ worker,
449
+ message: Result.isFailure(stored) ? stored.failure.message : "no durable request",
450
+ });
451
+ return;
452
+ }
453
+ yield* Effect.logInfo("The open Attempt's parent task failed before this process recorded it; harvesting the comments it posted from its checkout", { attemptId, worker });
454
+ const comments = yield* harvest
455
+ .value(stored.success.value.spec, record.windows)
456
+ .pipe(Effect.result);
457
+ if (Result.isFailure(comments)) {
458
+ yield* Effect.logWarning("Could not acquire a credential to harvest the open Attempt's comments; the comments it posted are not recorded", { attemptId, worker, errorTag: comments.failure._tag, message: comments.failure.message });
459
+ return;
460
+ }
461
+ yield* recordComments(attemptId, comments.success, record.comments);
462
+ });
463
+ /** Returns the request the reattached Attempt's parent task was created with. Fails with a `prepare` `ExecutorOperationError` if it's missing or unreadable. */
464
+ const storedRequest = Effect.fn("DurableSession.storedRequest")(function* (attemptId) {
465
+ yield* Effect.annotateCurrentSpan({ attemptId });
466
+ const stored = yield* runtime.request(attemptId).pipe(Effect.mapError((cause) => new ExecutorOperationError({
467
+ operation: "prepare",
468
+ message: "Can't read the durable request of the reattached attempt",
469
+ cause,
470
+ })));
471
+ if (Option.isNone(stored))
472
+ return yield* new ExecutorOperationError({
473
+ operation: "prepare",
474
+ message: "The reattached attempt has no durable request",
475
+ cause: new Error(attemptId),
476
+ });
477
+ return stored.value;
478
+ });
479
+ return {
480
+ launch,
481
+ prepare,
482
+ cancel,
483
+ intervene,
484
+ isLive,
485
+ outcome,
486
+ stopForRecovery,
487
+ recoverPostedComments,
488
+ storedRequest,
489
+ };
490
+ });
491
+ //# sourceMappingURL=durable-session.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"durable-session.js","sourceRoot":"","sources":["../src/durable-session.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,cAAc,MAAM,6BAA6B,CAAC;AAC9D,OAAO,EACL,YAAY,EAEZ,YAAY,EACZ,cAAc,GACf,MAAM,6BAA6B,CAAC;AAKrC,OAAO,EAEL,cAAc,EACd,cAAc,EACd,eAAe,GAChB,MAAM,gCAAgC,CAAC;AACxC,OAAO,EACL,KAAK,EACL,QAAQ,EACR,QAAQ,EACR,MAAM,EACN,IAAI,EACJ,KAAK,EACL,KAAK,EACL,MAAM,EACN,GA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AS;gBACpB,OAAO,EAAE,+CAA+C;gBACxD,KAAK,EAAE,IAAI,KAAK,CAAC,SAAS,CAAC;aAC5B,CAAC,CAAC;QACL,OAAO,MAAM,CAAC,KAAK,CAAC;IACtB,CAAC,CAAC,CAAC;IAEH,OAAO;QACL,MAAM;QACN,OAAO;QACP,MAAM;QACN,SAAS;QACT,MAAM;QACN,OAAO;QACP,eAAe;QACf,qBAAqB;QACrB,aAAa;KACL,CAAC;AACb,CAAC,CAAC,CAAC"}
@@ -1,22 +1,32 @@
1
+ import type { RemoteShell, SshCommand } from "@usine/agents/child-host";
2
+ import type { SshDestination } from "@usine/core/worker";
1
3
  import { Effect } from "effect";
2
- import { ChildProcessSpawner } from "effect/unstable/process";
3
- import { type CommandResult } from "../child-command.ts";
4
- import type { ExecutorOperation, ExecutorOperationError, RunHostCommand } from "../executor.ts";
5
- import type { SshDestination } from "./model.ts";
4
+ import type { CommandResult } from "../child-command.ts";
5
+ import type { ExecutorOperation, ExecutorOperationError } from "../executor.ts";
6
+ import { type RemoteCommands, type RemoteContext } from "../remote/commands.ts";
6
7
  export interface ExeDevCommands {
7
- readonly environment: Record<string, string>;
8
- readonly ssh: RunHostCommand;
8
+ readonly shared: RemoteCommands;
9
+ readonly childHost: (sshDest: SshDestination) => RemoteShell;
9
10
  readonly lobby: (operation: ExecutorOperation, args: ReadonlyArray<string>) => Effect.Effect<string, ExecutorOperationError>;
10
11
  readonly lobbyJson: (operation: ExecutorOperation, args: ReadonlyArray<string>) => Effect.Effect<string, ExecutorOperationError>;
11
12
  readonly remoteRaw: (operation: ExecutorOperation, sshDest: SshDestination, command: string, args: ReadonlyArray<string>) => Effect.Effect<CommandResult, ExecutorOperationError>;
12
- readonly remote: (operation: ExecutorOperation, sshDest: SshDestination, command: string, args: ReadonlyArray<string>) => Effect.Effect<string, ExecutorOperationError>;
13
+ readonly remote: (operation: ExecutorOperation, sshDest: SshDestination, command: string, args: ReadonlyArray<string>, context?: RemoteContext) => Effect.Effect<string, ExecutorOperationError>;
13
14
  }
14
- export declare const commandsFor: (configuredSsh?: RunHostCommand | undefined) => Effect.Effect<{
15
- environment: Record<string, string>;
15
+ export declare const commandsFor: (configuredSsh?: {
16
+ readonly command: string;
17
+ readonly args: readonly string[];
18
+ } | undefined) => Effect.Effect<{
19
+ shared: {
20
+ shellFor: (ssh: SshCommand, destination: SshDestination) => RemoteShell;
21
+ local: (operation: "cancel" | "cleanup" | "launch" | "preflight" | "prepare", host: string, command: string, args: readonly string[]) => Effect.Effect<string, ExecutorOperationError, never>;
22
+ inspect: (operation: ExecutorOperation, shell: RemoteShell, command: string, args: ReadonlyArray<string>) => Effect.Effect<CommandResult, ExecutorOperationError>;
23
+ run: (operation: "cancel" | "cleanup" | "launch" | "preflight" | "prepare", shell: RemoteShell, command: string, args: readonly string[], context?: RemoteContext | undefined) => Effect.Effect<string, ExecutorOperationError, never>;
24
+ runWithInput: (operation: "cancel" | "cleanup" | "launch" | "preflight" | "prepare", shell: RemoteShell, command: string, args: readonly string[], input: import("effect/Redacted").Redacted<string>) => Effect.Effect<string, ExecutorOperationError, never>;
25
+ };
26
+ childHost: (sshDest: SshDestination) => RemoteShell;
16
27
  lobby: (operation: ExecutorOperation, args: ReadonlyArray<string>) => Effect.Effect<string, ExecutorOperationError>;
17
28
  lobbyJson: (operation: ExecutorOperation, args: ReadonlyArray<string>) => Effect.Effect<string, ExecutorOperationError>;
18
- remote: (operation: ExecutorOperation, sshDest: SshDestination, command: string, args: ReadonlyArray<string>) => Effect.Effect<string, ExecutorOperationError>;
19
- remoteRaw: (operation: ExecutorOperation, sshDest: SshDestination, command: string, args: ReadonlyArray<string>) => Effect.Effect<CommandResult, ExecutorOperationError>;
20
- ssh: RunHostCommand;
21
- }, never, ChildProcessSpawner.ChildProcessSpawner>;
29
+ remoteRaw: (operation: "cancel" | "cleanup" | "launch" | "preflight" | "prepare", sshDest: string & import("effect/Brand").Brand<"SshDestination">, command: string, args: readonly string[]) => Effect.Effect<CommandResult, ExecutorOperationError, never>;
30
+ remote: (operation: "cancel" | "cleanup" | "launch" | "preflight" | "prepare", sshDest: string & import("effect/Brand").Brand<"SshDestination">, command: string, args: readonly string[], context: RemoteContext | undefined) => Effect.Effect<string, ExecutorOperationError, never>;
31
+ }, never, import("effect/unstable/process/ChildProcessSpawner").ChildProcessSpawner>;
22
32
  //# sourceMappingURL=commands.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"commands.d.ts","sourceRoot":"","sources":["../../src/exe-dev/commands.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAC9D,OAAO,EAIL,KAAK,aAAa,EACnB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,EAAE,iBAAiB,EAAE,sBAAsB,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAChG,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAGjD,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC7C,QAAQ,CAAC,GAAG,EAAE,cAAc,CAAC;IAC7B,QAAQ,CAAC,KAAK,EAAE,CACd,SAAS,EAAE,iBAAiB,EAC5B,IAAI,EAAE,aAAa,CAAC,MAAM,CAAC,KACxB,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,sBAAsB,CAAC,CAAC;IACnD,QAAQ,CAAC,SAAS,EAAE,CAClB,SAAS,EAAE,iBAAiB,EAC5B,IAAI,EAAE,aAAa,CAAC,MAAM,CAAC,KACxB,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,sBAAsB,CAAC,CAAC;IACnD,QAAQ,CAAC,SAAS,EAAE,CAClB,SAAS,EAAE,iBAAiB,EAC5B,OAAO,EAAE,cAAc,EACvB,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,aAAa,CAAC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