Files
nisse/scripts/review-bringup.sh
T
dongarandClaude Opus 5.5 75958aef28
CI / checks (push) Skipped
CI / checks (pull_request) Successful in 1m49s
CI / e2e (pull_request) Successful in 4m3s
Development Plan: every agent is its own container image
Each agent ships as its own image, since that's how it runs on the agent
host. nisse-review's image becomes M7.6, ahead of the agent host; its
deployment moves to M7.7. nisse-ops' image comes with its first slice.
Also fixes two stale references to M7.6.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01J5Utyfzw7gF7UhjRDEtjTk
2026-10-19 13:16:07 +00:00

63 lines
2.6 KiB
Bash
Executable File

#!/usr/bin/env bash
# Bring-up runs of nisse-review on this development VM (Development Plan M7.3).
#
# It runs from the exported code under test, in a virtualenv of its own, as a
# transient systemd unit, so it outlives the shell that started it. It runs
# from its image after M7.6, and on the agent host after M7.7.
#
# scripts/review-bringup.sh start [REF] export REF (default HEAD), install
# it, and start the reviewer
# scripts/review-bringup.sh stop stop it cleanly (SIGTERM)
# scripts/review-bringup.sh status the unit, and its items
# scripts/review-bringup.sh logs follow its log
#
# Layout, under $REVIEW (default /root/nisse-review):
# nisse-review.yaml, .env the config and its secrets (made by hand once)
# code/, venv/ the exported code and its install
# state.db, scratch/ its state, and repository trees while reviewing
# vault/ its memory (memory/nisse-review)
set -euo pipefail
REVIEW=${NISSE_REVIEW:-/root/nisse-review}
SRC=${NISSE_SRC:-/root/nisse}
UNIT=nisse-review-bringup
export PATH="$HOME/.local/bin:$PATH"
die() { echo "review-bringup: $*" >&2; exit 1; }
running() { systemctl is-active --quiet "$UNIT"; }
cmd_start() {
local ref=${1:-HEAD} sha
[ -f "$REVIEW/nisse-review.yaml" ] && [ -f "$REVIEW/.env" ] || die "no config in $REVIEW"
running && die "already running; stop it first"
sha=$(git -C "$SRC" rev-parse --verify "$ref^{commit}") || die "unknown ref $ref"
rm -rf "$REVIEW/code" && mkdir -p "$REVIEW/code" "$REVIEW/vault/memory/nisse-review"
git -C "$SRC" archive "$sha" | tar -x -C "$REVIEW/code"
UV_PROJECT_ENVIRONMENT="$REVIEW/venv" uv sync -q --frozen --no-dev \
--package nisse-review --no-editable --project "$REVIEW/code"
echo "$sha" > "$REVIEW/run-info"
systemd-run --unit="$UNIT" --collect \
-p WorkingDirectory="$REVIEW" \
-E NISSE_CONFIG="$REVIEW/nisse-review.yaml" -E NISSE_ENV="$REVIEW/.env" \
"$REVIEW/venv/bin/nisse-review"
echo "started $UNIT at $sha"
}
cmd_stop() { running && systemctl stop "$UNIT" || echo "not running"; }
cmd_status() {
systemctl status "$UNIT" --no-pager || true
[ -f "$REVIEW/state.db" ] && sqlite3 "$REVIEW/state.db" \
"SELECT id, position, status, outcome FROM work_items ORDER BY opened_at"
}
cmd_logs() { journalctl -u "$UNIT" -f; }
case "${1:-}" in
start) shift; cmd_start "$@" ;;
stop) cmd_stop ;;
status) cmd_status ;;
logs) cmd_logs ;;
*) die "usage: $0 start [REF] | stop | status | logs" ;;
esac