test: add failing regression tests for the two remaining gaps
1. Agent doesn't load its own skills: TestHandleMessageLoadsSkillsFromWorktree — creates a worktree with .agents/skills/tdd-bugfix/SKILL.md, sends a bare mission to HandleMessage, verifies the agent loaded the skill body from its workspace. Fails at runtime: HandleMessage never reads .agents/skills/, the Mission reaches the runner unchanged. 2. Core plugin registry nonexistent: TestPluginInterfaceExists, TestRegistryExists, TestLoadPluginsFromConfigDir — fails to compile: Plugin interface, Registry type, and LoadDir function are undefined. PRD section 5 Layer 2 entirely aspirational.
This commit is contained in:
1 parent
4edad31b66
commit
39b66fc1ef
2 files changed
+143
No files matched your search
@@ -0,0 +1,91 @@
|
||||
package agentexec
|
||||
|
||||
import (
|
||||
"context"
|
||||
"log/slog"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
)
|
||||
|
||||
// captureRunner records the Request it receives for test assertions.
|
||||
type captureRunner struct {
|
||||
callback func(Request)
|
||||
}
|
||||
|
||||
func (c *captureRunner) Run(_ context.Context, _ string, req Request) (Result, error) {
|
||||
c.callback(req)
|
||||
return Result{
|
||||
Version: ProtocolVersion,
|
||||
TaskID: req.TaskID,
|
||||
Attempt: req.Attempt,
|
||||
Stage: req.Stage,
|
||||
Status: StatusPassed,
|
||||
Summary: "done",
|
||||
TokensUsed: 1,
|
||||
}, nil
|
||||
}
|
||||
|
||||
// ── regression: Agent doesn't load its own skills ───────────────────
|
||||
|
||||
func TestHandleMessageLoadsSkillsFromWorktree(t *testing.T) {
|
||||
// PRD section 1: archie-agent owns skill loading — reads
|
||||
// .agents/skills/archie-wf-* from the worktree.
|
||||
//
|
||||
// Currently the daemon loads skills and injects the body into
|
||||
// the Mission string. HandleMessage never touches .agents/skills/.
|
||||
|
||||
dir := t.TempDir()
|
||||
skillsDir := filepath.Join(dir, ".agents", "skills", "tdd-bugfix")
|
||||
if err := os.MkdirAll(skillsDir, 0o755); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := os.WriteFile(filepath.Join(skillsDir, "SKILL.md"), []byte(`---
|
||||
name: tdd-bugfix
|
||||
description: TDD bugfix workflow
|
||||
version: 1.0.0
|
||||
---
|
||||
Analyse the bug. Write repro tests. Fix.
|
||||
`), 0o644); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
var capturedMission string
|
||||
captureFactory := func(providers map[string]Provider, log *slog.Logger) Runner {
|
||||
return &captureRunner{callback: func(req Request) {
|
||||
capturedMission = req.Mission
|
||||
}}
|
||||
}
|
||||
|
||||
msg := AgentRequestMessage{
|
||||
TaskID: 1,
|
||||
Attempt: 1,
|
||||
Stage: "analyse",
|
||||
Workflow: "tdd",
|
||||
Workspace: dir,
|
||||
Request: Request{
|
||||
Version: ProtocolVersion, TaskID: 1, Attempt: 1,
|
||||
Stage: "analyse", Model: "test/model",
|
||||
Mission: "Analyse this bug",
|
||||
Budget: Budget{MaxSteps: 1, MaxTokens: 10},
|
||||
},
|
||||
Providers: map[string]Provider{"test": {Class: "openai", APIKeyEnv: "FAKE"}},
|
||||
}
|
||||
|
||||
resp, err := HandleMessage(context.Background(), msg, slog.New(slog.DiscardHandler), captureFactory)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
_ = resp
|
||||
|
||||
// The agent must load the skill body from its workspace. If the
|
||||
// agent loaded the skill, the Mission sent to the runner would
|
||||
// include the skill body prepended.
|
||||
if capturedMission == "Analyse this bug" {
|
||||
t.Error("Gap: HandleMessage does not load skills from the worktree. " +
|
||||
"The Mission sent to the runner is the bare mission string — " +
|
||||
"no skill content was loaded from " + skillsDir + ". " +
|
||||
"HandleMessage must load .agents/skills/<workflow>/SKILL.md " +
|
||||
"from the workspace when processing a task. PRD section 1.")
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
package plugin
|
||||
|
||||
import "testing"
|
||||
|
||||
// ── regression: Core plugin registry nonexistent ─────────────────────
|
||||
|
||||
func TestPluginInterfaceExists(t *testing.T) {
|
||||
// PRD section 5 Layer 2: core plugins live at ~/.config/archie/plugins/
|
||||
// and extend the daemon itself (forges, ticketing, storage, secrets,
|
||||
// notifications). Each plugin implements:
|
||||
//
|
||||
// type Plugin interface {
|
||||
// Name() string
|
||||
// Version() string
|
||||
// Register(daemon *Daemon) error
|
||||
// }
|
||||
//
|
||||
// Currently zero code exists — no Plugin interface, no registry,
|
||||
// no loader for ~/.config/archie/plugins/.
|
||||
|
||||
var p Plugin
|
||||
if p == nil {
|
||||
t.Error("Gap: Plugin interface is not defined. " +
|
||||
"Define a Plugin interface with Name(), Version(), and Register(*Daemon) error " +
|
||||
"methods per PRD section 5 Layer 2.")
|
||||
}
|
||||
}
|
||||
|
||||
func TestRegistryExists(t *testing.T) {
|
||||
// A registry holds loaded plugins and dispatches extension points.
|
||||
r := &Registry{}
|
||||
if r == nil {
|
||||
t.Error("Gap: Registry type is not defined. " +
|
||||
"Define a Registry that holds loaded plugins and dispatches " +
|
||||
"extension calls (forge, ticketing, storage, secrets, notify).")
|
||||
}
|
||||
}
|
||||
|
||||
func TestLoadPluginsFromConfigDir(t *testing.T) {
|
||||
// The daemon loads .go files from ~/.config/archie/plugins/ at
|
||||
// startup. Failed plugins are logged and skipped.
|
||||
plugins, err := LoadDir("/nonexistent/path")
|
||||
if err != nil {
|
||||
t.Error("Gap: LoadDir function is not defined. " +
|
||||
"Define LoadDir(path string) ([]Plugin, error) that discovers " +
|
||||
"and evaluates .go files from ~/.config/archie/plugins/.")
|
||||
}
|
||||
if plugins != nil {
|
||||
// Even an empty directory should return empty slice, not nil.
|
||||
_ = plugins
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user