Files
boshu2__agentops/scripts/check-opencode-live.sh
Boden Fuller c4ff4188a3 evolve: reduce complexity in 7 cmd/ao files, add opencode timeout
Extracted helpers from task_sync.go, inject.go, inbox.go, plans.go,
feedback.go, store.go, and rpi_ledger.go to reduce cyclomatic
complexity. inject.go now fully below CC 10. Others reduced by 3-8.

Also add 60s timeout to check-opencode-live.sh to prevent ao goals
measure from hanging on headless test harness.
2026-02-22 11:08:32 -05:00

73 lines
2.2 KiB
Bash
Executable File

#!/usr/bin/env bash
# check-opencode-live.sh — GOALS.yaml gate for OpenCode live tier 1 tests
#
# Runs Tier 1 headless tests with brownian ratchet (3 attempts per skill).
# Passes if ≥4/6 skills succeed (allows 2 failures for model variability).
#
# Gracefully skips if:
# - opencode not in PATH (structural check only)
# - No model configured or reachable
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
REPO_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
HARNESS="$REPO_ROOT/tests/opencode/run-headless-tests.sh"
# Gate: opencode must be installed
if ! command -v opencode &>/dev/null; then
echo "SKIP: opencode not in PATH"
exit 0 # Graceful skip — don't fail the goal just because opencode isn't installed
fi
# Gate: harness must exist
if [[ ! -x "$HARNESS" ]]; then
echo "FAIL: harness not found or not executable: $HARNESS"
exit 1
fi
# Run tier 1 with 3 attempts (60s timeout to prevent hanging goals measure)
echo "Running OpenCode Tier 1 headless tests (3 attempts per skill)..."
if command -v timeout &>/dev/null; then
timeout 60 "$HARNESS" --tier 1 --attempts 3 2>&1 || {
rc=$?
if [[ $rc -eq 124 ]]; then
echo "SKIP: harness timed out after 60s"
exit 0
fi
}
elif command -v gtimeout &>/dev/null; then
gtimeout 60 "$HARNESS" --tier 1 --attempts 3 2>&1 || {
rc=$?
if [[ $rc -eq 124 ]]; then
echo "SKIP: harness timed out after 60s"
exit 0
fi
}
else
"$HARNESS" --tier 1 --attempts 3 2>&1
fi
# Parse summary for pass count
SUMMARY_FILE="$REPO_ROOT/.agents/opencode-tests/$(date +%Y-%m-%d)-summary.txt"
if [[ ! -f "$SUMMARY_FILE" ]]; then
echo "FAIL: summary file not found: $SUMMARY_FILE"
exit 1
fi
# Count skills that passed (PASS or FLAKY = at least 1 attempt succeeded)
PASSED=$(grep -cE '(PASS|FLAKY)' "$SUMMARY_FILE" || echo "0")
TOTAL=$(wc -l < "$SUMMARY_FILE" | tr -d ' ')
echo ""
echo "Gate result: $PASSED/$TOTAL skills passed"
# Threshold: ≥4 of 6 tier 1 skills must pass
if [[ $PASSED -ge 4 ]]; then
echo "PASS: $PASSED/$TOTAL meets threshold (≥4)"
exit 0
else
echo "FAIL: $PASSED/$TOTAL below threshold (need ≥4)"
exit 1
fi