Commit Graph
6 Commits
Author SHA1 Message Date
sam f6d51416f0 chore: replace 607 em-dashes with double hyphens project-wide
Includes MCP crash-after-init test fix (crash moved from handle() to serve()
entry point so transport sees immediate subprocess death).
2026-07-26 09:53:33 +10:00
sam d80401d595 feat: add config overlay and shared RPC/Yaegi packages
- Introduce `-config-overlay` flag and `config.LoadOverlay()` to merge a base config with an overlay file, only overriding fields the overlay sets. This enables docker-compose to mount the base config from the host and apply only deployment-specific overrides.
- Create `internal/natsrpc` package with reusable NATS request/reply primitives (Envelope, Client, Call, RegisterAll, Respond). Migrate storerpc, worktreerpc, and forgerpc to use it, eliminating duplicated marshal/unmarshal and error handling.
- Create `internal/yaegiutil` package with shared interpreter construction (stdlib + extra symbols), generic export resolution (Resolve), and panic recovery (Safe). Migrate all Yaegi-based surfaces (gate scripts, daemon plugins, skill plugins, workflow stages, skill scripts) to use it, reducing boilerplate and centralizing panic safety.
- Simplify `config.docker.toml` to contain only overlay fields (paths, container config) and remove the duplicated repos list – the base config is now the single source of truth.
- Update docker-compose.yml to pass both -config and -config-overlay flags and mount the base config from the host.
- Add tests for LoadOverlay, DockerConfigOverlaysExampleConfig, Envelope, and yaegiutil utilities.
2026-07-24 12:57:10 +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 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 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