Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

EffectWorker.test.ts

628 lines22.9 KB

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