Add internal/taskrun (Request/Response wire types) and cmd/archie-agent/taskrun.go: runTask builds a workflow.Registry from the container's own bind-mounted worktree, routes and runs the task's entire workflow via workflow.Route/workflow.Run, using storerpc.Client/ forgerpc.Client for Store/Forge and a new hybridTrees that splits Prepare/Push (proxied over worktreerpc — network ops needing the daemon's credential) from CommitAll/Diff/ChangedFiles/ChangedLines (local git against the mount). Add config.TaskConfig.ToConfig() to rebuild a usable Config from the curated payload, and storage.WorktreeMountDir (/data/worktree) — critical fix: hybridTrees.Prepare discards the RPC response's host-side directory and returns the container's fixed local mount path instead, since archied and archie-agent see the same files at different paths. Wired a queue-grouped core-NATS subscription on archie.taskrun.> in cmd/archie-agent/main.go alongside the existing per-stage consumer, so this is reachable in the running binary. End-to-end test drives the real "bootstrap" workflow (no LLM) through real storerpc/forgerpc/worktreerpc servers and a real local git remote — registry build, route, prepare, commit, push, PR creation, and confirms the authoritative task state lands in archied's store via RPC, not just in-memory. archie-core-5zh.8 (daemon.go handoff) is unblocked.
76 lines
2.0 KiB
Go
76 lines
2.0 KiB
Go
package taskrun
|
|
|
|
import (
|
|
"encoding/json"
|
|
"testing"
|
|
|
|
"github.com/samcharles93/archie-core/internal/agentexec"
|
|
"github.com/samcharles93/archie-core/internal/config"
|
|
"github.com/samcharles93/archie-core/internal/store"
|
|
)
|
|
|
|
func TestRequestJSONRoundTrip(t *testing.T) {
|
|
req := Request{
|
|
Task: &store.Task{
|
|
ID: 1,
|
|
Owner: "sam",
|
|
Repo: "archie",
|
|
IssueNumber: 42,
|
|
Title: "feat: thing",
|
|
Status: store.StatusRunning,
|
|
},
|
|
Repo: config.Repo{Owner: "sam", Name: "archie", Base: "main"},
|
|
Cfg: config.Config{DiffCapLines: 500}.ForTask(),
|
|
Providers: map[string]agentexec.Provider{
|
|
"anthropic": {Class: "anthropic", APIKeyEnv: "ANTHROPIC_API_KEY"},
|
|
},
|
|
}
|
|
|
|
data, err := json.Marshal(req)
|
|
if err != nil {
|
|
t.Fatalf("marshal: %v", err)
|
|
}
|
|
|
|
var got Request
|
|
if err := json.Unmarshal(data, &got); err != nil {
|
|
t.Fatalf("unmarshal: %v", err)
|
|
}
|
|
|
|
if got.Task == nil || got.Task.ID != 1 || got.Task.Owner != "sam" || got.Task.IssueNumber != 42 {
|
|
t.Fatalf("Task did not round-trip: %+v", got.Task)
|
|
}
|
|
if got.Repo.FullName() != "sam/archie" || got.Repo.BaseBranch() != "main" {
|
|
t.Fatalf("Repo did not round-trip: %+v", got.Repo)
|
|
}
|
|
if got.Cfg.DiffCapLines != 500 {
|
|
t.Fatalf("Cfg did not round-trip: %+v", got.Cfg)
|
|
}
|
|
if got.Providers["anthropic"].APIKeyEnv != "ANTHROPIC_API_KEY" {
|
|
t.Fatalf("Providers did not round-trip: %+v", got.Providers)
|
|
}
|
|
}
|
|
|
|
func TestResponseJSONRoundTrip(t *testing.T) {
|
|
resp := Response{
|
|
Task: &store.Task{ID: 1, Status: store.StatusPROpen},
|
|
Status: "passed",
|
|
}
|
|
data, err := json.Marshal(resp)
|
|
if err != nil {
|
|
t.Fatalf("marshal: %v", err)
|
|
}
|
|
var got Response
|
|
if err := json.Unmarshal(data, &got); err != nil {
|
|
t.Fatalf("unmarshal: %v", err)
|
|
}
|
|
if got.Task == nil || got.Task.Status != store.StatusPROpen || got.Status != "passed" {
|
|
t.Fatalf("Response did not round-trip: %+v", got)
|
|
}
|
|
}
|
|
|
|
func TestSubjectForTask(t *testing.T) {
|
|
if got := SubjectForTask(42); got != "archie.taskrun.42" {
|
|
t.Fatalf("SubjectForTask(42) = %q", got)
|
|
}
|
|
}
|