aien-architecture-mv
Canonical architecture for the AIEN ecosystem: flows, boundaries, ADRs, and the map from design to implementation repositories.
Brought by drakestapleton
aien-architecture-mv / tools / crumb / test-continuation.sh
| 1 | #!/bin/sh |
| 2 | # T9 (RFC-0002 section 9): Continuation revalidation. usage: sh test-continuation.sh ./crumb |
| 3 | # checkpoint at commit C, advance the repo, resume must report STALE for repo HEAD and status NEEDS_REVIEW. |
| 4 | C=${1:-./crumb}; C=$(cd "$(dirname "$C")" && pwd)/$(basename "$C") |
| 5 | CC=${CRUMB_CC:-$HOME/.claude/skills/checkpoint/scripts/cc.sh} |
| 6 | if [ ! -x "$CC" ] || ! command -v jq >/dev/null 2>&1; then echo "SKIP T9 (needs jq and cc.sh at $CC): NOT_RUN"; exit 0; fi |
| 7 | T=$(mktemp -d); trap 'rm -rf "$T"' EXIT |
| 8 | fail=0; ok() { echo "PASS $1"; }; bad() { echo "FAIL $1"; fail=1; } |
| 9 | export HOME="$T/home"; mkdir -p "$HOME" # seal leaves whispers under $HOME/handoffs: keep them in scratch |
| 10 | export CRUMB_CC="$CC" CRUMB_SESSION=t9-agent; unset CRUMB_COORD_ROOT CC_STORE |
| 11 | mkdir -p "$T/r/src" "$HOME/handoffs"; cd "$T/r" || exit 1 |
| 12 | git init -q -b main . && echo a > src/a.c && git add -A && git -c user.name=t -c user.email=t@t commit -qm init |
| 13 | C0=$(git rev-parse HEAD) |
| 14 | STORE=$(git rev-parse --absolute-git-dir)/crumb/v1 |
| 15 | |
| 16 | out=$("$C" checkpoint t9-agent --reason "t9 test") ; rc=$? |
| 17 | [ $rc -eq 0 ] && [ -f "$out" ] && case "$out" in "$STORE/continuations/"*) true;; *) false;; esac && ok "T9 checkpoint creates record in <coordination root>/continuations" || { bad "T9 checkpoint ($out)"; exit 1; } |
| 18 | id=$(basename "$out" .json) |
| 19 | jq -e '.identity.reason=="t9 test" and .identity.created_by=="t9-agent" and (.identity.repos[0].commit=="'"$C0"'")' "$out" >/dev/null && ok "T9 record pins HEAD and reason" || bad "T9 pin" |
| 20 | tmp="$out.t"; jq '.identity.project="t9" | .mission.current_goal="g" | .mission.milestone="m" | .mission.definition_of_done=["done"] |
| 21 | | .state.items=[{"tag":"OPEN","claim":"nothing yet"}] | .execution.current_task="t" | .execution.next_tasks=[{"id":"n1","task":"x"}] |
| 22 | | .resume.first_action="look" | .resume.validation_before_work=["git status"] | .resume.bootstrap_prompt="continue"' "$out" > "$tmp" && mv "$tmp" "$out" |
| 23 | seal=$("$C" checkpoint --seal "$id" t9-agent 2>&1); echo "$seal" | grep -q "SEALED $id" && ok "T9 seal succeeds" || bad "T9 seal: $seal" |
| 24 | [ "$(cat "$STORE/continuations/LATEST" 2>/dev/null)" = "$id" ] && ok "T9 LATEST updated in the shared store" || bad "T9 LATEST" |
| 25 | |
| 26 | echo more > src/b.c && git add -A && git -c user.name=t -c user.email=t@t commit -qm "advance" |
| 27 | res=$("$C" resume "$id" 2>&1) |
| 28 | echo "$res" | grep -q '^STALE .*repo\..*\.HEAD' && ok "T9 resume prints STALE for repo HEAD" || bad "T9 STALE line" |
| 29 | echo "$res" | grep -q '^status: NEEDS_REVIEW' && ok "T9 resume status NEEDS_REVIEW" || bad "T9 status" |
| 30 | [ "$(jq -r .revalidation.status "$STORE/continuations/$id.json")" = NEEDS_REVIEW ] && ok "T9 findings recorded in the record" || bad "T9 recorded" |
| 31 | CRUMB_CC="$T/missing/cc.sh" "$C" resume "$id" 2>&1 | grep -q 'cc.sh not found.*missing/cc.sh' && ok "T9 missing cc.sh gives a clear error naming the path" || bad "T9 missing cc.sh" |
| 32 | exit $fail |