From b43c429544d7e76224d783d7e5c32abeeb8954d4 Mon Sep 17 00:00:00 2001 From: ryan Date: Sat, 29 Aug 2026 10:17:57 +0800 Subject: [PATCH] chore(arch): forbid viper and mapstructure inside the micro-kernel MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 配置装载实现必须留在 plugins/infra/config 适配器里,内核只依赖 ConfigSource 抽象;把 viper 与 mapstructure 加入 1.1 禁止清单,防止配置 装载依赖重新渗回 core(已用临时探针文件反向验证检查生效)。 --- scripts/check_cordis_architecture.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/check_cordis_architecture.sh b/scripts/check_cordis_architecture.sh index 0874a908..6d862863 100755 --- a/scripts/check_cordis_architecture.sh +++ b/scripts/check_cordis_architecture.sh @@ -53,12 +53,12 @@ echo -e "${BOLD}═════════════════════ # ============================================================================== log_check "1. 检查微内核 (backend/core/) 纯洁度..." -# 1.1 禁止直接依赖重型 Web/ORM/Worker 框架 -CORE_FRAMEWORK_IMPORTS=$(rg -n '"github.com/gin-gonic/gin"|"gorm.io/gorm"|"github.com/hibiken/asynq"|"github.com/robfig/cron' \ +# 1.1 禁止直接依赖重型 Web/ORM/Worker/Config 框架 +CORE_FRAMEWORK_IMPORTS=$(rg -n '"github.com/gin-gonic/gin"|"gorm.io/gorm"|"github.com/hibiken/asynq"|"github.com/robfig/cron|"github.com/spf13/viper"|"github.com/mitchellh/mapstructure"' \ "${BACKEND_DIR}/core/" --glob '*.go' -g '!*contracts*' -g '!*_test.go' || true) if [ -n "${CORE_FRAMEWORK_IMPORTS}" ]; then - log_fail "backend/core/ 严禁导入具体 Web/ORM/Worker 运行时框架 (gin, gorm, asynq, cron):" + log_fail "backend/core/ 严禁导入具体 Web/ORM/Worker/Config 运行时框架 (gin, gorm, asynq, cron, viper, mapstructure):" echo "${CORE_FRAMEWORK_IMPORTS}" >&2 else log_pass "backend/core/ 无重型框架依赖"