Sweep for stale naming/defaults left over from the pi-only era (the same
class of bug as the pi_binary compile break):
- socket.rs: non-local spawn defaulted the binary to `hermes-agent` (a binary
that does not exist) and hardcoded `--mode json` (invalid for zot) — a
reachable latent bug via `colibri spawn-agent <provider>`. Default to zot and
derive argv from a single default_agent_args() helper, shared with autospawn
(removes the duplicated zot-vs-pi arg logic).
- glasspane/tui/client/daemon: rename the stale wire field `pi_session_id` →
`session_id` (zot agents have session ids too). `#[serde(alias =
"pi_session_id")]` keeps deserializing legacy/persisted snapshots.
- contracts + runtime_inventory: record `zot` version alongside `pi` for
complete agent provenance (detect_zot_version()).
- Harness-neutral stale comments ("Pi agent", "hermes-agent" example,
COLIBRI_PI_BINARY in a test doc).
- cmd_spawn_agent: #[allow(clippy::too_many_arguments)] — this lint was already
failing `clippy -D warnings`, i.e. the CI gate was red on main and thus
unenforceable. The gate (scripts/ci-checks.sh) now passes green.
- AGENTS.md: document that ci-checks.sh passing is mandatory before merge while
no Actions runner enforces .forgejo/workflows/ci.yml.
Validated: ./scripts/ci-checks.sh green (fmt, clippy -D warnings, tests, md).
Stacks on #157 (zot-rpc driver) and #156 (0.12 build fix).
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
91 lines
2.7 KiB
Rust
91 lines
2.7 KiB
Rust
//! Pi spawn path proof — integration test.
|
|
//!
|
|
//! Validates: Colibri spawns agent → reads JSONL stdout → glasspane ingests → snapshot correct.
|
|
//! Uses scripts/fake-pi-agent.py which emits the colibri-pi-events JSONL taxonomy.
|
|
//!
|
|
//! With real Pi binary (when installed):
|
|
//! COLIBRI_AGENT_BINARY=pi cargo test -p colibri-daemon --test pi_spawn_live -- --nocapture
|
|
|
|
use std::path::PathBuf;
|
|
use std::process::Stdio;
|
|
use std::time::SystemTime;
|
|
|
|
use colibri_glasspane::DEFAULT_STALL_AFTER;
|
|
use tokio::io::{AsyncBufReadExt, BufReader};
|
|
use tokio::process::Command;
|
|
|
|
#[tokio::test]
|
|
async fn pi_spawn_path_produces_correct_glasspane_state() {
|
|
let script = PathBuf::from(env!("CARGO_MANIFEST_DIR"))
|
|
.parent()
|
|
.unwrap()
|
|
.parent()
|
|
.unwrap()
|
|
.join("scripts")
|
|
.join("fake-pi-agent.py");
|
|
|
|
assert!(script.exists(), "fake-pi-agent.py not found at {script:?}");
|
|
|
|
let mut supervisor = colibri_glasspane::PaneSupervisor::new();
|
|
let pane_id = "pi-spawn-proof";
|
|
supervisor.attach_pane_at(pane_id, "fake-pi", SystemTime::now());
|
|
|
|
let mut child = Command::new(PathBuf::from("python3"))
|
|
.arg(&script)
|
|
.stdout(Stdio::piped())
|
|
.stderr(Stdio::piped())
|
|
.spawn()
|
|
.expect("failed to spawn fake-pi-agent.py");
|
|
|
|
let stdout = child.stdout.take().expect("no stdout");
|
|
let mut reader = BufReader::new(stdout).lines();
|
|
let mut accepted = 0usize;
|
|
|
|
loop {
|
|
match reader.next_line().await {
|
|
Ok(Some(line)) => {
|
|
if supervisor
|
|
.ingest_line_at(pane_id, &line, SystemTime::now())
|
|
.is_some()
|
|
{
|
|
accepted += 1;
|
|
}
|
|
}
|
|
Ok(None) => break,
|
|
Err(e) => {
|
|
eprintln!("JSONL read error: {e}");
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
let status = child.wait().await.expect("child wait failed");
|
|
assert!(status.success(), "fake-pi-agent.py exited with {status}");
|
|
assert!(
|
|
accepted >= 5,
|
|
"expected >=5 accepted JSONL lines, got {accepted}"
|
|
);
|
|
|
|
let snapshot = supervisor.snapshot_at("test-host", SystemTime::now(), DEFAULT_STALL_AFTER);
|
|
let pane = snapshot
|
|
.panes
|
|
.iter()
|
|
.find(|p| p.id == pane_id)
|
|
.expect("pane not found");
|
|
|
|
assert_eq!(
|
|
pane.state,
|
|
colibri_glasspane::AgentState::Done,
|
|
"expected Done after full agent run"
|
|
);
|
|
assert!(
|
|
pane.session_id.is_some(),
|
|
"expected session_id from session event, got {:?}",
|
|
pane.session_id
|
|
);
|
|
|
|
eprintln!(
|
|
"✓ Pi spawn proof: {} accepted, state={:?}, session={:?}",
|
|
accepted, pane.state, pane.session_id
|
|
);
|
|
}
|