Report supervised daemon topology accurately#370
Conversation
Deploying wireup-landing with
|
| Latest commit: |
e3ce055
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://be8cbdc8.wireup-landing.pages.dev |
| Branch Preview URL: | https://fix-doctor-supervisor-topolo.wireup-landing.pages.dev |
📝 WalkthroughWalkthrough
ChangesSupervisor topology diagnostics
Estimated code review effort: 4 (Complex) | ~45 minutes Sequence Diagram(s)sequenceDiagram
participant WireDoctor
participant ProcessDiscovery
participant SupervisorPidfile
participant SessionPidfiles
WireDoctor->>ProcessDiscovery: discover live daemon role PIDs
WireDoctor->>SupervisorPidfile: read supervisor PID
WireDoctor->>SessionPidfiles: read known session daemon PIDs
WireDoctor->>WireDoctor: derive owned workers and unmanaged daemons
WireDoctor-->>WireDoctor: emit daemon and fanout verdicts
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 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 `@src/cli/status.rs`:
- Around line 1042-1069: Update supervisor_worker_count to restrict its fanout
set to known_session_pids even when supervisor_pid is present, excluding
unmanaged daemon PIDs such as 12 when only 11 is known. In
supervisor_daemon_health_verdict, calculate the total daemon count separately
for health evaluation rather than reusing the restricted fanout count, and add
coverage for the specified PID case.
🪄 Autofix (Beta)
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: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 54719b1a-06e6-4167-aa79-5088d9e05e39
📒 Files selected for processing (2)
SESSION_LOG_2026_07_18.mdsrc/cli/status.rs
| fn supervisor_worker_count( | ||
| supervisor_pid: Option<u32>, | ||
| daemon_pids: &[u32], | ||
| known_session_pids: &[u32], | ||
| ) -> usize { | ||
| let known: std::collections::HashSet<u32> = known_session_pids.iter().copied().collect(); | ||
| daemon_pids | ||
| .iter() | ||
| .copied() | ||
| .filter(|pid| match supervisor_pid { | ||
| Some(supervisor) => *pid != supervisor, | ||
| None => known.contains(pid), | ||
| }) | ||
| .collect::<std::collections::HashSet<_>>() | ||
| .len() | ||
| } | ||
|
|
||
| fn supervisor_daemon_health_verdict( | ||
| supervisor_pid: Option<u32>, | ||
| supervisor_alive: bool, | ||
| daemon_pids: &[u32], | ||
| unmanaged_pids: &[u32], | ||
| ) -> Option<DoctorCheck> { | ||
| let supervisor_pid = | ||
| supervisor_pid.filter(|pid| supervisor_alive && daemon_pids.contains(pid))?; | ||
| let workers = supervisor_worker_count(Some(supervisor_pid), daemon_pids, &[]); | ||
| if !unmanaged_pids.is_empty() { | ||
| let managed_workers = workers.saturating_sub(unmanaged_pids.len()); |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
Exclude unmanaged daemon PIDs from the fanout count.
When a supervisor exists, Lines 1051-1053 count every daemon except the supervisor and ignore known_session_pids. An unmanaged daemon therefore inflates supervisor_fanout and may incorrectly classify it as a wire_defect.
Keep fanout restricted to known session PIDs, and calculate the health verdict’s total daemon count separately.
Proposed fix
daemon_pids
.iter()
.copied()
- .filter(|pid| match supervisor_pid {
- Some(supervisor) => *pid != supervisor,
- None => known.contains(pid),
- })
+ .filter(|pid| Some(*pid) != supervisor_pid && known.contains(pid))
.collect::<std::collections::HashSet<_>>()
.len()
}
fn supervisor_daemon_health_verdict(
@@
- let workers = supervisor_worker_count(Some(supervisor_pid), daemon_pids, &[]);
+ let workers = daemon_pids
+ .iter()
+ .copied()
+ .filter(|pid| *pid != supervisor_pid)
+ .collect::<std::collections::HashSet<_>>()
+ .len();Also add a case asserting that PID 12 is excluded when only PID 11 is known.
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| fn supervisor_worker_count( | |
| supervisor_pid: Option<u32>, | |
| daemon_pids: &[u32], | |
| known_session_pids: &[u32], | |
| ) -> usize { | |
| let known: std::collections::HashSet<u32> = known_session_pids.iter().copied().collect(); | |
| daemon_pids | |
| .iter() | |
| .copied() | |
| .filter(|pid| match supervisor_pid { | |
| Some(supervisor) => *pid != supervisor, | |
| None => known.contains(pid), | |
| }) | |
| .collect::<std::collections::HashSet<_>>() | |
| .len() | |
| } | |
| fn supervisor_daemon_health_verdict( | |
| supervisor_pid: Option<u32>, | |
| supervisor_alive: bool, | |
| daemon_pids: &[u32], | |
| unmanaged_pids: &[u32], | |
| ) -> Option<DoctorCheck> { | |
| let supervisor_pid = | |
| supervisor_pid.filter(|pid| supervisor_alive && daemon_pids.contains(pid))?; | |
| let workers = supervisor_worker_count(Some(supervisor_pid), daemon_pids, &[]); | |
| if !unmanaged_pids.is_empty() { | |
| let managed_workers = workers.saturating_sub(unmanaged_pids.len()); | |
| fn supervisor_worker_count( | |
| supervisor_pid: Option<u32>, | |
| daemon_pids: &[u32], | |
| known_session_pids: &[u32], | |
| ) -> usize { | |
| let known: std::collections::HashSet<u32> = known_session_pids.iter().copied().collect(); | |
| daemon_pids | |
| .iter() | |
| .copied() | |
| .filter(|pid| Some(*pid) != supervisor_pid && known.contains(pid)) | |
| .collect::<std::collections::HashSet<_>>() | |
| .len() | |
| } | |
| fn supervisor_daemon_health_verdict( | |
| supervisor_pid: Option<u32>, | |
| supervisor_alive: bool, | |
| daemon_pids: &[u32], | |
| unmanaged_pids: &[u32], | |
| ) -> Option<DoctorCheck> { | |
| let supervisor_pid = | |
| supervisor_pid.filter(|pid| supervisor_alive && daemon_pids.contains(pid))?; | |
| let workers = daemon_pids | |
| .iter() | |
| .copied() | |
| .filter(|pid| *pid != supervisor_pid) | |
| .collect::<std::collections::HashSet<_>>() | |
| .len(); | |
| if !unmanaged_pids.is_empty() { | |
| let managed_workers = workers.saturating_sub(unmanaged_pids.len()); |
🤖 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 `@src/cli/status.rs` around lines 1042 - 1069, Update supervisor_worker_count
to restrict its fanout set to known_session_pids even when supervisor_pid is
present, excluding unmanaged daemon PIDs such as 12 when only 11 is known. In
supervisor_daemon_health_verdict, calculate the total daemon count separately
for health evaluation rather than reusing the restricted fanout count, and add
coverage for the specified PID case.
Fixes final live-audit false positives in wire doctor. Worker fan-out now counts exact wire daemon roles instead of reused stale pid numbers, scopes unsupervised homes correctly, and treats a healthy all-session supervisor as owner of retired per-session pidfiles while still failing on unmanaged daemons.\n\nVerification:\n- 27 doctor unit tests\n- 655-stale-home restart regression\n- cargo fmt and clippy -D warnings\n- live candidate doctor: 11 workers under cap, no unmanaged daemons, zero FAIL\n- test-env/run.sh (final source; 11/11 integrations)\n- GitNexus detect_changes: HIGH diagnostic-path rating; no service/relay/send/pair mutation in exact diff
Summary by CodeRabbit
wire doctoraccuracy for supervisor and daemon health checks.