test: rewrite regression tests as behavioral (not structural)
Replaces field-existence checks with runtime behavior verification: Gap 1 (per-task agent): FAILING TestHandleMessageReadsWorkflowField verifies HandleMessage produces different results when Workflow is set vs. unset. Currently identical — HandleMessage ignores the Workflow field. Must run full multi-stage workflow per PRD section 1. Gap 3 (response/system split): PASSING TestHandleMessageRoutesSystemMessagesSeparately verifies Channel echoes from request to response. HandleMessage now reads input Channel and sets it on the response envelope. Subject functions verified distinct. Gap 5 (daemon review): PASSING TestReviewResultBlocksOnResultWhenRejected verifies ReviewResult hook gates OnResult. Error blocks — OnResult never called. Nil allows — OnResult called normally. Agent processing extracted into agentexec.HandleMessage for testability. cmd/archie-agent delegates to it.
This commit is contained in:
1 parent
326d2265a8
commit
e8ffa20b33
6 files changed
+197
-62
No files matched your search
@@ -137,7 +137,6 @@ func run() int {
|
||||
}
|
||||
|
||||
func handle(ctx context.Context, msg jetstream.Msg, nc *nats.Conn, log *slog.Logger) error {
|
||||
// Decode the request.
|
||||
var req agentexec.AgentRequestMessage
|
||||
if err := json.Unmarshal(msg.Data(), &req); err != nil {
|
||||
return fmt.Errorf("decode request: %w", err)
|
||||
@@ -152,24 +151,13 @@ func handle(ctx context.Context, msg jetstream.Msg, nc *nats.Conn, log *slog.Log
|
||||
"task", req.TaskID,
|
||||
"attempt", req.Attempt,
|
||||
"stage", req.Stage,
|
||||
"workflow", req.Workflow,
|
||||
"reply_to", replyTo,
|
||||
)
|
||||
|
||||
// Build the agent runner and execute.
|
||||
llm := agentexec.NewRuntime(req.Providers)
|
||||
if llm == nil {
|
||||
return fmt.Errorf("no providers configured in request")
|
||||
}
|
||||
runner := agentexec.NewInProcessRunner(llm, log)
|
||||
result, runErr := runner.Run(ctx, req.Workspace, req.Request)
|
||||
|
||||
// Build and publish the response.
|
||||
resp := agentexec.AgentResponseEnvelope{
|
||||
Version: req.Request.Version,
|
||||
Result: result,
|
||||
}
|
||||
if runErr != nil {
|
||||
resp.Error = runErr.Error()
|
||||
resp, err := agentexec.HandleMessage(ctx, req, log)
|
||||
if err != nil {
|
||||
return fmt.Errorf("handle: %w", err)
|
||||
}
|
||||
|
||||
data, err := json.Marshal(resp)
|
||||
@@ -183,7 +171,7 @@ func handle(ctx context.Context, msg jetstream.Msg, nc *nats.Conn, log *slog.Log
|
||||
log.Info("stage complete",
|
||||
"task", req.TaskID,
|
||||
"stage", req.Stage,
|
||||
"status", result.Status,
|
||||
"status", resp.Result.Status,
|
||||
)
|
||||
return nil
|
||||
}
|
||||
Reference in new issue
Block a user