Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions crates/korg-runtime/src/execution/dag.rs
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,10 @@ mod tests {
#[tokio::test]
async fn run_command_reflects_real_exit_status() {
assert!(run_command("true").await, "`true` exits 0 → success");
assert!(!run_command("false").await, "`false` exits non-zero → failure");
assert!(
!run_command("false").await,
"`false` exits non-zero → failure"
);
}

#[tokio::test]
Expand Down Expand Up @@ -522,7 +525,10 @@ mod tests {
let key = ed25519_dalek::SigningKey::generate(&mut rand::rngs::OsRng);
let mut scheduler = SpeculativeScheduler::new(dag, key);
let summary = scheduler.run(None).await.unwrap();
assert!(!summary.overall_success, "a real non-zero exit must fail the DAG");
assert!(
!summary.overall_success,
"a real non-zero exit must fail the DAG"
);
}

#[test]
Expand Down
5 changes: 4 additions & 1 deletion crates/korg-runtime/src/execution/recovery.rs
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,10 @@ mod tests {
// Without compiler stderr + a worktree path there is nothing real to
// repair, so heal_node must report that honestly — no fake "healed".
let healed = heal_node("thump test --fail", Some(tx)).await.unwrap();
assert!(!healed, "heal_node with no error/worktree context cannot heal");
assert!(
!healed,
"heal_node with no error/worktree context cannot heal"
);
let mut logs = Vec::new();
while let Ok(log) = rx.try_recv() {
logs.push(log);
Expand Down
6 changes: 5 additions & 1 deletion crates/korg-runtime/src/identity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,10 @@ mod tests {
load_or_create_identity_at(&path).unwrap();
assert!(path.exists(), "the key file must be created");
let mode = std::fs::metadata(&path).unwrap().permissions().mode();
assert_eq!(mode & 0o777, 0o600, "the private key file must be mode 0o600");
assert_eq!(
mode & 0o777,
0o600,
"the private key file must be mode 0o600"
);
}
}
15 changes: 12 additions & 3 deletions crates/korg-server/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2862,14 +2862,23 @@ mod tests {
// 0.0.0.0, which exposed the (mostly unauthenticated) control + telemetry
// routes to the whole local network.
let addr = resolve_bind_addr(None);
assert!(addr.starts_with("127.0.0.1"), "default must be loopback, got {addr}");
assert!(!addr.starts_with("0.0.0.0"), "default must not bind all interfaces");
assert!(
addr.starts_with("127.0.0.1"),
"default must be loopback, got {addr}"
);
assert!(
!addr.starts_with("0.0.0.0"),
"default must not bind all interfaces"
);
}

#[test]
fn bind_addr_honors_explicit_override() {
// Intentional network exposure stays possible, but only by explicit opt-in.
assert_eq!(resolve_bind_addr(Some("0.0.0.0:9000".into())), "0.0.0.0:9000");
assert_eq!(
resolve_bind_addr(Some("0.0.0.0:9000".into())),
"0.0.0.0:9000"
);
}

#[tokio::test]
Expand Down
94 changes: 71 additions & 23 deletions crates/korg-tui/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1710,21 +1710,40 @@ async fn run_tui_event_loop(
// Reset the working tree to HEAD.
let terminal_tx_clone = terminal_tx.clone();
tokio::spawn(async move {
let _ = terminal_tx_clone.send("[System] Resetting working tree to HEAD...".to_string()).await;
let _ = terminal_tx_clone
.send(
"[System] Resetting working tree to HEAD..."
.to_string(),
)
.await;
let output = tokio::process::Command::new("git")
.args(["read-tree", "--reset", "-u", "HEAD"])
.output()
.await;
match output {
Ok(out) if out.status.success() => {
let _ = terminal_tx_clone.send("[System] Working tree reset to HEAD.".to_string()).await;
let _ = terminal_tx_clone
.send(
"[System] Working tree reset to HEAD."
.to_string(),
)
.await;
}
Ok(out) => {
let err = String::from_utf8_lossy(&out.stderr);
let _ = terminal_tx_clone.send(format!("[System] git reversion failed: {}", err.trim())).await;
let _ = terminal_tx_clone
.send(format!(
"[System] git reversion failed: {}",
err.trim()
))
.await;
}
Err(e) => {
let _ = terminal_tx_clone.send(format!("[System] git reversion failed: {e}")).await;
let _ = terminal_tx_clone
.send(format!(
"[System] git reversion failed: {e}"
))
.await;
}
}
});
Expand Down Expand Up @@ -2448,21 +2467,40 @@ async fn run_tui_event_loop(

let terminal_tx_clone = terminal_tx.clone();
tokio::spawn(async move {
let _ = terminal_tx_clone.send("[System] Resetting working tree to HEAD...".to_string()).await;
let _ = terminal_tx_clone
.send(
"[System] Resetting working tree to HEAD..."
.to_string(),
)
.await;
let output = tokio::process::Command::new("git")
.args(["read-tree", "--reset", "-u", "HEAD"])
.output()
.await;
match output {
Ok(out) if out.status.success() => {
let _ = terminal_tx_clone.send("[System] Working tree reset to HEAD.".to_string()).await;
let _ = terminal_tx_clone
.send(
"[System] Working tree reset to HEAD."
.to_string(),
)
.await;
}
Ok(out) => {
let err = String::from_utf8_lossy(&out.stderr);
let _ = terminal_tx_clone.send(format!("[System] git reversion failed: {}", err.trim())).await;
let _ = terminal_tx_clone
.send(format!(
"[System] git reversion failed: {}",
err.trim()
))
.await;
}
Err(e) => {
let _ = terminal_tx_clone.send(format!("[System] git reversion failed: {e}")).await;
let _ = terminal_tx_clone
.send(format!(
"[System] git reversion failed: {e}"
))
.await;
}
}
});
Expand Down Expand Up @@ -3174,14 +3212,16 @@ fn draw_dashboard(f: &mut Frame, app: &KorgTui) {
} else {
let last_idx = app.workers.len() - 1;
for (i, w) in app.workers.iter().enumerate() {
let branch = if i == last_idx { " └─ " } else { " ├─ " };
let branch = if i == last_idx {
" └─ "
} else {
" ├─ "
};
let (glyph, glyph_color) = match w.state {
WorkerLifecycle::Spawning => {
("\u{22ef}", Color::Rgb(128, 142, 162))
} // ⋯
WorkerLifecycle::Running => ("\u{25b8}", Color::Rgb(0, 180, 216)), // ▸
WorkerLifecycle::Ok => ("\u{2713}", Color::Rgb(165, 222, 103)), // ✓
WorkerLifecycle::Crashed => ("\u{2717}", Color::Rgb(247, 37, 133)), // ✗
WorkerLifecycle::Spawning => ("\u{22ef}", Color::Rgb(128, 142, 162)), // ⋯
WorkerLifecycle::Running => ("\u{25b8}", Color::Rgb(0, 180, 216)), // ▸
WorkerLifecycle::Ok => ("\u{2713}", Color::Rgb(165, 222, 103)), // ✓
WorkerLifecycle::Crashed => ("\u{2717}", Color::Rgb(247, 37, 133)), // ✗
WorkerLifecycle::TimedOut => ("\u{23f1}", Color::Rgb(255, 198, 109)), // ⏱
WorkerLifecycle::SpawnError => ("!", Color::Rgb(247, 37, 133)),
};
Expand All @@ -3201,10 +3241,7 @@ fn draw_dashboard(f: &mut Frame, app: &KorgTui) {
format!("{} ", w.persona),
Style::default().fg(Color::Rgb(255, 255, 255)),
),
Span::styled(
format!("[{}] ", short_id),
Style::default().fg(fg_slate),
),
Span::styled(format!("[{}] ", short_id), Style::default().fg(fg_slate)),
Span::styled(
format!("{}ms", w.elapsed_ms),
Style::default().fg(Color::Rgb(180, 180, 180)),
Expand Down Expand Up @@ -3278,12 +3315,16 @@ fn draw_dashboard(f: &mut Frame, app: &KorgTui) {
// Derive state from the same fields TuiUpdate::Verdict writes — never claims.
let goal_state =
derive_goal_state(&app.current_verdict, &app.rubric_status, app.progress);
let met = app.rubric_status.iter().filter(|(_, passed)| *passed).count();
let met = app
.rubric_status
.iter()
.filter(|(_, passed)| *passed)
.count();
let total = app.rubric_status.len();
// Pill color: only Verified earns green; a claim with failing criteria is amber.
let pill_color = match goal_state {
GoalState::Awaiting => Color::Rgb(100, 110, 125), // dim grey
GoalState::InProgress => Color::Rgb(0, 180, 216), // cyan
GoalState::InProgress => Color::Rgb(0, 180, 216), // cyan
GoalState::ClaimedUnverified => Color::Rgb(255, 198, 109), // amber
GoalState::Verified => Color::Rgb(165, 222, 103), // green
};
Expand Down Expand Up @@ -4674,7 +4715,11 @@ mod tests {
WorkerLifecycle::Crashed,
999,
);
assert_eq!(app.workers.len(), 2, "distinct node_ids create distinct rows");
assert_eq!(
app.workers.len(),
2,
"distinct node_ids create distinct rows"
);

// The first row stays at its latest values; the new row carries its own.
let benjamin = app
Expand Down Expand Up @@ -4857,7 +4902,10 @@ mod tests {

#[test]
fn test_goal_state_label_strings() {
assert_eq!(goal_state_label(&GoalState::Awaiting), "Awaiting first round");
assert_eq!(
goal_state_label(&GoalState::Awaiting),
"Awaiting first round"
);
assert_eq!(goal_state_label(&GoalState::InProgress), "In progress");
assert_eq!(
goal_state_label(&GoalState::ClaimedUnverified),
Expand Down
6 changes: 5 additions & 1 deletion src/introspect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,11 @@ mod tests {
let codes = exit_codes();
assert_eq!(codes.get("0").map(|s| s.as_str()), Some("success"));
for key in codes.keys() {
assert!(key.parse::<u32>().is_ok(), "non-numeric exit-code key: {}", key);
assert!(
key.parse::<u32>().is_ok(),
"non-numeric exit-code key: {}",
key
);
}
}

Expand Down
Loading