From 49c1259e00cc68d140ef7b6d073f267cd0c59132 Mon Sep 17 00:00:00 2001 From: weichen Date: Wed, 21 Oct 2026 17:35:53 +0000 Subject: [PATCH] Keep the server admission test inside the intent boundary Why: the U6 admission test imported agent-intent directly from internal/server, which lint-boundaries forbids (only intentgate, intentsem and the squad intent adapter may import it). Evidence: repair receipt success; server/intentgate/route tests pass (verify-u6r.json); fixtures moved behind intentgate helpers. Impact: test-only rework plus a small intentgate fixture helper. Refs: feature/agent-stack-audit-remediation-b1 U6 repair --- internal/intentgate/gate.go | 11 +++++++---- internal/server/e2e_test.go | 2 +- internal/server/intent_admission_test.go | 7 ++++--- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/internal/intentgate/gate.go b/internal/intentgate/gate.go index de95c66..f9bd0e1 100644 --- a/internal/intentgate/gate.go +++ b/internal/intentgate/gate.go @@ -55,11 +55,14 @@ type MatchResult struct { // Complete 报告槽位是否齐全且全部通过权威校验:false 时业务动作不得派发。 func (m MatchResult) Complete() bool { return len(m.Missing) == 0 && len(m.Invalid) == 0 } -// 命令类型经闸门投影(别名):生态库按边界规则只许本包导入, -// Router/runmgr 等消费方只依赖本包表面。 +// 命令与目录类型经闸门投影(别名):生态库按边界规则只许本包导入, +// Router/runmgr 等消费方只依赖本包表面。CatalogSpec/CatalogSlot 随生成器端口 +// (SetGenerator 的入参)投影,实现生成器不必越过本包直接引用生态库。 type ( - Command = agentintent.Command - ActionRef = agentintent.ActionRef + Command = agentintent.Command + ActionRef = agentintent.ActionRef + CatalogSpec = agentintent.CatalogSpec + CatalogSlot = agentintent.CatalogSlot ) const ( diff --git a/internal/server/e2e_test.go b/internal/server/e2e_test.go index e1b1e0a..6ee4b6f 100644 --- a/internal/server/e2e_test.go +++ b/internal/server/e2e_test.go @@ -946,7 +946,7 @@ func TestStaticServed(t *testing.T) { _ = io.Discard } -// TestHITLIntentPivot:装载插件意图后,自由输入命中其他意图 → 转轨(agent-intent 闸门)。 +// TestHITLIntentPivot:装载插件意图后,自由输入命中其他意图 → 转轨(intentgate 闸门)。 func TestHITLIntentPivot(t *testing.T) { srv, _ := newTestServer(t) h := srv.Handler() diff --git a/internal/server/intent_admission_test.go b/internal/server/intent_admission_test.go index 981737b..d2d6bba 100644 --- a/internal/server/intent_admission_test.go +++ b/internal/server/intent_admission_test.go @@ -7,7 +7,6 @@ import ( "testing" agentcommand "agent-command" - agentintent "agent-intent/intent" "agent-system-backend/internal/cmdbus" "agent-system-backend/internal/intentgate" ) @@ -303,8 +302,10 @@ func TestHighRiskCommandStillRequiresConfirmation(t *testing.T) { // 显式取消命令宿主未实现:如实回落普通回合,不派发同一句里的 Start。 type cancelGenerator struct{} -func (cancelGenerator) Generate(context.Context, string, []agentintent.CatalogSpec) ([]agentintent.Command, error) { - return []agentintent.Command{ +// 生成器只经 intentgate 表面接线:目录与命令类型都由闸门投影, +// 宿主实现不必(也不应)直接导入生态库。 +func (cancelGenerator) Generate(context.Context, string, []intentgate.CatalogSpec) ([]intentgate.Command, error) { + return []intentgate.Command{ {Kind: intentgate.CommandStart, Action: intentgate.ActionRef{Kind: intentgate.ActionCommand, ID: "demo.report"}}, {Kind: intentgate.CommandCancel, Target: "demo.report"}, }, nil