Repository navigation
Evict expired turn claims and stabilize turn listing order - #592
Merged
TheGreatAxios merged 2 commits intoSep 4, 2026
Merged
TheGreatAxios merged 2 commits into
TheGreatAxios merged 2 commits into
Conversation
Contributor
Author
|
Fixes CL-7200 |
Contributor
Author
Self-reviewVerdict: the change is correct and narrowly scoped — expired turn-claim entries are now evicted as a side effect of
Targeted tests: No commits pushed; nothing to fix. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Expired in-memory turn claims no longer linger in the Map until that workbench is claimed again.
tryClaim,holds, andreleasedelete an expired entry when they observe it. A mismatchedreleasestill cannot evict a live successor (CL-7129), but it does drop a dead expired entry instead of leaving a zombie.Turn listing and the running-turn resolver now share the same newest-first key:
startedAtdescending, withoccurrenceas the deterministic tiebreak. Same-millisecond timestamps no longer let listing keep Map insertion order whilefindRunningTurnpicked a different row. The Drizzle store uses the sameORDER BY started_at DESC, occurrence DESC.Test plan
bun test packages/chat/src/turn-claims.test.ts packages/chat/src/agent-turns.test.ts packages/chat/src/turn-queue.test.ts— 47 pass, 0 fail (exit 0). New tests failed before the implementation (expired entry still releasable by the original token; listing order[first, second]vs running-turnsecond) and passed after.bun run typecheck— exit 0.bun run lint— prettier clean; eslint 0 errors / 10 pre-existing warnings.bun run check:structural— ok (deletion, killdates, licenses, db-gate, and remaining structural checks).bun run checkreached the test step and failed inscripts/db-setup.test.tswithPostgresError: password authentication failed for user "thegreataxios"(pre-existing localDATABASE_URL, unrelated). Drizzle chat suites fail the same way.CL-7200
Fixes CL-7200