summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorAdam Malczewski <[email protected]>2026-10-21 02:56:48 +0900
committerAdam Malczewski <[email protected]>2026-10-21 02:56:48 +0900
commit0c0f366b3820136c9877f80005939011c30b2de4 (patch)
treed6cd470b038ea968e677436131d34f3d1fd66b6a /src
parent2686cf6bcd247d17528922e36aa380a521c964e0 (diff)
downloaddispatch-web-0c0f366b3820136c9877f80005939011c30b2de4.tar.gz
dispatch-web-0c0f366b3820136c9877f80005939011c30b2de4.zip
fix(review-4.4): tolerate additive terminal turn events
Diffstat (limited to 'src')
-rw-r--r--src/core/chunks/reducer.test.ts10
-rw-r--r--src/core/chunks/reducer.ts3
-rw-r--r--src/core/wire/conformance.test.ts6
-rw-r--r--src/core/wire/conformance.ts2
4 files changed, 19 insertions, 2 deletions
diff --git a/src/core/chunks/reducer.test.ts b/src/core/chunks/reducer.test.ts
index cba6fad..ae0aa73 100644
--- a/src/core/chunks/reducer.test.ts
+++ b/src/core/chunks/reducer.test.ts
@@ -1051,3 +1051,13 @@ describe("turnId provenance on live chunks", () => {
expect(selectChunks(s).map((c) => c.turnId)).toEqual(["t9", undefined]);
});
});
+
+describe("foldEvent — additive wire compatibility", () => {
+ it.each(["turn-ended", "future-event"])("preserves transcript identity for %s", (type) => {
+ const state = foldEvent(foldEvent(initialState(), turnStart("t1")), textDelta("t1", "partial"));
+ const before = structuredClone(state);
+ const event = { type, conversationId: "c1", turnId: "t1", reason: "sealed" };
+ expect(foldEvent(state, event as Parameters<typeof foldEvent>[1])).toBe(state);
+ expect(state).toEqual(before);
+ });
+});
diff --git a/src/core/chunks/reducer.ts b/src/core/chunks/reducer.ts
index 4eb08c1..0af2ddd 100644
--- a/src/core/chunks/reducer.ts
+++ b/src/core/chunks/reducer.ts
@@ -408,6 +408,9 @@ function reduceEvent(state: TranscriptState, event: AgentEvent): TranscriptState
// (already true from `turn-start`) is left untouched.
return { ...state, providerRetry: event };
}
+
+ default:
+ return state; // Forward-compatible with additive wire events.
}
}
diff --git a/src/core/wire/conformance.test.ts b/src/core/wire/conformance.test.ts
index e74a663..1c5829b 100644
--- a/src/core/wire/conformance.test.ts
+++ b/src/core/wire/conformance.test.ts
@@ -75,6 +75,7 @@ describe("classifies every AgentEvent type", () => {
{ type: "error", conversationId: "c1", turnId: "t1", message: "oops" },
{ type: "done", conversationId: "c1", turnId: "t1", reason: "complete" },
{ type: "turn-sealed", conversationId: "c1", turnId: "t1" },
+ { type: "turn-ended", conversationId: "c1", turnId: "t1", reason: "sealed" },
{ type: "steering", conversationId: "c1", turnId: "t1", text: "steer mid-turn" },
{
type: "provider-retry",
@@ -103,13 +104,14 @@ describe("classifies every AgentEvent type", () => {
"error",
"done",
"turn-sealed",
+ "turn-ended",
"steering",
"provider-retry",
]);
});
- it("covers all 15 AgentEvent variants", () => {
- expect(samples).toHaveLength(15);
+ it("covers all 16 AgentEvent variants", () => {
+ expect(samples).toHaveLength(16);
});
});
diff --git a/src/core/wire/conformance.ts b/src/core/wire/conformance.ts
index 855f7ea..9847081 100644
--- a/src/core/wire/conformance.ts
+++ b/src/core/wire/conformance.ts
@@ -32,6 +32,8 @@ export function assertAgentEventExhaustive(event: AgentEvent): string {
return "done";
case "turn-sealed":
return "turn-sealed";
+ case "turn-ended":
+ return "turn-ended";
case "step-complete":
return "step-complete";
case "steering":