The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 21, 17:15 UTC
test(server): windowed history pages are checked against the full index at the window edges (#35877)
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Theo Browne committed
Nov 12, 2026 at 19:44 UTC
f5390209c2a0f9e6f1f858af460f2c8ce3bfc862
1 file changed
+58
-33
apps/server/src/orchestration-v2/ProjectionStore.test.ts
+58
-33
@@ -5804,7 +5804,7 @@ it.layer(layerTest)("ProjectionStoreV2", (it) => {
5804
let windowReads = 0;
5805
let foldedGroups = 0;
5806
5807
- for (let round = 0; round < 4; round += 1) {
5807
+ for (let round = 0; round < 5; round += 1) {
5808
const threadId = ThreadId.make(`thread:window-equivalence:${round}`);
5809
const created = {
5810
id: EventId.make(`event:window-equivalence:${round}`),
@@ -5836,35 +5836,41 @@ it.layer(layerTest)("ProjectionStoreV2", (it) => {
5836
},
5837
} satisfies Parameters<typeof projectionStore.apply>[0];
5838
yield* projectionStore.apply(created);
5839
+ // The last thread puts three things below a window: a user turn under a hidden queued
5840
+ // turn, the start of a long run that folds, and the start of the run before it, which
5841
+ // has later rows among the first rows of the long run.
5842
+ const windowEdges = round === 4;
5843
// One run of each kind in a random order, then an active run. Every other thread has
5844
// one user turn and then only wake turns.
5841
- // The last thread is a long run that a late notification wakes, then enough one-row
5842
- // runs that a page stops at the raw turn limit only if it counts that wake as a turn.
5845
+ // The fourth thread is a turn, many rolled-back rows, a late notification of that turn,
5846
+ // then 149 one-row turns. A page stops at that notification only if it counts as a turn.
5847
const kinds =
5848
round === 3
5845
- ? ["late wake", ...Array.from({ length: 148 }, () => "one row")]
5846
- : [
5847
- "rolled back",
5848
- "cancelled queued turn",
5849
- "held queued turn",
5850
- "replaced attempt",
5851
- "stopped",
5852
- "stopped",
5853
- "folds work",
5854
- "folds work",
5855
- "short",
5856
- "short",
5857
- "short",
5858
- ]
5859
- .map((kind) => ({ kind, order: random() }))
5860
- .toSorted((left, right) => left.order - right.order)
5861
- .map(({ kind }) => kind);
5849
+ ? ["rolled back", "late wake", ...Array.from({ length: 149 }, () => "one row")]
5850
+ : windowEdges
5851
+ ? ["short", "cancelled queued turn", "folds work", "long fold", "stopped"]
5852
+ : [
5853
+ "rolled back",
5854
+ "cancelled queued turn",
5855
+ "held queued turn",
5856
+ "replaced attempt",
5857
+ "stopped",
5858
+ "stopped",
5859
+ "folds work",
5860
+ "folds work",
5861
+ "short",
5862
+ "short",
5863
+ "short",
5864
+ ]
5865
+ .map((kind) => ({ kind, order: random() }))
5866
+ .toSorted((left, right) => left.order - right.order)
5867
+ .map(({ kind }) => kind);
5868
const agentDriven = round === 1;
5869
const runs: Array<unknown> = [];
5870
const attempts: Array<unknown> = [];
5871
const items: Array<unknown> = [];
5872
const tiedWithHidden: Array<TurnItemId> = [];
5867
- const repliesInStoppedRuns: Array<string> = [];
5873
+ const pageEnds: Array<string> = [];
5874
let ordinal = 0;
5875
for (const [index, kind] of [...kinds, "active"].entries()) {
5876
const run = index + 1;
@@ -5958,7 +5964,11 @@ it.layer(layerTest)("ProjectionStoreV2", (it) => {
5964
const wakes =
5965
kind === "one row"
5966
? run % 10 !== 0
5961
- : kind !== "late wake" && (agentDriven ? run > 1 : chance(0.2));
5967
+ : windowEdges
5968
+ ? ["folds work", "long fold", "stopped"].includes(kind)
5969
+ : kind !== "late wake" && (agentDriven ? run > 1 : chance(0.2));
5970
+ if (round === 3 && kind === "active")
5971
+ pageEnds.push(`turn-item:window-equivalence:${round}:${items.length}`);
5972
if (wakes) notification();
5973
else
5974
userMessage(
@@ -5974,25 +5984,40 @@ it.layer(layerTest)("ProjectionStoreV2", (it) => {
5984
? 320 + Math.floor(random() * 60)
5985
: kind === "folds work"
5986
? 155 + Math.floor(random() * 60)
5977
- : kind === "one row"
5978
- ? 0
5979
- : Math.floor(random() * 30);
5987
+ : kind === "long fold"
5988
+ ? 300
5989
+ : kind === "one row"
5990
+ ? 0
5991
+ : Math.floor(random() * 30);
5992
for (let row = 0; row < work; row += 1) {
5981
- if (chance(0.5)) add("command_execution", { input: "echo", output: "ok", exitCode: 0 });
5982
- else add("reasoning", { text: "", streaming: false });
5993
+ // The first rows of a long fold and the work of a late wake belong to the run before.
5994
+ const owner =
5995
+ (kind === "long fold" && row < 140) || kind === "late wake"
5996
+ ? {
5997
+ runId: `run:window-equivalence:${round}:${run - 1}`,
5998
+ nodeId: `node:window-equivalence:${round}:${run - 1}`,
5999
+ }
6000
+ : {};
6001
+ if (chance(0.5))
6002
+ add("command_execution", { input: "echo", output: "ok", exitCode: 0, ...owner });
6003
+ else add("reasoning", { text: "", streaming: false, ...owner });
6004
// A reply deep in a stopped run: a page that ends on it has enough work below it
6005
// to fold, and only the stop request above it says that it does not.
6006
const reply = kind === "stopped" && row === 200;
5986
- if (reply)
5987
- repliesInStoppedRuns.push(`turn-item:window-equivalence:${round}:${items.length}`);
5988
- if (reply || chance(0.02))
6007
+ if (reply) pageEnds.push(`turn-item:window-equivalence:${round}:${items.length}`);
6008
+ // With these replies, the part of a long fold in one window is too small to fold,
6009
+ // and a shown row lies below the notification of a late wake.
6010
+ const replies = kind === "long fold" || kind === "late wake";
6011
+ if (reply || (replies && row % 5 === 0) || chance(0.02))
6012
add("assistant_message", {
6013
messageId: `message:window-equivalence:${round}:${items.length}`,
6014
text: "Reply",
6015
streaming: false,
6016
});
5994
- if (chance(0.01)) notification();
5995
- if (chance(0.004) && !agentDriven) userMessage("steer");
6017
+ // A late wake has no other input above its turn start.
6018
+ if (chance(0.01) && kind !== "late wake") notification();
6019
+ if (chance(0.004) && !agentDriven && !windowEdges && kind !== "late wake")
6020
+ userMessage("steer");
6021
}
6022
if (kind === "late wake") notification();
6023
if (kind === "stopped") add("run_interrupt_request", { message: "Stop" });
@@ -6087,7 +6112,7 @@ it.layer(layerTest)("ProjectionStoreV2", (it) => {
6112
cursor = page.nextCursor;
6113
}
6114
}
6090
- for (const sourceItemId of repliesInStoppedRuns) {
6115
+ for (const sourceItemId of pageEnds) {
6116
const cursor = encodeThreadHistoryCursor({
6117
snapshotSequence: 0,
6118
sourceThreadId: threadId,