mirror of
https://github.com/boshu2/agentops.git
synced 2026-09-14 15:08:13 +08:00
e556834d3d
## Legible membrane, Train 1: fix what ships Intent source: `docs/plans/2026-09-02-legible-membrane-plan.md` (added in this PR). Provenance: the 2026-09-02 field audit of this repo against mattpocock/skills, compound-engineering, and the jsm corpus. Three defects a stranger hits today, all verified on `main` before the change: 1. **Codex projection truncated 51 of 56 skill descriptions mid-clause** (`scripts/codex-sync.sh` capped prose at 44 chars, so the Codex router read "Freshly judge whether a finished change is Triggers: …"). Now: first sentence of the source prose plus the full `Triggers:` clause, abbreviation- and quote-aware; the per-catalog bound is computed live as "Codex prose average may not exceed Claude's" (cross-multiplied, floor-free) with a 180-char hard ceiling. `using-flywheel` is exempted from runtime-phrase rewriting so its cross-runtime text projects verbatim. The dormant `ao codex ensure-start` emitter and the `# /x`→`# $x` title rewrite are removed. A literal oracle pins five twins and a rule oracle covers all 56. 2. **23 shebang-bearing shell entry points were committed non-executable**, including `scripts/regen-all.sh` and three gate scripts. Now `100755`, with an advisory gate `shell.exec-bits` (fast+full, fail-closed on enumeration error, reads the index blob, skips symlinks by stated policy). 3. **`tests/run-all.sh` was red on `main`**: the GOALS validator asserted a pre-08-25 file shape, and validate's description exceeded the 180-char budget. The validator now parses only the `## Gates` block (stops at any heading, like production), requires cited script paths to exist, takes its path via argv, and fails closed on tokenization; four negative fixtures. validate's description is 177 chars and gains the reality-check negative. `AGENTS.md` quotes CI's authoritative bats and Go commands. README and `docs/install-day2-ops.md` replace "No other runtime is required" with a runtime table derived by reading each skill's procedure (HARD / OPTIONAL / conditional), covered by a bats test that grounds every HARD row in an invocation line. Evidence on the tip: full gate 71/71 (HEAD binary), CI's bats command green across `tests/scripts/*.bats`, `tests/run-all.sh` green, Go build/vet/test green, golangci-lint clean, security gate quick PASS, `scripts/regen-all.sh --check` clean. Each lane was validated by a fresh context; the integrated train had two cross-family (Codex) review rounds and every finding is closed on this tip. Out of scope (successor intent): promoted set / `skills-internal/`, the process-artifact sweep, "It's working if" blocks, routing clusters, doctrine diet. One pre-existing drift noted for a follow-up: `packs/agentops-executor/agents/validator/skills/validate/SKILL.md` carries a stale third description that no gate binds.
199 lines
5.4 KiB
Bash
Executable File
199 lines
5.4 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
|
|
SCRIPT="$ROOT/scripts/validate-skill-cli-snippets.sh"
|
|
|
|
PASS=0
|
|
FAIL=0
|
|
|
|
pass() { echo "PASS: $1"; PASS=$((PASS + 1)); }
|
|
fail() { echo "FAIL: $1"; FAIL=$((FAIL + 1)); }
|
|
|
|
if [[ ! -f "$SCRIPT" ]]; then
|
|
echo "FAIL: missing script: $SCRIPT" >&2
|
|
exit 1
|
|
fi
|
|
|
|
TMP_DIR="$(mktemp -d)"
|
|
trap 'rm -rf "$TMP_DIR"' EXIT
|
|
|
|
setup_fixture() {
|
|
local repo="$1"
|
|
mkdir -p "$repo/scripts/lib" "$repo/skills/example" "$repo/skills-codex/example" "$repo/cli"
|
|
cp "$SCRIPT" "$repo/scripts/validate-skill-cli-snippets.sh"
|
|
chmod +x "$repo/scripts/validate-skill-cli-snippets.sh"
|
|
# The validator sources scripts/lib/ao-snippet-resolve.sh and its inline
|
|
# Python imports ao_snippet_resolve from AO_SNIPPET_LIB_DIR (the same lib
|
|
# dir) — the fixture must carry both alongside the copied validator.
|
|
cp "$ROOT/scripts/lib/ao-snippet-resolve.sh" "$repo/scripts/lib/ao-snippet-resolve.sh"
|
|
cp "$ROOT/scripts/lib/ao_snippet_resolve.py" "$repo/scripts/lib/ao_snippet_resolve.py"
|
|
|
|
# Mode-agnostic fake `ao`: understands BOTH resolution shapes so the fixture
|
|
# exercises whichever predicate the validator's AO_RESOLVE_MODE selects —
|
|
# help mode: `ao help <chain>` (trust rc==0)
|
|
# strict mode: `ao <chain> --help` (reject "unknown command" in stdout)
|
|
# Normalize either invocation to the bare <chain>, then dispatch. An unknown
|
|
# chain prints cobra's "unknown command" to stdout and exits non-zero, so it
|
|
# fails BOTH predicates (rc!=0 for help mode; matched regex for strict mode).
|
|
cat > "$repo/fake-ao" <<'EOF'
|
|
#!/usr/bin/env bash
|
|
args=("$@")
|
|
# Drop a leading `help` (help-mode) or a trailing `--help`/`-h` (strict-mode),
|
|
# and drop the root-help forms so `ao --help` == `ao help` == global help.
|
|
if [[ "${args[0]:-}" == "help" ]]; then
|
|
args=("${args[@]:1}")
|
|
fi
|
|
if [[ "${#args[@]}" -gt 0 ]]; then
|
|
last_idx=$(( ${#args[@]} - 1 ))
|
|
case "${args[$last_idx]}" in
|
|
--help|-h) unset 'args[last_idx]'; args=("${args[@]}") ;;
|
|
esac
|
|
fi
|
|
chain="${args[*]}"
|
|
case "$chain" in
|
|
"")
|
|
cat <<'INNER'
|
|
Usage:
|
|
ao [command]
|
|
|
|
Flags:
|
|
-h, --help
|
|
INNER
|
|
exit 0
|
|
;;
|
|
"lookup")
|
|
cat <<'INNER'
|
|
Usage:
|
|
ao lookup [flags]
|
|
|
|
Flags:
|
|
--query string
|
|
--json
|
|
INNER
|
|
exit 0
|
|
;;
|
|
"goals measure")
|
|
cat <<'INNER'
|
|
Usage:
|
|
ao goals measure [flags]
|
|
|
|
Flags:
|
|
--json
|
|
INNER
|
|
exit 0
|
|
;;
|
|
*)
|
|
echo "Error: unknown command \"${args[0]:-}\" for \"ao\"" >&2
|
|
echo "unknown command"
|
|
exit 1
|
|
;;
|
|
esac
|
|
EOF
|
|
chmod +x "$repo/fake-ao"
|
|
}
|
|
|
|
test_passes_for_current_commands() {
|
|
local repo="$TMP_DIR/pass"
|
|
setup_fixture "$repo"
|
|
|
|
cat > "$repo/skills/example/SKILL.md" <<'EOF'
|
|
Use `ao lookup --query "topic" --json`.
|
|
EOF
|
|
cat > "$repo/skills-codex/example/SKILL.md" <<'EOF'
|
|
Use `ao goals measure --json`.
|
|
EOF
|
|
|
|
if (cd "$repo" && AGENTOPS_AO_BIN="$repo/fake-ao" bash scripts/validate-skill-cli-snippets.sh >/dev/null); then
|
|
pass "passes for valid ao command snippets"
|
|
else
|
|
fail "should pass for valid ao command snippets"
|
|
fi
|
|
}
|
|
|
|
test_fails_for_unknown_command() {
|
|
local repo="$TMP_DIR/fail-command"
|
|
setup_fixture "$repo"
|
|
|
|
cat > "$repo/skills/example/SKILL.md" <<'EOF'
|
|
Use `ao work goals`.
|
|
EOF
|
|
cat > "$repo/skills-codex/example/SKILL.md" <<'EOF'
|
|
Use `ao lookup --query "topic"`.
|
|
EOF
|
|
|
|
if (cd "$repo" && AGENTOPS_AO_BIN="$repo/fake-ao" bash scripts/validate-skill-cli-snippets.sh >/dev/null 2>&1); then
|
|
fail "should fail for unknown ao command snippets"
|
|
else
|
|
pass "fails for unknown ao command snippets"
|
|
fi
|
|
}
|
|
|
|
test_fails_for_unknown_flag() {
|
|
local repo="$TMP_DIR/fail-flag"
|
|
setup_fixture "$repo"
|
|
|
|
cat > "$repo/skills/example/SKILL.md" <<'EOF'
|
|
Use `ao lookup --badflag`.
|
|
EOF
|
|
cat > "$repo/skills-codex/example/SKILL.md" <<'EOF'
|
|
Use `ao goals measure --json`.
|
|
EOF
|
|
|
|
if (cd "$repo" && AGENTOPS_AO_BIN="$repo/fake-ao" bash scripts/validate-skill-cli-snippets.sh >/dev/null 2>&1); then
|
|
fail "should fail for unknown flags"
|
|
else
|
|
pass "fails for unknown flags"
|
|
fi
|
|
}
|
|
|
|
test_passes_for_pipeline_and_placeholder_flags() {
|
|
local repo="$TMP_DIR/pipeline-placeholder"
|
|
setup_fixture "$repo"
|
|
|
|
cat > "$repo/skills/example/SKILL.md" <<'EOF'
|
|
Use `ao lookup --query="topic" --json | head -20`.
|
|
EOF
|
|
cat > "$repo/skills-codex/example/SKILL.md" <<'EOF'
|
|
Use `ao --help` and `ao goals measure --json`.
|
|
EOF
|
|
|
|
if (cd "$repo" && AGENTOPS_AO_BIN="$repo/fake-ao" bash scripts/validate-skill-cli-snippets.sh >/dev/null); then
|
|
pass "passes for shell pipelines and normalized flag values"
|
|
else
|
|
fail "should pass for shell pipelines and normalized flag values"
|
|
fi
|
|
}
|
|
|
|
test_fails_for_stale_beads_resolver() {
|
|
local repo="$TMP_DIR/fail-beads-resolver"
|
|
setup_fixture "$repo"
|
|
|
|
cat > "$repo/skills/example/SKILL.md" <<'EOF'
|
|
Read the bead with `BEADS_DIR=$PWD/_beads br show ag-123`.
|
|
EOF
|
|
cat > "$repo/skills-codex/example/SKILL.md" <<'EOF'
|
|
Use `ao lookup --query "topic"`.
|
|
EOF
|
|
|
|
if (cd "$repo" && AGENTOPS_AO_BIN="$repo/fake-ao" bash scripts/validate-skill-cli-snippets.sh >/dev/null 2>&1); then
|
|
fail "should fail for stale BEADS_DIR=$PWD/_beads skill examples"
|
|
else
|
|
pass "fails for stale BEADS_DIR=$PWD/_beads skill examples"
|
|
fi
|
|
}
|
|
|
|
echo "== test-skill-cli-snippets =="
|
|
test_passes_for_current_commands
|
|
test_fails_for_unknown_command
|
|
test_fails_for_unknown_flag
|
|
test_passes_for_pipeline_and_placeholder_flags
|
|
test_fails_for_stale_beads_resolver
|
|
|
|
echo ""
|
|
echo "Results: $PASS PASS, $FAIL FAIL"
|
|
if [[ "$FAIL" -gt 0 ]]; then
|
|
exit 1
|
|
fi
|
|
exit 0
|