Open History to see the last commit
1import { assert, it } from "@effect/vitest";
2import {
3 CheckpointId,
4 CheckpointScopeId,
5 CommandId,
6 NodeId,
7 ProviderSessionId,
8 ProviderThreadId,
9 ProviderTurnId,
10 RunAttemptId,
11 RunId,
12 RuntimeRequestId,
13 ThreadId,
14 VcsProcessExitError,
15} from "@t3tools/contracts";
16import * as Cause from "effect/Cause";
17import * as DateTime from "effect/DateTime";
18import * as Deferred from "effect/Deferred";
19import * as Effect from "effect/Effect";
20import * as Exit from "effect/Exit";
21import * as Layer from "effect/Layer";
22import * as Option from "effect/Option";
23import * as Ref from "effect/Ref";
24import * as Stream from "effect/Stream";
25
26import * as CheckpointRollbackService from "./CheckpointRollbackService.ts";
27import * as CheckpointService from "./CheckpointService.ts";
28import * as EffectOutbox from "./EffectOutbox.ts";
29import * as EffectWorker from "./EffectWorker.ts";
30import * as RunFinalizationService from "./RunFinalizationService.ts";
31import * as ProviderSessionManager from "./ProviderSessionManager.ts";
32import * as ProviderTurnControlService from "./ProviderTurnControlService.ts";
33import * as ProviderTurnStartService from "./ProviderTurnStartService.ts";
34import * as RuntimeRequestService from "./RuntimeRequestService.ts";
35import * as ThreadTitleRegenerationService from "./ThreadTitleRegenerationService.ts";
36import * as ThreadManagementService from "./ThreadManagementService.ts";
37import * as ServerSettings from "../serverSettings.ts";
38
39const threadId = ThreadId.make("thread:effect-worker-restart");
40const oldSessionId = ProviderSessionId.make("provider-session:effect-worker-restart:old");
41const providerThreadId = ProviderThreadId.make("provider-thread:effect-worker-restart");
42const providerTurnId = ProviderTurnId.make("provider-turn:effect-worker-restart");
43const attemptId = RunAttemptId.make("run-attempt:effect-worker-restart");
44const runId = RunId.make("run:effect-worker-restart");
45
46function restartEffect(
47 now: DateTime.Utc,
48 sessionTransition: NonNullable<
49 Extract<
50 EffectOutbox.OrchestrationEffectV2["request"],
51 { readonly type: "provider-turn.restart" }
52 >["sessionTransition"]
53 >,
54): EffectOutbox.OrchestrationEffectV2 {
55 const timestamp = DateTime.formatIso(now);
56 return {
57 id: `effect:restart:${sessionTransition.type}`,
58 commandId: CommandId.make(`command:restart:${sessionTransition.type}`),
59 threadId,
60 request: {
61 type: "provider-turn.restart",
62 providerSessionId: oldSessionId,
63 providerThreadId,
64 providerTurnId,
65 interruptedAttemptId: attemptId,
66 runId,
67 sessionTransition,
68 },
69 status: "running",
70 attemptCount: 1,
71 availableAt: timestamp,
72 leaseOwner: "test-worker",
73 createdAt: timestamp,
74 updatedAt: timestamp,
75 completedAt: null,
76 lastError: null,
77 };
78}
79
80function layerExecutorFor(input: {
81 readonly events: Ref.Ref<ReadonlyArray<string>>;
82 readonly failFirstStart?: Ref.Ref<boolean>;
83 readonly threads?: Partial<ThreadManagementService.ThreadManagementService["Service"]>;
84 readonly continueAfterRestart?: boolean;
85 readonly interrupt?: ProviderTurnControlService.ProviderTurnControlServiceV2Shape["interrupt"];
86 readonly rollback?: CheckpointRollbackService.CheckpointRollbackServiceV2Shape["execute"];
87 readonly respond?: RuntimeRequestService.RuntimeRequestServiceV2["Service"]["respond"];
88}) {
89 const record = (event: string) => Ref.update(input.events, (events) => [...events, event]);
90 const layerDependencies = Layer.mergeAll(
91 Layer.succeed(
92 ProviderTurnControlService.ProviderTurnControlServiceV2,
93 ProviderTurnControlService.ProviderTurnControlServiceV2.of({
94 interrupt: input.interrupt ?? (() => Effect.void),
95 steer: () => Effect.void,
96 interruptAndAwaitTerminal: (request) =>
97 record(
98 request.replacementProviderSessionId === undefined
99 ? "interrupt"
100 : `interrupt:${request.replacementProviderSessionId}`,
101 ),
102 }),
103 ),
104 Layer.succeed(
105 ProviderSessionManager.ProviderSessionManagerV2,
106 ProviderSessionManager.ProviderSessionManagerV2.of({
107 shutdown: Effect.void,
108 open: () => Effect.die("unused open"),
109 get: () => Effect.succeedNone,
110 isLive: () => Effect.succeed(false),
111 close: () => Effect.void,
112 closeInstance: () => Effect.void,
113 release: () => record("release"),
114 detach: () => record("detach"),
115 otherWorkingThreads: () => Effect.succeed([]),
116 releaseUnlessBusy: () => Effect.succeed(true),
117 subscribePromptSuggestion: () => Stream.empty,
118 }),
119 ),
120 Layer.succeed(
121 ProviderTurnStartService.ProviderTurnStartServiceV2,
122 ProviderTurnStartService.ProviderTurnStartServiceV2.of({
123 start: () =>
124 Effect.gen(function* () {
125 yield* record("start");
126 if (
127 input.failFirstStart !== undefined &&
128 (yield* Ref.getAndSet(input.failFirstStart, false))
129 ) {
130 return yield* new ProviderTurnStartService.ProviderTurnStartError({
131 runId,
132 cause: "simulated first start failure",
133 });
134 }
135 }),
136 }),
137 ),
138 Layer.succeed(
139 RunFinalizationService.RunFinalizationService,
140 RunFinalizationService.RunFinalizationService.of({ finalize: () => Effect.void }),
141 ),
142 Layer.succeed(
143 CheckpointRollbackService.CheckpointRollbackServiceV2,
144 CheckpointRollbackService.CheckpointRollbackServiceV2.of({
145 execute: input.rollback ?? (() => Effect.void),
146 }),
147 ),
148 Layer.succeed(
149 RuntimeRequestService.RuntimeRequestServiceV2,
150 RuntimeRequestService.RuntimeRequestServiceV2.of({
151 respond: input.respond ?? (() => Effect.void),
152 }),
153 ),
154 Layer.succeed(
155 ThreadTitleRegenerationService.ThreadTitleRegenerationService,
156 ThreadTitleRegenerationService.ThreadTitleRegenerationService.of({
157 execute: () => Effect.void,
158 }),
159 ),
160 );
161 return EffectWorker.layerExecutor.pipe(
162 Layer.provide(
163 Layer.mergeAll(
164 layerDependencies,
165 Layer.mock(ThreadManagementService.ThreadManagementService)(input.threads ?? {}),
166 ServerSettings.layerTest(
167 input.continueAfterRestart === true ? { continueThreadsAfterServerUpdate: true } : {},
168 ),
169 ),
170 ),
171 );
172}
173
174it.effect.each([
175 {
176 name: "settles a stopped run when its adapter has already lost the native turn",
177 unresponsive: false,
178 dispatched: ["thread.background-work.settle"],
179 },
180 {
181 name: "leaves the run running and flags the Stop when the provider never confirms it",
182 unresponsive: true,
183 dispatched: ["thread.interrupt.unresponsive"],
184 },
185])("$name", ({ unresponsive, dispatched }) =>
186 Effect.gen(function* () {
187 const now = yield* DateTime.now;
188 const events = yield* Ref.make<ReadonlyArray<string>>([]);
189 const layer = layerExecutorFor({
190 events,
191 interrupt: () =>
192 new ProviderTurnControlService.ProviderTurnControlError({
193 threadId,
194 operation: "interrupt",
195 providerTurnId,
196 ...(unresponsive ? { unresponsive } : {}),
197 cause: unresponsive ? "Timed out." : "Provider turn is not active.",
198 }),
199 threads: {
200 dispatch: (command) =>
201 Ref.update(events, (current) => [...current, command.type]).pipe(
202 Effect.as({ sequence: 1, storedEvents: [] }),
203 ),
204 },
205 });
206 yield* Effect.gen(function* () {
207 const executor = yield* EffectWorker.OrchestrationEffectExecutorV2;
208 yield* executor.execute({
209 ...restartEffect(now, { type: "detach" }),
210 request: {
211 type: "provider-turn.interrupt",
212 providerSessionId: oldSessionId,
213 providerThreadId,
214 providerTurnId,
215 },
216 });
217 }).pipe(Effect.provide(layer));
218 assert.deepEqual(yield* Ref.get(events), dispatched);
219 }),
220);
221
222const lockedIndexMessage =
223 "Git's index is locked. Wait for other Git operations to finish, then try again.";
224const rollbackCheckpointId = CheckpointId.make("checkpoint:effect-worker-rollback");
225const rollbackScopeId = CheckpointScopeId.make("checkpoint-scope:effect-worker-rollback");
226const restoreFailure = (detail: string) =>
227 new CheckpointRollbackService.CheckpointRollbackExecutionError({
228 reason: "unexpected-failure",
229 threadId,
230 providerThreadId,
231 checkpointId: rollbackCheckpointId,
232 cause: new CheckpointService.CheckpointRestoreError({
233 scopeId: rollbackScopeId,
234 checkpointId: rollbackCheckpointId,
235 cause: new VcsProcessExitError({
236 operation: "GitVcsDriverCore.restoreCheckpoint",
237 command: "git",
238 cwd: "/private/repo",
239 exitCode: 128,
240 detail,
241 failureKind: "command-failed",
242 }),
243 }),
244 });
245
246it.effect.each([
247 {
248 name: "a held Git index lock",
249 failure: restoreFailure(lockedIndexMessage),
250 message: lockedIndexMessage,
251 },
252 {
253 name: "raw Git output",
254 failure: restoreFailure("error: could not clean /private/repo/secret.txt"),
255 message: CheckpointRollbackService.ROLLBACK_FAILED_MESSAGE,
256 },
257])("reports a rollback blocked by $name only after the last attempt", ({ failure, message }) =>
258 Effect.gen(function* () {
259 const now = yield* DateTime.now;
260 const failures = yield* Ref.make<ReadonlyArray<string>>([]);
261 const layer = layerExecutorFor({
262 events: yield* Ref.make<ReadonlyArray<string>>([]),
263 rollback: () => Effect.fail(failure),
264 threads: {
265 dispatch: (command) =>
266 Ref.update(failures, (current) =>
267 command.type === "checkpoint.rollback.fail" ? [...current, command.message] : current,
268 ).pipe(Effect.as({ sequence: 1, storedEvents: [] })),
269 },
270 });
271 yield* Effect.gen(function* () {
272 const executor = yield* EffectWorker.OrchestrationEffectExecutorV2;
273 const rollback: EffectOutbox.OrchestrationEffectV2 = {
274 ...restartEffect(now, { type: "detach" }),
275 request: {
276 type: "provider-thread.rollback",
277 providerThreadId,
278 checkpointId: rollbackCheckpointId,
279 scopeId: rollbackScopeId,
280 restoreFiles: true,
281 },
282 };
283 yield* Effect.flip(executor.execute(rollback, { willRetry: true }));
284 assert.deepEqual(yield* Ref.get(failures), []);
285 yield* Effect.flip(executor.execute(rollback, { willRetry: false }));
286 }).pipe(Effect.provide(layer));
287 assert.deepEqual(yield* Ref.get(failures), [message]);
288 }),
289);
290
291it.effect("does not report an answer whose last delivery attempt is interrupted", () =>
292 Effect.gen(function* () {
293 const now = yield* DateTime.now;
294 const reported = yield* Ref.make(0);
295 const layer = layerExecutorFor({
296 events: yield* Ref.make<ReadonlyArray<string>>([]),
297 respond: () => Effect.interrupt,
298 threads: {
299 dispatch: (command) =>
300 Ref.update(reported, (count) =>
301 command.type === "runtime-request.delivery.fail" ? count + 1 : count,
302 ).pipe(Effect.as({ sequence: 1, storedEvents: [] })),
303 },
304 });
305 const exit = yield* Effect.gen(function* () {
306 const executor = yield* EffectWorker.OrchestrationEffectExecutorV2;
307 return yield* Effect.exit(
308 executor.execute(
309 {
310 ...restartEffect(now, { type: "detach" }),
311 request: {
312 type: "runtime-request.respond",
313 providerSessionId: oldSessionId,
314 requestId: RuntimeRequestId.make("runtime-request:effect-worker-interrupted"),
315 answers: { next: "Ship it" },
316 },
317 },
318 { willRetry: false },
319 ),
320 );
321 }).pipe(Effect.provide(layer));
322 assert.isTrue(Exit.hasInterrupts(exit));
323 assert.equal(yield* Ref.get(reported), 0);
324 }),
325);
326
327it.effect("requeues a claim when a pre-execution worker check fails", () =>
328 Effect.gen(function* () {
329 const now = DateTime.formatIso(yield* DateTime.now);
330 const effectId = "effect:worker-pre-execution-failure";
331 const workerId = "worker-pre-execution-failure";
332 const claimedEffect: EffectOutbox.OrchestrationEffectV2 = {
333 id: effectId,
334 commandId: CommandId.make("command:worker-pre-execution-failure"),
335 threadId: ThreadId.make("thread:worker-pre-execution-failure"),
336 request: { type: "terminal.cleanup" },
337 status: "running",
338 attemptCount: 1,
339 availableAt: now,
340 leaseOwner: workerId,
341 createdAt: now,
342 updatedAt: now,
343 completedAt: null,
344 lastError: null,
345 };
346 const retries = yield* Ref.make<
347 ReadonlyArray<{
348 readonly effectId: string;
349 readonly workerId: string;
350 readonly error: string;
351 readonly delayMs: number;
352 }>
353 >([]);
354 const executionCount = yield* Ref.make(0);
355 const layerOutbox = Layer.mock(EffectOutbox.EffectOutboxV2)({
356 claimNext: () => Effect.succeedSome(claimedEffect),
357 get: () =>
358 Effect.fail(
359 new EffectOutbox.EffectOutboxError({
360 operation: "get",
361 effectId,
362 cause: "simulated cancellation-state read failure",
363 }),
364 ),
365 retry: (input) =>
366 Ref.update(retries, (existing) => [...existing, input]).pipe(Effect.as(true)),
367 });
368 const layerExecutor = Layer.succeed(
369 EffectWorker.OrchestrationEffectExecutorV2,
370 EffectWorker.OrchestrationEffectExecutorV2.of({
371 execute: () => Ref.update(executionCount, (count) => count + 1),
372 }),
373 );
374 const layerWorker = EffectWorker.layerWithOptions({ workerId }).pipe(
375 Layer.provide(Layer.merge(layerOutbox, layerExecutor)),
376 );
377
378 const exit = yield* EffectWorker.OrchestrationEffectWorkerV2.pipe(
379 Effect.flatMap((worker) => worker.runOnce),
380 Effect.provide(layerWorker),
381 Effect.exit,
382 );
383
384 assert.isTrue(Exit.isFailure(exit));
385 if (Exit.isFailure(exit)) {
386 assert.include(Cause.pretty(exit.cause), "simulated cancellation-state read failure");
387 }
388 assert.equal(yield* Ref.get(executionCount), 0);
389 const retry = (yield* Ref.get(retries))[0];
390 assert.isDefined(retry);
391 assert.equal(retry.effectId, effectId);
392 assert.equal(retry.workerId, workerId);
393 assert.equal(retry.delayMs, 0);
394 assert.include(retry.error, "simulated cancellation-state read failure");
395 }),
396);
397
398it.effect("arms cancellation before the durable pre-execution check", () =>
399 Effect.gen(function* () {
400 const now = DateTime.formatIso(yield* DateTime.now);
401 const effectId = "effect:worker-cancellation-registration-race";
402 const workerId = "worker-cancellation-registration-race";
403 const claimedEffect: EffectOutbox.OrchestrationEffectV2 = {
404 id: effectId,
405 commandId: CommandId.make("command:worker-cancellation-registration-race"),
406 threadId: ThreadId.make("thread:worker-cancellation-registration-race"),
407 request: { type: "terminal.cleanup" },
408 status: "running",
409 attemptCount: 1,
410 availableAt: now,
411 leaseOwner: workerId,
412 createdAt: now,
413 updatedAt: now,
414 completedAt: null,
415 lastError: null,
416 };
417 const signal = yield* Deferred.make<void>();
418 let cancellationArmed = false;
419 const executionCount = yield* Ref.make(0);
420 const settlementCount = yield* Ref.make(0);
421 const layerOutbox = Layer.mock(EffectOutbox.EffectOutboxV2)({
422 claimNext: () => Effect.succeedSome(claimedEffect),
423 awaitCancellation: () => {
424 cancellationArmed = true;
425 return Deferred.await(signal);
426 },
427 get: () =>
428 Effect.gen(function* () {
429 if (cancellationArmed) {
430 yield* Deferred.succeed(signal, undefined);
431 }
432 return Option.some(claimedEffect);
433 }),
434 clearCancellation: () => Effect.void,
435 succeed: () => Ref.update(settlementCount, (count) => count + 1).pipe(Effect.as(true)),
436 });
437 const layerExecutor = Layer.succeed(
438 EffectWorker.OrchestrationEffectExecutorV2,
439 EffectWorker.OrchestrationEffectExecutorV2.of({
440 execute: () =>
441 Effect.yieldNow.pipe(Effect.andThen(Ref.update(executionCount, (count) => count + 1))),
442 }),
443 );
444 const layerWorker = EffectWorker.layerWithOptions({ workerId }).pipe(
445 Layer.provide(Layer.merge(layerOutbox, layerExecutor)),
446 );
447
448 const exit = yield* EffectWorker.OrchestrationEffectWorkerV2.pipe(
449 Effect.flatMap((worker) => worker.runOnce),
450 Effect.provide(layerWorker),
451 Effect.exit,
452 );
453
454 if (Exit.isFailure(exit)) {
455 assert.fail(Cause.pretty(exit.cause));
456 }
457 assert.equal(yield* Ref.get(executionCount), 0);
458 assert.equal(yield* Ref.get(settlementCount), 0);
459 }),
460);
461
462it.effect("terminalizes a process-bound claim when success settlement fails", () =>
463 Effect.gen(function* () {
464 const now = DateTime.formatIso(yield* DateTime.now);
465 const effectId = "effect:worker-process-bound-settlement-failure";
466 const workerId = "worker-process-bound-settlement-failure";
467 const claimedEffect: EffectOutbox.OrchestrationEffectV2 = {
468 id: effectId,
469 commandId: CommandId.make("command:worker-process-bound-settlement-failure"),
470 threadId: ThreadId.make("thread:worker-process-bound-settlement-failure"),
471 request: {
472 type: "provider-turn.start",
473 runId: RunId.make("run:worker-process-bound-settlement-failure"),
474 },
475 status: "running",
476 attemptCount: 1,
477 availableAt: now,
478 leaseOwner: workerId,
479 createdAt: now,
480 updatedAt: now,
481 completedAt: null,
482 lastError: null,
483 };
484 const retries = yield* Ref.make(0);
485 const terminalErrors = yield* Ref.make<ReadonlyArray<string>>([]);
486 const executionCount = yield* Ref.make(0);
487 const layerOutbox = Layer.mock(EffectOutbox.EffectOutboxV2)({
488 claimNext: () => Effect.succeedSome(claimedEffect),
489 get: () => Effect.succeedSome(claimedEffect),
490 awaitCancellation: () => Effect.never,
491 clearCancellation: () => Effect.void,
492 succeed: () =>
493 Effect.fail(
494 new EffectOutbox.EffectOutboxError({
495 operation: "succeed",
496 effectId,
497 cause: "simulated success settlement failure",
498 }),
499 ),
500 retry: () => Ref.update(retries, (count) => count + 1).pipe(Effect.as(true)),
501 fail: ({ error }) =>
502 Ref.update(terminalErrors, (existing) => [...existing, error]).pipe(Effect.as(true)),
503 });
504 const layerExecutor = Layer.succeed(
505 EffectWorker.OrchestrationEffectExecutorV2,
506 EffectWorker.OrchestrationEffectExecutorV2.of({
507 execute: () => Ref.update(executionCount, (count) => count + 1),
508 }),
509 );
510 const layerWorker = EffectWorker.layerWithOptions({ workerId }).pipe(
511 Layer.provide(Layer.merge(layerOutbox, layerExecutor)),
512 );
513
514 const exit = yield* EffectWorker.OrchestrationEffectWorkerV2.pipe(
515 Effect.flatMap((worker) => worker.runOnce),
516 Effect.provide(layerWorker),
517 Effect.exit,
518 );
519
520 assert.isTrue(Exit.isFailure(exit));
521 assert.equal(yield* Ref.get(executionCount), 1);
522 assert.equal(yield* Ref.get(retries), 0);
523 const terminalError = (yield* Ref.get(terminalErrors))[0];
524 assert.isDefined(terminalError);
525 assert.include(terminalError, "after execution started");
526 assert.include(terminalError, "simulated success settlement failure");
527 }),
528);
529
530it.effect("settles a delegated child once its restart continuation fails for good", () =>
531 Effect.gen(function* () {
532 const timestamp = DateTime.formatIso(yield* DateTime.now);
533 const events = yield* Ref.make<ReadonlyArray<string>>([]);
534 const recovered = yield* Ref.make<ReadonlyArray<ThreadId>>([]);
535 const layer = layerExecutorFor({
536 events,
537 continueAfterRestart: true,
538 threads: {
539 getThreadRecords: () => Effect.fail(new Error("provider instance removed") as never),
540 recoverDelegatedTask: (childThreadId) =>
541 Ref.update(recovered, (ids) => [...ids, childThreadId]),
542 },
543 });
544 const effect: EffectOutbox.OrchestrationEffectV2 = {
545 id: `effect:restart-continuation:${runId}`,
546 commandId: CommandId.make("command:restart-continuation-failure"),
547 threadId,
548 request: { type: "provider-runtime.continue", sourceRunId: runId },
549 status: "running",
550 attemptCount: 1,
551 availableAt: timestamp,
552 leaseOwner: "test-worker",
553 createdAt: timestamp,
554 updatedAt: timestamp,
555 completedAt: null,
556 lastError: null,
557 };
558 yield* Effect.gen(function* () {
559 const executor = yield* EffectWorker.OrchestrationEffectExecutorV2;
560 assert.isTrue(
561 Exit.isFailure(yield* Effect.exit(executor.execute(effect, { willRetry: true }))),
562 );
563 assert.deepEqual(yield* Ref.get(recovered), []);
564 assert.isTrue(
565 Exit.isFailure(yield* Effect.exit(executor.execute(effect, { willRetry: false }))),
566 );
567 assert.deepEqual(yield* Ref.get(recovered), [threadId]);
568 }).pipe(Effect.provide(layer));
569 }),
570);
571
572it.effect.each(["confirmed", "unconfirmed", "failed"] as const)(
573 "a native subagent stop only repairs %s provider evidence",
574 (outcome) =>
575 Effect.gen(function* () {
576 const now = yield* DateTime.now;
577 const events = yield* Ref.make<ReadonlyArray<string>>([]);
578 const layer = layerExecutorFor({
579 events,
580 interrupt: (input) => {
581 assert.equal(input.subagent?.nativeTaskId, "native-task");
582 return Ref.update(events, (current) => [...current, "stop-child"]).pipe(
583 Effect.andThen(
584 outcome === "failed"
585 ? new ProviderTurnControlService.ProviderTurnControlError({
586 threadId,
587 providerTurnId,
588 operation: "interrupt",
589 cause: "SDK stop failed",
590 })
591 : Effect.succeed(
592 outcome === "confirmed"
593 ? {
594 status: "cancelled" as const,
595 completedAt: now,
596 result: "Stopped by Claude",
597 }
598 : undefined,
599 ),
600 ),
601 );
602 },
603 threads: {
604 dispatch: (command) => {
605 assert.equal(command.type, "thread.background-work.settle");
606 if (command.type === "thread.background-work.settle") {
607 assert.equal(command.subagent?.id, "subagent");
608 assert.deepEqual(command.subagent?.outcome, {
609 status: "cancelled",
610 completedAt: now,
611 result: "Stopped by Claude",
612 });
613 }
614 return Ref.update(events, (current) => [...current, "settle-child"]).pipe(
615 Effect.as({ sequence: 1, storedEvents: [] }),
616 );
617 },
618 },
619 });
620 const execution = yield* Effect.gen(function* () {
621 const executor = yield* EffectWorker.OrchestrationEffectExecutorV2;
622 yield* executor.execute({
623 ...restartEffect(now, { type: "detach" }),
624 request: {
625 type: "provider-turn.interrupt",
626 providerSessionId: oldSessionId,
627 providerThreadId,
628 providerTurnId,
629 subagent: { id: NodeId.make("subagent"), nativeTaskId: "native-task" },
630 },
631 });
632 }).pipe(Effect.provide(layer), Effect.exit);
633 assert.equal(Exit.isFailure(execution), outcome === "failed");
634 assert.deepEqual(
635 yield* Ref.get(events),
636 outcome === "confirmed" ? ["stop-child", "settle-child"] : ["stop-child"],
637 );
638 }),
639);