Files
Agent-System/internal/contracts/contracts_test.go
T
weichenandCursor e9d57ea772 feat(arch): add contracts skeleton and warn-mode arch-check
Give later waves a measurable import/table/path baseline without changing business behavior or occupying the integration slot.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-14 13:00:32 +00:00

47 lines
1.1 KiB
Go

package contracts
import (
"go/parser"
"go/token"
"os"
"path/filepath"
"strings"
"testing"
)
func TestContractsHasNoBusinessImports(t *testing.T) {
dir, err := os.Getwd()
if err != nil {
t.Fatal(err)
}
ents, err := os.ReadDir(dir)
if err != nil {
t.Fatal(err)
}
fset := token.NewFileSet()
for _, ent := range ents {
if ent.IsDir() || !strings.HasSuffix(ent.Name(), ".go") {
continue
}
f, err := parser.ParseFile(fset, filepath.Join(dir, ent.Name()), nil, parser.ImportsOnly)
if err != nil {
t.Fatal(err)
}
for _, spec := range f.Imports {
path := strings.Trim(spec.Path.Value, `"`)
if strings.HasPrefix(path, "chat-agent-system/internal/") && path != "chat-agent-system/internal/contracts" {
t.Fatalf("%s imports business package %s", ent.Name(), path)
}
}
}
}
func TestVocabularyAndErrorCodesStable(t *testing.T) {
if StageV01Triage != "V0.1_triage" || ErrorPlanFrozen != "PLAN_FROZEN" {
t.Fatal("Wave 0 vocabulary drifted")
}
if EventDocumentApproved == "" || EventRunFinalized == "" {
t.Fatal("event names required")
}
}