refactor(agent): move worker runtime into application layer
cmd/archie-agent used to own worker construction, NATS lifecycle, task execution, MCP setup, and workflow wiring. It now owns process input only and invokes internal/app/agentworker, while transport-specific NATS, boot-brief, and git-safety mechanics live under infrastructure.
This commit is contained in:
1 parent
0243c13d37
commit
45345cdfb6
35 files changed
+2901
-689
No files matched your search
@@ -53,7 +53,7 @@ Do not simplify these facts into the target model:
|
||||
| Durable work | `store.Task` combines forge/chat source data, workflow position, output, retry, identity, and PR state. | `internal/store/store.go` |
|
||||
| Workflow | `internal/workflow` routes a `store.Task` into a `map[string]Workflow`, mutates a broad `TaskContext` through sequential stages. | `internal/workflow/workflow.go` |
|
||||
| Agent-stage boundary | Versioned `agentexec.Request`/`Result` carries one autonomous stage; validation correlates task, attempt, and stage. | `internal/agentexec/protocol.go` |
|
||||
| Container handoff | `internal/taskrun` carries entire task plus `config.Repo` and `config.TaskConfig`; `archie-agent` runs routing and sequencing. | `internal/taskrun/taskrun.go`; `cmd/archie-agent/main.go` |
|
||||
| Container handoff | `internal/taskrun` carries entire task plus `config.Repo` and `config.TaskConfig`; `internal/app/agentworker` owns routing and sequencing while its NATS adapter owns wire mechanics. | `internal/taskrun/taskrun.go`; `internal/app/agentworker/`; `internal/infrastructure/agenttransport/nats/` |
|
||||
| Git ownership | Daemon-owned worktree operations clone, commit, push, diff, and clean up. | `internal/worktree/`; `internal/workflow/steps.go`; `ARCHITECTURE.md` |
|
||||
| Enforcement | Gates, read-only/protected paths, TDD inverted test gates, and diff caps are represented outside prompt prose. | `internal/agentexec/inprocess.go`; `internal/workflow/{agent,tdd,steps}.go` |
|
||||
| Configuration | `internal/config.Config`, `IdentityConfig`, `Repo`, and task snapshots mix input decoding with runtime concerns. | `internal/config/config.go` |
|
||||
|
||||
@@ -8,7 +8,8 @@ description: "Trace Archie behavior and blast radius through Go source, types, s
|
||||
Use evidence from the current checkout to explain a behavior before changing it.
|
||||
Volatile tool facts below were verified on **2026-07-28**.
|
||||
|
||||
**Composition root**: `cmd/archied/main.go` and `cmd/archie-agent/`.
|
||||
**Composition roots**: `cmd/archied/main.go` (legacy wiring) and
|
||||
`internal/app/agentworker` (invoked by `cmd/archie-agent/main.go`).
|
||||
**Production wiring**: a path selected by a shipped entrypoint — not a
|
||||
constructor, decoder, or passing unit test. **State owner**: component with
|
||||
authority to validate and persist a state transition.
|
||||
@@ -63,7 +64,7 @@ Start at these verified anchors:
|
||||
| Concern | Current anchor |
|
||||
|---|---|
|
||||
| Resident daemon | `cmd/archied/main.go` → `run()` → `daemon.Daemon` |
|
||||
| Sandboxed worker | `cmd/archie-agent/main.go`, `cmd/archie-agent/taskrun.go` |
|
||||
| Sandboxed worker | `cmd/archie-agent/main.go` → `internal/app/agentworker/`; NATS boundary in `internal/infrastructure/agenttransport/nats/` |
|
||||
| Task orchestration | `internal/daemon/daemon.go`, `internal/workflow/` |
|
||||
| Task contracts and SQLite | `internal/store/interface.go`, `internal/store/` |
|
||||
| Production task persistence | `internal/store/`; `store.Open` in `cmd/archied/main.go` |
|
||||
@@ -176,7 +177,8 @@ test-only.
|
||||
1. Start at `cmd/archied/main.go:run`.
|
||||
2. Record config condition per branch.
|
||||
3. Follow concrete construction into `daemon.Daemon` and gateway start.
|
||||
4. For container/NATS behavior, also trace `cmd/archie-agent`.
|
||||
4. For container/NATS behavior, trace `cmd/archie-agent/main.go` into
|
||||
`internal/app/agentworker` and `internal/infrastructure/agenttransport/nats`.
|
||||
5. Trace both sides of every RPC/transport and error/timeout paths.
|
||||
6. Read contract/architecture tests.
|
||||
7. Confirm deploy inputs in Compose and CI.
|
||||
|
||||
@@ -91,7 +91,7 @@ commit `308c199`, not proof that Yaegi cannot run external commands.
|
||||
| Task discovery | `archie.task.>` in `ARCHIE_TASKS` | Work-queue retention; daemon durable `archie-daemon`; max deliver 3 |
|
||||
| Per-stage agent request | `archie.agent.<task>.request` | Reply inbox in `X-Archie-Reply`; wall-clock budget or 30m |
|
||||
| Full task handoff | `archie.taskrun.<task-id>` | Core request/reply; no-responder retry 20s every 250ms |
|
||||
| Store RPC | `archie.store.update`, `.transition` | Client timeout 60s by `cmd/archie-agent/taskrun.go` |
|
||||
| Store RPC | `archie.store.update`, `.transition` | Client timeout 60s composed by `internal/app/agentworker/worker.go` through the infrastructure transport |
|
||||
| Forge RPC | `archie.forge.*` | Error travels in a JSON envelope |
|
||||
| Worktree RPC | `archie.worktree.prepare`, `.push` | Server default handler bound 15m |
|
||||
| Discovery dedup | `Nats-Msg-Id: archie:<owner>/<repo>/<issue>` | JetStream duplicate window 2m |
|
||||
|
||||
Reference in new issue
Block a user