Skip to content

Commit b84d7e3

Browse files
authored
fix(ci): repair release E2E regressions (#117656)
* test(agents): use canonical subagent execution fixtures * fix(gateway): surface session migration conflicts * test(gateway): remove stale history helper * chore(release): leave changelog generation to release flow
1 parent 0e45b46 commit b84d7e3

3 files changed

Lines changed: 51 additions & 47 deletions

File tree

‎src/agents/subagent-announce.format.e2e.test.ts‎

Lines changed: 24 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -54,14 +54,16 @@ type MockSubagentRun = {
5454
task: string;
5555
cleanup: "keep" | "delete";
5656
createdAt: number;
57-
endedAt?: number;
57+
execution: {
58+
endedAt?: number;
59+
outcome?: {
60+
status: "ok" | "timeout" | "error" | "unknown";
61+
error?: string;
62+
};
63+
};
5864
cleanupCompletedAt?: number;
5965
label?: string;
6066
frozenResultText?: string | null;
61-
outcome?: {
62-
status: "ok" | "timeout" | "error" | "unknown";
63-
error?: string;
64-
};
6567
};
6668
type SessionEntryFixture = Partial<Omit<SessionEntry, "updatedAt">> & {
6769
updatedAt?: number;
@@ -2474,10 +2476,9 @@ describe("subagent announce formatting", () => {
24742476
label: "child-stale",
24752477
cleanup: "keep",
24762478
createdAt: 1,
2477-
endedAt: 2,
2479+
execution: { endedAt: 2, outcome: { status: "ok" } },
24782480
cleanupCompletedAt: 3,
24792481
frozenResultText: "stale result that should be filtered",
2480-
outcome: { status: "ok" },
24812482
},
24822483
];
24832484
}
@@ -2491,10 +2492,9 @@ describe("subagent announce formatting", () => {
24912492
label: "child-a",
24922493
cleanup: "keep",
24932494
createdAt: 10,
2494-
endedAt: 20,
2495+
execution: { endedAt: 20, outcome: { status: "ok" } },
24952496
cleanupCompletedAt: 21,
24962497
frozenResultText: "result from child a",
2497-
outcome: { status: "ok" },
24982498
},
24992499
{
25002500
runId: "run-child-b",
@@ -2505,10 +2505,9 @@ describe("subagent announce formatting", () => {
25052505
label: "child-b",
25062506
cleanup: "keep",
25072507
createdAt: 11,
2508-
endedAt: 21,
2508+
execution: { endedAt: 21, outcome: { status: "ok" } },
25092509
cleanupCompletedAt: 22,
25102510
frozenResultText: "result from child b",
2511-
outcome: { status: "ok" },
25122511
},
25132512
];
25142513
},
@@ -2562,10 +2561,9 @@ describe("subagent announce formatting", () => {
25622561
label: "child-a",
25632562
cleanup: "keep",
25642563
createdAt: 10,
2565-
endedAt: 20,
2564+
execution: { endedAt: 20, outcome: { status: "ok" } },
25662565
cleanupCompletedAt: 21,
25672566
frozenResultText: "stale result from child a",
2568-
outcome: { status: "ok" },
25692567
},
25702568
{
25712569
runId: "run-child-current",
@@ -2576,10 +2574,9 @@ describe("subagent announce formatting", () => {
25762574
label: "child-a",
25772575
cleanup: "keep",
25782576
createdAt: 11,
2579-
endedAt: 22,
2577+
execution: { endedAt: 22, outcome: { status: "ok" } },
25802578
cleanupCompletedAt: 23,
25812579
frozenResultText: "current result from child a",
2582-
outcome: { status: "ok" },
25832580
},
25842581
{
25852582
runId: "run-child-b",
@@ -2590,10 +2587,9 @@ describe("subagent announce formatting", () => {
25902587
label: "child-b",
25912588
cleanup: "keep",
25922589
createdAt: 12,
2593-
endedAt: 24,
2590+
execution: { endedAt: 24, outcome: { status: "ok" } },
25942591
cleanupCompletedAt: 25,
25952592
frozenResultText: "result from child b",
2596-
outcome: { status: "ok" },
25972593
},
25982594
];
25992595
},
@@ -2638,10 +2634,9 @@ describe("subagent announce formatting", () => {
26382634
label: "shared-child",
26392635
cleanup: "keep",
26402636
createdAt: 10,
2641-
endedAt: 20,
2637+
execution: { endedAt: 20, outcome: { status: "ok" } },
26422638
cleanupCompletedAt: 21,
26432639
frozenResultText: "stale old parent result",
2644-
outcome: { status: "ok" },
26452640
},
26462641
];
26472642
},
@@ -2660,10 +2655,9 @@ describe("subagent announce formatting", () => {
26602655
label: "shared-child",
26612656
cleanup: "keep",
26622657
createdAt: 11,
2663-
endedAt: 22,
2658+
execution: { endedAt: 22, outcome: { status: "ok" } },
26642659
cleanupCompletedAt: 23,
26652660
frozenResultText: "current new parent result",
2666-
outcome: { status: "ok" },
26672661
};
26682662
},
26692663
);
@@ -2713,10 +2707,9 @@ describe("subagent announce formatting", () => {
27132707
label: "child-a",
27142708
cleanup: "keep",
27152709
createdAt: 10,
2716-
endedAt: 20,
2710+
execution: { endedAt: 20, outcome: { status: "ok" } },
27172711
cleanupCompletedAt: 21,
27182712
frozenResultText: "result from child a",
2719-
outcome: { status: "ok" },
27202713
},
27212714
{
27222715
runId: "run-child-b",
@@ -2727,10 +2720,9 @@ describe("subagent announce formatting", () => {
27272720
label: "child-b",
27282721
cleanup: "keep",
27292722
createdAt: 11,
2730-
endedAt: 21,
2723+
execution: { endedAt: 21, outcome: { status: "ok" } },
27312724
cleanupCompletedAt: 22,
27322725
frozenResultText: "result from child b",
2733-
outcome: { status: "ok" },
27342726
},
27352727
];
27362728
},
@@ -2793,10 +2785,9 @@ describe("subagent announce formatting", () => {
27932785
label: "child-a",
27942786
cleanup: "keep",
27952787
createdAt: 10,
2796-
endedAt: 20,
2788+
execution: { endedAt: 20, outcome: { status: "ok" } },
27972789
cleanupCompletedAt: 21,
27982790
frozenResultText: "result from child a",
2799-
outcome: { status: "ok" },
28002791
},
28012792
];
28022793
},
@@ -2849,10 +2840,9 @@ describe("subagent announce formatting", () => {
28492840
label: "grandchild",
28502841
cleanup: "keep",
28512842
createdAt: 10,
2852-
endedAt: 20,
2843+
execution: { endedAt: 20, outcome: { status: "ok" } },
28532844
cleanupCompletedAt: 21,
28542845
frozenResultText: "grandchild final output",
2855-
outcome: { status: "ok" },
28562846
},
28572847
];
28582848
}
@@ -2867,10 +2857,9 @@ describe("subagent announce formatting", () => {
28672857
label: "child",
28682858
cleanup: "keep",
28692859
createdAt: 11,
2870-
endedAt: 21,
2860+
execution: { endedAt: 21, outcome: { status: "ok" } },
28712861
cleanupCompletedAt: 22,
28722862
frozenResultText: "child synthesized output from grandchild",
2873-
outcome: { status: "ok" },
28742863
},
28752864
];
28762865
}
@@ -3182,10 +3171,12 @@ describe("subagent announce formatting", () => {
31823171
label: params.label,
31833172
cleanup: "keep" as const,
31843173
createdAt: params.createdAt,
3185-
endedAt: params.endedAt ?? params.createdAt + 1,
3174+
execution: {
3175+
endedAt: params.endedAt ?? params.createdAt + 1,
3176+
outcome: params.outcome ?? ({ status: "ok" } as const),
3177+
},
31863178
cleanupCompletedAt: params.cleanupCompletedAt ?? params.createdAt + 2,
31873179
frozenResultText: params.frozenResultText,
3188-
outcome: params.outcome ?? ({ status: "ok" } as const),
31893180
};
31903181
}
31913182

‎src/gateway/sessions-history-http.test.ts‎

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -302,14 +302,6 @@ async function readSessionHistoryBody(
302302
return (await res.json()) as SessionHistoryBody;
303303
}
304304

305-
async function expectSessionHistoryText(params: { sessionKey: string; expectedText: string }) {
306-
await withGatewayHarness(async (harness) => {
307-
const body = await readSessionHistoryBody(harness.port, params.sessionKey);
308-
expect(body.sessionKey).toBe(params.sessionKey);
309-
expect(body.messages?.[0]?.content?.[0]?.text).toBe(params.expectedText);
310-
});
311-
}
312-
313305
async function readSseEvent(
314306
reader: ReadableStreamDefaultReader<Uint8Array>,
315307
state: { buffer: string },
@@ -801,7 +793,7 @@ describe("session history HTTP endpoints", () => {
801793
});
802794
});
803795

