tests: roundtrip smoke; CLAUDE.md

This commit is contained in:
müde 2026-05-14 22:29:25 +02:00
parent 2a98e3ca87
commit 4f191b2e43
2 changed files with 218 additions and 0 deletions

61
tests/roundtrip.sh Executable file
View file

@ -0,0 +1,61 @@
#!/usr/bin/env bash
# Phase 3 end-to-end smoke test: spawn alice + bob, send alice→bob, observe
# bob's harness echo-reply land in alice's journal.
#
# Run as root (uses nixos-container + hive-c0re). Idempotent — wipes any prior
# h-alice / h-bob first.
#
# With claude not logged in inside the containers, both fall back to echo and
# the chain terminates after one round trip (the "echo: " guard).
set -euo pipefail
cleanup() {
echo "=== cleaning up any prior test agents ==="
sudo hive-c0re kill alice 2>/dev/null || true
sudo hive-c0re kill bob 2>/dev/null || true
sudo nixos-container destroy h-alice 2>/dev/null || true
sudo nixos-container destroy h-bob 2>/dev/null || true
}
cleanup
echo "=== spawn alice + bob ==="
sudo hive-c0re spawn alice
sudo hive-c0re spawn bob
echo "=== wait for harnesses to come up ==="
sleep 3
T=$(date +"%Y-%m-%d %H:%M:%S")
echo "test start: $T"
echo "=== alice → bob: 'ping' ==="
sudo nixos-container run h-alice -- hive-ag3nt send bob "ping"
echo "=== wait for bob to reply, alice to receive ==="
sleep 4
echo
echo "=== bob's journal since test start ==="
sudo journalctl -M h-bob -u hive-ag3nt --since "$T" --no-pager | tail -20 || true
echo
echo "=== alice's journal since test start ==="
sudo journalctl -M h-alice -u hive-ag3nt --since "$T" --no-pager | tail -20 || true
echo
echo "=== broker rows (last 10) ==="
sudo sqlite3 /var/lib/hyperhive/broker.sqlite \
"SELECT id, sender, recipient, substr(body,1,60) AS body, sent_at, delivered_at FROM messages ORDER BY id DESC LIMIT 10;" \
2>/dev/null || echo "(sqlite3 not available — skip)"
echo
echo "=== expected ==="
echo " bob's journal: 'inbox from=alice body=ping' then 'claude failed; falling back to echo'"
echo " alice's journal: 'inbox from=bob body=echo: ping' (no reply, echo guard stopped the chain)"
echo " broker rows: 2 messages — alice→bob 'ping' (delivered) and bob→alice 'echo: ping' (delivered)"
echo
read -r -p "Press enter to tear down test agents, Ctrl-C to leave them up: "
cleanup