mirror of
https://github.com/boshu2/agentops.git
synced 2026-09-14 15:08:13 +08:00
5d61bf8a3f
Fixes the three gremlins observed 2026-07-18 (bead age-gate-scripts-worktree-gitdir-p62wo): 1. **Gate scripts broke under hook env from linked worktrees** (#919 regression): new scripts/lib/repo-root.sh (GIT_*-scrubbed resolution, BASH_SOURCE anchor, worktree-correct) swept across 32 scripts. Proof: this PR's own push ran the pre-push gates from a linked worktree and passed. 2. **core.bare=true recurrence**: mechanism proven (leaked GIT_DIR + no-arg git init --bare rewrites the SHARED config); writer traced with high confidence to a live Gas City city process (concrete suspect: gascity cmd_rig_test.go runGitInTest, unscrubbed env + no-arg init --bare — fork-side fix filed separately). Defense: new always.git-config-hygiene gate fails fast on core.bare/test identities with the repair command inline (--self-test proves fail-closed). 3. **Test/test@test.com identity leak**: writer convicted — our own pre-push chain leaked GIT_DIR into go test, whose helpers wrote the shared config via git -C (mechanism proven). Cut at both ends: validate-go-fast scrubs env for children; every test git-helper set-site scrubs; check-test-isolation gains a WARN-ratchet rule (baseline 3 → FAIL at 0). Gates: shellcheck rc=0 across 36 scripts; go build/vet clean; 655+379+149 tests; hygiene self-test; both originally-failing validators pass under the repro env.
80 lines
2.1 KiB
Bash
Executable File
80 lines
2.1 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
# shellcheck disable=SC1007,SC1091
|
|
. "$(CDPATH= cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/lib/repo-root.sh"
|
|
ROOT="${1:-$(resolve_repo_root)}"
|
|
DEPRECATED_COMMANDS_GO="$ROOT/cli/internal/quality/stale_refs.go"
|
|
SKILL_ROOTS=("$ROOT/skills" "$ROOT/skills-codex")
|
|
|
|
failures=0
|
|
|
|
fail() {
|
|
echo "FAIL: $1" >&2
|
|
failures=$((failures + 1))
|
|
}
|
|
|
|
print_matches() {
|
|
local matches="$1"
|
|
while IFS= read -r line; do
|
|
printf ' %s\n' "$line" >&2
|
|
done <<< "$matches"
|
|
}
|
|
|
|
require_path() {
|
|
local path="$1"
|
|
[[ -e "$path" ]] || {
|
|
echo "Missing required path: $path" >&2
|
|
exit 1
|
|
}
|
|
}
|
|
|
|
require_path "$DEPRECATED_COMMANDS_GO"
|
|
for root in "${SKILL_ROOTS[@]}"; do
|
|
require_path "$root"
|
|
done
|
|
|
|
echo "=== Skill runtime parity validation ==="
|
|
|
|
mapfile -t deprecated_commands < <(
|
|
sed -n '/var DeprecatedCommands/,/^}/p' "$DEPRECATED_COMMANDS_GO" \
|
|
| grep '"ao ' \
|
|
| sed 's/.*"\(ao [^"]*\)".*:.*"\(ao [^"]*\)".*/\1|\2/' \
|
|
| cut -d'|' -f1 \
|
|
| sort -u
|
|
)
|
|
|
|
echo "--- Deprecated ao command scan ---"
|
|
for cmd in "${deprecated_commands[@]}"; do
|
|
[[ -n "$cmd" ]] || continue
|
|
if matches="$(rg -n -F "$cmd" "${SKILL_ROOTS[@]}" 2>/dev/null || true)" && [[ -n "$matches" ]]; then
|
|
fail "deprecated command reference found: $cmd"
|
|
print_matches "$matches"
|
|
fi
|
|
done
|
|
|
|
echo "--- Hook install claim scan ---"
|
|
declare -a hook_patterns=(
|
|
'all 8 events|hook coverage count is stale; current local source of truth is full 12-event coverage by default'
|
|
'SessionStart \+ Stop|minimal hooks now install SessionStart + SessionEnd + Stop'
|
|
'ao init --hooks --full|ao init --hooks is already the full install path; use --minimal-hooks for lightweight mode'
|
|
)
|
|
|
|
for entry in "${hook_patterns[@]}"; do
|
|
pattern="${entry%%|*}"
|
|
message="${entry#*|}"
|
|
if matches="$(rg -n --pcre2 "$pattern" "${SKILL_ROOTS[@]}" 2>/dev/null || true)" && [[ -n "$matches" ]]; then
|
|
fail "$message"
|
|
print_matches "$matches"
|
|
fi
|
|
done
|
|
|
|
echo "--- Summary ---"
|
|
if [[ "$failures" -gt 0 ]]; then
|
|
echo "Skill runtime parity validation FAILED ($failures finding(s))." >&2
|
|
exit 1
|
|
fi
|
|
|
|
echo "Skill runtime parity validation passed."
|
|
exit 0
|