cyclop (5→0): extract subcommand/case bodies in codesearch, subprocess, Telegram, indexing funlen (5→3): extract memory action handlers, tool provider startup gocognit (7→2): extract config finalize/loadDirInto helpers, release announcer, capture tool validation, Telegram gateway (200→108), archie-agent main loop (35→0) nestif (8→0): extract identity validation, container validation, conf.d scanning, email multipart parsing, Telegram model/update parsing, build-no-changes closure interfacebloat (3→0): split Forge/IssueForge/PRForge/RepoForge, SessionStore/SessionLifecycle/MessageHistory, TaskStore/TaskLifecycle/TaskQueries/TaskEvents Remaining: daemon process, workflow Feasibility/TDD/AgentStage, archied main.go run (108→30 remaining). These require deeper refactoring best done per-function in follow-up beads. Updated contract tests and archied wiring tests to check both main.go and the new telegram_setup.go.
74 lines
2.2 KiB
Go
74 lines
2.2 KiB
Go
package provider_test
|
|
|
|
import (
|
|
"os"
|
|
"path/filepath"
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
func TestToolProviderEngineContractExists(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
source, err := os.ReadFile(filepath.Join("provider.go"))
|
|
if err != nil {
|
|
t.Fatalf("read provider.go: %v", err)
|
|
}
|
|
text := string(source)
|
|
for _, required := range []string{
|
|
"type Engine interface",
|
|
"plugin.Module",
|
|
"Discover(context.Context) ([]tools.ToolEntry, error)",
|
|
"type Registry struct",
|
|
"func (r *Registry) Register(engine Engine) error",
|
|
"func (r *Registry) Get(id string) (Engine, bool)",
|
|
} {
|
|
if !strings.Contains(text, required) {
|
|
t.Errorf("provider.go does not contain required typed-family contract %q", required)
|
|
}
|
|
}
|
|
}
|
|
|
|
func TestArchiedWiresTypedProvidersAndExecutableConsumers(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
mainPath := filepath.Join("..", "..", "..", "cmd", "archied", "main.go")
|
|
source, err := os.ReadFile(mainPath)
|
|
if err != nil {
|
|
t.Fatalf("read archied main: %v", err)
|
|
}
|
|
text := string(source)
|
|
|
|
// Also check telegram_setup.go, which holds the chat-turn wiring
|
|
// extracted from main.go during the Phase 4 structural refactor.
|
|
tgPath := filepath.Join("..", "..", "..", "cmd", "archied", "telegram_setup.go")
|
|
tgSource, tgErr := os.ReadFile(tgPath)
|
|
if tgErr == nil {
|
|
text += string(tgSource)
|
|
}
|
|
|
|
for _, required := range []string{
|
|
"toolprovider.NewRegistry(toolReg)",
|
|
"memorytoolprovider.New(memManager)",
|
|
"configuredMCPProvider(srv)",
|
|
"capabilityHost.Register(providerRegistry)",
|
|
// The chat turn builds its toolset from the registry before the
|
|
// system prompt is rendered, so the prompt can advertise exactly
|
|
// the tools the model is handed. After the Phase 4 structural
|
|
// refactor these calls live in telegram_setup.go.
|
|
"chatGenerateOptions(nil,",
|
|
"toolSummaries(options.Tools)",
|
|
"agentexec.NewInProcessRunner(llm, log, toolReg)",
|
|
} {
|
|
if !strings.Contains(text, required) {
|
|
t.Errorf("archied wiring not found: %q", required)
|
|
}
|
|
}
|
|
if strings.Contains(text, ".RegisterTools(ctx, toolReg)") {
|
|
t.Error("composition bypasses the typed provider registry with direct MCP registration")
|
|
}
|
|
if strings.Contains(text, "memManager.GetToolSchemas()") {
|
|
t.Error("composition bypasses the typed memory tool provider")
|
|
}
|
|
}
|