Skip to content

Commit aa3b73a

Browse files
t3dotggclaude
andcommitted
test(server): wire budget covers stale todo lists in long threads
A todo list node and its plan stay open when their run ends. Before #34490 each one counted as live work, so every window carried the records of every finished run. The transfer budget test now opens a thread of 40 finished runs behind one working run and caps the decoded bytes and the node, subagent, plan, provider turn and checkpoint counts of its bounded snapshot. Co-Authored-By: Claude Fable 5.2 <[email protected]>
1 parent c8e8b58 commit aa3b73a

4 files changed

Lines changed: 443 additions & 2 deletions

File tree

‎apps/server/integration/TransferBudgetReport.integration.ts‎

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ import {
1515
LONG_TURN_WORK_ROWS,
1616
SHELL_IDLE_SUBAGENTS,
1717
SHELL_SETTLED_THREADS,
18+
STALE_TODO_LIVE_ROWS,
19+
STALE_TODO_SETTLED_RUNS,
20+
STALE_TODO_SUBAGENTS_PER_RUN,
1821
} from "./TransferBudgetV2Fixture.integration.ts";
1922

2023
export interface WebSocketCatchUpMeasurement extends WebSocketTransferTotals {
@@ -26,6 +29,15 @@ export interface TimelineHttpMeasurement {
2629
readonly rows: number;
2730
}
2831

32+
const STALE_TODO_RECORD_KINDS = [
33+
"nodes",
34+
"subagents",
35+
"plans",
36+
"providerTurns",
37+
"checkpoints",
38+
] as const;
39+
type StaleTodoRecordCounts = Readonly<Record<(typeof STALE_TODO_RECORD_KINDS)[number], number>>;
40+
2941
export interface TransferBudgetRun {
3042
readonly provider: ProviderDriverKind;
3143
readonly threadSnapshot: HttpTransferMeasurement;
@@ -46,6 +58,13 @@ export interface TransferBudgetRun {
4658
/** The cold-connect shell snapshot after the settled-thread fleet is written. */
4759
readonly fleetShell: TimelineHttpMeasurement;
4860
readonly fleetShellLegacy: TimelineHttpMeasurement;
61+
/**
62+
* The compact bounded snapshot of the long thread whose finished runs left todo lists open,
63+
* with the count of each record kind that rides along with its rows.
64+
*/
65+
readonly staleTodoColdOpen: TimelineHttpMeasurement & {
66+
readonly records: StaleTodoRecordCounts;
67+
};
4968
}
5069

5170
interface ProviderTransferBudget {
@@ -84,6 +103,21 @@ const FLEET_SHELL_BUDGET = {
84103
rows: 27,
85104
};
86105

106+
// About 14% above the observed 75 KB. The window holds the working run only: 2 nodes, 2 subagents,
107+
// 1 plan, 1 provider turn and the last finished turn's checkpoint. When finished runs ride along
108+
// it holds 82 nodes, 82 subagents, 41 plans, 41 provider turns, 40 checkpoints and 740 KB.
109+
const STALE_TODO_BUDGET = {
110+
decodedBytes: 85_000,
111+
rows: 75,
112+
records: {
113+
nodes: 4,
114+
subagents: 4,
115+
plans: 2,
116+
providerTurns: 2,
117+
checkpoints: 2,
118+
} satisfies StaleTodoRecordCounts,
119+
};
120+
87121
function totalWireBytes(run: TransferBudgetRun): number {
88122
return run.threadSnapshot.wireBytes + run.measuredTurnWebSocket.wireBytes;
89123
}
@@ -245,6 +279,20 @@ export function transferBudgetViolations(runs: ReadonlyArray<TransferBudgetRun>)
245279
FLEET_SHELL_BUDGET.decodedBytes,
246280
],
247281
["fleet shell snapshot rows", run.fleetShell.rows, FLEET_SHELL_BUDGET.rows],
282+
[
283+
"stale todo list cold open decoded bytes",
284+
run.staleTodoColdOpen.http.decodedBodyBytes,
285+
STALE_TODO_BUDGET.decodedBytes,
286+
],
287+
["stale todo list cold open rows", run.staleTodoColdOpen.rows, STALE_TODO_BUDGET.rows],
288+
...STALE_TODO_RECORD_KINDS.map(
289+
(kind) =>
290+
[
291+
`stale todo list cold open ${kind}`,
292+
run.staleTodoColdOpen.records[kind],
293+
STALE_TODO_BUDGET.records[kind],
294+
] as const,
295+
),
248296
] as const;
249297
for (const [metric, observed, maximum] of checks) {
250298
if (observed > maximum) {
@@ -264,6 +312,7 @@ export function formatTransferBudgetReport(runs: ReadonlyArray<TransferBudgetRun
264312
`Scenario: ${TRANSFER_HISTORY_TURN_COUNT} historical turns with ${TRANSFER_HISTORY_TOOLS_PER_TURN} command tools and one retained ${formatBytes(TRANSFER_HISTORY_MCP_RESULT_BYTES)} MCP result each, followed by one measured turn with ${TRANSFER_MEASURED_TOOLS} command tools and a retained ${formatBytes(TRANSFER_MEASURED_MCP_RESULT_BYTES)} MCP result. Synthetic V2 domain events exercise persistence, wire projection, and production HTTP/subscription handlers; this does not measure provider adapter ingestion. Payloads contain no user data.`,
265313
`The long-turn rows open a second thread through the compact bounded snapshot web and mobile use, then load one older page. Its last user turn holds ${LONG_TURN_WORK_ROWS} rows of reasoning, commands, file changes, MCP calls, progress messages, checkpoints, and subagents.`,
266314
`The fleet shell rows read the cold-connect shell after ${SHELL_SETTLED_THREADS} settled threads and ${SHELL_IDLE_SUBAGENTS} idle subagent children are added. Budgeted reads send the opt-ins current clients send; "older client" rows show the same read without the opt-ins added since row budgets.`,
315+
`The stale todo list rows open a third thread the same way: ${STALE_TODO_SETTLED_RUNS} finished runs, then one run still at work with ${STALE_TODO_LIVE_ROWS} rows. Every run left its todo list open and has ${STALE_TODO_SUBAGENTS_PER_RUN} finished subagents, a provider turn and, once finished, a checkpoint. The record counts must not grow with the number of finished runs.`,
267316
"",
268317
"| Provider | Total thread wire | Budget | Result |",
269318
"| --- | ---: | ---: | --- |",
@@ -352,6 +401,22 @@ export function formatTransferBudgetReport(runs: ReadonlyArray<TransferBudgetRun
352401
...legacyRows(run.provider, "long-turn history page", run.longTurnHistoryPageLegacy),
353402
...timelineRows(run.provider, "fleet shell snapshot", run.fleetShell, FLEET_SHELL_BUDGET),
354403
...legacyRows(run.provider, "fleet shell snapshot", run.fleetShellLegacy),
404+
...timelineRows(
405+
run.provider,
406+
"stale todo list cold open",
407+
run.staleTodoColdOpen,
408+
STALE_TODO_BUDGET,
409+
),
410+
...STALE_TODO_RECORD_KINDS.map((kind) =>
411+
row(
412+
run.provider,
413+
"stale todo list cold open",
414+
kind,
415+
run.staleTodoColdOpen.records[kind],
416+
STALE_TODO_BUDGET.records[kind],
417+
String,
418+
),
419+
),
355420
);
356421
}
357422

0 commit comments

Comments
 (0)