804-
test("prefers the freshest duplicate row for direct history reads", async () => {
796+
test("rejects duplicate canonical rows with an actionable migration error", async () => {
805797
testState.sessionConfig = { mainKey: "work" };
806798
const storePath = await createSessionStoreFile();
807799
await replaceTranscriptEvents(
@@ -848,9 +840,14 @@ describe("session history HTTP endpoints", () => {
848840
],
849841
});
850842

851-
await expectSessionHistoryText({
852-
sessionKey: "agent:main:work",
853-
expectedText: "fresh history",
843+
await withGatewayHarness(async (harness) => {
844+
const res = await fetchSessionHistory(harness.port, "agent:main:work");
845+
expect(res.status).toBe(409);
846+
expectErrorResponse(await res.json(), {
847+
type: "migration_required",
848+
message:
849+
"duplicate rows resolve to canonical session key agent:main:work; stop the Gateway and run openclaw doctor --fix",
850+
});
854851
});
855852
});
856853

‎src/gateway/sessions-history-http.ts‎

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,24 @@ export async function handleSessionHistoryHttpRequest(
132132
}
133133
const { cfg } = authResult;
134134

135-
const target = resolveGatewaySessionStoreTargetWithStore({ cfg, key: sessionKey });
136-
const entry = resolveCanonicalSessionEntryFromStoreKeys(target.store, target.storeKeys);
135+
let target: ReturnType<typeof resolveGatewaySessionStoreTargetWithStore>;
136+
let entry: ReturnType<typeof resolveCanonicalSessionEntryFromStoreKeys>;
137+
try {
138+
target = resolveGatewaySessionStoreTargetWithStore({ cfg, key: sessionKey });
139+
entry = resolveCanonicalSessionEntryFromStoreKeys(target.store, target.storeKeys);
140+
} catch (error) {
141+
if ((error as { code?: unknown })?.code !== "SESSION_CANONICAL_KEY_MIGRATION_REQUIRED") {
142+
throw error;
143+
}
144+
sendJson(res, 409, {
145+
ok: false,
146+
error: {
147+
type: "migration_required",
148+
message: error instanceof Error ? error.message : String(error),
149+
},
150+
});
151+
return true;
152+
}
137153
if (!entry?.sessionId) {
138154
sendJson(res, 404, {
139155
ok: false,

0 commit comments

Comments
 (0)