Commit Graph
76 Commits
Author SHA1 Message Date
sam e4368f70af feat: persistent volumes with TTL for container/worktree storage (archie-core-j7v)
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.
2026-07-24 10:22:11 +10:00
sam 75f237d1ad feat: daemon hands off tasks to archie-agent in sandboxed mode (archie-core-5zh.8)
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.
2026-07-24 09:14:56 +10:00
sam 1eee983681 feat: archie-agent runs a full task's workflow itself (archie-core-5zh.7)
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.
2026-07-24 09:08:19 +10:00
sam b544af6e92 refactor: trim TaskContext.Forge/Store/Trees to interfaces (archie-core-5zh.6)
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.
2026-07-24 08:56:23 +10:00
sam 159fbce18f feat: curated TaskConfig payload for archie-agent (archie-core-5zh.5)
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.
2026-07-24 08:53:15 +10:00
sam 1369ab1c84 fix: proxy worktree Prepare too, not just Push (archie-core-5zh.3 follow-up)
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.
2026-07-24 08:27:35 +10:00
sam afa8c05ca7 feat: worktree push RPC proxy for archie-agent (archie-core-5zh.3)
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.
2026-07-24 08:05:15 +10:00
sam 65eda765ab feat: Forge RPC proxy for archie-agent (archie-core-5zh.2)
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.
2026-07-24 08:02:46 +10:00
sam c9d0f015ca feat: Store RPC proxy for archie-agent (archie-core-5zh.1)
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.
2026-07-24 07:58:56 +10:00
sam 4be28e0e48 feat: optional NATS token authentication (archie-core-l1q)
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).
2026-07-24 07:51:06 +10:00
sam b6b23bbb59 feat: per-repo allow_concurrent override for same-repo dispatch (archie-core-g1l)
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.
2026-07-24 07:47:10 +10:00
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
archie b164bcbb14 fix: agent context doubled up — conversation history duplicated in prompt (archie)
Implements #65
2026-07-23 23:47:23 +10:00
sam 368221b285 fix: pull latest instead of skipping when worktree exists 2026-07-23 23:00:43 +10:00
sam 739c3d5c46 fix: branch prefix from labels, default feat 2026-07-23 22:39:46 +10:00
sam 51ade3e503 fix: conventional commit prefix in branch names (feat/62-... not archie/issue-62) 2026-07-23 22:29:32 +10:00
sam 3898fd179c fix: descriptive branch names — archie/62-clear-finished-button instead of archie/issue-62 2026-07-23 20:25:38 +10:00
sam 423eb78fef feat: add CreateIssue to Forge interface with Gitea implementation 2026-07-23 19:12:12 +10:00
sam 1bf4f7668f fix: disable diff cap (0 = unlimited), let human review PRs 2026-07-23 18:57:23 +10:00
sam c17df29ce4 Merge pull request 'Archie/issue 61' (#64) from archie/issue-61 into main
Reviewed-on: http://git.catlow.cloud/sam/archie-core/pulls/64
2026-07-23 08:52:21 +00:00
archie d2b2f29096 Implement max_retries cap on maybeRetryParked to prevent infinite parked-task loops (archie)
Implements #61
2026-07-23 18:49:38 +10:00
sam 556edc3ea7 Merge branch 'main' into archie/issue-62 2026-07-23 08:31:07 +00:00
archie 11b6316c6b Add "Clear Completed" button to web dashboard (archie)
Implements #62
2026-07-23 18:04:33 +10:00
archie 02408d2085 fix: baseline gate repair (go test ./... -count=1) 2026-07-23 18:02:05 +10:00
sam 7ef9220032 fix: set Outcome on BuildNoChanges to stop workflow before open-pr 2026-07-23 17:43:15 +10:00
sam 212b48a0a0 fix: close issue when build passes with 0 changes (no-op detection) 2026-07-23 17:25:03 +10:00
sam 0d6b26244e fix: remove all hardcoded MaxSteps — inherit from config budget 2026-07-23 16:15:01 +10:00
sam 3264102ee2 fix: increase plan max_steps to 30 for large repos, bump token budget 2026-07-23 16:10:34 +10:00
sam 7581bcc896 test: update responsive feature test to match fixed CSS 2026-07-23 13:55:22 +10:00
archie 7534cbe2c4 fix: baseline gate repair (go test ./... -count=1) 2026-07-23 13:22:27 +10:00
sam 27157412d8 fix: set protocol version on baseline-fix agent request 2026-07-23 13:07:37 +10:00
sam 278e49fc2e feat: auto-fix pre-existing gate failures instead of parking on baseline red 2026-07-23 12:52:30 +10:00
sam 898f9c4681 chore: whitespace 2026-07-22 21:13:31 +10:00
sam 3598498813 fix: clone worktree before container acquire to fix bind-mount race 2026-07-22 21:02:25 +10:00
sam 880faa0b5f fix: repair broken CSS from PR#2 and add frontend quality gate skill 2026-07-22 09:32:39 +10:00
sam ab1faa4c48 Responsive web UI improvements (archie)
Implements #1
2026-07-22 05:53:37 +10:00
sam 720b95b57a fix: default empty agentloop status to blocked in InProcessRunner 2026-07-22 05:44:27 +10:00
sam edd05aea6b feat: add Gitea forge support alongside GitHub
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.
2026-07-22 05:15:09 +10:00
sam fd360fcc0b fix: resolve 8 remaining design-decision audit items
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.
2026-07-22 05:00:37 +10:00
sam 8a8e676bd6 fix: address 6 'Soon' resilience audit findings
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).
2026-07-22 04:55:26 +10:00
sam 04175a1a6a fix: address 9 'Now' adversarial audit findings
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.
2026-07-22 04:50:11 +10:00
sam 7dbb17a4cb feat: pluggable storage backends with Docker volumes and /data/ layout
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.
2026-07-22 04:28:30 +10:00
sam a9a3f7b3f9 feat: per-worktree dynamic registry augmentation
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.
2026-07-22 04:18:12 +10:00
sam 9bd61e61ac fix: nil-guard _Plugin wrapper, add adversarial tests
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.
2026-07-22 04:12:56 +10:00
sam f38ba5d515 feat: wire Layer 2 daemon plugin loader into archied startup
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.
2026-07-22 04:11:02 +10:00
sam 8958a82233 feat: replace hardcoded workflow registry with catalog-driven skillbuild.BuildRegistry()
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.
2026-07-22 04:02:58 +10:00
sam bba6827ec2 feat: build workflows from skill stage plugins
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.
2026-07-22 03:50:00 +10:00
sam 2182cc00a5 refactor: replace hardcoded workflow→skill maps with catalog-driven lookup
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.
2026-07-22 03:44:42 +10:00
sam d3c843e8f5 feat: close final two gaps — agent skill loading + core plugin registry
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.
2026-07-22 03:37:15 +10:00
sam 39b66fc1ef test: add failing regression tests for the two remaining gaps
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.
2026-07-22 03:35:03 +10:00