fix(platform): let an interaction detach from its owner signal on completion (Q-6.9-7)

createExecutionContext forwarded an owner signal's abort and removed
that listener only when the interaction itself aborted. An interaction
that finished normally under a long-lived owner signal left its listener
and AbortController on the owner. ExecutionContext gains complete():
idempotent, detaches from the owner without aborting the interaction.
No caller passes an owner signal today, so this closes a latent leak.

Verified: new test in tests/platform/execution/execution-context.test.ts
(RED before: complete is not a function); all gates pass except the
known tests/unit/removal-fixture.test.ts (artifacts/ absent).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
DongHyeonka
2026-09-24 13:58:35 +09:00
co-authored by Claude Opus 5.5
parent b7c4e380e2
commit 911561985b
2 changed files with 39 additions and 6 deletions
@@ -1,4 +1,4 @@
import { describe, expect, it } from "vitest";
import { describe, expect, it, vi } from "vitest";
import { createExecutionContext } from "../../../src/platform/execution/execution-context.ts";
@@ -69,6 +69,26 @@ describe("createExecutionContext", () => {
expect(direct.cancellation.signal.aborted).toBe(true);
});
it("detaches from a long-lived owner signal when the interaction completes (Q-6.9-7)", () => {
const owner = new AbortController();
const remove = vi.spyOn(owner.signal, "removeEventListener");
const context = createExecutionContext({
interactionId: "interaction-7",
deadlineMs: 1_000,
traffic: TRAFFIC,
signal: owner.signal,
});
context.complete();
context.complete();
expect(remove).toHaveBeenCalledOnce();
expect(remove).toHaveBeenCalledWith("abort", expect.any(Function));
// A finished interaction is not cancelled by its owner afterwards.
owner.abort();
expect(context.cancellation.signal.aborted).toBe(false);
});
it.each([0, -1, Number.POSITIVE_INFINITY, 60_001, 1.5])(
"rejects an unbounded or invalid deadline %s",
(deadlineMs) => {