Files
archie/internal/app/agentworker/architecture_test.go
T
sam 45345cdfb6 refactor(agent): move worker runtime into application layer
cmd/archie-agent used to own worker construction, NATS lifecycle, task execution, MCP setup, and workflow wiring. It now owns process input only and invokes internal/app/agentworker, while transport-specific NATS, boot-brief, and git-safety mechanics live under infrastructure.
2026-08-15 00:43:12 +10:00

52 lines
1.3 KiB
Go

package agentworker
import (
"go/ast"
"go/parser"
"go/token"
"path/filepath"
"strconv"
"strings"
"testing"
)
func TestApplicationOwnsNoTransportWireMechanics(t *testing.T) {
files, err := filepath.Glob("*.go")
if err != nil {
t.Fatal(err)
}
for _, path := range files {
if strings.HasSuffix(path, "_test.go") {
continue
}
file, err := parser.ParseFile(token.NewFileSet(), path, nil, 0)
if err != nil {
t.Fatal(err)
}
for _, imported := range file.Imports {
name, err := strconv.Unquote(imported.Path.Value)
if err != nil {
t.Fatal(err)
}
switch {
case name == "encoding/json":
t.Errorf("%s imports JSON wire encoding", path)
case name == "github.com/samcharles93/archie-core/internal/domain/workintake":
t.Errorf("%s imports NATS topology subjects", path)
case name == "github.com/nats-io/nats.go" || strings.HasPrefix(name, "github.com/nats-io/nats.go/"):
t.Errorf("%s imports raw NATS SDK package %q", path, name)
}
}
ast.Inspect(file, func(node ast.Node) bool {
selector, ok := node.(*ast.SelectorExpr)
if !ok {
return true
}
if selector.Sel.Name == "ReplyAddress" || selector.Sel.Name == "Subject" || selector.Sel.Name == "Data" {
t.Errorf("%s inspects transport wire selector %s", path, selector.Sel.Name)
}
return true
})
}
}