| … | … | @@ -6292,6 +6293,15 @@ export const layer: Layer.Layer<ProjectionStoreV2, never, SqlClient.SqlClient> = | |
| 6293 | 6294 | AND link.type = 'link_request' AND link.status = 'waiting' | |
| 6294 | 6295 | ) | |
| 6296 | + | AND NOT ( | |
| 6297 | + | r.status IS 'failed' AND EXISTS ( | |
🟠 High orchestration-v2/ProjectionStore.ts:6297
getSettlementCandidates returns usage-limit-blocked threads as settlement candidates when a newer queued or cancelled run is selected as r; this lets settlement hide the recovery controls that the shell displays for the blocked run. The exclusion checks only r, while shellThreadStateFromRow can present the usage-limit failure from an earlier blocked run. Apply the exclusion to the same blocked-run selection used by the shell.
🤖 Copy this AI Prompt to have your agent fix this:
| 1 | In file @apps/server/src/orchestration-v2/ProjectionStore.ts around line 6297: |
| 2 | |
| 3 | `getSettlementCandidates` returns usage-limit-blocked threads as settlement candidates when a newer queued or cancelled run is selected as `r`; this lets settlement hide the recovery controls that the shell displays for the blocked run. The exclusion checks only `r`, while `shellThreadStateFromRow` can present the usage-limit failure from an earlier blocked run. Apply the exclusion to the same blocked-run selection used by the shell. |
Note
🤖 T3 Code agent responding on behalf of EhsanulHaqueSiam
Confirmed and fixed in 54eada734f. The exclusion only checked the newest run by ordinal, so a message queued behind the limit (status queued, ordinal 2) became r, and the sweep could settle a thread the shell still presents as limited through its blocked join.
The exclusion now uses the same selection as the shell's blocked join and getLimitRecoveryCandidates: the latest executed run (skipping queued and never-started cancelled, ordered as in runRanAfter), status failed, whose latest root error item is usage_limit. A cheap per-thread EXISTS on usage-limit error items runs first, so other threads skip the run sort.
ProjectionSettlement.test.ts now seeds a queued-behind-limit thread (a failed usage_limit run plus a queued run). On the previous SQL it is wrongly eligible (9 vs 8 expected). With the fix it is excluded on both the candidate and the shell side, and 212/212 tests pass across the settlement, projection and runtime-layer suites.
Sorry, I'm unable to act on this request because you do not have permissions within this repository.