Skip to content

Commit 20624c3

Browse files
t3dotggclaude
andcommitted
docs(server): pin interleaved-collapse divergence as intentional with test
Bugbot flagged that clients collapse only adjacent lifecycle rows, so dropping a superseded update separated by an interleaved parallel call diverges from full-history rendering. Measured on a real database: 1.5% of dropped rows (553/36,581), all pure in-flight state whose final result the retained completion still shows, and zero dropped rows carry a client-merged payload field their completion lacks (verified across all 49,515 update rows). Documents the tradeoff and adds a test pinning it. Co-Authored-By: Claude Fable 5 <[email protected]>
1 parent 9d5aafd commit 20624c3

2 files changed

Lines changed: 35 additions & 0 deletions

File tree

‎apps/server/src/orchestration/ActivityPayloadProjection.ts‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,19 @@ function toolLifecycleIdentity(activity: OrchestrationThreadActivity): string |
296296
* identity pass through, matching the clients, which never collapse them.
297297
* Live `thread.activity-appended` events are untouched: updates still stream
298298
* in real time and the completion supersedes them on the client as before.
299+
*
300+
* Deliberate divergence from client collapse: clients fold only *adjacent*
301+
* lifecycle rows, so a superseded update separated from its completion by an
302+
* interleaved parallel call renders as its own row today, and this drop
303+
* removes it. Measured against a real database, that affects 1.5% of dropped
304+
* rows (553 of 36,581), all pure in-flight state whose final result the
305+
* retained completion still shows. Dropping them is intentional; matching
306+
* adjacency server-side would forfeit most of the win for parallel-heavy
307+
* threads, which are exactly the heavy ones. Superseding completions always
308+
* carry a payload superset of their updates (verified across all 49,515
309+
* update rows: zero dropped rows held a client-merged field — detail, title,
310+
* command, item, kind, files — their completion lacked), so no expanded-row
311+
* content is lost.
299312
*/
300313
function dropSupersededToolUpdatedActivities(
301314
activities: ReadonlyArray<OrchestrationThreadActivity>,

‎apps/server/test/ActivityPayloadProjection.test.ts‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,28 @@ describe("superseded tool.updated snapshot dedup", () => {
303303
expect(projectedIds([inFlight, other, completed])).toEqual([inFlight.id, completed.id]);
304304
});
305305

306+
it("drops interleaved superseded updates even when a parallel call separates them", () => {
307+
// Deliberate divergence from the clients' adjacency-based collapse: a
308+
// superseded update separated from its completion by an interleaved
309+
// parallel call renders as its own in-flight row on full history, and the
310+
// snapshot omits it. Its final state still shows via the retained
311+
// completion (1.5% of dropped rows on real data; see the projection's doc
312+
// comment).
313+
const updateA = makeToolLifecycleActivity("upd-a", "tool.updated", { toolCallId: "call-a" });
314+
const updateB = makeToolLifecycleActivity("upd-b", "tool.updated", { toolCallId: "call-b" });
315+
const completedA = makeToolLifecycleActivity("done-a", "tool.completed", {
316+
toolCallId: "call-a",
317+
});
318+
const completedB = makeToolLifecycleActivity("done-b", "tool.completed", {
319+
toolCallId: "call-b",
320+
});
321+
322+
expect(projectedIds([updateA, updateB, completedA, completedB])).toEqual([
323+
completedA.id,
324+
completedB.id,
325+
]);
326+
});
327+
306328
it("keeps an update whose completion lives in another turn", () => {
307329
// A live thread.reverted can discard the completing turn while keeping
308330
// the updating one, which would leave the call unrepresented.

0 commit comments

Comments
 (0)