chore(lint): guard the messaging service's contract boundary with depguard instead of a test
This commit is contained in:
2 files changed
+8
-39
No files matched your search
@@ -88,6 +88,14 @@ linters:
|
||||
- {pkg: "github.com/samcharles93/archie-core/internal/container", desc: "only the daemon owns containers"}
|
||||
- {pkg: "github.com/samcharles93/archie-core/internal/agentexec", desc: "only the daemon owns containers"}
|
||||
- {pkg: "github.com/samcharles93/archie-core/internal/app/archied", desc: "the daemon is another service"}
|
||||
messaging-service:
|
||||
files: ["**/internal/app/archiemessaging/**", "**/cmd/archie-messaging/**"]
|
||||
deny:
|
||||
- {pkg: "github.com/jackc/pgx", desc: "reach the State Store through its contract"}
|
||||
- {pkg: "github.com/samcharles93/archie-core/internal/infrastructure/postgres", desc: "reach the State Store through its contract"}
|
||||
- {pkg: "github.com/samcharles93/archie-core/internal/infrastructure/controlplanestore", desc: "reach the State Store through its contract"}
|
||||
- {pkg: "github.com/samcharles93/archie-core/internal/domain/workflow", desc: "the workflow engine is the daemon's"}
|
||||
- {pkg: "github.com/samcharles93/archie-core/internal/agentexec", desc: "agent execution is the daemon's"}
|
||||
shared:
|
||||
files: ["**/internal/app/servicekit/**", "**/internal/app/chattask/**"]
|
||||
deny:
|
||||
|
||||
@@ -1,39 +0,0 @@
|
||||
// The Messaging Service reaches the State Store and the workflow engine only
|
||||
// through their contracts. Go imports are atomic, so one reference relinks a
|
||||
// runtime, and the boundary holds only while something re-measures it.
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"os/exec"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
func TestMessagingDoesNotLinkStoreOrWorkflowRuntime(t *testing.T) {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
|
||||
defer cancel()
|
||||
out, err := exec.CommandContext(ctx, "go", "list", "-deps", ".").Output()
|
||||
if err != nil {
|
||||
t.Fatalf("go list -deps .: %v", err)
|
||||
}
|
||||
linked := map[string]bool{}
|
||||
for line := range strings.SplitSeq(strings.TrimSpace(string(out)), "\n") {
|
||||
linked[line] = true
|
||||
}
|
||||
for _, pkg := range []string{
|
||||
"github.com/jackc/pgx/v5/pgxpool",
|
||||
"github.com/samcharles93/archie-core/internal/infrastructure/postgres",
|
||||
"github.com/samcharles93/archie-core/internal/infrastructure/controlplanestore",
|
||||
"github.com/samcharles93/archie-core/internal/domain/workflow",
|
||||
"github.com/samcharles93/archie-core/internal/agentexec",
|
||||
} {
|
||||
t.Run(pkg, func(t *testing.T) {
|
||||
if linked[pkg] {
|
||||
t.Errorf("cmd/archie-messaging links %s: services reach each other only through contracts", pkg)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user