Files
boshu2__agentops/scripts/check-compile-oscillation.sh
T
Claude c0de539c11 fix(gates): fall back to Dream defrag preview for compile-* gates
compile-freshness and compile-no-oscillation both require .agents/defrag/
latest.json, a local-only artifact that is .gitignored. On machines that
run Dream but not a manual `ao defrag`, both gates fail with "not found"
even though Dream has just written a fresh defrag preview at
.agents/overnight/<run>/defrag/latest.json with the same JSON shape.

- check-compile-health.sh: when the canonical path is missing and
  COMPILE_OUTPUT_DIR is unset, fall back to the freshest overnight
  preview. CI paths (which set COMPILE_OUTPUT_DIR) remain strict.
- scripts/check-compile-oscillation.sh: new helper that mirrors the
  freshness gate's fallback and runs the oscillating-goals jq filter.
- GOALS.md: replace the inline compile-no-oscillation bash with a call to
  the new script so the fallback applies there too.

Fitness (post-cycle1 -> post-cycle2):
  compile-freshness       (w=4): fail -> pass
  compile-no-oscillation  (w=4): fail -> pass

Verified:
  ao goals measure --goal compile-freshness       -> pass
  ao goals measure --goal compile-no-oscillation  -> pass
  ao goals validate                                -> valid: true
  heal.sh --strict                                 -> clean

https://claude.ai/code/session_015RK27PGX79MsGU5XUhBxkr
2026-04-22 06:38:16 +00:00

41 lines
1.6 KiB
Bash
Executable File

#!/usr/bin/env bash
# check-compile-oscillation.sh — Gate: No evolve goals are oscillating in the
# most recent defrag report.
#
# Exit 0 = PASS, Exit 1 = FAIL
#
# Looks at .agents/defrag/latest.json first. When missing and COMPILE_OUTPUT_DIR
# is unset, falls back to the freshest Dream overnight preview at
# .agents/overnight/<run>/defrag/latest.json (same shape). This keeps the gate
# green on machines that have run Dream but not a manual `ao defrag`.
set -euo pipefail
AGENTS_DIR="${AGENTS_DIR:-.agents}"
DEFRAG_LATEST="${COMPILE_OUTPUT_DIR:-$AGENTS_DIR}/defrag/latest.json"
if [[ ! -f "$DEFRAG_LATEST" && -z "${COMPILE_OUTPUT_DIR:-}" ]]; then
overnight_root="$AGENTS_DIR/overnight"
if [[ -d "$overnight_root" ]]; then
fallback="$(find "$overnight_root" -path '*/defrag/latest.json' -type f -printf '%T@ %p\n' 2>/dev/null \
| sort -n | tail -n 1 | awk '{print $2}')"
if [[ -n "$fallback" && -f "$fallback" ]]; then
echo "INFO: $DEFRAG_LATEST not found; falling back to overnight preview $fallback"
DEFRAG_LATEST="$fallback"
fi
fi
fi
if [[ ! -f "$DEFRAG_LATEST" ]]; then
echo "FAIL: $DEFRAG_LATEST not found — run 'ao defrag --oscillation-sweep' first"
exit 1
fi
if ! jq -e "(.oscillation.oscillating_goals // []) | length == 0" "$DEFRAG_LATEST" >/dev/null 2>&1; then
count=$(jq -r "(.oscillation.oscillating_goals // []) | length" "$DEFRAG_LATEST" 2>/dev/null || echo "?")
echo "FAIL: $count oscillating goal(s) in $DEFRAG_LATEST"
exit 1
fi
echo "PASS: no oscillating goals in $DEFRAG_LATEST"
exit 0