fix(kernel): checkpoint TTL evict race and wake loss on inject error - #15
Draft
cursor[bot] wants to merge 1 commit into
Draft
fix(kernel): checkpoint TTL evict race and wake loss on inject error#15cursor[bot] wants to merge 1 commit into
cursor[bot] wants to merge 1 commit into
Conversation
…ject error - Skip mark_expired when the same session was re-acquired during slow evict (summarize), avoiding silent checkpoint corruption on daemon restart. - Abort staged wake delivery on inject_turn processing errors so poll_due_wakes can retry instead of permanently dropping the wake. Add regression tests for both paths. Co-authored-by: Yuxuan Liu <Osc-7@users.noreply.github.com>
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
Fixes two critical correctness bugs found in recent kernel changes.
1. Checkpoint corruption during slow TTL evict (data loss)
Impact: Daemon restart could drop a live session's conversation/goals.
Root cause:
CorePool.evict()pops the session, then awaits slow work (summarize). If the user messages during that window, a new Core is acquired and writes a fresh checkpoint. The stale evict then calledmark_expired()on the shared checkpoint file, settingexpired=Trueon the new state.Fix: Skip
mark_expired()when the session is already back in_pool.Trigger: Idle session past Core TTL → TTL evict starts (summarize takes seconds) → user sends a message → turn completes → stale evict marks checkpoint expired → restart loses session.
2. Scheduled wakes dropped after inject_turn errors
Impact: Goal auto-continue /
schedule_wakesilently stops after any processing error (e.g. LLM 401).Root cause: On
inject_turnfailure (no waiter),_finalize_agent_wake_delivery(confirmed=True)permanently removed the wake instead of aborting for retry.Fix: Use
confirmed=Falseon the error path, matching cancel/skip semantics.Validation
test_evict_skips_mark_expired_when_session_reacquiredtest_inject_turn_error_aborts_agent_wake_deliveryNotes