Print hook liveness and aggregated failures. The two facts are printed together because either alone misleads: a healthy log proves nothing about whether the recorder is running, and a live recorder proves nothing about what it failed to do earlier.
(repo_root: &std::path::Path, installed: &[&str], registry: &AgentRegistry)
| 501 | /// healthy log proves nothing about whether the recorder is running, and a |
| 502 | /// live recorder proves nothing about what it failed to do earlier. |
| 503 | fn print_hook_health(repo_root: &std::path::Path, installed: &[&str], registry: &AgentRegistry) { |
| 504 | let mut log_unavailable = false; |
| 505 | let health = super::hook_log::read(repo_root).unwrap_or_else(|error| { |
| 506 | log_unavailable = true; |
| 507 | eprintln!(" ⚠ Hook log unavailable: {error}"); |
| 508 | super::hook_log::pending_health(repo_root) |
| 509 | }); |
| 510 | let rows = health |
| 511 | .as_ref() |
| 512 | .map(super::health::summarize) |
| 513 | .unwrap_or_default(); |
| 514 | let errors = super::health::read_errors(repo_root); |
| 515 | |
| 516 | // With no observations there is no evidence either way, so stay |
| 517 | // quiet rather than accusing a freshly-upgraded repository of never |
| 518 | // having recorded. |
| 519 | let silent: Vec<&str> = if health.is_none() || log_unavailable { |
| 520 | Vec::new() |
| 521 | } else { |
| 522 | installed |
| 523 | .iter() |
| 524 | .copied() |
| 525 | .filter(|name| !rows.iter().any(|r| r.name == *name && r.last_ok.is_some())) |
| 526 | .collect() |
| 527 | }; |
| 528 | |
| 529 | if rows.is_empty() && errors.is_none() && silent.is_empty() { |
| 530 | return; |
| 531 | } |
| 532 | |
| 533 | // Liveness, one line per agent that has ever fired. |
| 534 | for row in &rows { |
| 535 | let display = registry.get(&row.name).map_or_else( |
| 536 | || row.display_name.clone(), |
| 537 | |a| a.display_name().to_string(), |
| 538 | ); |
| 539 | let marker = if row.last_ok.is_some() { "✓" } else { "⚠" }; |
| 540 | let failing = if row.failing_verbs.is_empty() { |
| 541 | String::new() |
| 542 | } else { |
| 543 | format!(" ⚠ failing: {}", row.failing_verbs.join(", ")) |
| 544 | }; |
| 545 | println!(" {marker} {display} — {}", row.liveness()); |
| 546 | if !failing.is_empty() { |
| 547 | println!("{failing}"); |
| 548 | } |
| 549 | } |
| 550 | |
| 551 | // Attribute outstanding failures to their sessions. |
| 552 | if let Some(health) = &health { |
| 553 | for session in health.sessions.values() { |
| 554 | let failing: Vec<_> = session |
| 555 | .health |
| 556 | .verbs |
| 557 | .iter() |
| 558 | .filter(|(_, verb)| verb.outcome == super::health::FireOutcome::Error) |
| 559 | .map(|(name, _)| name.as_str()) |
| 560 | .collect(); |
no test coverage detected