Add [containers].volume_ttl (default 72h). Persistent-storage repos get a
per-repo bare Git cache (--reference-if-able --dissociate) so task
worktrees clone fast without repeated full network clones, while staying
fully independent of the cache's lifecycle — cache expiry can never
corrupt an active or parked task's worktree. Docker repo volumes are
labeled as Archie-owned and swept non-forced (a volume still attached to a
running container survives and retries next cycle); the repo cache
directory is swept by mtime. Both cleanups run at daemon startup and each
poll cycle.
Filed archie-core-756 (repo-wide golangci-lint baseline) and archie-core-340
(intermittent JetStream TempDir teardown flake) as separate follow-ups
rather than scope-creeping them into this change.
daemon.process() branches on ContainerPool != nil: sandboxed tasks publish
a taskrun.Request to archie.taskrun.<id> and await the response via the
new runViaAgent method, instead of running workflow.Route/workflow.Run
locally. Non-container mode is unchanged. Every durable side effect
(Store, Forge, git push) already landed via the storerpc/forgerpc/
worktreerpc proxies during archie-agent's run by the time runViaAgent
returns — it only parks the task itself on transport/setup failure, never
duplicating a terminal state archie-agent's own workflow.Run already
recorded.
Also fixes a real correctness gap: with concurrent multi-task dispatch
(archie-core-u64/g1l) plus containerized archie-agent, a shared queue-group
subscription could let one container answer a sibling's taskrun message
while having a *different* task's worktree mounted. archie-agent now reads
its boot-time task.json and subscribes to its own exact per-task subject
when present, falling back to the shared queue group only in dev/pool mode
(no task.json).
Adds agentexec.ProvidersFromConfig, deduped from cmd/archied's former
executionProviders.
Closes the archie-core-5zh epic: archie-agent runs an entire task's
workflow per invocation instead of one stage per round trip, with all
credentials staying daemon-side throughout.
Add internal/taskrun (Request/Response wire types) and
cmd/archie-agent/taskrun.go: runTask builds a workflow.Registry from the
container's own bind-mounted worktree, routes and runs the task's entire
workflow via workflow.Route/workflow.Run, using storerpc.Client/
forgerpc.Client for Store/Forge and a new hybridTrees that splits
Prepare/Push (proxied over worktreerpc — network ops needing the daemon's
credential) from CommitAll/Diff/ChangedFiles/ChangedLines (local git
against the mount).
Add config.TaskConfig.ToConfig() to rebuild a usable Config from the
curated payload, and storage.WorktreeMountDir (/data/worktree) — critical
fix: hybridTrees.Prepare discards the RPC response's host-side directory
and returns the container's fixed local mount path instead, since archied
and archie-agent see the same files at different paths.
Wired a queue-grouped core-NATS subscription on archie.taskrun.> in
cmd/archie-agent/main.go alongside the existing per-stage consumer, so
this is reachable in the running binary. End-to-end test drives the real
"bootstrap" workflow (no LLM) through real storerpc/forgerpc/worktreerpc
servers and a real local git remote — registry build, route, prepare,
commit, push, PR creation, and confirms the authoritative task state
lands in archied's store via RPC, not just in-memory.
archie-core-5zh.8 (daemon.go handoff) is unblocked.
Add Forger/TaskStore/Trees interfaces in internal/workflow/workflow.go,
scoped to exactly the methods stages call mid-run: 4 Forge methods
(Comment, CloseIssue, CreatePR, SetStateLabel), 2 Store methods (Update,
Transition), 6 Trees methods (Prepare, CommitAll, Push, Diff, ChangedFiles,
ChangedLines). This lets storerpc.Client/forgerpc.Client/worktreerpc.Client
satisfy TaskContext from inside archie-agent.
Go's structural typing meant zero other changes were needed — forge.Forge,
*store.Store, and *worktree.Manager already satisfy the trimmed interfaces.
No behavior change for the daemon's existing inprocess/subprocess paths.
Also fixes a gofmt nit left over from the 5zh.2 commit.
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.
Discovered while scoping archie-core-5zh.4: Trees.Prepare's fetch/checkout/
reset also run through the token-authenticated askpass helper, and workflow
stages call tc.Trees.Prepare directly (internal/workflow/steps.go), not
just the daemon's pre-container clone. So Prepare needs the same proxy
treatment as Push — both are network git ops requiring the credential;
CommitAll/Diff/ChangedFiles/ChangedLines stay local as originally scoped.
Add internal/worktreerpc: core NATS request/reply so archie-agent can
request a git push without holding the forge push token. The server
resolves the worktree directory itself from owner/repo/issue rather than
trusting a path from the sandboxed agent, then calls the daemon's own
worktree.Manager.Push (which already holds the token). Prepare, CommitAll,
Diff, ChangedFiles, and ChangedLines stay local git ops the agent can run
directly against its bind-mounted worktree — only Push needed proxying.
All three RPC proxies for archie-core-5zh now exist (Store, Forge,
worktree push); archie-core-5zh.4 (the actual stage-loop move) is
unblocked.
Add internal/forgerpc: core NATS request/reply for the four forge.Forge
methods workflow stages call mid-run (Comment, CloseIssue, CreatePR,
SetStateLabel). archied stays the sole holder of forge API tokens. All
other Forge methods are daemon-only poll/reconcile-loop calls and don't
need proxying (confirmed by grep across internal/workflow).
Groundwork for archie-core-5zh — not yet wired into daemon.go or
workflow.TaskContext.
Add internal/storerpc: core NATS request/reply so archie-agent can call
Store.Update/Transition without a direct SQLite connection. archied stays
the sole DB owner and responds to update/transition subjects; store.Task
gains json tags to cross the wire.
Groundwork for archie-core-5zh — not yet wired into daemon.go or
workflow.TaskContext. Splitting 5zh into sub-issues (.1 Store RPC, .2 Forge
RPC, .3 worktree push RPC, .4 the actual stage-loop move) since the full
move needs all three proxies to keep secrets/DB ownership on the daemon.
Add token_env to [nats] config, resolved and validated at daemon startup
(fails early if configured but the named env var is unset). Container
workers get NATS_URL/NATS_TOKEN; archie-agent honors both while CLI-supplied
URL still takes precedence. Anonymous auth remains the default for
single-node deployments.
Unblocks archie-core-5zh (promote archie-agent to per-task process).
Add config.Repo.AllowConcurrent (allow_concurrent toml key). Repos opted in
skip the daemon's default FIFO same-repo task serialization while still
respecting [containers].max_concurrency globally. Worktrees are already keyed
per issue number, so opted-in repos don't collide on disk.
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).
Implements the Forge interface for Gitea instances (tested against
git.catlow.cloud, Gitea v1.26.4). The forge.New factory now dispatches
on forge type, and config validation accepts 'gitea'.
Changes:
- internal/forge/gitea.go — GiteaClient implementing all 11 Forge
methods: issue polling (assigned + label), comments, PR creation,
PR state reconciliation, issue closure, reactions, state labels,
push verification. Handles edge cases: not-found PRs return
'closed', GetUserByName errors from the Gitea SDK are mapped to
user-friendly messages.
- internal/forge/forge.go — New() factory dispatching on forge type
(github/gitea). GitHub constructor renamed to NewGitHub.
- internal/forge/github_test.go — updated to use New() signature
- internal/config/config.go — forge.type accepts 'gitea', BotEmail
defaults change per forge type (gitea uses @gitea.local)
- cmd/archied/main.go — passes cfg.Forge.Type to forge.New()
Dependencies: added code.gitea.io/sdk/gitea v0.25.1
End-to-end verified against live Gitea instance: daemon starts clean,
registry built (5 workflows), web UI listening, no errors or warnings.
Fixes (4 items):
S4 — Add TypeScript, Deno, Bun cache ecosystems to
cacheVolumesByEcosystem. TypeScript shares node+pnpm volumes;
Deno and Bun get dedicated cache volumes.
R4 — Share single Docker client between container.Pool and
storage.DockerBackend. NewPool now accepts an optional
DockerClient in Config; if nil, creates its own. Pool
tracks ownership (ownCli) and only closes its own client.
S2 — Wire Storage.Teardown() call in daemon.process() after
workflow.Run(). Docker backend is a no-op; this closes the
interface contract for future backends.
R5 — Emit observability event on AugmentRegistry failure.
Previously only logged a warning; now emits a
'registry_augment_failed' event with error detail.
Promoted log level to Error.
Documentation (4 items):
D1 — Document PluginRegistry as reserved for future daemon
extension points (forge resolvers, storage backends, etc.)
S1 — Fix /data/ layout comment to reflect actual task.json path
(/data/worktree/task.json, not /data/task.json)
S3 — Add TODO(PRD §3) for session.jsonl, memory.jsonl, plugins/
volume — these need agent-side implementation first
N6 — Document that VolumeInspectOptions{} requires moby v25+
(go.mod pins compatible version)
N7 — Document that _Plugin.IValue is required by Yaegi interface
bridging; warn that go generate strips nil-guards
Test: TestCacheMountsForTypeScript verifies typescript ecosystem
returns node+pnpm volumes sorted by destination.
Verification: single client.New(client.FromEnv) in main.go;
all 21 storage tests pass; full suite green.
R2 (resilience): skip broken stage plugins, don't abort daemon startup.
BuildWorkflow now skips individual broken plugins with a warning
instead of hard-failing. BuildRegistry and AugmentRegistry skip
broken skills with a warning instead of returning an error. One
bad plugin in one skill no longer prevents the daemon from starting
or blocks other skills from registering their workflows.
R1 (resilience): log skipped daemon plugins in LoadDir. Every failure
path now emits a WARN log via slog.Default() — unreadable files,
compile errors, missing Plugin exports, wrong types. Operators can
now see WHY a plugin was skipped. PRD says 'logged and skipped';
code now matches spec.
N3 (resilience): log symbol-table load errors separately from plugin
source errors. A broken pluginextract.Symbols no longer causes
silent skip of ALL plugins — each failure is logged with the
symbol table index that failed.
N4 (resilience): centralize Yaegi interpreter setup in
newStageInterpreter(). Each plugin file still needs its own
interpreter (package main with duplicate Stage() symbols cannot
co-evaluate), but the setup is now explicit and documented.
N5 (resilience): document tuple fallback positional-field fragility.
The func() (string, func(...)) fallback in loadStage now warns
that it constructs Stage with positional fields and will silently
zero-value any future Stage fields.
R3 (resilience): document nil-client edge case in ensureVolume.
Tests: TestBuildWorkflowSkipsBrokenPlugin (broken plugin skipped,
surviving stages execute), TestBuildRegistrySkipsBrokenSkill (bad
skill doesn't block others, built-in fallbacks preserved).
P1 (panic): nil Storage guard in daemon.process()
C1 (correctness): check WriteTaskJSON error — don't start blind
C2 (correctness): move 'working' label after container setup
C3 (correctness): warn on duplicate workflow names in registry
C4 (correctness): test that generated _Plugin wrapper has nil-guards
C5 (correctness): .agents/skills as file (ENOTDIR) not fatal
C6 (correctness): ecosystem case-insensitive in cacheMounts
N1 (correctness): TOCTOU race — treat 'already exists' as success
N2 (correctness): recover from panicking plugin.Name() at startup
--- Details ---
P1: d.Storage.Setup() is now guarded by a nil check. In normal
operation Storage is always set when ContainerPool is set, but
the invariant is now explicit and enforced.
C1: container.WriteTaskJSON() error was discarded with _. Now it
returns early with a park transition — the container never starts
without a boot-time brief.
C2: SetStateLabel('working') was called before container setup.
If Acquire failed, the task was parked but the label stayed
'working' permanently. Now the label is set only after successful
container setup (or immediately if no containers are configured).
C3: BuildRegistry and AugmentRegistry now log a warning when two
skills declare the same workflow name and one overwrites the other.
C4: TestGeneratedWrapperHasNilGuards verifies that nil WName/
WVersion don't panic. If go generate strips the nil-guards, this
test catches it before the daemon crashes.
C5: skill.Catalog() now returns nil (no skills) instead of
propagating ENOTDIR errors when .agents/skills is a file.
C6: cacheMounts() normalizes ecosystem to lowercase. 'Python',
'NODE', 'Go' all resolve correctly now.
N1: ensureVolume() treats Docker's 'already exists' error as
success, closing the TOCTOU window between VolumeInspect and
VolumeCreate.
N2: safePluginInfo() wraps plugin.Name()/Version() calls in a
recover. A plugin with a panicking Name() no longer crashes the
daemon at startup.
Introduces the storage.Backend interface for pluggable container mount
management. The Docker implementation (DockerBackend) is the MVP —
no NFS/SMB/S3, just Docker volumes + bind mounts.
/data/ volume layout:
/data/worktree/ — bind mount of host worktree (always)
/data/repo/ — per-repo Docker volume (when persistent_storage = true)
/data/cache/go/ — shared GOMODCACHE volume
/data/cache/node/— shared npm cache volume
/data/cache/pnpm/— shared pnpm store volume
/data/cache/pip/ — shared pip cache volume
/data/cache/cargo/— shared Rust cargo cache volume
/data/task.json — boot-time brief (existing WriteTaskJSON)
Changes:
- internal/storage/: Backend interface, DockerBackend, Mount types,
ecosystem-to-cache-volume mapping, ConvertMounts helper
- container.Pool.Acquire: now accepts []storage.Mount instead of
hardcoding a single bind mount — mount list comes from the storage
backend
- daemon.process(): calls d.Storage.Setup() to build the mount list,
passes Ecosystem + PersistentStorage from repo config
- config.Repo.PersistentStorage: when true, a named Docker volume
(archie-repo-<owner>-<repo>) is mounted at /data/repo and survives
task completion
- main.go: creates DockerBackend when containers are enabled
21 tests: interface contract, ecosystem cache mounts (go/node/
python/rust/custom), worktree bind mount ordering, persistent
storage on/off/empty-owner guard, mount list sort+dedup, adversarial
(nonexistent worktree, empty ecosystem, unknown ecosystem).
Why: daemon-managed cache volumes mean warm GOMODCACHE/npm cache
across tasks. Per-repo persistent volumes preserve expensive build
artifacts. The interface leaves room for future backends without
rewiring container orchestration.
When a worktree already exists on disk (retry, waiting_human ->
implement handoff), the daemon now scans it for .agents/skills/ that
declare metadata.archie.workflow and augments the startup registry
with any newly discovered workflows. Worktree skills take precedence
over the startup registry for that task only.
Changes:
- skillbuild.AugmentRegistry(worktree, base) — scans a worktree
directory for skills, builds workflows from plugins, returns a
new registry with worktree entries merged over base. Base is never
mutated. Mirrors BuildRegistry but starts from caller's registry
instead of builtins.
- daemon.process() — computes worktree path, calls AugmentRegistry
if the directory exists, uses augmented registry for routing.
Degrades gracefully to startup registry on error.
Tests (10 new):
- Adds worktree workflows to base registry
- Worktree skills override same-named base entries
- Base registry is not mutated (copy semantics)
- Nonexistent worktree returns base unchanged
- Worktree with no .agents/skills/ returns base unchanged
- Worktree skill with no plugins does not override base
- Adversarial: concurrent augmentation is safe
- Adversarial: broken SKILL.md is skipped
- Adversarial: bare worktree (no .agents/) does not error
- Adversarial: nil base is treated as empty
Why: skills are per-project (.agents/skills/ in each repo). The
startup registry only knows about a shared skills directory. Per-
worktree augmentation means a repo can define its own workflows
without restarting the daemon.
Two bugs found by adversarial tests:
1. _Plugin wrapper panicked on nil WName/WVersion — the daemon calls
Name()/Version() at startup to log loaded plugins, so a plugin with
nil func fields would crash the daemon. Fixed with nil guards
returning empty strings.
2. LoadDir returned nil for empty directories instead of an empty
slice — inconsistent with the contract (nil means 'no plugin dir
configured', empty means 'no plugins found').
Added 9 adversarial tests that attempt to break LoadDir:
- Nil function fields (must not panic on load or call)
- Empty name/version (valid per interface contract)
- Wrong export type (int instead of Plugin — must skip)
- Partial interface implementation (missing method — must skip)
- Empty directory (returns empty slice, not nil)
- Nested subdirectories (must not be traversed)
- Panic in Name() function (deferred to call time, loader survives)
- Unused import (must not crash eval)
- Go build tags (must be ignored in Yaegi)
Why: per test-first-build skill, every build/test failure results in
a test that would have caught it. Adversarial tests alongside
confirmation tests prevent silent breakage.
Daemon plugins (Yaegi-interpreted .go files) are now loaded from the
configured plugin_dir at startup. Each file must export a 'Plugin'
variable using the _Plugin wrapper struct, which bridges Yaegi types
to the Go plugin.Plugin interface.
Changes:
- internal/plugin/pluginextract/ — generated Yaegi symbol table for
the plugin package (mirrors wfextract pattern), including the
_Plugin interface wrapper that lets interpreted code implement
Go interfaces
- LoadDir now accepts optional symbol tables via variadic parameter,
avoiding an import cycle between plugin and pluginextract
- Plugin tests rewritten as behavioral (not structural), verifying
actual Yaegi interpretation of valid, invalid, and missing plugins
- config.PluginDir field for specifying the plugin directory
- daemon.PluginRegistry field for holding loaded plugins
- main.go wires plugin loading: LoadDir at startup, register into
daemon, log each loaded plugin
Why: the Plugin interface and LoadDir existed but weren't connected
to the daemon. Skills define workflows; daemon plugins are the
extension point for forge resolvers, storage backends, and other
core-daemon concerns.
The daemon no longer hardcodes workflow.Registry{...} in main.go.
Instead, skillbuild.BuildRegistry() scans .agents/skills/ for catalog
entries declaring metadata.archie.workflow and builds each workflow
from its Yaegi-interpreted stage plugins.
Built-in workflows (bootstrap, implement, tdd, feasibility, default)
serve as fallbacks when no skill declares a given workflow name. A
skill that declares metadata.archie.workflow: implement overrides the
built-in — skills define workflows, plugins define stages.
Why: skills must be extension primitives. Adding a workflow should
mean creating .agents/skills/archie-wf-<name>/plugins/*.go, not
modifying Go code in main.go. The catalog is the single source of
truth for what workflows exist.
New skillbuild package: BuildWorkflow() loads Yaegi-interpreted stage
plugins from a skill's plugins/ directory and constructs a runnable
workflow.Workflow. Uses wfextract symbol tables for type access.
A skill directory with metadata.archie.workflow: greet and stage plugins
in plugins/*.go IS the workflow definition — no Go code changes needed.
Stage plugins export:
func Stage() workflow.Stage
or the fallback signature:
func Stage() (string, func(context.Context, *workflow.TaskContext) error)
Stages are loaded in filename order. Missing plugins dir is not an error
(matches wfeval.Discover pattern).
Test: skill with two plugins (hello, world) produces a 2-stage workflow
that modifies BuildSummary sequentially.
Skills now declare their workflow in metadata.archie.workflow.
Catalog() scans frontmatter only (lazy, Tier 1). SkillForWorkflow()
derives the skill directory from the catalog — no hardcoded maps.
Removed workflowToSkill map (agent.go) and workflowToSkillDir switch
(worker.go). Both daemon and agent use the same catalog-based lookup.
Skills renamed to archie-wf-* convention. SKILL.md files updated with
workflow metadata field.
Progressive disclosure Tier 1: Catalog() returns name+description
+workflow. Tier 2: LoadBody() loads full body on activation.
Agent skill loading: HandleMessage now loads .agents/skills/<workflow>/SKILL.md
from its own workspace before running stages. Skill body prepended to each
stage's Mission. Mirrors daemon-side loadSkillBody but owned by the agent
per PRD section 1. workflowToSkillDir mapping added.
Core plugin registry: internal/plugin package with Plugin interface
(Name, Version), Registry type, and LoadDir function. Yaegi-interprets
.go files from ~/.config/archie/plugins/ at startup. Failed plugins are
skipped. PRD section 5 Layer 2.
All 21 PRD claims now have tests. Zero failing tests.
1. Agent doesn't load its own skills:
TestHandleMessageLoadsSkillsFromWorktree — creates a worktree with
.agents/skills/tdd-bugfix/SKILL.md, sends a bare mission to
HandleMessage, verifies the agent loaded the skill body from its
workspace. Fails at runtime: HandleMessage never reads .agents/skills/,
the Mission reaches the runner unchanged.
2. Core plugin registry nonexistent:
TestPluginInterfaceExists, TestRegistryExists,
TestLoadPluginsFromConfigDir — fails to compile: Plugin interface,
Registry type, and LoadDir function are undefined. PRD section 5
Layer 2 entirely aspirational.