fix: Cleanup FallThrough sessions - #313
Conversation
- Automatically when they finish (`session_final`). - After one hour of inactivity, to catch those that never finish cleanly. Assisted-by: Codex:GPT 5.6 Sol medium Signed-off-by: Graham King <grahamk@nvidia.com>
|
@CodeRabbit review |
✅ Action performedReview finished.
|
|
WalkthroughThe router now stores shared session state with access timestamps, starts periodic weak-reference cleanup, removes completed sessions after success or errors, and clears session eviction records. Tests cover final-session cleanup, access refresh, and stale-session removal. ChangesSession lifecycle management
Estimated code review effort: 4 (Complex) | ~45 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (1)
crates/libsy/src/algorithms/fall_through.rs (1)
366-372: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winDocument the cleanup task's cadence and exit condition.
The task's lifecycle is not obvious from the signature: the first tick is delayed by one interval, missed ticks are skipped, and the loop ends when the router is dropped. The guidelines require comments for async and lifecycle behavior.
♻️ Proposed doc comment
+/// Sweeps idle session state once per [`SESSION_CLEANUP_INTERVAL`], starting one +/// interval after spawn. Holds only a weak handle, so the task ends at the first +/// tick after the router is dropped. async fn cleanup_inactive_sessions<S>(states: Weak<SessionStates<S>>)🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@crates/libsy/src/algorithms/fall_through.rs` around lines 366 - 372, Document the lifecycle behavior in cleanup_inactive_sessions: state that the first tick is delayed by SESSION_CLEANUP_INTERVAL, missed ticks are skipped, and the cleanup loop exits when the router/session state is dropped. Place the comment near the interval setup or loop, without changing the existing timing or termination behavior.Source: Coding guidelines
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@crates/libsy/src/algorithms/fall_through.rs`:
- Around line 42-43: Update SESSION_STATE_TTL to one hour so unfinished sessions
are evicted after the intended inactivity period, while keeping
SESSION_CLEANUP_INTERVAL at one hour. Add concise comments above both constants
documenting the cleanup interval and idle-state eviction policy.
- Around line 1345-1357: Update the test cleanup setup in
cleanup_removes_only_inactive_idle_sessions to compute now as a forward time
using Instant::now() plus SESSION_STATE_TTL and one second, instead of
subtracting from Instant::now() with checked_sub and expect. Preserve the
inserted last_accessed values as stale relative to the new now, and remove the
underflow-prone timestamp calculation.
---
Nitpick comments:
In `@crates/libsy/src/algorithms/fall_through.rs`:
- Around line 366-372: Document the lifecycle behavior in
cleanup_inactive_sessions: state that the first tick is delayed by
SESSION_CLEANUP_INTERVAL, missed ticks are skipped, and the cleanup loop exits
when the router/session state is dropped. Place the comment near the interval
setup or loop, without changing the existing timing or termination behavior.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Enterprise
Run ID: c2cd87b4-0aa1-45ed-bc09-9ebf6762ff05
📒 Files selected for processing (2)
crates/libsy/src/algorithms/fall_through.rscrates/libsy/src/core/algorithm.rs
elyasmnvidian
left a comment
There was a problem hiding this comment.
A cancelled final request can keep its session data, and one test checks a timestamp rather than cleanup behavior. The suggested changes are inline.
session_final).cleanly.
Assisted-by: Codex:GPT 5.6 Sol medium
Signed-off-by: Graham King grahamk@nvidia.com
Summary by CodeRabbit
Bug Fixes
Tests