refactor(agentexec): remove legacy execution paths

Autonomous workflows now have exactly one production boundary: a task-scoped archie-agent receives a full-task core-NATS request and runs the worker-local stage loop. The legacy [agent] section remains decode-only for migration; it no longer selects runtime behavior.
This commit is contained in:
sam committed 2026-08-24 14:56:57 +10:00
1 parent cc6b093820
commit 5d00ec7b0c
65 files changed
+454 -2678

No files matched your search

+5 -4
View File
@@ -185,7 +185,8 @@ running after crash -> queued
Workflows select and sequence deterministic and agent-run stages. Implement,
TDD, feasibility, and bootstrap are current Workflow definitions.
WorkflowExecutions may run in-process or be handed wholesale to `archie-agent`.
Every WorkflowExecution is handed wholesale over core NATS to a task-scoped
`archie-agent` container, which owns the workflow stage loop.
## Current workflow-feature placement
@@ -222,7 +223,7 @@ each meaning deliberately; a global text replacement is prohibited.
| Per-stage `agentexec.Request.TaskID` | `internal/agentexec` | WorkflowExecutionID correlation | An agent invocation is a bounded WorkflowStep execution. Correlate request/result with WorkflowExecutionID, StepExecutionID, attempt, and protocol version. |
| NATS `TaskMessage` and `archie.task.*` | `internal/nats` | Channel request or WorkflowExecution transport | Discovery messages and execution dispatch are different contracts and subjects. Domain meaning stays outside NATS infrastructure. Identity and source-message idempotency must be explicit. |
| `taskDispatcher` work item | `internal/daemon` | WorkflowExecution scheduling | Scheduling operates on execution references and declared concurrency policy. Repository serialization is policy, not identity derived from an incomplete task struct. |
| `container.TaskPayload` and `task.json` | `internal/container`; read by `internal/infrastructure/agentboot` | WorkflowExecution brief | Rename the boot artifact and schema. It identifies the mounted execution and required workspace only; it is not an alternative execution definition. Malformed input must fail safely rather than silently joining an unrelated shared queue. |
| `container.TaskPayload` and `task.json` | `internal/container`; read by `internal/infrastructure/agentboot` | WorkflowExecution brief | Rename the boot artifact and schema. It identifies the mounted execution and required workspace only; it is not an alternative execution definition. Missing or malformed input must fail startup before the worker subscribes. |
| `storage.TaskRef` | `internal/storage` | WorkflowExecution workspace lease | Storage receives the minimal execution/workspace reference and policy required to provision and release resources. It does not receive the WorkflowExecution aggregate. |
| Gateway `TaskCreator` | `internal/gateway` | Accepted work request handoff | A channel may carry a request for durable workflow-backed work, but it does not request or create a WorkflowExecution directly. Work intake admits and routes the request; the Agent System consumes the accepted work request and is the sole owner of selecting a Workflow version and creating the WorkflowExecution. Ordinary agent interactions do not require this handoff. |
| Gateway `TaskController` and `ChatTaskStatus` | `internal/gateway/tasks.go` | WorkflowExecution commands and query view | Approve, cancel, and status use Agent System contracts. Channel code does not duplicate lifecycle constants or decide transitions. |
@@ -315,8 +316,8 @@ implemented in different packages:
configuration plus forge, store, worktree, agent, event bus, logging, memory,
guardrails, skills, and scratch state.
- Lifecycle changes occur in both daemon and workflow code.
- In-process and container execution place workflow orchestration on different
sides of the process boundary.
- Workflow orchestration runs inside task-scoped agent containers while the
daemon retains lifecycle, admission, and authority-bearing RPC ownership.
- Forge-backed and chat-created work share one record through source flags and
synthetic issue numbers.
- Repository labels currently select workflows and mirror task state, coupling
+10 -11
View File
@@ -171,19 +171,18 @@ and tests must decide:
Conversation branches do not create another memory scope. A memory action has
the same scoped effect regardless of which Conversation originated it.
### 6. Runtime and process boundaries
### 6. Runtime and process boundaries — DECIDED
The migration must decide which current execution paths survive:
`archied` is the native resident orchestration and interactive-chat process.
Every autonomous repository workflow crosses one full-task core-NATS handoff
into a task-scoped `archie-agent` container. Embedded versus external NATS
changes broker deployment only; it never selects an executor. The former host
in-process runner, per-stage NATS protocol, and subprocess runner are removed.
- in-process execution;
- `archie-agent` subprocess execution;
- NATS worker execution;
- container isolation;
- forge, store, and worktree RPC services.
The source architecture remains a modular monolith. A retained process boundary
requires a concrete security-isolation, failure-containment, scaling, or
operational justification. Possible future extraction is insufficient.
Forge, store, and worktree authority remains in `archied` and is exposed to the
task container through scoped RPC services. The worker runs the workflow and
its worker-local ai-sdk loop; it does not receive forge credentials or direct
store access. See `docs/prds/embedded-nats.md`.
### 7. Shared mechanics
+10 -17
View File
@@ -10,10 +10,8 @@ rotating file sink, a live `Feed` the dashboard subscribes to, and a reader
the `/api/logs` endpoint serves from. Before this implementation, none of
that reached inside a task.
A task's actual work happens in an `archie-agent` container, dispatched over
NATS (`[agent] mode = "nats"` is the only supported mode; the in-process
runner exists for tests and is being migrated away — see
[Decision: no new functionality on non-NATS transports](#decision-no-new-functionality-on-non-nats-transports)).
A task's actual work happens in a task-scoped `archie-agent` container,
dispatched as one complete workflow over NATS.
Before this design was implemented, five things destroyed the evidence of what
that container did:
@@ -51,18 +49,14 @@ intended to be usable by people other than the original operator. A system
that is only debuggable by an operator who happens to be watching `docker ps`
in real time does not meet that bar.
## Decision: NATS is the only transport this feature targets
## Decision: NATS is the sole autonomous handoff
`[agent] mode = "nats"` is the supported deployment; the agent image must
already be able to reach NATS in every deployment, because it is the *only*
channel carrying stage results back to the daemon — if it can't reach NATS,
the task cannot complete regardless of logging. The in-process runner
(`agentexec.InProcessRunner`) exists for tests and is being migrated away.
New functionality is NOT added to it or to any non-NATS path. A container
The agent image must reach NATS in every deployment, because the broker is the
only autonomous task handoff and the only channel carrying task results back
to the daemon. `archied` has no workflow runner or host fallback. A container
that dies before establishing a NATS connection is a distinct, narrower
failure (connectivity/config) from the one this document addresses (a
connected container's own output being unrecoverable), and is out of scope
here.
failure (connectivity/config) from the one this document addresses (a connected
container's own output being unrecoverable), and is out of scope here.
## Implemented design
@@ -94,9 +88,8 @@ fail the run it is reporting on.
### Daemon side
`cmd/archied/main.go` currently registers `subscribeSystemLogs` once at
startup for the `.system` suffix of `agentexec.SubjectAgentWildcard`
(`"archie.agent.>"`). It demultiplexes by task ID, appends to that task's
`cmd/archied/main.go` registers `subscribeSystemLogs` once at startup on
`agentexec.SubjectSystemWildcard`. It demultiplexes by task ID, appends to that task's
sink, and publishes into the existing `logging.Feed` so live task output
appears on the dashboard exactly like daemon output. The approved target is
for this composition to move to `internal/app/archied`; that package does not
+10 -1
View File
@@ -1,9 +1,18 @@
# Adversarial self-review stage -- decision
**Status:** Decided, not yet implemented
**Status:** Superseded; requires redesign before implementation
**Date:** 2026-08-22
**Beads issue:** `archie-core-h019.1`, blocks `h019.2/.3/.4/.5`
> **Superseded 2026-08-24 by the full-task worker boundary.** This document is
> retained as the record of the earlier decision, not as an implementation
> contract. It assumes daemon-owned in-process execution and a daemon-side
> second `Pool.Acquire`; both call sites were removed by `archie-core-q15y`.
> The still-useful findings and lifecycle decisions below do not authorize an
> implementation. The feature must first decide how a fresh reviewer receives
> an isolated snapshot from inside the existing task-scoped worker without
> creating a host executor or a nested container lifecycle.
Answers the five questions in `h019.1`'s description against the actual
implement workflow, not designed from scratch: the gate pattern, the
container pool, and the workflow engine's `Outcome` mechanism already answer