

























@@ -84,6 +84,7 @@ const mocks = vi.hoisted(() => ({
8484updateSessionStore: vi.fn(),
8585emitSessionLifecycleEvent: vi.fn(),
8686persistSubagentRunsToDisk: vi.fn(),
87+persistSubagentRunsToDiskOrThrow: vi.fn(),
8788restoreSubagentRunsFromDisk: vi.fn(() => 0),
8889getSubagentRunsSnapshotForRead: vi.fn(
8990(runs: Map<string, import("./subagent-registry.types.js").SubagentRunRecord>) => new Map(runs),
@@ -130,6 +131,7 @@ vi.mock("../sessions/session-lifecycle-events.js", () => ({
130131vi.mock("./subagent-registry-state.js", () => ({
131132getSubagentRunsSnapshotForRead: mocks.getSubagentRunsSnapshotForRead,
132133persistSubagentRunsToDisk: mocks.persistSubagentRunsToDisk,
134+persistSubagentRunsToDiskOrThrow: mocks.persistSubagentRunsToDiskOrThrow,
133135restoreSubagentRunsFromDisk: mocks.restoreSubagentRunsFromDisk,
134136}));
135137@@ -211,6 +213,7 @@ describe("subagent registry seam flow", () => {
211213cleanupBrowserSessionsForLifecycleEnd: mocks.cleanupBrowserSessionsForLifecycleEnd,
212214onAgentEvent: mocks.onAgentEvent,
213215persistSubagentRunsToDisk: mocks.persistSubagentRunsToDisk,
216+persistSubagentRunsToDiskOrThrow: mocks.persistSubagentRunsToDiskOrThrow,
214217resolveAgentTimeoutMs: mocks.resolveAgentTimeoutMs,
215218restoreSubagentRunsFromDisk: mocks.restoreSubagentRunsFromDisk,
216219runSubagentAnnounceFlow: mocks.runSubagentAnnounceFlow,
@@ -732,6 +735,29 @@ describe("subagent registry seam flow", () => {
732735expect(mocks.persistSubagentRunsToDisk).toHaveBeenCalledTimes(6);
733736});
734737738+it("throws and removes the entry when the initial durable registry write fails", () => {
739+mocks.persistSubagentRunsToDiskOrThrow.mockImplementationOnce(() => {
740+throw new Error("disk full");
741+});
742+743+expect(() =>
744+mod.registerSubagentRun({
745+runId: "run-durability-required",
746+childSessionKey: "agent:main:subagent:child",
747+requesterSessionKey: "agent:main:main",
748+requesterDisplayKey: "main",
749+task: "must fail closed",
750+cleanup: "keep",
751+}),
752+).toThrowError("disk full");
753+754+expect(
755+mod
756+.listSubagentRunsForRequester("agent:main:main")
757+.find((entry) => entry.runId === "run-durability-required"),
758+).toBeUndefined();
759+});
760+735761it("continues completion announce cleanup when lifecycle cleanup fails", async () => {
736762mocks.cleanupBrowserSessionsForLifecycleEnd.mockRejectedValueOnce(
737763new Error("browser cleanup unavailable"),
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。