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.
This commit is contained in:
sam committed 2026-07-22 04:11:02 +10:00
1 parent 8958a82233
commit f38ba5d515
8 files changed
+256 -35

No files matched your search

+12 -1
View File
@@ -8,6 +8,7 @@ import (
"fmt"
"os"
"path/filepath"
"reflect"
"sort"
"strings"
@@ -40,7 +41,12 @@ func (r *Registry) Plugins() []Plugin { return r.plugins }
// Each file must export a variable named "Plugin" that implements the
// Plugin interface. Failed plugins are logged and skipped — the daemon
// starts with the remaining plugins (PRD section 5).
func LoadDir(dir string) ([]Plugin, error) {
//
// extraSymbols are additional Yaegi symbol tables made available to
// interpreted code. Callers should pass pluginextract.Symbols so that
// interpreted types can satisfy the plugin.Plugin interface across
// the Yaegi/Go boundary.
func LoadDir(dir string, extraSymbols ...map[string]map[string]reflect.Value) ([]Plugin, error) {
entries, err := os.ReadDir(dir)
if os.IsNotExist(err) {
return nil, nil
@@ -68,6 +74,11 @@ func LoadDir(dir string) ([]Plugin, error) {
if err := i.Use(stdlib.Symbols); err != nil {
continue
}
for _, s := range extraSymbols {
if err := i.Use(s); err != nil {
continue
}
}
if _, err := i.Eval(string(src)); err != nil {
continue // skip files that don't compile
}