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.
Adds a harvested .okf/ knowledge bundle (codebase concepts + starter
architecture/services/rules scaffolding) and .mcp.json pointing at the
shared okf MCP service (http://localhost:8765/archie-core/), which
serves multiple projects' bundles from a single process.
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.
GracePeriod now enforced in Release(): if > 0, container stays alive
for the configured duration after task completion before being killed,
per PRD section 1.
WriteTaskJSON now called from daemon.process() before container
Acquire, writing the task payload to <workspace>/task.json per
PRD section 3 /data/ layout.
PluginSpecs populated from TaskContext.SkillPlugins into the
Request sent to the agent. PluginSpec type added to protocol.go.
pluginSpecs() converts skill.Plugin → agentexec.PluginSpec for
transport. PRD section 5 Layer 1.
Gap 8 (frontmatter plugins key): add Plugins []string to
Metadata.Archie struct. Parses the plugins list from SKILL.md
YAML frontmatter per PRD section 5.
Gap 2 (grace period): add GracePeriod field to container.Config,
distinct from MaxUptime. MaxUptime = total container lifetime cap.
GracePeriod = idle time after task completion before kill.
Documented per PRD sections 1 and 4.
Gap 6 (task.json): add TaskPayload struct and WriteTaskJSON
function to internal/container. Daemon writes the task payload
to <workspace>/task.json before container start, matching the
PRD section 3 /data/task.json boot brief.
loadSkillBody() now populates TaskContext.SkillPlugins alongside
SkillBody. Plugins are discovered from .agents/skills/<name>/plugins/*.go
once, lazily on the first agent stage that loads the skill body.
New field: TaskContext.SkillPlugins []skill.Plugin — populated by
loadSkillBody, nil when no skill or no plugins.
Test-first: TestSkillPluginsAvailableDuringStageExecution creates a
worktree with a skill + bundled plugin, verifies plugins are loaded
and runnable via plugin.Run() after loadSkillBody().
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.
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.
Seven failing tests that must pass when gaps 1, 3, and 5 are closed:
Gap 1 (per-task agent):
TestAgentRequestMessageHasWorkflowField — AgentRequestMessage needs
a Workflow field so the agent runs full multi-stage workflows, not
one stage at a time.
Gap 3 (response/system channel split):
TestAgentResponseEnvelopeHasChannelField — envelope needs a Channel
field ("response"|"system").
TestSubjectForAgentResponseExists / TestSubjectForAgentSystemExists
— subject functions for archie.agent.<id>.response and .system.
Gap 5 (daemon review step):
TestAgentStageHasReviewHook — AgentStage needs a ReviewResult hook
that gates agent output before OnResult forwards to humans.
All tests currently fail (compilation errors on missing fields).
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.
Adds plugin discovery to internal/skill — Yaegi .go files in a skill's
plugins/ directory are loaded alongside the SKILL.md body.
- Plugin type: Name, Path, Src, Run(input) (string, error) via Yaegi
- DiscoverPlugins(dir, skillName): scans .agents/skills/<name>/plugins/*.go
- Run() uses Yaegi interpreter with full stdlib access; plugins must use
package main and export func Run(string) string
- Discover() now populates Skill.Plugins alongside frontmatter + body
- Missing plugins/ dir returns empty slice (not an error)
- Missing skill returns nil (not an error)
5 new tests: DiscoverPlugins, DiscoverPluginsNone,
DiscoverPluginsMissingSkill, PluginRun (Yaegi round-trip),
DiscoverIncludesPlugins (integration with Discover).