feat: curated TaskConfig payload for archie-agent (archie-core-5zh.5)
Add config.TaskConfig/TaskForge and Config.ForTask(): a non-secret, explicit-allowlist snapshot (Models, Budgets, Dispatch, DiffCapLines, Notify, Forge.Host) of the fields workflow stages read from tc.Cfg. Forge.TokenEnv is excluded even though it's just a var name, not a secret. Maps are deep-copied to avoid aliasing the daemon's live config. Duration gains JSON marshaling (string form, matching TOML); config.Repo gets full json tags. Groundwork for archie-core-5zh — not yet wired into workflow.TaskContext.
This commit is contained in:
1 parent
1369ab1c84
commit
159fbce18f
4 files changed
+250
-20
No files matched your search
@@ -5,3 +5,5 @@
|
||||
{"id":"int-4b10e52acc74cd691919159a77b36f6d","kind":"field_change","created_at":"2026-07-23T21:58:50.804043554Z","actor":"Sam Catlow","issue_id":"archie-core-5zh.1","extra":{"field":"status","new_value":"closed","old_value":"in_progress","reason":"Added internal/storerpc: core-NATS request/reply RPC so archie-agent can call Store.Update/Transition without direct DB access. archied's Store stays the sole owner; store.Task gained json tags to cross the wire. Not yet wired into daemon.go or workflow.TaskContext — that's archie-core-5zh.4's job once all three RPC proxies exist."}}
|
||||
{"id":"int-b4c080744419b9e5838f016f0f7e3d2f","kind":"field_change","created_at":"2026-07-23T22:02:41.482197412Z","actor":"Sam Catlow","issue_id":"archie-core-5zh.2","extra":{"field":"status","new_value":"closed","old_value":"in_progress","reason":"Added internal/forgerpc: core-NATS request/reply RPC for the four forge.Forge methods workflow stages actually call mid-run (Comment, CloseIssue, CreatePR, SetStateLabel). Confirmed via grep that all other Forge methods (AssignedIssues, IssuesWithLabel, React, RepliesAfter, PRState, CreateIssue, AcceptInvitations, VerifyPush) are daemon-only poll/reconcile-loop calls, never invoked from a workflow stage, so nothing else needs proxying. archied stays the sole holder of forge API tokens. Not yet wired into daemon.go or workflow.TaskContext — deferred to archie-core-5zh.4."}}
|
||||
{"id":"int-94134ef6491261db5696279899fe6e9b","kind":"field_change","created_at":"2026-07-23T22:05:09.970642059Z","actor":"Sam Catlow","issue_id":"archie-core-5zh.3","extra":{"field":"status","new_value":"closed","old_value":"in_progress","reason":"Added internal/worktreerpc: core-NATS request/reply RPC so archie-agent can request a git push without holding the forge push token. Server resolves the worktree directory itself from owner/repo/issue (never trusts a path from the sandboxed agent) and calls the daemon's own worktree.Manager.Push, which already holds the token via its askpass helper. Prepare/CommitAll/Diff/ChangedFiles/ChangedLines stay local git ops the agent can run directly against its bind-mounted worktree — only Push needed proxying. Not yet wired into daemon.go or workflow.TaskContext — deferred to archie-core-5zh.4, which now has all three RPC proxies (Store, Forge, worktree push) it depends on."}}
|
||||
{"id":"int-22fa22c9e086bd94634514c7a7708cfb","kind":"field_change","created_at":"2026-07-23T22:28:08.383511654Z","actor":"Sam Catlow","issue_id":"archie-core-5zh.4","extra":{"field":"status","new_value":"closed","old_value":"open","reason":"Superseded by finer-grained sub-issues 5zh.5 (TaskConfig payload), 5zh.6 (TaskContext interface refactor), 5zh.7 (archie-agent full-task handler), 5zh.8 (daemon.go handoff), 5zh.9 (register RPC servers in archied). The original single acceptance criterion (workflow.Route/Run execute in archie-agent) is satisfied once 5zh.7 and 5zh.8 land; splitting further because implementation revealed real design forks (Prepare needing the push token, tc.Cfg needing a curated non-secret payload) that each warrant their own test-first pass."}}
|
||||
{"id":"int-52ef9df12424463a13205bb9f244a308","kind":"field_change","created_at":"2026-07-23T22:51:47.945822737Z","actor":"Sam Catlow","issue_id":"archie-core-5zh.5","extra":{"field":"status","new_value":"closed","old_value":"in_progress","reason":"Implemented curated non-secret TaskConfig/TaskForge payload with detached map snapshots, stable JSON Duration encoding, full Repo JSON tags, and regression coverage. Focused config tests, go vet, go fix -diff, and full race suite pass; repository-wide lint remains blocked only by 36 unrelated pre-existing findings."}}
|
||||
+6
-1
@@ -1,7 +1,12 @@
|
||||
{"_type":"issue","id":"archie-core-u64","title":"Daemon: process multiple tasks concurrently (max_concurrency enforcement)","description":"Daemon currently processes one task at a time (docs/prds/archie-core-v2-architecture.md Phase 2). This is the core blocker between current state and any multi-agent scaling mode — needed before container max_concurrency or same-repo concurrency can matter. Wire the daemon's dispatch loop to run N tasks in parallel, respecting a configurable max_concurrency.","design":"internal/container/pool.go already enforces max_concurrency for container lifecycle — reuse that limit/pattern in the daemon's task dispatch rather than inventing a second concurrency control.","acceptance_criteria":"Daemon dispatch loop runs multiple tasks concurrently up to a configured max_concurrency limit; single-task-at-a-time behavior is gone.","status":"closed","priority":1,"issue_type":"feature","assignee":"Sam Catlow","owner":"sam@catlow.tech","created_at":"2026-07-23T19:36:31Z","created_by":"Sam Catlow","updated_at":"2026-07-23T21:37:42Z","started_at":"2026-07-23T21:29:41Z","closed_at":"2026-07-23T21:37:42Z","close_reason":"Implemented concurrent SQLite and NATS task dispatch using containers.max_concurrency, with default same-repo serialization and race-tested dispatcher coverage.","dependency_count":0,"dependent_count":2,"comment_count":0}
|
||||
{"_type":"issue","id":"archie-core-5zh.7","title":"archie-agent: run full task (workflow.Route + workflow.Run) via RPC-backed TaskContext","description":"The actual stage-loop move for archie-core-5zh, depending on the TaskConfig payload and TaskContext interface refactor. cmd/archie-agent gains a handler for a new 'run whole task' NATS message (task summary + TaskConfig + repo config, no secrets). On receipt it: builds its own workflow.Registry via skillbuild.BuildRegistry against its mounted worktree (/data/worktree — same pattern the daemon already uses, no registry needs to cross the wire); calls workflow.Route itself; builds a TaskContext using storerpc.Client (Store), forgerpc.Client (Forge), and a hybrid Trees (worktreerpc.Client for Prepare/Push, a local *worktree.Manager with no token for CommitAll/Diff/ChangedFiles/ChangedLines against the bind-mounted dir); calls workflow.Run; reports completion once instead of round-tripping per stage.","acceptance_criteria":"When agent.mode=nats and containers are enabled, archie-agent runs an entire task's workflow (all stages) per invocation, not one stage per round trip; inprocess/subprocess modes are unaffected.","status":"open","priority":2,"issue_type":"task","owner":"sam@catlow.tech","created_at":"2026-07-23T22:28:00Z","created_by":"Sam Catlow","updated_at":"2026-07-23T22:28:00Z","dependencies":[{"issue_id":"archie-core-5zh.7","depends_on_id":"archie-core-5zh","type":"parent-child","created_at":"2026-07-24T08:27:59Z","created_by":"Sam Catlow","metadata":"{}"},{"issue_id":"archie-core-5zh.7","depends_on_id":"archie-core-5zh.5","type":"blocks","created_at":"2026-07-24T08:28:07Z","created_by":"Sam Catlow","metadata":"{}"},{"issue_id":"archie-core-5zh.7","depends_on_id":"archie-core-5zh.6","type":"blocks","created_at":"2026-07-24T08:28:07Z","created_by":"Sam Catlow","metadata":"{}"}],"dependency_count":2,"dependent_count":1,"comment_count":0}
|
||||
{"_type":"issue","id":"archie-core-5zh.8","title":"daemon.go: hand off whole task to archie-agent in sandboxed NATS+container mode","description":"Depends on the archie-agent full-task handler existing. internal/daemon/daemon.go's process() currently always calls workflow.Route/workflow.Run itself, dispatching per-stage LLM calls to d.Agent (NATSRunner does this over NATS today). When d.Nats != nil \u0026\u0026 d.ContainerPool != nil (the sandboxed path this whole PRD phase targets), process() should instead publish one 'run whole task' message to archie-agent and await its completion report, skipping local workflow.Route/workflow.Run entirely. inprocess/subprocess modes (no container pool) keep calling workflow.Run in the daemon exactly as today — this only changes behavior for the fully-sandboxed path.","acceptance_criteria":"With containers enabled, daemon.process() delegates the entire task to archie-agent in one round trip; without containers, behavior is unchanged (verified by existing daemon tests continuing to pass).","status":"open","priority":2,"issue_type":"task","owner":"sam@catlow.tech","created_at":"2026-07-23T22:28:00Z","created_by":"Sam Catlow","updated_at":"2026-07-23T22:28:00Z","dependencies":[{"issue_id":"archie-core-5zh.8","depends_on_id":"archie-core-5zh.7","type":"blocks","created_at":"2026-07-24T08:28:07Z","created_by":"Sam Catlow","metadata":"{}"},{"issue_id":"archie-core-5zh.8","depends_on_id":"archie-core-5zh","type":"parent-child","created_at":"2026-07-24T08:28:00Z","created_by":"Sam Catlow","metadata":"{}"}],"dependency_count":1,"dependent_count":0,"comment_count":0}
|
||||
{"_type":"issue","id":"archie-core-5zh.9","title":"Register storerpc/forgerpc/worktreerpc servers in archied startup","description":"Depends on the TaskContext interface refactor. cmd/archied/main.go builds the Daemon with Store/Forge/Trees but never registers the storerpc.Server/forgerpc.Server/worktreerpc.Server handlers, so archie-agent's RPC calls currently have no responder in production. Wire all three Register(nc) calls into archied's startup when cfg.NATS is configured, alongside the existing NATS client connect.","acceptance_criteria":"When [nats] is configured, archied subscribes to all storerpc/forgerpc/worktreerpc subjects at startup; an archie-agent container can successfully call Store/Forge/worktree operations against a running archied.","status":"open","priority":2,"issue_type":"task","owner":"sam@catlow.tech","created_at":"2026-07-23T22:28:00Z","created_by":"Sam Catlow","updated_at":"2026-07-23T22:28:00Z","dependencies":[{"issue_id":"archie-core-5zh.9","depends_on_id":"archie-core-5zh","type":"parent-child","created_at":"2026-07-24T08:28:00Z","created_by":"Sam Catlow","metadata":"{}"},{"issue_id":"archie-core-5zh.9","depends_on_id":"archie-core-5zh.6","type":"blocks","created_at":"2026-07-24T08:28:08Z","created_by":"Sam Catlow","metadata":"{}"}],"dependency_count":1,"dependent_count":0,"comment_count":0}
|
||||
{"_type":"issue","id":"archie-core-5zh.5","title":"Curated TaskConfig payload for archie-agent (no secrets)","description":"Groundwork for archie-core-5zh.4. workflow.TaskContext.Cfg (config.Config) is read throughout stages (Models, Budgets, Dispatch incl. label mapping, DiffCapLines, Notify.Webhook, Forge.Host) but the full Config also carries forge/NATS credentials that must never enter the agent container. Add a config.TaskConfig struct — same field names/shapes as the subset config.Config exposes (Models, Budgets, Dispatch, DiffCapLines, Notify, Forge) — with json tags, plus a constructor (e.g. config.Config.ForTask()) that builds it from the daemon's live config. Add json tags to config.Repo's remaining fields (only AllowConcurrent has them today) since tc.Repo also needs to cross the wire.","acceptance_criteria":"config.TaskConfig marshals/unmarshals via JSON and carries exactly the fields workflow stages read; no token/credential field is reachable from it; config.Repo fully round-trips through JSON.","status":"closed","priority":2,"issue_type":"task","assignee":"Sam Catlow","owner":"sam@catlow.tech","created_at":"2026-07-23T22:27:59Z","created_by":"Sam Catlow","updated_at":"2026-07-23T22:51:48Z","started_at":"2026-07-23T22:43:06Z","closed_at":"2026-07-23T22:51:48Z","close_reason":"Implemented curated non-secret TaskConfig/TaskForge payload with detached map snapshots, stable JSON Duration encoding, full Repo JSON tags, and regression coverage. Focused config tests, go vet, go fix -diff, and full race suite pass; repository-wide lint remains blocked only by 36 unrelated pre-existing findings.","dependencies":[{"issue_id":"archie-core-5zh.5","depends_on_id":"archie-core-5zh","type":"parent-child","created_at":"2026-07-24T08:27:58Z","created_by":"Sam Catlow","metadata":"{}"}],"dependency_count":0,"dependent_count":1,"comment_count":0}
|
||||
{"_type":"issue","id":"archie-core-5zh.6","title":"TaskContext interface refactor: Forge/Store/Trees as trimmed interfaces","description":"Groundwork for archie-core-5zh.4. workflow.TaskContext currently types Forge/Store/Trees as concrete daemon types (forge.Forge interface already, *store.Store, *worktree.Manager). Define trimmed interfaces in internal/workflow scoped to exactly the methods stages call (Forge: Comment/CloseIssue/CreatePR/SetStateLabel; Store: Update/Transition; Trees: Prepare/CommitAll/Push/Diff/ChangedFiles/ChangedLines) so storerpc.Client, forgerpc.Client, and a worktreerpc-backed implementation can satisfy them from inside archie-agent, while *store.Store/*worktree.Manager and the real forge.Forge implementations keep satisfying them unchanged for the daemon's existing inprocess/subprocess paths.","acceptance_criteria":"TaskContext.Forge/Store/Trees are interface-typed; daemon.go compiles and all existing tests pass unchanged (concrete types satisfy the new interfaces structurally); no behavior change for inprocess/subprocess modes.","status":"open","priority":2,"issue_type":"task","owner":"sam@catlow.tech","created_at":"2026-07-23T22:27:59Z","created_by":"Sam Catlow","updated_at":"2026-07-23T22:27:59Z","dependencies":[{"issue_id":"archie-core-5zh.6","depends_on_id":"archie-core-5zh","type":"parent-child","created_at":"2026-07-24T08:27:59Z","created_by":"Sam Catlow","metadata":"{}"}],"dependency_count":0,"dependent_count":2,"comment_count":0}
|
||||
{"_type":"issue","id":"archie-core-5zh.2","title":"Forge RPC proxy: archie-agent → archied for forge API calls","description":"Phase 1 groundwork for archie-core-5zh. Stages call Forge.SetStateLabel/Comment/CreatePR/CloseIssue/CreateIssue/React/RepliesAfter mid-workflow. Forge holds live API tokens (Gitea/GitHub) that must stay daemon-side per the PRD's 'daemon never runs untrusted code, owns all secrets' boundary. Once workflow.Run moves into archie-agent, these calls need to become NATS request/reply RPCs to the daemon rather than shipping forge credentials into the agent container.","acceptance_criteria":"archie-agent can invoke the forge.Forge interface methods used by workflow stages over NATS; archied executes them against the real forge client and replies; no forge API tokens are present in the agent container.","status":"closed","priority":2,"issue_type":"task","assignee":"Sam Catlow","owner":"sam@catlow.tech","created_at":"2026-07-23T21:55:44Z","created_by":"Sam Catlow","updated_at":"2026-07-23T22:02:41Z","started_at":"2026-07-23T22:00:46Z","closed_at":"2026-07-23T22:02:41Z","close_reason":"Added internal/forgerpc: core-NATS request/reply RPC for the four forge.Forge methods workflow stages actually call mid-run (Comment, CloseIssue, CreatePR, SetStateLabel). Confirmed via grep that all other Forge methods (AssignedIssues, IssuesWithLabel, React, RepliesAfter, PRState, CreateIssue, AcceptInvitations, VerifyPush) are daemon-only poll/reconcile-loop calls, never invoked from a workflow stage, so nothing else needs proxying. archied stays the sole holder of forge API tokens. Not yet wired into daemon.go or workflow.TaskContext — deferred to archie-core-5zh.4.","dependencies":[{"issue_id":"archie-core-5zh.2","depends_on_id":"archie-core-5zh","type":"parent-child","created_at":"2026-07-24T07:55:43Z","created_by":"Sam Catlow","metadata":"{}"}],"dependency_count":0,"dependent_count":1,"comment_count":0}
|
||||
{"_type":"issue","id":"archie-core-5zh.3","title":"Worktree push RPC proxy: archie-agent → archied for git push","description":"Phase 1 groundwork for archie-core-5zh. worktree.Manager.Push needs the forge HTTPS push token (held daemon-side, used via an askpass helper). Trees.Prepare/CommitAll/Diff/ChangedFiles/ChangedLines are local git operations against the already-mounted worktree and can run agent-side unchanged (containers already bind-mount /data/worktree) — only Push needs to be proxied back to the daemon, which holds the credential.","acceptance_criteria":"archie-agent can request a git push over NATS; archied performs the authenticated push using its held token and replies with success/failure; the push token is never sent to or stored in the agent container.","status":"closed","priority":2,"issue_type":"task","assignee":"Sam Catlow","owner":"sam@catlow.tech","created_at":"2026-07-23T21:55:44Z","created_by":"Sam Catlow","updated_at":"2026-07-23T22:05:10Z","started_at":"2026-07-23T22:02:54Z","closed_at":"2026-07-23T22:05:10Z","close_reason":"Added internal/worktreerpc: core-NATS request/reply RPC so archie-agent can request a git push without holding the forge push token. Server resolves the worktree directory itself from owner/repo/issue (never trusts a path from the sandboxed agent) and calls the daemon's own worktree.Manager.Push, which already holds the token via its askpass helper. Prepare/CommitAll/Diff/ChangedFiles/ChangedLines stay local git ops the agent can run directly against its bind-mounted worktree — only Push needed proxying. Not yet wired into daemon.go or workflow.TaskContext — deferred to archie-core-5zh.4, which now has all three RPC proxies (Store, Forge, worktree push) it depends on.","dependencies":[{"issue_id":"archie-core-5zh.3","depends_on_id":"archie-core-5zh","type":"parent-child","created_at":"2026-07-24T07:55:43Z","created_by":"Sam Catlow","metadata":"{}"}],"dependency_count":0,"dependent_count":1,"comment_count":0}
|
||||
{"_type":"issue","id":"archie-core-5zh.4","title":"Move workflow.Route/workflow.Run stage loop into archie-agent","description":"Final step of archie-core-5zh, depends on the Store/Forge/push RPC proxies existing. Move workflow.Route + workflow.Run's stage-loop execution from internal/daemon/daemon.go's process() into cmd/archie-agent, using the RPC proxies for Store/Forge/push and reimplementing CustomStages discovery (wfeval.Discover) agent-side against the already-mounted worktree. daemon.process() keeps worktree prepare + container acquire/release, then hands off the whole task to archie-agent in one NATS round trip instead of one round trip per stage.","acceptance_criteria":"workflow.Route and workflow.Run execute inside archie-agent, not archied, when agent.mode=nats; archie-agent handles a full task (not a single stage) per invocation; inprocess/subprocess modes keep working unchanged.","status":"open","priority":2,"issue_type":"task","owner":"sam@catlow.tech","created_at":"2026-07-23T21:55:44Z","created_by":"Sam Catlow","updated_at":"2026-07-23T21:55:44Z","dependencies":[{"issue_id":"archie-core-5zh.4","depends_on_id":"archie-core-5zh.1","type":"blocks","created_at":"2026-07-24T07:55:48Z","created_by":"Sam Catlow","metadata":"{}"},{"issue_id":"archie-core-5zh.4","depends_on_id":"archie-core-5zh","type":"parent-child","created_at":"2026-07-24T07:55:44Z","created_by":"Sam Catlow","metadata":"{}"},{"issue_id":"archie-core-5zh.4","depends_on_id":"archie-core-5zh.3","type":"blocks","created_at":"2026-07-24T07:55:49Z","created_by":"Sam Catlow","metadata":"{}"},{"issue_id":"archie-core-5zh.4","depends_on_id":"archie-core-5zh.2","type":"blocks","created_at":"2026-07-24T07:55:49Z","created_by":"Sam Catlow","metadata":"{}"}],"dependency_count":3,"dependent_count":0,"comment_count":0}
|
||||
{"_type":"issue","id":"archie-core-5zh.4","title":"Move workflow.Route/workflow.Run stage loop into archie-agent","description":"Final step of archie-core-5zh, depends on the Store/Forge/push RPC proxies existing. Move workflow.Route + workflow.Run's stage-loop execution from internal/daemon/daemon.go's process() into cmd/archie-agent, using the RPC proxies for Store/Forge/push and reimplementing CustomStages discovery (wfeval.Discover) agent-side against the already-mounted worktree. daemon.process() keeps worktree prepare + container acquire/release, then hands off the whole task to archie-agent in one NATS round trip instead of one round trip per stage.","acceptance_criteria":"workflow.Route and workflow.Run execute inside archie-agent, not archied, when agent.mode=nats; archie-agent handles a full task (not a single stage) per invocation; inprocess/subprocess modes keep working unchanged.","status":"closed","priority":2,"issue_type":"task","owner":"sam@catlow.tech","created_at":"2026-07-23T21:55:44Z","created_by":"Sam Catlow","updated_at":"2026-07-23T22:28:08Z","closed_at":"2026-07-23T22:28:08Z","close_reason":"Superseded by finer-grained sub-issues 5zh.5 (TaskConfig payload), 5zh.6 (TaskContext interface refactor), 5zh.7 (archie-agent full-task handler), 5zh.8 (daemon.go handoff), 5zh.9 (register RPC servers in archied). The original single acceptance criterion (workflow.Route/Run execute in archie-agent) is satisfied once 5zh.7 and 5zh.8 land; splitting further because implementation revealed real design forks (Prepare needing the push token, tc.Cfg needing a curated non-secret payload) that each warrant their own test-first pass.","dependencies":[{"issue_id":"archie-core-5zh.4","depends_on_id":"archie-core-5zh.1","type":"blocks","created_at":"2026-07-24T07:55:48Z","created_by":"Sam Catlow","metadata":"{}"},{"issue_id":"archie-core-5zh.4","depends_on_id":"archie-core-5zh","type":"parent-child","created_at":"2026-07-24T07:55:44Z","created_by":"Sam Catlow","metadata":"{}"},{"issue_id":"archie-core-5zh.4","depends_on_id":"archie-core-5zh.3","type":"blocks","created_at":"2026-07-24T07:55:49Z","created_by":"Sam Catlow","metadata":"{}"},{"issue_id":"archie-core-5zh.4","depends_on_id":"archie-core-5zh.2","type":"blocks","created_at":"2026-07-24T07:55:49Z","created_by":"Sam Catlow","metadata":"{}"}],"dependency_count":3,"dependent_count":0,"comment_count":0}
|
||||
{"_type":"issue","id":"archie-core-5zh.1","title":"Store RPC proxy: archie-agent → archied for task state mutations","description":"Phase 1 groundwork for archie-core-5zh. workflow.Run calls tc.Store.Update every stage and tc.Store.Transition on terminal outcomes — Store wraps a direct SQLite *sql.DB handle that only the daemon owns. Once workflow.Run moves into archie-agent, these calls need to become NATS request/reply RPCs to the daemon (the sole DB owner), reusing the existing AgentRequestMessage/reply-inbox plumbing pattern (internal/agentexec/nats.go) rather than giving the agent container direct DB access.","acceptance_criteria":"archie-agent can call Store.Update and Store.Transition equivalents over NATS; archied executes them against SQLite and replies; no direct DB access from the agent container.","status":"closed","priority":2,"issue_type":"task","assignee":"Sam Catlow","owner":"sam@catlow.tech","created_at":"2026-07-23T21:55:43Z","created_by":"Sam Catlow","updated_at":"2026-07-23T21:58:51Z","started_at":"2026-07-23T21:55:58Z","closed_at":"2026-07-23T21:58:51Z","close_reason":"Added internal/storerpc: core-NATS request/reply RPC so archie-agent can call Store.Update/Transition without direct DB access. archied's Store stays the sole owner; store.Task gained json tags to cross the wire. Not yet wired into daemon.go or workflow.TaskContext — that's archie-core-5zh.4's job once all three RPC proxies exist.","dependencies":[{"issue_id":"archie-core-5zh.1","depends_on_id":"archie-core-5zh","type":"parent-child","created_at":"2026-07-24T07:55:43Z","created_by":"Sam Catlow","metadata":"{}"}],"dependency_count":0,"dependent_count":1,"comment_count":0}
|
||||
{"_type":"issue","id":"archie-core-358","title":"ContainerRunner: implement agentexec.Runner against Docker for sandboxed execution","description":"Phase 2 of docs/prds/archie-core-v2-architecture.md. agentexec.Runner (InProcessRunner/SubprocessRunner) is an interface deliberately designed to be swapped for a container-backed runner without touching workflow orchestration. internal/container/pool.go already handles Docker lifecycle (pull, create, start, release, orphan recovery). Implement ContainerRunner against the existing Runner interface.","design":"Do not redesign the execution boundary — implement strictly against the existing Runner interface per its doc comments.","acceptance_criteria":"ContainerRunner implements agentexec.Runner, runs tasks in ephemeral Docker containers with workspace bind-mounted, and is selectable via [agent] mode = \"nats\" + containers.enabled = true.","status":"open","priority":2,"issue_type":"feature","owner":"sam@catlow.tech","created_at":"2026-07-23T19:36:32Z","created_by":"Sam Catlow","updated_at":"2026-07-23T19:36:32Z","dependencies":[{"issue_id":"archie-core-358","depends_on_id":"archie-core-5zh","type":"blocks","created_at":"2026-07-24T05:36:37Z","created_by":"Sam Catlow","metadata":"{}"}],"dependency_count":1,"dependent_count":1,"comment_count":0}
|
||||
{"_type":"issue","id":"archie-core-5zh","title":"Promote archie-agent to per-task process; move workflow routing out of archied","description":"cmd/archie-agent exists but only executes one workflow stage per invocation over the internal/agentexec stdin/stdout JSON protocol (v1). Phase 1 of the PRD requires promoting it to the PRD's per-task process model, moving workflow.Route/workflow.Run out of archied and into archie-agent.","acceptance_criteria":"workflow.Route and workflow.Run execute inside archie-agent, not archied; archie-agent handles a full task (not a single stage) per invocation.","status":"in_progress","priority":2,"issue_type":"task","assignee":"Sam Catlow","owner":"sam@catlow.tech","created_at":"2026-07-23T19:36:32Z","created_by":"Sam Catlow","updated_at":"2026-07-23T21:51:46Z","started_at":"2026-07-23T21:51:46Z","dependencies":[{"issue_id":"archie-core-5zh","depends_on_id":"archie-core-l1q","type":"blocks","created_at":"2026-07-24T05:36:36Z","created_by":"Sam Catlow","metadata":"{}"}],"dependency_count":1,"dependent_count":1,"comment_count":0}
|
||||
|
||||
+73
-19
@@ -3,8 +3,10 @@
|
||||
package config
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"maps"
|
||||
"net/url"
|
||||
"os"
|
||||
"path/filepath"
|
||||
@@ -26,52 +28,66 @@ func (d *Duration) UnmarshalText(b []byte) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// MarshalJSON encodes a Duration using the same string representation as TOML.
|
||||
func (d Duration) MarshalJSON() ([]byte, error) {
|
||||
return json.Marshal(d.Std().String())
|
||||
}
|
||||
|
||||
// UnmarshalJSON decodes a duration string such as "60s".
|
||||
func (d *Duration) UnmarshalJSON(data []byte) error {
|
||||
var value string
|
||||
if err := json.Unmarshal(data, &value); err != nil {
|
||||
return fmt.Errorf("duration must be a string: %w", err)
|
||||
}
|
||||
return d.UnmarshalText([]byte(value))
|
||||
}
|
||||
|
||||
func (d Duration) Std() time.Duration { return time.Duration(d) }
|
||||
|
||||
// Repo is one managed repository.
|
||||
type Repo struct {
|
||||
Owner string `toml:"owner"`
|
||||
Name string `toml:"name"`
|
||||
Owner string `toml:"owner" json:"owner"`
|
||||
Name string `toml:"name" json:"name"`
|
||||
// Base is the branch PRs target. Defaults to "main".
|
||||
Base string `toml:"base"`
|
||||
Base string `toml:"base" json:"base"`
|
||||
// Gate is the quality-gate command list for this repo, e.g.
|
||||
// [["go","vet","./..."], ["task","check"]]. By convention the
|
||||
// LAST command is the test runner — TDD workflows invert only
|
||||
// that one with ExpectFailure during the repro stage and re-run
|
||||
// it in capture-proof. Workflow stages may extend or override
|
||||
// Gate (a TDD repro stage inverts the test command).
|
||||
Gate [][]string `toml:"gate"`
|
||||
Gate [][]string `toml:"gate" json:"gate"`
|
||||
// Protect lists path suffixes agents must never write directly —
|
||||
// generated files (e.g. "_templ.go") whose sources they should edit
|
||||
// instead. Enforced environmentally via agentloop.ProtectPaths.
|
||||
Protect []string `toml:"protect"`
|
||||
Protect []string `toml:"protect" json:"protect"`
|
||||
|
||||
// Ecosystem selects a default preflight check and test-file glob
|
||||
// ("go", "python", "node", "rust", or "custom"). Empty defaults
|
||||
// to "go" for backward compatibility.
|
||||
Ecosystem string `toml:"ecosystem"`
|
||||
Ecosystem string `toml:"ecosystem" json:"ecosystem"`
|
||||
// Preflight is an explicit override for the ecosystem's default
|
||||
// preflight commands. Empty inherits the ecosystem default.
|
||||
Preflight [][]string `toml:"preflight"`
|
||||
Preflight [][]string `toml:"preflight" json:"preflight"`
|
||||
// TestGlob is an explicit override for the ecosystem's default
|
||||
// test-file pattern (e.g. "*_test.go"). Empty inherits the
|
||||
// ecosystem default.
|
||||
TestGlob string `toml:"test_glob"`
|
||||
TestGlob string `toml:"test_glob" json:"test_glob"`
|
||||
// PersistentStorage creates a named Docker volume for this repo
|
||||
// (archie-repo-<owner>-<repo>) mounted at /data/repo. The volume
|
||||
// survives task completion and retains data across tasks. Use for
|
||||
// repos with expensive build artifacts or large dependency trees.
|
||||
PersistentStorage bool `toml:"persistent_storage"`
|
||||
PersistentStorage bool `toml:"persistent_storage" json:"persistent_storage"`
|
||||
// MaxRetries caps how many times a parked task is retried before
|
||||
// being permanently parked (status "dead"). 0 means use the
|
||||
// global Config.MaxRetries.
|
||||
MaxRetries int `toml:"max_retries"`
|
||||
MaxRetries int `toml:"max_retries" json:"max_retries"`
|
||||
// AllowConcurrent lets the daemon dispatch multiple tasks for this
|
||||
// repo at once instead of the default FIFO one-task-per-repo
|
||||
// serialization. Only safe for repos where concurrent worktrees
|
||||
// won't collide (e.g. different base branches or packages per
|
||||
// task). Still bounded by [containers].max_concurrency globally.
|
||||
AllowConcurrent bool `toml:"allow_concurrent"`
|
||||
AllowConcurrent bool `toml:"allow_concurrent" json:"allow_concurrent"`
|
||||
}
|
||||
|
||||
// Protected reports whether path matches a protected suffix.
|
||||
@@ -139,10 +155,10 @@ func (r Repo) EffectiveMaxRetries(global int) int {
|
||||
|
||||
// Budgets bound every agent stage. Zero disables a limit.
|
||||
type Budgets struct {
|
||||
MaxSteps int `toml:"max_steps"`
|
||||
MaxTokens int `toml:"max_tokens"`
|
||||
WallClock Duration `toml:"wall_clock"`
|
||||
GateMaxFailures int `toml:"gate_max_failures"`
|
||||
MaxSteps int `toml:"max_steps" json:"max_steps"`
|
||||
MaxTokens int `toml:"max_tokens" json:"max_tokens"`
|
||||
WallClock Duration `toml:"wall_clock" json:"wall_clock"`
|
||||
GateMaxFailures int `toml:"gate_max_failures" json:"gate_max_failures"`
|
||||
}
|
||||
|
||||
// Provider configures one LLM provider for the runtime catalog.
|
||||
@@ -175,16 +191,16 @@ type Forge struct {
|
||||
type Dispatch struct {
|
||||
// Trigger is how tasks are discovered: "assignee" (poll assigned
|
||||
// issues), "label" (poll labelled issues), or "either" (both).
|
||||
Trigger string `toml:"trigger"`
|
||||
Trigger string `toml:"trigger" json:"trigger"`
|
||||
// AckReaction is the emoji reaction posted on issue pickup. Set
|
||||
// ack_reaction = "off" in TOML to disable it; Load normalizes that
|
||||
// sentinel to an empty string for callers.
|
||||
AckReaction string `toml:"ack_reaction"`
|
||||
AckReaction string `toml:"ack_reaction" json:"ack_reaction"`
|
||||
// Labels maps state names ("queued", "working", "waiting", "pr",
|
||||
// "parked") to their forge label strings. Each key is defaulted
|
||||
// independently; missing keys fall back to the legacy archie:*
|
||||
// constants at call time via StateLabel().
|
||||
Labels map[string]string `toml:"labels"`
|
||||
Labels map[string]string `toml:"labels" json:"labels"`
|
||||
}
|
||||
|
||||
// dispatchLabelDefaults is the fallback label set, reproducing the
|
||||
@@ -272,6 +288,44 @@ type Config struct {
|
||||
Repos []Repo `toml:"repos"`
|
||||
}
|
||||
|
||||
// TaskConfig is the non-secret subset of Config needed to run workflow
|
||||
// stages. It is safe to send to an archie-agent container.
|
||||
type TaskConfig struct {
|
||||
Models map[string]string `json:"models"`
|
||||
Budgets Budgets `json:"budgets"`
|
||||
Dispatch Dispatch `json:"dispatch"`
|
||||
DiffCapLines int `json:"diff_cap_lines"`
|
||||
Notify Notify `json:"notify"`
|
||||
Forge TaskForge `json:"forge"`
|
||||
}
|
||||
|
||||
// TaskForge is the non-secret forge configuration needed by workflow stages.
|
||||
type TaskForge struct {
|
||||
Host string `json:"host"`
|
||||
}
|
||||
|
||||
// ForTask returns a detached, non-secret snapshot of the configuration fields
|
||||
// needed to run a workflow.
|
||||
func (c Config) ForTask() TaskConfig {
|
||||
return TaskConfig{
|
||||
Models: cloneStringMap(c.Models),
|
||||
Budgets: c.Budgets,
|
||||
Dispatch: Dispatch{Trigger: c.Dispatch.Trigger, AckReaction: c.Dispatch.AckReaction, Labels: cloneStringMap(c.Dispatch.Labels)},
|
||||
DiffCapLines: c.DiffCapLines,
|
||||
Notify: c.Notify,
|
||||
Forge: TaskForge{Host: c.Forge.Host},
|
||||
}
|
||||
}
|
||||
|
||||
func cloneStringMap(src map[string]string) map[string]string {
|
||||
if src == nil {
|
||||
return nil
|
||||
}
|
||||
dst := make(map[string]string, len(src))
|
||||
maps.Copy(dst, src)
|
||||
return dst
|
||||
}
|
||||
|
||||
// NATSConfig configures NATS JetStream for task distribution. When URL is
|
||||
// empty the existing SQLite ClaimNext flow is used unchanged.
|
||||
type NATSConfig struct {
|
||||
@@ -302,7 +356,7 @@ type ContainerConfig struct {
|
||||
type Notify struct {
|
||||
// Webhook receives JSON POSTs for events that need a human (e.g.
|
||||
// feasibility PRDs awaiting go/no-go). Empty disables.
|
||||
Webhook string `toml:"webhook"`
|
||||
Webhook string `toml:"webhook" json:"webhook"`
|
||||
}
|
||||
|
||||
// Web configures the observability dashboard.
|
||||
|
||||
@@ -1,12 +1,181 @@
|
||||
package config
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"reflect"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
func TestConfigForTaskJSONRoundTrip(t *testing.T) {
|
||||
cfg := Config{
|
||||
DiffCapLines: 321,
|
||||
Models: map[string]string{
|
||||
"builder": "anthropic/claude",
|
||||
"planner": "openai/gpt",
|
||||
},
|
||||
Budgets: Budgets{
|
||||
MaxSteps: 12,
|
||||
MaxTokens: 34_000,
|
||||
WallClock: Duration(45 * time.Minute),
|
||||
GateMaxFailures: 3,
|
||||
},
|
||||
Dispatch: Dispatch{
|
||||
Trigger: "label",
|
||||
AckReaction: "eyes",
|
||||
Labels: map[string]string{"working": "bot:working"},
|
||||
},
|
||||
Notify: Notify{Webhook: "https://notify.example.test/hook"},
|
||||
Forge: Forge{
|
||||
Type: "github",
|
||||
Host: "https://forge.example.test",
|
||||
TokenEnv: "TOP_SECRET_FORGE_TOKEN",
|
||||
},
|
||||
Providers: map[string]Provider{
|
||||
"secret": {APIKeyEnv: "TOP_SECRET_PROVIDER_TOKEN"},
|
||||
},
|
||||
NATS: NATSConfig{TokenEnv: "TOP_SECRET_NATS_TOKEN"},
|
||||
}
|
||||
|
||||
want := TaskConfig{
|
||||
Models: cfg.Models,
|
||||
Budgets: cfg.Budgets,
|
||||
Dispatch: cfg.Dispatch,
|
||||
DiffCapLines: cfg.DiffCapLines,
|
||||
Notify: cfg.Notify,
|
||||
Forge: TaskForge{Host: cfg.Forge.Host},
|
||||
}
|
||||
got := cfg.ForTask()
|
||||
if !reflect.DeepEqual(got, want) {
|
||||
t.Fatalf("ForTask() = %#v, want %#v", got, want)
|
||||
}
|
||||
cfg.Models["source-only"] = "source/model"
|
||||
if _, ok := got.Models["source-only"]; ok {
|
||||
t.Fatal("ForTask().Models aliases Config.Models")
|
||||
}
|
||||
got.Models["task-only"] = "task/model"
|
||||
if _, ok := cfg.Models["task-only"]; ok {
|
||||
t.Fatal("Config.Models aliases ForTask().Models")
|
||||
}
|
||||
cfg.Dispatch.Labels["source-only"] = "source:label"
|
||||
if _, ok := got.Dispatch.Labels["source-only"]; ok {
|
||||
t.Fatal("ForTask().Dispatch.Labels aliases Config.Dispatch.Labels")
|
||||
}
|
||||
got.Dispatch.Labels["task-only"] = "task:label"
|
||||
if _, ok := cfg.Dispatch.Labels["task-only"]; ok {
|
||||
t.Fatal("Config.Dispatch.Labels aliases ForTask().Dispatch.Labels")
|
||||
}
|
||||
|
||||
data, err := json.Marshal(got)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
assertJSONKeys(t, data, "models", "budgets", "dispatch", "diff_cap_lines", "notify", "forge")
|
||||
|
||||
var forgePayload map[string]json.RawMessage
|
||||
var payload map[string]json.RawMessage
|
||||
if err := json.Unmarshal(data, &payload); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
var budgetsPayload map[string]json.RawMessage
|
||||
if err := json.Unmarshal(payload["budgets"], &budgetsPayload); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if string(budgetsPayload["wall_clock"]) != `"45m0s"` {
|
||||
t.Fatalf("wall_clock = %s, want JSON duration string", budgetsPayload["wall_clock"])
|
||||
}
|
||||
if err := json.Unmarshal(payload["forge"], &forgePayload); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if !reflect.DeepEqual(forgePayload, map[string]json.RawMessage{
|
||||
"host": json.RawMessage(`"https://forge.example.test"`),
|
||||
}) {
|
||||
t.Fatalf("forge payload = %s, want only host", payload["forge"])
|
||||
}
|
||||
for _, secret := range []string{
|
||||
cfg.Forge.TokenEnv,
|
||||
cfg.Providers["secret"].APIKeyEnv,
|
||||
cfg.NATS.TokenEnv,
|
||||
} {
|
||||
if strings.Contains(string(data), secret) {
|
||||
t.Fatalf("task config JSON contains credential reference %q: %s", secret, data)
|
||||
}
|
||||
}
|
||||
|
||||
var roundTripped TaskConfig
|
||||
if err := json.Unmarshal(data, &roundTripped); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if !reflect.DeepEqual(roundTripped, got) {
|
||||
t.Fatalf("JSON round trip = %#v, want %#v", roundTripped, got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestRepoJSONRoundTrip(t *testing.T) {
|
||||
repo := Repo{
|
||||
Owner: "acme",
|
||||
Name: "widget",
|
||||
Base: "develop",
|
||||
Gate: [][]string{{"task", "check"}, {"go", "test", "./..."}},
|
||||
Protect: []string{"_templ.go", ".generated"},
|
||||
Ecosystem: "go",
|
||||
Preflight: [][]string{{"go", "version"}},
|
||||
TestGlob: "*_test.go",
|
||||
PersistentStorage: true,
|
||||
MaxRetries: 4,
|
||||
AllowConcurrent: true,
|
||||
}
|
||||
|
||||
data, err := json.Marshal(repo)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
assertJSONKeys(t, data,
|
||||
"owner",
|
||||
"name",
|
||||
"base",
|
||||
"gate",
|
||||
"protect",
|
||||
"ecosystem",
|
||||
"preflight",
|
||||
"test_glob",
|
||||
"persistent_storage",
|
||||
"max_retries",
|
||||
"allow_concurrent",
|
||||
)
|
||||
|
||||
var got Repo
|
||||
if err := json.Unmarshal(data, &got); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if !reflect.DeepEqual(got, repo) {
|
||||
t.Fatalf("JSON round trip = %#v, want %#v", got, repo)
|
||||
}
|
||||
}
|
||||
|
||||
func assertJSONKeys(t *testing.T, data []byte, want ...string) {
|
||||
t.Helper()
|
||||
|
||||
var payload map[string]json.RawMessage
|
||||
if err := json.Unmarshal(data, &payload); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
got := make(map[string]bool, len(payload))
|
||||
for key := range payload {
|
||||
got[key] = true
|
||||
}
|
||||
wantSet := make(map[string]bool, len(want))
|
||||
for _, key := range want {
|
||||
wantSet[key] = true
|
||||
}
|
||||
if !reflect.DeepEqual(got, wantSet) {
|
||||
t.Fatalf("JSON keys = %v, want %v", got, wantSet)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDispatchDefaults(t *testing.T) {
|
||||
// Simulate a config with no [dispatch] section — all fields zero.
|
||||
var d Dispatch
|
||||
|
||||
Reference in new issue
Block a user