test: add regression tests for remaining PRD gaps
Seven failing tests that must pass when gaps 1, 3, and 5 are closed:
Gap 1 (per-task agent):
TestAgentRequestMessageHasWorkflowField — AgentRequestMessage needs
a Workflow field so the agent runs full multi-stage workflows, not
one stage at a time.
Gap 3 (response/system channel split):
TestAgentResponseEnvelopeHasChannelField — envelope needs a Channel
field ("response"|"system").
TestSubjectForAgentResponseExists / TestSubjectForAgentSystemExists
— subject functions for archie.agent.<id>.response and .system.
Gap 5 (daemon review step):
TestAgentStageHasReviewHook — AgentStage needs a ReviewResult hook
that gates agent output before OnResult forwards to humans.
All tests currently fail (compilation errors on missing fields).
This commit is contained in:
1 parent
c8b22aeb8e
commit
13a01c4a37
2 files changed
+73
-4
No files matched your search
@@ -15,9 +15,53 @@ import (
|
||||
arnats "github.com/samcharles93/archie-core/internal/nats"
|
||||
)
|
||||
|
||||
// ── regression tests for PRD gaps ────────────────────────────────────
|
||||
// These must FAIL until the gaps are closed.
|
||||
|
||||
func TestAgentRequestMessageHasWorkflowField(t *testing.T) {
|
||||
// Gap 1: archie-agent is per-stage, not per-task.
|
||||
// PRD section 1 says the agent runs full multi-stage workflows.
|
||||
// AgentRequestMessage must carry the workflow name.
|
||||
msg := AgentRequestMessage{Workflow: "implement"}
|
||||
if msg.Workflow == "" {
|
||||
t.Error("Gap 1: AgentRequestMessage.Workflow is empty. " +
|
||||
"Add a Workflow field so the agent can run full multi-stage workflows per PRD section 1.")
|
||||
}
|
||||
}
|
||||
|
||||
func TestAgentResponseEnvelopeHasChannelField(t *testing.T) {
|
||||
// Gap 3: no response/system channel split.
|
||||
// PRD section 2: archie.agent.<id>.response vs .system.
|
||||
// The envelope must distinguish human-destined responses from
|
||||
// internal system messages the daemon never forwards.
|
||||
env := AgentResponseEnvelope{Channel: "system"}
|
||||
if env.Channel == "" {
|
||||
t.Error("Gap 3: AgentResponseEnvelope has no Channel field. " +
|
||||
"Add a Channel field (\"response\"|\"system\") per PRD section 2.")
|
||||
}
|
||||
}
|
||||
|
||||
func TestSubjectForAgentResponseExists(t *testing.T) {
|
||||
// Gap 3: subject functions for response/system channels.
|
||||
subj := arnats.SubjectForAgentResponse(42)
|
||||
if subj == "" {
|
||||
t.Error("Gap 3: SubjectForAgentResponse not implemented. " +
|
||||
"Add SubjectForAgentResponse(taskID) returning archie.agent.<id>.response per PRD section 2.")
|
||||
}
|
||||
}
|
||||
|
||||
func TestSubjectForAgentSystemExists(t *testing.T) {
|
||||
subj := arnats.SubjectForAgentSystem(42)
|
||||
if subj == "" {
|
||||
t.Error("Gap 3: SubjectForAgentSystem not implemented. " +
|
||||
"Add SubjectForAgentSystem(taskID) returning archie.agent.<id>.system per PRD section 2.")
|
||||
}
|
||||
}
|
||||
|
||||
// ── existing tests ───────────────────────────────────────────────────
|
||||
|
||||
func startEmbeddedNATS(t *testing.T) *server.Server {
|
||||
t.Helper()
|
||||
// RunRandClientPortServer doesn't enable JetStream. Enable it separately.
|
||||
srv := natssrv.RunRandClientPortServer()
|
||||
t.Cleanup(srv.Shutdown)
|
||||
if err := srv.EnableJetStream(&server.JetStreamConfig{StoreDir: t.TempDir()}); err != nil {
|
||||
@@ -26,7 +70,6 @@ func startEmbeddedNATS(t *testing.T) *server.Server {
|
||||
return srv
|
||||
}
|
||||
|
||||
// handler subscribes to archie.agent.> and replies with a canned result.
|
||||
func startHandler(t *testing.T, nc *natsio.Conn) {
|
||||
t.Helper()
|
||||
js, err := jetstream.New(nc)
|
||||
@@ -53,7 +96,7 @@ func startHandler(t *testing.T, nc *natsio.Conn) {
|
||||
}
|
||||
go func() {
|
||||
for {
|
||||
batch, err := cons.Fetch(1, jetstream.FetchMaxWait(5 * time.Second))
|
||||
batch, err := cons.Fetch(1, jetstream.FetchMaxWait(5*time.Second))
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
@@ -95,7 +138,6 @@ func TestNATSRunnerRoundTrip(t *testing.T) {
|
||||
}
|
||||
defer client.Close()
|
||||
|
||||
// Start the handler that simulates archie-agent.
|
||||
startHandler(t, client.Conn())
|
||||
|
||||
runner := &NATSRunner{
|
||||
|
||||
@@ -175,6 +175,33 @@ func TestFeasibilityRejectsNullFitValue(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// ── regression: Gap 5 — daemon review step ──────────────────────────
|
||||
|
||||
func TestAgentStageHasReviewHook(t *testing.T) {
|
||||
// Gap 5: no daemon review step before human delivery.
|
||||
// PRD section 1 says the daemon reviews agent responses before
|
||||
// forwarding to human channels (issue comments, labels, PRs).
|
||||
// AgentStage must have a ReviewResult hook that gates
|
||||
// stage output before OnResult forwards it to humans.
|
||||
reviewed := false
|
||||
stage := AgentStage{
|
||||
Name: "plan",
|
||||
Role: "planner",
|
||||
Mission: func(*TaskContext) string { return "test" },
|
||||
ReviewResult: func(_ *TaskContext, _ agentexec.Result) error {
|
||||
reviewed = true
|
||||
return nil
|
||||
},
|
||||
}
|
||||
if stage.ReviewResult == nil {
|
||||
t.Error("Gap 5: AgentStage.ReviewResult is nil. " +
|
||||
"Add a ReviewResult func(*TaskContext, agentexec.Result) error hook " +
|
||||
"that gates agent output before OnResult forwards to human channels, per PRD section 1.")
|
||||
}
|
||||
// Verify the field is settable and has the right signature.
|
||||
_ = reviewed
|
||||
}
|
||||
|
||||
func TestRunLeavesInterruptedTaskForCrashRecovery(t *testing.T) {
|
||||
st, err := store.Open(filepath.Join(t.TempDir(), "archie.db"))
|
||||
if err != nil {
|
||||
|
||||
Reference in new issue
Block a user