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.
This commit is contained in:
sam committed 2026-07-24 12:57:10 +10:00
1 parent 4573ed125a
commit d80401d595
18 files changed
+580 -506

No files matched your search

+17 -24
View File
@@ -11,8 +11,9 @@ import (
"os"
"github.com/traefik/yaegi/interp"
"github.com/traefik/yaegi/stdlib"
"github.com/traefik/yaegi/stdlib/unrestricted"
"github.com/samcharles93/archie-core/internal/yaegiutil"
)
// Run interprets the Go script at path and executes its main function,
@@ -21,33 +22,25 @@ import (
// (os/exec included — these scripts wrap external tools the way a shell
// script would), so a panic inside it is recovered and returned as an
// error rather than taking down the daemon.
func Run(path string) (output string, err error) {
func Run(path string) (string, error) {
if _, statErr := os.Stat(path); statErr != nil {
return "", statErr
}
defer func() {
if r := recover(); r != nil {
err = fmt.Errorf("yaegi: %s panicked: %v", path, r)
return yaegiutil.Safe(path, func() (string, error) {
var buf bytes.Buffer
i, err := yaegiutil.New(interp.Options{Stdout: &buf, Stderr: &buf}, unrestricted.Symbols)
if err != nil {
return "", err
}
}()
var buf bytes.Buffer
i := interp.New(interp.Options{Stdout: &buf, Stderr: &buf})
if err := i.Use(stdlib.Symbols); err != nil {
return "", fmt.Errorf("yaegi: load stdlib symbols: %w", err)
}
if err := i.Use(unrestricted.Symbols); err != nil {
return "", fmt.Errorf("yaegi: load unrestricted symbols: %w", err)
}
// EvalPath treats a package-main source file the way `go run` does:
// evaluating it executes its main() directly. Unlike `go build`, it
// does not complain about a missing main() — such a script simply
// produces no output.
if _, err := i.EvalPath(path); err != nil {
return "", fmt.Errorf("yaegi: run %s: %w", path, err)
}
return buf.String(), nil
// EvalPath treats a package-main source file the way `go run` does:
// evaluating it executes its main() directly. Unlike `go build`, it
// does not complain about a missing main() — such a script simply
// produces no output.
if _, err := i.EvalPath(path); err != nil {
return "", fmt.Errorf("yaegi: run %s: %w", path, err)
}
return buf.String(), nil
})
}