Files
Agent-Intent/catalogcheck/align_test.go
T
weichen 3a8468c83a Enable canonical versioned Go module consumption
Why: Allow consumers to download an immutable module revision without nested source checkouts or local path replacements.

Evidence: SELF package tests and the prior canonical-path rejection are recorded in the Dev dependency-workspace task card; remote consumption is replayed against the committed candidate.

Impact: Change the module identity and its Go imports while preserving API behavior. Existing historical submodule revisions remain buildable.

Refs: Versioned dependencies U1/U3; feature/dependency-workspace
2026-10-13 15:36:11 +00:00

35 lines
1.2 KiB
Go

// Package catalogcheck 保证本仓错误常量与 Error-Code-System 的 intent 域种子码
// 逐个相等,防止出现第二套平行权威(仅测试,无生产代码)。
package catalogcheck
import (
"testing"
_ "git-ssh.u1680832.nyat.app/weichen/Error-Code-System.git/domains" // 填充 errcode.Default 种子码
"git-ssh.u1680832.nyat.app/weichen/Error-Code-System.git/errcode"
"git-ssh.u1680832.nyat.app/weichen/Agent-Intent.git/intent"
)
func TestIntentCodesAlignWithCatalog(t *testing.T) {
pairs := []struct {
local string
canonical errcode.Code
}{
{intent.InvalidSpec, errcode.IntentInvalidSpec},
{intent.SpecProtected, errcode.IntentSpecProtected},
{intent.LoadFailed, errcode.IntentLoadFailed},
{intent.InvalidArgument, errcode.SysInvalidArgument},
}
for _, p := range pairs {
if string(p.canonical) != p.local {
t.Fatalf("常量漂移:intent=%q catalog=%q", p.local, string(p.canonical))
}
// 规范码必须已在目录注册;未注册码 Resolve 会回落 sys.unknown_code,借此检出。
def := errcode.Default.Resolve(p.local)
if string(def.Code) != p.local {
t.Fatalf("码未注册或被回落:%q -> %q", p.local, string(def.Code))
}
}
}