fix(server): avoid completed-item scans when starting turns #23557
github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:S
- apps/server/src/orchestration-v2/ProjectionStore.test.ts lines 3133 to 3134OutdatedResolvedby coderabbitai[bot](GitHub profile, opens in a new tab)@@ -3115,4 +3115,20 @@31153115 assert.include(recoveryThreadIds, childThreadId);31163116 assert.notInclude(recoveryThreadIds, settledThreadId);31173117 assert.notInclude(recoveryThreadIds, rolledBackThreadId);3118- const memberRecovery = yield* projectionStore.getRuntimeRecoveryProjection(memberThreadId);3118+ const { statements, tracer } = traceSqlStatements();3119+ const memberRecovery = yield* projectionStore3120+ .getRuntimeRecoveryProjection(memberThreadId)3121+ .pipe(Effect.withTracer(tracer));3122+ // Completed history grows without bound, so the provider-thread read's3123+ // unfinished-item lookups must stay on a partial index.3124+ const providerThreadRead = statements.find((query) =>3125+ query.includes("SELECT provider_thread.payload_json"),3126+ );3127+ assert.isDefined(providerThreadRead);3128+ const sql = yield* SqlClient.SqlClient;3129+ const itemLookups = (yield* sql.unsafe<{ readonly detail: string }>(3130+ `EXPLAIN QUERY PLAN ${providerThreadRead}`,3131+ ))3132+ .map((row) => row.detail)3133+ .filter((detail) => detail.startsWith("SEARCH item "));3134+ assert.isNotEmpty(itemLookups);
macroscopeapp[bot](GitHub profile, opens in a new tab) approved these changes
juliusmarminge added labelsbugfix
juliusmarminge added labelspr:gate-failed
juliusmarminge added labelspr:needs-julius
juliusmarminge removed labelspr:gate-failed
juliusmarminge closed this
juliusmarminge removed labelspr:needs-julius
Sign in to join this conversation.
macroscopeapp[bot](GitHub profile, opens in a new tab) reviewed