#!/bin/sh # Static P0 gate: the current tree may only describe the current public # Analysis revision 3 / Tool revision 1 boundary. This script intentionally # has no allow-list for src/, tool.json or scripts. set -eu ROOT=$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd) fail=0 if command -v rg >/dev/null 2>&1; then search() { rg -n --no-heading "$2" "$1" || true; } else search() { grep -RInE "$2" "$1" || true; } fi scan() { label=$1 pattern=$2 path=$3 hits=$(search "$path" "$pattern") if [ -n "$hits" ]; then printf 'FAIL: %s\n%s\n' "$label" "$hits" fail=1 fi } scan "retired Analysis acceptance" '2 \| 3|version == 2|Analysis v2|需要 2 或 3' "$ROOT/src" scan "retired Tool negotiation" 'compatibility|TOOL_PROTOCOL|PROTOCOL_ANALYSIS|PROTOCOL_TRACE' "$ROOT/src" scan "legacy tool manifest field" '"compatibility"' "$ROOT/tool.json" scan "retired version branches" 'schema_version == 2|match .*schema_version' "$ROOT/src/model" scan "silent parser downgrade" 'fallback|legacy|best effort|尽力' "$ROOT/src" # Exclude this gate script itself: its patterns necessarily spell the retired # names. Any other current script is scanned literally. for script in "$ROOT"/scripts/*; do [ -f "$script" ] || continue [ "$(basename "$script")" = "check-no-legacy.sh" ] && continue scan "retired core in $(basename "$script")" 'rc1|rc2|RC\.1|RC\.2' "$script" done if [ "$fail" -ne 0 ]; then printf '\ncheck-no-legacy: FAIL\n' exit 1 fi printf 'check-no-legacy: PASS\n'