#!/usr/bin/env bash # 分层棘轮:新增依赖边失败,消失的边只告警。 # 负例:注入一条基线里没有的边,必须失败。 set -euo pipefail root=$(cd "$(dirname "$0")/.." && pwd) base="$root/policy/architecture-baseline.json" tool=(go run "$root/scripts/lint-architecture.go" -root "$root" -baseline "$base") ( cd "$root/scripts" && "${tool[@]}" ) set +e ( cd "$root/scripts" && "${tool[@]}" -inject 'backend/store->backend/__architecture_probe__' ) >/tmp/architecture-probe.out 2>&1 code=$? set -e if [ "$code" -eq 0 ]; then echo "architecture: injected edge was accepted" >&2 cat /tmp/architecture-probe.out >&2 exit 1 fi if ! grep -q '__architecture_probe__' /tmp/architecture-probe.out; then echo "architecture: injected edge did not fail for the expected reason" >&2 cat /tmp/architecture-probe.out >&2 exit 1 fi rm -f /tmp/architecture-probe.out echo "architecture negative ok"