iop/packages/go/streamgate/package_boundary_test.go
toki c90bb755a9 feat: streamline plan/code-review/finalize router, add stream gate SDDs, sync dev-test inventory, update roadmap milestones
- Refactor plan, code-review, finalize-task-routing, refine-local-plans, router skills
- Add agent-workflow-loop-orchestration skill and plan agent configs
- Update roadmap: knowledge-tool-optimization milestones, stream-evidence-gate-core SDD
- Add stream-evidence-gate-core task, archive, and Go streamgate package
- Update dev-test inventory (edge/node smoke), agent-contract, edge-local-dev-guide
- Deprecate USER_REVIEW for output-validation-filters SDD
2026-07-24 15:11:00 +09:00

61 lines
1.5 KiB
Go

package streamgate_test
import (
"go/parser"
"go/token"
"os"
"path/filepath"
"strings"
"testing"
)
// TestStreamgateProductionImportsStayTransportAgnostic verifies that production
// .go files in packages/go/streamgate do not import apps/*/internal or
// proto/gen/iop paths. This ensures the package remains transport-agnostic
// and owns its typed contract exclusively.
func TestStreamgateProductionImportsStayTransportAgnostic(t *testing.T) {
pkgRoot := "."
fset := token.NewFileSet()
entries, err := os.ReadDir(pkgRoot)
if err != nil {
t.Fatalf("failed to read directory: %v", err)
}
for _, entry := range entries {
if entry.IsDir() {
continue
}
name := entry.Name()
// Skip test files; only check production source.
if strings.HasSuffix(name, "_test.go") {
continue
}
if !strings.HasSuffix(name, ".go") {
continue
}
filePath := filepath.Join(pkgRoot, name)
f, err := parser.ParseFile(fset, filePath, nil, parser.ImportsOnly)
if err != nil {
t.Fatalf("failed to parse %s: %v", name, err)
}
for _, imp := range f.Imports {
importPath := strings.Trim(imp.Path.Value, "\"")
// Reject apps/*/internal imports.
if strings.Contains(importPath, "/apps/") && strings.Contains(importPath, "/internal") {
t.Errorf("%s imports app-internal path: %s", name, importPath)
}
// Reject proto/gen/iop imports to ensure Core owns raw wire contract.
if strings.Contains(importPath, "proto/gen/iop") {
t.Errorf("%s imports proto gen path: %s", name, importPath)
}
}
}
}