@devries-cameron20 / t3code Mirror · read-only / commits / d8125a5d88
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 23, 03:00 UTC

fix(server): usage-limit sweep stops scanning every run each tick (#21191)

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>

Alyx committed Oct 18, 2026 at 21:03 UTC d8125a5d88e8b33e6dca9a1efc8d368fa55ab024
1 file changed +8
apps/server/src/orchestration-v2/ProjectionStore.ts
+8
@@ -3590,6 +3590,14 @@ export const layer: Layer.Layer<ProjectionStoreV2, never, SqlClient.SqlClient> =
3590 LIMIT 1
3591 )
3592 WHERE t.deleted_at IS NULL
3593 + -- The sweep runs every scheduler tick. Without this list the latest-run
3594 + -- lookup above sorts every run of every thread, tens of milliseconds
3595 + -- for one long thread; only threads with a usage-limit failure qualify.
3596 + AND t.thread_id IN (
3597 + SELECT failure.thread_id FROM orchestration_v2_projection_turn_items failure
3598 + WHERE failure.type = 'error' AND failure.status = 'failed'
3599 + AND json_extract(failure.payload_json, '$.failure.class') = 'usage_limit'
3600 + )
3601 AND json_extract(t.payload_json, '$.archivedAt') IS NULL
3602 AND json_extract(t.payload_json, '$.settledOverride') IS NOT 'settled'
3603 AND json_extract(item.payload_json, '$.failure.class') = 'usage_limit'