Files
Agent-System-Dev/scripts/check-pins.sh
T

71 lines
2.2 KiB
Bash
Executable File

#!/usr/bin/env bash
# 组合指针一致:容器仓在 Dev 钉住的提交上,deps/ 里的每个 gitlink
# 必须等于 Dev 顶层对应指针。development-guidelines / development-manager
# 是治理规范与工具,版本由各项目固定采纳自行决定,不是运行时依赖,只告警。
set -euo pipefail
root=$(cd "$(dirname "$0")/.." && pwd)
cd "$root"
fail=0
pin_of() {
git rev-parse ":$1"
}
check_link() {
local container="$1" name="$2" sha="$3" expect_path="$4"
local expect
if ! expect=$(pin_of "$expect_path" 2>/dev/null); then
echo "pin: $container deps/$name has no Dev pin at $expect_path" >&2
fail=1
return
fi
if [ "$sha" != "$expect" ]; then
local sha_tree expect_tree
if ! sha_tree=$(git -C "$expect_path" rev-parse "${sha}^{tree}" 2>/dev/null); then
echo "pin: $container deps/$name ${sha:0:12} is missing locally; fetch $expect_path first" >&2
fail=1
return
fi
if ! expect_tree=$(git -C "$expect_path" rev-parse "${expect}^{tree}" 2>/dev/null); then
echo "pin: Dev $expect_path ${expect:0:12} is missing locally; fetch $expect_path first" >&2
fail=1
return
fi
if [ "$sha_tree" = "$expect_tree" ]; then
echo "ok $container $name (same tree)"
return
fi
echo "pin: $container deps/$name is ${sha:0:12}, Dev $expect_path is ${expect:0:12}" >&2
fail=1
return
fi
echo "ok $container $name"
}
containers=(modules/backend deps/agent-native deps/agent-squad deps/agent-intent)
for container in "${containers[@]}"; do
commit=$(pin_of "$container")
while read -r mode _typ sha name; do
[ "$mode" = "160000" ] || continue
base=${name#deps/}
if [ "$base" = "development-guidelines" ] || [ "$base" = "development-manager" ]; then
dev=$(pin_of "deps/$base")
if [ "$sha" != "$dev" ]; then
echo "warn: $container deps/$base is ${sha:0:12}, Dev is ${dev:0:12}" >&2
fi
continue
fi
if [ "$base" = "agent-system-core" ]; then
check_link "$container" "$base" "$sha" modules/core
else
check_link "$container" "$base" "$sha" "deps/$base"
fi
done < <(git -C "$container" ls-tree "$commit" deps/)
done
if [ "$fail" -ne 0 ]; then
exit 1
fi
echo "pins ok"