ci / test (pull_request) Failing after 1m0s
Why: Merge commits share a tree with the pinned feature commit, the import ratchet downloaded modules during CI, and task sync wrote the checkpoint onto the wrong card. Evidence: check-pins accepts 6c0f1e8 (same tree as Backend squad 8e987bf) and rejects empty-tree 8db069d; both objects stayed local. An empty GOMODCACHE run of lint-boundaries matches the cached go list, 14 pairs. bash -n scripts/task.sh. Impact: make pin no longer checks out Backend nested core or agent-command, and a failing pin check does not fail the target. task sync writes the branch card or warns. precheck reports completed-but-unarchived cards and card-close branches older than 24 hours. Refs: feature/agent-stack-r0-r1 Co-authored-by: Cursor <cursoragent@cursor.com>
74 lines
2.3 KiB
Bash
Executable File
74 lines
2.3 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# 依赖边界:公开扩展 SDK 与示例不得导入后端 internal。
|
|
# pkg/extension/link 是唯一例外:下游空白导入它才能把 extension.Main 接到产品组合根。
|
|
set -euo pipefail
|
|
root=$(cd "$(dirname "$0")/.." && pwd)
|
|
fail=0
|
|
|
|
check() {
|
|
local path="$1"
|
|
if [ -d "$path" ] && grep -R -n --include='*.go' --include='*.ts' --include='*.tsx' 'agent-system-backend/internal' "$path" >/dev/null; then
|
|
echo "boundary: $path imports agent-system-backend/internal" >&2
|
|
grep -R -n --include='*.go' --include='*.ts' --include='*.tsx' 'agent-system-backend/internal' "$path" >&2
|
|
fail=1
|
|
fi
|
|
}
|
|
|
|
sdk="$root/modules/backend/pkg/extension"
|
|
if [ -d "$sdk" ]; then
|
|
hits=$(grep -R -n --include='*.go' 'agent-system-backend/internal' "$sdk" | grep -v '/link/' || true)
|
|
if [ -n "$hits" ]; then
|
|
echo "boundary: pkg/extension imports agent-system-backend/internal" >&2
|
|
echo "$hits" >&2
|
|
fail=1
|
|
fi
|
|
fi
|
|
check "$root/examples"
|
|
|
|
# 库间依赖棘轮:三个库的包导入兄弟库的配对,相对白名单只许减少、不许新增。
|
|
allow="$root/policy/lib-deps-allowlist.txt"
|
|
observed=$(mktemp)
|
|
recorded=$(mktemp)
|
|
trap 'rm -f "$observed" "$recorded"' EXIT
|
|
siblings=(agent-intent agent-native agent-squad)
|
|
for dir in deps/agent-intent deps/agent-native deps/agent-squad; do
|
|
mod=$(awk '/^module /{print $2; exit}' "$root/$dir/go.mod")
|
|
(
|
|
cd "$root/scripts"
|
|
go run lint-imports.go "$root/$dir"
|
|
) | while read -r importer rest; do
|
|
for imp in $rest; do
|
|
for sib in "${siblings[@]}"; do
|
|
case "$imp" in
|
|
"$sib"|"$sib"/*) ;;
|
|
*) continue ;;
|
|
esac
|
|
case "$importer" in
|
|
"$mod"|"$mod"/*) ;;
|
|
*) continue ;;
|
|
esac
|
|
if [ "$sib" != "$mod" ]; then
|
|
echo "$importer $imp"
|
|
fi
|
|
done
|
|
done
|
|
done
|
|
done | sort -u >"$observed"
|
|
grep -v -e '^#' -e '^$' "$allow" | sort -u >"$recorded"
|
|
new_pairs=$(comm -13 "$recorded" "$observed" || true)
|
|
if [ -n "$new_pairs" ]; then
|
|
echo "boundary: new sibling-library import pairs" >&2
|
|
echo "$new_pairs" >&2
|
|
fail=1
|
|
fi
|
|
stale_pairs=$(comm -23 "$recorded" "$observed" || true)
|
|
if [ -n "$stale_pairs" ]; then
|
|
echo "warn: sibling-library pairs no longer imported; delete from policy/lib-deps-allowlist.txt" >&2
|
|
echo "$stale_pairs" >&2
|
|
fi
|
|
|
|
if [ "$fail" -ne 0 ]; then
|
|
exit 1
|
|
fi
|
|
echo "boundaries ok"
|