Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(server): older history pages no longer read every run and attempt of the thread #36141

Openjuliusmarmingewants to merge 3 commits intomain fromrefs/pull/36141/headopened View on GitHub

Showing 5 changed files with 47 additions and 3 deletions (loading 4).

x
0 of 5 viewed, 5 left
47 additions and 3 deletionsapps/server/src/orchestration-v2/ProjectionStore.test.tsModified
View file
@@ -4147,6 +4147,17 @@
const rowReads = pageStatements.filter((statement) => !countsPositions(statement));
+ // A range over the thread's run index walks every item of the thread.
+ for (const [query, params] of rowReads) {
+ const plan = copy
+ .prepare(`EXPLAIN QUERY PLAN ${query}`)
+ .all(...(params as ReadonlyArray<NodeSqlite.SQLInputValue>))
+ .map((row) => String(row.detail));
+ assert.isFalse(
+ plan.some((detail) => detail.includes("thread_run_idx (thread_id=? AND run_id>?)")),
+ `${query}\n${plan.join("\n")}`,
+ );
+ }
const rowReadSteps = () =>
rowReads.reduce((steps, [query, params]) => {
const statement = copy.prepare(query);
@@ -4632,11 +4643,32 @@
statement.all(...(params as ReadonlyArray<NodeSqlite.SQLInputValue>));
return steps + statement.stat("vmStep");
}, 0);
+ // Settled runs below the window, each with an attempt, a provider turn and a checkpoint.
+ copy.exec(`
+ INSERT INTO orchestration_v2_projection_run_attempts (attempt_id, thread_id, run_id,
+ attempt_ordinal, root_node_id, provider, provider_thread_id, status, payload_json)
+ SELECT 'attempt:' || run_id, thread_id, run_id, 1, 'node:' || run_id, provider,
+ 'provider-thread', 'completed', '{}' FROM orchestration_v2_projection_runs
+ WHERE thread_id = '${threadId}';