Skip to content

Commit 75c2437

Browse files
t3dotggclaude
andcommitted
test(server): windowed history pages are checked against the full index at the window edges
Four planted bugs in the windowed history read passed every test. The generated test of window pages against full-index pages gets a fifth thread that puts a user turn under a hidden queued turn, the start of a long folding run, and the start of the run before it below one window. Co-Authored-By: Claude Fable 5.2 <[email protected]>
1 parent 95cb068 commit 75c2437

1 file changed

Lines changed: 46 additions & 26 deletions

File tree

‎apps/server/src/orchestration-v2/ProjectionStore.test.ts‎

Lines changed: 46 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -5804,7 +5804,7 @@ it.layer(layerTest)("ProjectionStoreV2", (it) => {
58045804
let windowReads = 0;
58055805
let foldedGroups = 0;
58065806

5807-
for (let round = 0; round < 4; round += 1) {
5807+
for (let round = 0; round < 5; round += 1) {
58085808
const threadId = ThreadId.make(`thread:window-equivalence:${round}`);
58095809
const created = {
58105810
id: EventId.make(`event:window-equivalence:${round}`),
@@ -5836,29 +5836,35 @@ it.layer(layerTest)("ProjectionStoreV2", (it) => {
58365836
},
58375837
} satisfies Parameters<typeof projectionStore.apply>[0];
58385838
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;
58395843
// One run of each kind in a random order, then an active run. Every other thread has
58405844
// 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
5845+
// The fourth thread is a long run that a late notification wakes, then enough one-row
58425846
// runs that a page stops at the raw turn limit only if it counts that wake as a turn.
58435847
const kinds =
58445848
round === 3
58455849
? ["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);
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);
58625868
const agentDriven = round === 1;
58635869
const runs: Array<unknown> = [];
58645870
const attempts: Array<unknown> = [];
@@ -5958,7 +5964,9 @@ it.layer(layerTest)("ProjectionStoreV2", (it) => {
59585964
const wakes =
59595965
kind === "one row"
59605966
? 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));
59625970
if (wakes) notification();
59635971
else
59645972
userMessage(
@@ -5974,25 +5982,37 @@ it.layer(layerTest)("ProjectionStoreV2", (it) => {
59745982
? 320 + Math.floor(random() * 60)
59755983
: kind === "folds work"
59765984
? 155 + Math.floor(random() * 60)
5977-
: kind === "one row"
5978-
? 0
5979-
: Math.floor(random() * 30);
5985+
: kind === "long fold"
5986+
? 300
5987+
: kind === "one row"
5988+
? 0
5989+
: Math.floor(random() * 30);
59805990
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 });
5991+
// The first rows of a long fold belong to the run before it.
5992+
const owner =
5993+
kind === "long fold" && row < 140
5994+
? {
5995+
runId: `run:window-equivalence:${round}:${run - 1}`,
5996+
nodeId: `node:window-equivalence:${round}:${run - 1}`,
5997+
}
5998+
: {};
5999+
if (chance(0.5))
6000+
add("command_execution", { input: "echo", output: "ok", exitCode: 0, ...owner });
6001+
else add("reasoning", { text: "", streaming: false, ...owner });
59836002
// A reply deep in a stopped run: a page that ends on it has enough work below it
59846003
// to fold, and only the stop request above it says that it does not.
59856004
const reply = kind === "stopped" && row === 200;
59866005
if (reply)
59876006
repliesInStoppedRuns.push(`turn-item:window-equivalence:${round}:${items.length}`);
5988-
if (reply || chance(0.02))
6007+
// With these replies, the part of a long fold in one window is too small to fold.
6008+
if (reply || (kind === "long fold" && row % 5 === 0) || chance(0.02))
59896009
add("assistant_message", {
59906010
messageId: `message:window-equivalence:${round}:${items.length}`,
59916011
text: "Reply",
59926012
streaming: false,
59936013
});
59946014
if (chance(0.01)) notification();
5995-
if (chance(0.004) && !agentDriven) userMessage("steer");
6015+
if (chance(0.004) && !agentDriven && !windowEdges) userMessage("steer");
59966016
}
59976017
if (kind === "late wake") notification();
59986018
if (kind === "stopped") add("run_interrupt_request", { message: "Stop" });

0 commit comments

Comments
 (0)