#!/usr/bin/env bash # The dependency DAG in ARCHITECTURE §2, enforced. A cycle or a shortcut here is how the # module boundaries quietly stop meaning anything. set -uo pipefail cd "$(dirname "$0")/../.." || exit 1 fail=0 check() { # file, forbidden pattern, why if grep -qE "$2" "$1" 2>/dev/null; then printf ' %s\n forbidden: %s\n why: %s\n' "$1" "$2" "$3"; fail=1 fi } # Features are leaves: only app/ may depend on a feature. for f in $(find core hal plugin feature -name 'build.gradle.kts' -not -path '*/build/*' 2>/dev/null); do check "$f" 'project\(":feature:' 'only :app may depend on a feature module' done # Features must never reach a concrete HAL adapter; they see hal/api only. for f in $(find feature -name 'build.gradle.kts' -not -path '*/build/*' 2>/dev/null); do check "$f" 'project\(":hal:(obd|mcu-)' 'features depend on hal:api, never a concrete adapter' done # Nothing in hal/ or core/ may depend on the app or on a feature. for f in $(find core hal plugin -name 'build.gradle.kts' -not -path '*/build/*' 2>/dev/null); do check "$f" 'project\(":app"\)|project\(":feature:' 'lower layers must not depend upward' done [ "$fail" -eq 0 ] || { printf 'FAIL: module graph violates ARCHITECTURE §2\n'; exit 1; } printf 'OK: module graph matches ARCHITECTURE §2\n'