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.
79 lines
2.5 KiB
Bash
Executable File
79 lines
2.5 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# check-retrieval-manifest-paths.sh — validate every ground_truth path in a
|
|
# retrieval-eval manifest resolves against `git ls-tree HEAD`.
|
|
#
|
|
# Catches the failure mode where a generated/merged manifest references files
|
|
# that never existed on any branch (see f-2026-05-02-004). Without this gate,
|
|
# such a manifest passes schema validation but silently collapses retrieval
|
|
# quality metrics (any_relevant_at_k → ~0).
|
|
#
|
|
# Usage:
|
|
# scripts/check-retrieval-manifest-paths.sh <manifest.json> [<manifest.json> ...]
|
|
#
|
|
# Exit codes:
|
|
# 0 — every ground_truth path in every manifest resolves at HEAD
|
|
# 1 — one or more paths missing (details on stderr)
|
|
# 2 — usage error (no manifests, jq missing, file unreadable)
|
|
|
|
set -euo pipefail
|
|
|
|
if [[ $# -lt 1 ]]; then
|
|
echo "usage: $0 <manifest.json> [<manifest.json> ...]" >&2
|
|
exit 2
|
|
fi
|
|
|
|
if ! command -v jq >/dev/null 2>&1; then
|
|
echo "FAIL retrieval manifest paths: jq is required" >&2
|
|
exit 2
|
|
fi
|
|
|
|
if ! command -v git >/dev/null 2>&1; then
|
|
echo "FAIL retrieval manifest paths: git is required" >&2
|
|
exit 2
|
|
fi
|
|
|
|
# shellcheck disable=SC1007,SC1091
|
|
. "$(CDPATH= cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/lib/repo-root.sh"
|
|
REPO_ROOT="$(resolve_repo_root)"
|
|
|
|
fail=0
|
|
total=0
|
|
for manifest in "$@"; do
|
|
if [[ ! -f "$manifest" ]]; then
|
|
echo "FAIL retrieval manifest paths: $manifest: not a file" >&2
|
|
fail=1
|
|
continue
|
|
fi
|
|
|
|
# Support both canonical {queries:[{ground_truth:[]}]} and legacy
|
|
# [{relevant:[]}] shapes — same coverage as the Go loader.
|
|
if jq -e 'type == "array"' "$manifest" >/dev/null 2>&1; then
|
|
paths="$(jq -r '.[] | (.relevant // [])[]' "$manifest")"
|
|
else
|
|
paths="$(jq -r '.queries[] | (.ground_truth // [])[]' "$manifest")"
|
|
fi
|
|
|
|
if [[ -z "$paths" ]]; then
|
|
echo "WARN retrieval manifest paths: $manifest has zero ground_truth paths" >&2
|
|
continue
|
|
fi
|
|
|
|
while IFS= read -r path; do
|
|
[[ -z "$path" ]] && continue
|
|
total=$((total + 1))
|
|
# Strip ./ prefix if present
|
|
path="${path#./}"
|
|
if ! git -C "$REPO_ROOT" ls-tree --name-only HEAD -- "$path" 2>/dev/null | grep -qFx "$path"; then
|
|
echo "FAIL retrieval manifest paths: $manifest: ground_truth path missing at HEAD: $path" >&2
|
|
fail=1
|
|
fi
|
|
done <<<"$paths"
|
|
done
|
|
|
|
if [[ $fail -ne 0 ]]; then
|
|
exit 1
|
|
fi
|
|
|
|
echo "PASS retrieval manifest paths: $total ground_truth path(s) validated across $# manifest(s)"
|
|
exit 0
|