Files
jason.woltje db330c12c7 feat(release): self-determination - ensure at launch, drift warnings, M20 packages/* decision (#38)
- release.sh ensure: aligned no-op; drift -> package-if-needed + health-gated
  activate (M3 gate-then-flip, automated)
- ensure_release_aligned in common.sh: invoked by hello/verify/agent;
  MOSAIC_ENSURE_SKIP guards recursion; run-task warns on drift without
  auto-aligning (workers/suites never trigger builds or model gates)
- ROADMAP: M20 decision recorded - v2 adopts packages/* monorepo at usurpation
- BUILD-LOG Phase 20 + tool-race process note

Live-verified: post-reset pointer loss auto-restored via health-gated
ensure; drift warning fires on desired-version bump; idempotent no-op on
aligned state.

Closes #38
2026-09-03 14:42:09 -05:00

70 lines
2.1 KiB
Bash
Executable File

#!/usr/bin/env bash
# Complete verification test:
# 1. Build or confirm the image is built.
# 2. Run the agent request.
# 3. Remove surrounding whitespace from the response.
# 4. Compare with the expected marker (default MOSAIC_HELLO_OK).
# 5. Exit 0 only on exact match; nonzero otherwise.
#
# EXPECTED_MARKER may be overridden to prove the failure path
# (acceptance criterion 9), e.g.:
# EXPECTED_MARKER=MOSAIC_NOT_OK scripts/verify.sh
set -euo pipefail
cd "$(dirname "$0")/.."
# shellcheck source=common.sh
source scripts/common.sh
EXPECTED="${EXPECTED_MARKER:-MOSAIC_HELLO_OK}"
# Status colors: terminal-only, NO_COLOR-respecting; plain when piped.
if [ -t 1 ] && [ -z "${NO_COLOR:-}" ]; then
C_OK=$'\033[0;32m'; C_FAIL=$'\033[0;31m'; C_RESET=$'\033[0m'
else
C_OK=""; C_FAIL=""; C_RESET=""
fi
load_config
load_release
IMAGE="$MOSAIC_IMAGE_TAG"
# Ensure the configured data root exists (host-owned) before the mount,
# otherwise Docker would auto-create a root-owned directory.
bootstrap_runtime_dir
ensure_release_aligned
# 1. Build the image only if it is not already present.
if ! docker image inspect "$IMAGE" >/dev/null 2>&1; then
echo "verify: image $IMAGE not found, building..." >&2
bootstrap_runtime_dir
docker compose build
fi
# 2. Run the agent request (stdout only = model response).
# stdin detached: see hello.sh — print mode would block on a terminal.
set +e
RESPONSE="$(docker compose run --rm -T mosaic-agent </dev/null 2>/tmp/mosaic-poc-stderr.$$)"
RC=$?
set -e
STDERR_FILE="/tmp/mosaic-poc-stderr.$$"
if [ $RC -ne 0 ]; then
echo "verify: agent run failed (exit $RC):" >&2
cat "$STDERR_FILE" >&2
rm -f "$STDERR_FILE"
exit 1
fi
rm -f "$STDERR_FILE"
# 3. Remove surrounding whitespace.
TRIMMED="$(printf '%s' "$RESPONSE" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')"
# 4-6. Exact comparison gate.
if [ "$TRIMMED" = "$EXPECTED" ]; then
echo "${C_OK}PASS${C_RESET}: response matches expected marker"
exit 0
fi
echo "${C_FAIL}FAIL${C_RESET}: response does not match expected marker" >&2
printf 'expected: %s\n' "$EXPECTED" >&2
printf 'actual : %s\n' "$TRIMMED" >&2
exit 1