Add architecture tests enforcing agent package boundaries#569
Conversation
Adds two tests that run in CI to prevent agent implementations from coupling to framework internals (strategy, checkpoint, session, etc.). - TestAgentPackages_NoForbiddenImports: scans all agent package imports and fails if they reference forbidden internal packages - TestAgentPackages_SelfRegister: verifies every agent has an init() calling Register() for proper discovery New agent packages are auto-discovered — no test maintenance needed. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Entire-Checkpoint: f3063f5cf65e
Now that architecture tests enforce the agent package boundary at the code level, the researcher can reference agent.go and event.go for exact interface signatures and EventType constants. The hard "Do NOT read" prohibition is replaced with guidance to prefer agent-guide.md but use source files as ground truth when needed. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Entire-Checkpoint: 6a10aa4a4f3b
PR SummaryMedium Risk Overview Updates the Written by Cursor Bugbot for commit 0051efb. Configure here. |
There was a problem hiding this comment.
Pull request overview
This PR adds “architecture tests” to enforce package-boundary rules for agent implementations in the Entire CLI, and updates the agent-integration researcher skill docs to allow referencing the public agent contract source files (agent.go, event.go) now that boundaries are CI-enforced.
Changes:
- Added
architecture_test.goundercmd/entire/cli/agent/to (1) forbid agent implementations from importing internal framework packages and (2) require each agent package to self-register viainit(). - Updated the researcher skill documentation to permit referencing
agent.go/event.goas ground truth while continuing to discourage reading deeper internals.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
cmd/entire/cli/agent/architecture_test.go |
Adds CI-enforced architecture tests for agent package import boundaries and self-registration. |
.claude/skills/agent-integration/researcher.md |
Relaxes researcher guidance to allow consulting the agent contract source for exact interfaces/constants. |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 2 potential issues.
Autofix Details
Bugbot Autofix prepared fixes for both issues found in the latest run.
- ✅ Fixed: Missing continue after forbidden import causes misleading error
- Added an
isForbiddenflag in the forbidden suffix loop and acontinueafter it to skip the allowed-prefix check for explicitly forbidden imports.
- Added an
- ✅ Fixed: SelfRegister test silently passes with zero packages
- Added
len(agentPkgs) == 0guard witht.FataltoTestAgentPackages_SelfRegister, matching the existing guard inTestAgentPackages_NoForbiddenImports.
- Added
Or push these changes by commenting:
@cursor push 4c98db8422
Preview (4c98db8422)
diff --git a/cmd/entire/cli/agent/architecture_test.go b/cmd/entire/cli/agent/architecture_test.go
--- a/cmd/entire/cli/agent/architecture_test.go
+++ b/cmd/entire/cli/agent/architecture_test.go
@@ -80,11 +80,16 @@
// Check forbidden suffixes
rel := strings.TrimPrefix(imp, repoPrefix)
+ isForbidden := false
for _, forbidden := range forbiddenSuffixes {
if rel == forbidden || strings.HasPrefix(rel, forbidden+"/") {
t.Errorf("forbidden import %q — agent packages must not import %s internals", imp, forbidden)
+ isForbidden = true
}
}
+ if isForbidden {
+ continue
+ }
// Check it's in the allowed list
allowed := false
@@ -186,6 +191,10 @@
agentDir := findAgentDir(t)
agentPkgs := discoverAgentPackages(t, agentDir)
+ if len(agentPkgs) == 0 {
+ t.Fatal("no agent packages found — test setup is broken")
+ }
+
for _, pkgDir := range agentPkgs {
pkgName := filepath.Base(pkgDir)
t.Run(pkgName, func(t *testing.T) {- Add continue after forbidden suffix match to avoid duplicate "unexpected internal import" error on already-forbidden imports - Add zero-package guard to TestAgentPackages_SelfRegister (matching NoForbiddenImports) - Fix misleading findAgentDir comment Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Entire-Checkpoint: 8a947931a662
|
bugbot run |
More robust and idiomatic than strings.Trim for extracting string values from Go AST literal nodes. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Entire-Checkpoint: dab7eedcbec5

Summary
agent.goandevent.gofor exact interface signaturesWhat the tests do
TestAgentPackages_NoForbiddenImports: Scans all agent package imports and fails if they reference forbidden internal packages. New agent packages are auto-discovered.TestAgentPackages_SelfRegister: Verifies every agent package has aninit()callingRegister()for proper discovery.Why
From reviewing #555 — the researcher skill had a hard "Do NOT read internal source files" instruction to prevent agents from building on internals. But agent instructions are a weak enforcement mechanism. These tests enforce the real boundary at the code level, so the doc instruction can be relaxed to useful guidance instead.
Test plan
mise run fmt && mise run lint— clean🤖 Generated with Claude Code