Physically move the pure-code subtrees out of .specify into the package, leaving compat symlinks at the old .specify/<dir> paths so every existing reference (internal CASAN_HARNESS_ROOT + external CI/docker/mjs) keeps resolving. Runtime state stays put. Moved (git mv): scripts/ tests/ security/ templates/ config/ governance/ memory/ .specify/<dir> -> packages/casan-harness/<dir> (+ .specify/<dir> symlink) Stays in .specify (state/governance/domain, handled later): logs/ agentops/ level5/ init-options.json traceability-map.json Python `.resolve()` self-location followed the compat symlink into packages and lost the app root; generate-casan-demo-context.py, generate-agentops-dashboard.py and dashboard-server.py now walk UP for the `.specify` state marker instead of a fixed parent depth (fixes "missing trace files" in run-casan4). Full gate: PASS=64 FAIL=0 SKIP=3 (CASAN_CI_STEP_TIMEOUT_SEC=1200 — track-a ~450s runs close to the 600s default and can tip over under load; this is timing variance, not a regression — it passed cleanly with headroom). Runtime log/audit artifacts kept unstaged. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
72 lines
1.8 KiB
Bash
Executable File
72 lines
1.8 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
# CASAN Level 5 fallback runner.
|
|
# Usage:
|
|
# model-fallback.sh <output-file> --primary '<cmd>' --fallback '<cmd>'
|
|
|
|
OUTPUT_FILE="${1:-}"
|
|
shift || true
|
|
|
|
PRIMARY_CMD=""
|
|
FALLBACK_CMD=""
|
|
|
|
while [[ "$#" -gt 0 ]]; do
|
|
case "$1" in
|
|
--primary)
|
|
PRIMARY_CMD="${2:-}"
|
|
shift 2
|
|
;;
|
|
--fallback)
|
|
FALLBACK_CMD="${2:-}"
|
|
shift 2
|
|
;;
|
|
*)
|
|
echo "Unknown argument: $1" >&2
|
|
exit 64
|
|
;;
|
|
esac
|
|
done
|
|
|
|
if [[ -z "$OUTPUT_FILE" || -z "$PRIMARY_CMD" || -z "$FALLBACK_CMD" ]]; then
|
|
echo "Usage: model-fallback.sh <output-file> --primary '<cmd>' --fallback '<cmd>'" >&2
|
|
exit 64
|
|
fi
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
source "$SCRIPT_DIR/casan-paths.sh"
|
|
PROJECT_ROOT="$(cd "$SCRIPT_DIR/../../.." && pwd)"
|
|
LOG_DIR="$CASAN_STATE_ROOT/logs/level5"
|
|
mkdir -p "$LOG_DIR" "$(dirname "$OUTPUT_FILE")"
|
|
FALLBACK_LOG="$LOG_DIR/fallback.jsonl"
|
|
TRACE_ID="$(uuidgen 2>/dev/null | tr '[:upper:]' '[:lower:]' || printf 'fallback-%s-%s' "$(date +%s)" "$$")"
|
|
TIMESTAMP="$(date -u +"%Y-%m-%dT%H:%M:%SZ")"
|
|
|
|
TMP_PRIMARY="$(mktemp)"
|
|
TMP_FALLBACK="$(mktemp)"
|
|
|
|
set +e
|
|
bash -c "$PRIMARY_CMD" > "$TMP_PRIMARY" 2>&1
|
|
PRIMARY_RC=$?
|
|
set -e
|
|
|
|
ROUTE="primary"
|
|
FINAL_RC="$PRIMARY_RC"
|
|
if [[ "$PRIMARY_RC" -eq 0 && -s "$TMP_PRIMARY" ]]; then
|
|
cp "$TMP_PRIMARY" "$OUTPUT_FILE"
|
|
else
|
|
ROUTE="fallback"
|
|
set +e
|
|
bash -c "$FALLBACK_CMD" > "$TMP_FALLBACK" 2>&1
|
|
FALLBACK_RC=$?
|
|
set -e
|
|
FINAL_RC="$FALLBACK_RC"
|
|
cp "$TMP_FALLBACK" "$OUTPUT_FILE"
|
|
fi
|
|
|
|
printf '{"timestamp":"%s","trace_id":"%s","harness":"L5-model-fallback","primary_exit":%s,"route":"%s","final_exit":%s,"output":"%s"}\n' \
|
|
"$TIMESTAMP" "$TRACE_ID" "$PRIMARY_RC" "$ROUTE" "$FINAL_RC" "$OUTPUT_FILE" >> "$FALLBACK_LOG"
|
|
|
|
echo "FALLBACK_ROUTE route=$ROUTE primary_exit=$PRIMARY_RC final_exit=$FINAL_RC output=$OUTPUT_FILE"
|
|
exit "$FINAL_RC"
|