Files
boshu2__agentops/scripts/goal-failure-taxonomy.sh
T
Bo fcacbed3f9 fix(scripts): clean 6 pre-existing shellcheck warnings (soc-j026) (#349)
## Summary

Child arc of `soc-l4n8` (drift surfaced during #348). Mechanical cleanup
of 6 pre-existing shellcheck warnings in scripts I did not previously
touch — all SC2034 unused-vars, SC2088 intended-literal, SC2089/SC2090
template-string, SC2221/SC2222 redundant-case.

Per anti-pattern #2 (no bundling pre-existing fixes), filed as an atomic
side-quest off the #348 `soc-1lp1` PR rather than bundled into it.

Closes: soc-j026
Discovered-from: soc-l4n8

## Diff

| File | Fix |
|---|---|
| `validate-codex-api-conformance.sh:59` | SC2088 disable directive —
grep is intentionally matching the literal documented path |
| `goal-failure-taxonomy.sh:30` | Trim redundant case patterns
(`*toolchain-security*`, `*release-security*`, `*ci-security*` all
already matched by `*security*`) |
| `purge-global-garbage.sh:24` | Remove unused `bodylen` |
| `nightly-pr-digest.sh:316` | Remove unused `landing_policy` (local +
assignment) |
| `add-validate-job.sh` | File-level SC2089/SC2090 disable for the
template-string section |
| `check-skill-size.sh:34` | Remove unused `name` |

## Validation

- `shellcheck -S warning` clean on all 6 files.
- `scripts/ship.sh` routes to `--fast` (no inventory touched).
- Pre-push gate (fast): PASSED, 31 skipped, 1 advisory WARN
(executable-spec, unrelated).

Bounded-context: BC0-foundations (scripts)
Evidence: `shellcheck -S warning scripts/*` (clean for the 6 files)

Co-authored-by: Codex <codex@example.invalid>
2026-05-19 10:52:40 +00:00

79 lines
2.0 KiB
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
# goal-failure-taxonomy.sh
# Classify failing goals from ao fitness JSON into actionable categories.
#
# Usage:
# scripts/goal-failure-taxonomy.sh [fitness-json]
# If omitted, uses latest .agents/evolve/fitness-*-pre.json
INPUT="${1:-}"
if [[ -z "$INPUT" ]]; then
INPUT="$(ls -t .agents/evolve/fitness-*-pre.json 2>/dev/null | head -1 || true)"
fi
if [[ -z "$INPUT" || ! -f "$INPUT" ]]; then
echo "ERROR: fitness JSON not found. Provide a file path or generate .agents/evolve/fitness-*-pre.json." >&2
exit 1
fi
if ! jq -e . "$INPUT" >/dev/null 2>&1; then
echo "ERROR: invalid JSON: $INPUT" >&2
exit 1
fi
classify() {
local id="${1:-}"
case "$id" in
*security*|*secret*|*hook-preflight*)
echo "security"
;;
*build*|*test*|*vet*|*wiring*|*evolve*|*rpi*|*session-start*|*kill-switch*)
echo "reliability"
;;
*coverage*|*complexity*|*smoke*|*opencode*|*skill-validation*|*semantic-stability*|*frontmatter*)
echo "quality"
;;
*goal-*|*pillar-*|*product-freshness*|*manifest-versions-match*|*ao-goals*)
echo "governance"
;;
*)
echo "other"
;;
esac
}
TMP="$(mktemp)"
jq -c '.goals[] | select(.result=="fail") | {goal_id, description}' "$INPUT" > "$TMP"
TOTAL="$(wc -l < "$TMP" | tr -d ' ')"
if [[ "$TOTAL" == "0" ]]; then
jq -n '{summary:{total_failing:0,by_category:{}},failing_goals:[]}'
rm -f "$TMP"
exit 0
fi
OUT_TMP="$(mktemp)"
while IFS= read -r row; do
gid="$(jq -r '.goal_id // ""' <<<"$row")"
desc="$(jq -r '.description // ""' <<<"$row")"
cat="$(classify "$gid")"
jq -n --arg goal_id "$gid" --arg description "$desc" --arg category "$cat" \
'{goal_id:$goal_id,category:$category,description:$description}' >> "$OUT_TMP"
done < "$TMP"
jq -s '
{
summary: {
total_failing: length,
by_category: (group_by(.category) | map({key: .[0].category, value: length}) | from_entries)
},
failing_goals: .
}
' "$OUT_TMP"
rm -f "$TMP" "$OUT_TMP"