fix: harden reviewer registration and scoped resume context#21
fix: harden reviewer registration and scoped resume context#21justinmoon merged 2 commits intomasterfrom
Conversation
|
Caution Review failedPull request was closed or merged during review 📝 WalkthroughWalkthroughThis PR adds identity-aware saved run context storage with per-workspace and per-identity lookups, introduces agent resolution pathways that prefer saved identities, and implements sophisticated reviewer slot auto-assignment logic for Implement sessions with validation and fallback mechanisms. Changes
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Comment |
| @@ -1129,6 +1289,14 @@ fn ensure_agent_registered( | |||
| ) | |||
There was a problem hiding this comment.
🔴 Deadlock: ensure_agent_registered holds exclusive session lock while calling join_with_registry which re-acquires it
When agent == "review", ensure_agent_registered opens a SessionHandle at src/command_surface.rs:1233 which acquires an exclusive file lock via fs2::lock_exclusive() (flock(LOCK_EX) on Linux). The handle variable remains in scope (holding the lock) when commands::join_with_registry is called at lines 1241 and 1282. join_with_registry (src/commands.rs:190) opens its own SessionHandle on the same session, attempting to acquire the same exclusive lock on a different file description. On Linux, flock locks are per-open-file-description, so the second lock_exclusive() blocks forever waiting for the first lock — held by the same thread — causing a deadlock.
This affects two code paths:
- Line 1241: non-Implement sessions where agent is
"review"and not already registered - Line 1282: Implement sessions where reviewer slots still have room
The old code did not have this problem because the "review" path went directly to join_with_registry without first opening a SessionHandle.
(Refers to lines 1233-1289)
Prompt for agents
In src/command_surface.rs, the ensure_agent_registered function (starting around line 1203) must drop the SessionHandle before calling commands::join_with_registry. The handle is opened at line 1233 and holds an exclusive flock. It must be dropped before the join_with_registry calls at lines 1241 and 1282.
One approach: extract the needed data (session_type, agents map, expected_agents) from the handle/state into local variables, then explicitly drop the handle before any branch that calls join_with_registry. For example:
1. After line 1235 (let state = handle.load_state()?;), copy the fields you need into locals:
let session_type = state.session_type.clone();
let agents = state.agents.clone();
let expected_agents = state.config.expected_agents;
2. Then drop(handle); drop(state);
3. Use the local copies for the remaining logic.
This ensures the exclusive lock is released before join_with_registry tries to re-acquire it.
Was this helpful? React with 👍 or 👎 to provide feedback.
Summary
reviewfallback, capacity guard, role validation)(workspace, session, agent)for exact-match resume lookupValidation
just pre-mergecommand_surfacefor identity lookup and multi-agent saved-resume gatingSummary by CodeRabbit
Release Notes
New Features
Improvements
Tests