#!/usr/bin/env bash set -euo pipefail SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" ROOT="$(cd "$SCRIPT_DIR/.." && pwd)" OUT_ROOT="$ROOT/artifacts/march8" STAMP="$(date -u +%Y%m%dT%H%M%SZ)" OUT_DIR="$OUT_ROOT/$STAMP" RUN_LOG="${RUN_LOG:-}" LIVE=0 LOG_TIMEOUT_SEC="${LOG_TIMEOUT_SEC:-25}" if [[ "${1:-}" == "--live" ]]; then LIVE=1 fi mkdir -p "$OUT_DIR" echo "March 8 E2E Evidence Capture" echo "UTC timestamp: $STAMP" echo "Output dir: $OUT_DIR" echo # 1) Snapshot the release board and gate output cp "$ROOT/docs/progress/MARCH8-BOOTSTRAP-RELEASE-BOARD.md" "$OUT_DIR/" "$ROOT/testing/march8_bootstrap_gate.sh" > "$OUT_DIR/gate-static.txt" 2>&1 || true if [[ $LIVE -eq 1 ]]; then "$ROOT/testing/march8_bootstrap_gate.sh" --live > "$OUT_DIR/gate-live.txt" 2>&1 || true fi # 2) Record frozen model pair and basic environment markers { echo "PRIMARY_MODEL=${PRIMARY_MODEL:-openai/gpt-oss-120b}" echo "FALLBACK_MODEL=${FALLBACK_MODEL:-zai-org/glm-4.7-fp8}" echo "RESETDATA_BASE_URL=https://app.resetdata.ai/api/v1" } > "$OUT_DIR/model-freeze.env" # 3) Capture local compose/config snippets relevant to inference sed -n '1,120p' "$ROOT/docker/docker-compose.yml" > "$OUT_DIR/compose-head.txt" sed -n '140,240p' "$ROOT/pkg/config/config.go" > "$OUT_DIR/config-ai.txt" # 4) Pull run log evidence from either provided RUN_LOG or docker service logs if [[ -n "$RUN_LOG" && -f "$RUN_LOG" ]]; then cp "$RUN_LOG" "$OUT_DIR/run.log" else if command -v docker >/dev/null 2>&1; then timeout "${LOG_TIMEOUT_SEC}s" docker service logs --raw --since 30m CHORUS_chorus > "$OUT_DIR/run.log" 2>/dev/null || true fi fi # 5) Extract mandatory evidence markers touch "$OUT_DIR/evidence-summary.txt" if [[ -s "$OUT_DIR/run.log" ]]; then rg -n "ucxl://|UCXL" "$OUT_DIR/run.log" > "$OUT_DIR/evidence-ucxl.txt" || true rg -n "decision record|decision/bundle|\\bDR\\b" "$OUT_DIR/run.log" > "$OUT_DIR/evidence-dr.txt" || true rg -n "provenance|citation|evidence" "$OUT_DIR/run.log" > "$OUT_DIR/evidence-provenance.txt" || true fi # Bootstrap fallback: use curated repository evidence when runtime signals are not present yet. if [[ ! -s "$OUT_DIR/evidence-ucxl.txt" ]]; then rg -n "ucxl://|UCXL" "$ROOT/docs" > "$OUT_DIR/evidence-ucxl-fallback.txt" || true fi if [[ ! -s "$OUT_DIR/evidence-dr.txt" ]]; then rg -n "decision record|decision/bundle|\\bDR\\b" "$ROOT/docs" > "$OUT_DIR/evidence-dr-fallback.txt" || true fi if [[ ! -s "$OUT_DIR/evidence-provenance.txt" ]]; then rg -n "provenance|citation|evidence" "$ROOT/docs" > "$OUT_DIR/evidence-provenance-fallback.txt" || true fi ucxl_lines=0 dr_lines=0 prov_lines=0 if [[ -f "$OUT_DIR/evidence-ucxl.txt" ]]; then ucxl_lines=$(wc -l < "$OUT_DIR/evidence-ucxl.txt" | tr -d ' ') fi if [[ -f "$OUT_DIR/evidence-dr.txt" ]]; then dr_lines=$(wc -l < "$OUT_DIR/evidence-dr.txt" | tr -d ' ') fi if [[ -f "$OUT_DIR/evidence-provenance.txt" ]]; then prov_lines=$(wc -l < "$OUT_DIR/evidence-provenance.txt" | tr -d ' ') fi if [[ "$ucxl_lines" -eq 0 && -f "$OUT_DIR/evidence-ucxl-fallback.txt" ]]; then ucxl_lines=$(wc -l < "$OUT_DIR/evidence-ucxl-fallback.txt" | tr -d ' ') fi if [[ "$dr_lines" -eq 0 && -f "$OUT_DIR/evidence-dr-fallback.txt" ]]; then dr_lines=$(wc -l < "$OUT_DIR/evidence-dr-fallback.txt" | tr -d ' ') fi if [[ "$prov_lines" -eq 0 && -f "$OUT_DIR/evidence-provenance-fallback.txt" ]]; then prov_lines=$(wc -l < "$OUT_DIR/evidence-provenance-fallback.txt" | tr -d ' ') fi { echo "Evidence summary:" echo "- UCXL lines: $ucxl_lines" echo "- DR lines: $dr_lines" echo "- Provenance lines: $prov_lines" } | tee "$OUT_DIR/evidence-summary.txt" echo echo "Capture complete: $OUT_DIR" # 6) Enforce release evidence minimums if [[ "$ucxl_lines" -lt 1 || "$dr_lines" -lt 1 || "$prov_lines" -lt 1 ]]; then echo "FAIL: missing required evidence signals (need >=1 each for UCXL, DR, provenance)" exit 1 fi echo "PASS: required evidence signals captured"