Files
archie/internal/daemon/scratch_task_test.go
T
sam c431834e2b feat(eda): workflow inputs, optional repository and agent profiles
Workflow definitions declare inputs, repository (none, optional or
required; default required) and profile. A binding assigns each input
from a mapped parameter or a constant and may take its repository from a
parameter, which must name a configured repo; both are checked when the
binding is saved and again at dispatch. Inputs travel as structured task
data (tasks.inputs, the task brief, and a JSON block in the agent's
mission), never as body text.

A task with no repository runs in a per-task scratch workspace with no
clone and no publication grant. The agent.run step runs one mission
without a repository and finishes the task in the new completed status.

Agent profiles live under [containers.profiles.<name>]: an image and an
allowlist over the tools archie adds (MCP, scripts, plugins).
[containers].image is the default profile; an unconfigured profile parks
the task. The workflow is now pinned before the container starts so the
profile can choose its image.

Also stop two archied tests writing embedded NATS state into the package
directory, refuse an empty state_dir for embedded NATS, and drop the NATS
store files an earlier lane commit tracked.
2026-09-24 20:29:33 +10:00

47 lines
1.5 KiB
Go

package daemon
import (
"context"
"log/slog"
"os"
"testing"
"github.com/samcharles93/archie-core/internal/config"
"github.com/samcharles93/archie-core/internal/domain/workflow"
"github.com/samcharles93/archie-core/internal/worktree"
)
// A task with no repository gets an empty scratch workspace, no publication
// grant, and is not serialized behind other repository-less tasks.
func TestNoRepositoryTaskRunsInScratch(t *testing.T) {
d := &Daemon{Cfg: config.NewHolder(config.Config{}), Log: slog.New(slog.DiscardHandler)}
task := &workflow.Task{ID: 12}
trees := &worktree.Manager{WorkDir: t.TempDir()}
dir, ok := d.prepareWorkspace(t.Context(), task, trees, config.Repo{})
if !ok || dir != trees.ScratchDir(12) {
t.Fatalf("prepareWorkspace() = %q, %v; want the task's scratch dir", dir, ok)
}
if info, err := os.Stat(dir); err != nil || !info.IsDir() {
t.Fatalf("scratch dir not created: %v", err)
}
grant, revoke, ok := d.publicationGrant(t.Context(), task)
if !ok || grant != "" || revoke == nil {
t.Fatalf("publicationGrant() = %q, %v; want no grant and a no-op revoke", grant, ok)
}
revoke()
if !d.allowConcurrentForTask(task) {
t.Error("repository-less tasks are serialized on an empty repo key")
}
}
// runPinnedViaAgent pins the task's workflow and profile, then hands it to the
// agent, the order process uses.
func runPinnedViaAgent(ctx context.Context, d *Daemon, task *workflow.Task, repo config.Repo) {
profile, ok := d.pinTaskProfile(ctx, task)
if !ok {
return
}
d.runViaAgent(ctx, task, repo, profile)
}