Skip to content

fix(kernel): checkpoint TTL evict race and wake loss on inject error - #15

Draft
cursor[bot] wants to merge 1 commit into
masterfrom
cursor/critical-bug-management-b2f7
Draft

fix(kernel): checkpoint TTL evict race and wake loss on inject error#15
cursor[bot] wants to merge 1 commit into
masterfrom
cursor/critical-bug-management-b2f7

Conversation

@cursor

@cursor cursor Bot commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

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 called mark_expired() on the shared checkpoint file, setting expired=True on 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_wake silently stops after any processing error (e.g. LLM 401).

Root cause: On inject_turn failure (no waiter), _finalize_agent_wake_delivery(confirmed=True) permanently removed the wake instead of aborting for retry.

Fix: Use confirmed=False on the error path, matching cancel/skip semantics.

Validation

  • test_evict_skips_mark_expired_when_session_reacquired
  • test_inject_turn_error_aborts_agent_wake_delivery

Notes

Open in Web View Automation 

…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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant