Files
weichen b58595fb38 Implement the intent core
Details (original message):
Implement the intent core, conformance suite, catalog alignment, examples, and the intentctl diagnostics CLI.
2026-09-29 15:35:18 +00:00

35 lines
1.1 KiB
Go

// Package catalogcheck 保证本仓错误常量与 Error-Code-System 的 intent 域种子码
// 逐个相等,防止出现第二套平行权威(仅测试,无生产代码)。
package catalogcheck
import (
"testing"
_ "error-code-system/domains" // 填充 errcode.Default 种子码
"error-code-system/errcode"
"agent-intent/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))
}
}
}