Commit Graph
6 Commits
Author SHA1 Message Date
sam f8df051b19 feat: bounded concurrent task dispatch in daemon (archie-core-u64)
Daemon previously processed one task at a time. Add bounded concurrent
dispatch for SQLite and NATS agent modes, reusing [containers].max_concurrency
(0 = unlimited). Same-repository tasks stay FIFO-serialized to avoid worktree
conflicts; different repositories now run concurrently.

Unblocks archie-core-l1q (NATS transport) and archie-core-g1l
(per-repo allow_concurrent override).
2026-07-24 07:42:13 +10:00
sam ce9ce050ed feat: close Gap 1 — per-task agent (multi-stage batch execution)
HandleMessage now supports two modes:
- Single-stage (Request only): backward compatible, no Workflow set
- Per-task batch (Workflow + Stages): runs all stages sequentially,
  accumulates tokens/iterations/notes, sets TaskCompleted on success

New fields:
- AgentRequestMessage.Stages []Request — batch of agent stages
- AgentResponseEnvelope.TaskCompleted bool — true when batch done

RunnerFactory injection for testability — HandleMessage accepts a
factory function. DefaultRunnerFactory creates InProcessRunner.
Tests use mockRunner.

runStages() executes each stage, stops on first failure, aggregates
results. Combined summary uses "[stage] summary" format.
2026-07-22 03:20:37 +10:00
sam e8ffa20b33 test: rewrite regression tests as behavioral (not structural)
Replaces field-existence checks with runtime behavior verification:

Gap 1 (per-task agent): FAILING
  TestHandleMessageReadsWorkflowField verifies HandleMessage produces
  different results when Workflow is set vs. unset. Currently identical
  — HandleMessage ignores the Workflow field. Must run full multi-stage
  workflow per PRD section 1.

Gap 3 (response/system split): PASSING
  TestHandleMessageRoutesSystemMessagesSeparately verifies Channel
  echoes from request to response. HandleMessage now reads input Channel
  and sets it on the response envelope. Subject functions verified
  distinct.

Gap 5 (daemon review): PASSING
  TestReviewResultBlocksOnResultWhenRejected verifies ReviewResult
  hook gates OnResult. Error blocks — OnResult never called. Nil
  allows — OnResult called normally.

Agent processing extracted into agentexec.HandleMessage for testability.
cmd/archie-agent delegates to it.
2026-07-22 03:13:57 +10:00
sam 326d2265a8 feat: close PRD gaps 1, 3, and 5
Gap 1 (per-task agent): add Workflow field to Request and
AgentRequestMessage. Populated from TaskContext by AgentStage
and forwarded through NATSRunner to the agent.

Gap 3 (response/system split): add SubjectForAgentResponse and
SubjectForAgentSystem to subjects.go. Add Channel field to
AgentResponseEnvelope ("response"|"system").

Gap 5 (daemon review): add ReviewResult hook to AgentStage.
Called after status check and before OnResult. Nil = pass-through
(current behaviour). When set, errors block the stage.

All seven regression tests pass.
2026-07-22 03:07:04 +10:00
sam c8b22aeb8e fix: three quick-wins to close PRD gaps
Gap 2 (MaxUptime): container created with context deadline when
MaxUptime > 0 — Docker kills the container on expiry.

Gap 6 (/data/ volume): mount worktree at /data/worktree instead of
/workspace, matching PRD section 3 volume layout.

Gap 4 (per-task subjects): change SubjectForAgentRequest from per-stage
(archie.agent.<id>.<stage>) to per-task (archie.agent.<id>.request).
Stage name is carried in the AgentRequestMessage payload. PRD section 2.
2026-07-22 02:57:41 +10:00
sam 8c4bb1ef1d feat: promote archie-agent to NATS-connected per-task worker
Replaces stdin/stdout subprocess transport with NATS JetStream
request-reply pattern. The Runner interface and workflow orchestration
are unchanged.

New NATSRunner (implements Runner):
- Publishes AgentRequestMessage to JetStream with X-Archie-Reply header
- Blocks on core NATS inbox subscription for response
- Same Run(ctx, workspace, req) (Result, error) contract

Rewritten archie-agent (cmd/archie-agent):
- Long-running NATS-connected process (was 28-line stdin/stdout)
- Pull-consumes from ARCHIE_TASKS with archie.agent.> filter
- Builds InProcessRunner, executes agent loop, replies to inbox
- Graceful shutdown via signal handling

Extended internal/nats:
- SubjectAgentWildcard, SubjectForAgentRequest, ReplyHeader
- Conn() accessor, NewReplyInbox(), PublishMsg() for JetStream
- Stream subjects extended to ["archie.task.>", "archie.agent.>"]

Config: "nats" added as valid agent.mode alongside inprocess/subprocess
Tests: NATSRunner round-trip with embedded NATS server + handler
2026-07-22 02:13:01 +10:00