version: "3" # RFC §15.7 — `tests/cli/restart/` validates that dispatch state survives a # kill+restart cycle without leaving ghost agents in the registry. The # Taskfile path mirrors the surface under test (`core-agent restart` is not a # command — restart is the lifecycle, validated by simulating a stale # workspace and confirming `status` reports it as failed/queued, not running). tasks: test: cmds: - | bash <<'EOF' set -euo pipefail source ../_lib/run.sh go build -trimpath -ldflags="-s -w" -o bin/core-agent ../../../cmd/core-agent # Use an isolated CORE_WORKSPACE so the test cannot disturb the # operator's own .core/ directory. workspace="$(mktemp -d)" export CORE_WORKSPACE="$workspace" export CORE_HOME="$workspace" export DIR_HOME="$workspace" # Pre-seed a workspace with status.json showing a process that is # not alive — simulating the "dispatch -> kill -> restart" cycle. ghost_dir="$workspace/workspace/core/go-io/task-restart" mkdir -p "$ghost_dir" cat >"$ghost_dir/status.json" <&2 cat "$output" >&2 exit 1 fi assert_contains "failed" "$output" # The reaped status should be persisted back to disk per RFC §15.3 — # cross-process consumers (other tooling reading status.json) must # see the same coherent state. status_file="$ghost_dir/status.json" if grep -q '"status":[[:space:]]*"running"' "$status_file"; then printf 'expected reaped status persisted to %s\n' "$status_file" >&2 cat "$status_file" >&2 exit 1 fi EOF