From c5558c43fb2b217bb089bec6ff11c6f6a669095d Mon Sep 17 00:00:00 2001 From: Sam Catlow Date: Sun, 4 Oct 2026 03:08:46 +1100 Subject: [PATCH] chore: remove Yaegi yaegiutil, the go.mod dependency, the .yaegi host-code entry and the legacy guard stages for .archie/gate.go and .archie/stages are gone. --- go.mod | 1 - go.sum | 2 - internal/app/archied/control_plane.go | 3 +- .../app/controlplane/operational_settings.go | 6 +- internal/domain/storepkg/descriptor.go | 2 +- internal/domain/workflow/implement.go | 2 - internal/domain/workflow/steps.go | 29 ---- internal/domain/workflow/tdd.go | 2 - internal/domain/workflow/workflow.go | 3 - .../configuration/setup/secretref.go | 5 +- internal/tools/provider/running.go | 4 +- internal/yaegiutil/yaegiutil.go | 137 ------------------ 12 files changed, 8 insertions(+), 188 deletions(-) delete mode 100644 internal/yaegiutil/yaegiutil.go diff --git a/go.mod b/go.mod index ca2040cb4..46bf1b415 100644 --- a/go.mod +++ b/go.mod @@ -123,7 +123,6 @@ require ( github.com/samcharles93/ai-sdk v0.1.40 github.com/testcontainers/testcontainers-go v0.44.0 github.com/testcontainers/testcontainers-go/modules/postgres v0.44.0 - github.com/traefik/yaegi v0.16.1 go.lsp.dev/jsonrpc2 v1.0.1 go.lsp.dev/protocol v1.0.1 go.lsp.dev/uri v1.0.1 diff --git a/go.sum b/go.sum index d60f050ff..3c182c327 100644 --- a/go.sum +++ b/go.sum @@ -253,8 +253,6 @@ github.com/tklauser/go-sysconf v0.4.0 h1:7H0uAN+7RkwWRaxhYXDLqa5V3LPrJeV8wmD9dRU github.com/tklauser/go-sysconf v0.4.0/go.mod h1:8mTNWyog7H+MpKijp4VmKJAd2bbYQ2zuUwkYRbUArPI= github.com/tklauser/numcpus v0.12.0 h1:NR85qdvHA9pFse3x3weVZ0r0ST8R6l5RHbZrlRaqob4= github.com/tklauser/numcpus v0.12.0/go.mod h1:ABHeXzJnr/qqwguhClkZKT1/8VABcYrsyUiUGobwWJg= -github.com/traefik/yaegi v0.16.1 h1:f1De3DVJqIDKmnasUF6MwmWv1dSEEat0wcpXhD2On3E= -github.com/traefik/yaegi v0.16.1/go.mod h1:4eVhbPb3LnD2VigQjhYbEJ69vDRFdT2HQNrXx8eEwUY= github.com/yosida95/uritemplate/v3 v3.0.2 h1:Ed3Oyj9yrmi9087+NczuL5BwkIc4wvTb5zIM+UJPGz4= github.com/yosida95/uritemplate/v3 v3.0.2/go.mod h1:ILOh0sOhIJR3+L/8afwt/kE++YT040gmv5BQTMR2HP4= github.com/yusufpapurcu/wmi v1.2.4 h1:zFUKzehAFReQwLys1b/iSMl+JQGSCSjtVqQn9bBrPo0= diff --git a/internal/app/archied/control_plane.go b/internal/app/archied/control_plane.go index bf89b31f8..1fdfac38b 100644 --- a/internal/app/archied/control_plane.go +++ b/internal/app/archied/control_plane.go @@ -242,8 +242,7 @@ func (b *boot) startLiveSettings(ctx context.Context) error { // re-reads it. ToolSettingsKind is on it because applyRuntimeResourceUpdate // reconciles the MCP provider set and rebuilds the two config-derived tool // entries (boot.reconcileToolSettings, its consumer); a removed MCP server -// really disconnects, because it is a child process with a Stop, not a Yaegi -// interpreter. ContainerRuntimePoliciesKind is on it because both consumers +// really disconnects, because it is a child process with a Stop. ContainerRuntimePoliciesKind is on it because both consumers // re-read the published config: the container pool takes its image, pull // policy, network, max-uptime and concurrency cap per acquire, and the daemon's // dispatcher is resized after the publish (applyRuntimeResourceUpdate below). diff --git a/internal/app/controlplane/operational_settings.go b/internal/app/controlplane/operational_settings.go index de04d1fd9..483496c85 100644 --- a/internal/app/controlplane/operational_settings.go +++ b/internal/app/controlplane/operational_settings.go @@ -42,10 +42,8 @@ func operationalDefinitions() []Definition { // Live: changed MCP servers are reconnected, rolling back to the old engine // if the new one fails to start. {Kind: ToolSettingsKind, Title: "Tool and MCP settings", ApplyMode: "live", Document: toolSettings{}, Seed: seedTools, Validate: validateTools}, - // ApplyMode is live for additions: a stored directory change re-layers live - // and the daemon's reconciliation loads new and changed files without a - // restart. A removal cannot unload Yaegi's interpreter, so it stays an - // outstanding apply-status problem rather than a restart of the whole kind + // The one field, skills_dir, is read at boot: a stored value that differs + // from the running one is refused until restart (refuseSkillsDirChange). {Kind: PluginSettingsKind, Title: "Plugin settings", ApplyMode: "live", Document: pluginSettings{}, Seed: func(cfg config.Config) any { return pluginSettings{cfg.SkillsDir} }, Validate: validatePluginSettings}, diff --git a/internal/domain/storepkg/descriptor.go b/internal/domain/storepkg/descriptor.go index 4586f9655..dd461d427 100644 --- a/internal/domain/storepkg/descriptor.go +++ b/internal/domain/storepkg/descriptor.go @@ -203,7 +203,7 @@ func validateFile(file File, extension bool) error { func isHostCodePath(file string) bool { ext := strings.ToLower(path.Ext(file)) switch ext { - case ".go", ".yaegi", ".sh", ".bash", ".zsh", ".fish", ".ksh", ".csh", + case ".go", ".sh", ".bash", ".zsh", ".fish", ".ksh", ".csh", ".py", ".pyw", ".rb", ".pl", ".pm", ".php", ".lua", ".tcl", ".r", ".js", ".mjs", ".cjs", ".ts", ".bat", ".cmd", ".ps1": return true diff --git a/internal/domain/workflow/implement.go b/internal/domain/workflow/implement.go index 804fd78c9..540512c5b 100644 --- a/internal/domain/workflow/implement.go +++ b/internal/domain/workflow/implement.go @@ -132,7 +132,6 @@ func Implement() Workflow { Name: "implement", Stages: []Stage{ StagePrepareWorktree(), - StageRepoStages(), StageBaselineGate(), AgentStage{ @@ -192,7 +191,6 @@ func Implement() Workflow { return fmt.Sprintf("%s (archie)", tc.Task.Title) + commitIssueReference("Implements", tc.Task) }), - StageYaegiGate(), StageDiffCap(), StagePRReviewAndOpenPR(implementPRBody), }, diff --git a/internal/domain/workflow/steps.go b/internal/domain/workflow/steps.go index 117f5930b..8006df687 100644 --- a/internal/domain/workflow/steps.go +++ b/internal/domain/workflow/steps.go @@ -205,35 +205,6 @@ func StageDiffCap() Stage { }} } -// StageRepoStages rejects obsolete repository-authored Go stages. -func StageRepoStages() Stage { - return Stage{Name: "repo-stages", Run: func(_ context.Context, tc *TaskContext) error { - stages, err := filepath.Glob(filepath.Join(tc.Dir, ".archie", "stages", "*.go")) - if err != nil { - return fmt.Errorf("inspect legacy repository stages: %w", err) - } - if len(stages) > 0 { - return fmt.Errorf("legacy .archie/stages/*.go is unsupported; migrate repository behavior to database-backed YAML workflow steps (the %s step type runs operator argv in the task worktree)", CommandRunStepName) - } - return nil - }} -} - -// StageYaegiGate rejects the obsolete interpreted gate rather than silently -// omitting behavior that cannot be represented by the typed registry. -func StageYaegiGate() Stage { - return Stage{Name: "custom-gate", Run: func(_ context.Context, tc *TaskContext) error { - _, err := os.Stat(filepath.Join(tc.Dir, ".archie", "gate.go")) - if err == nil { - return fmt.Errorf("legacy .archie/gate.go is unsupported; migrate its behavior to a registered YAML workflow step") - } - if !os.IsNotExist(err) { - return fmt.Errorf("inspect legacy .archie/gate.go: %w", err) - } - return nil - }} -} - // OpenPR opens the task's pull request, records its number, and sets // the terminal pr_open outcome. Stages that need to act after the PR // exists (e.g. posting evidence comments) call this and then do so in diff --git a/internal/domain/workflow/tdd.go b/internal/domain/workflow/tdd.go index d83834da6..d538c4968 100644 --- a/internal/domain/workflow/tdd.go +++ b/internal/domain/workflow/tdd.go @@ -19,7 +19,6 @@ func TDD() Workflow { Name: "tdd", Stages: []Stage{ StagePrepareWorktree(), - StageRepoStages(), StageBaselineGate(), tddAnalyseStage(), tddReproTestsStage(), @@ -32,7 +31,6 @@ func TDD() Workflow { return fmt.Sprintf("fix: %s (archie)", tc.Task.Title) + commitIssueReference("Fixes", tc.Task) }), - StageYaegiGate(), StageDiffCap(), tddOpenPRStage(), }, diff --git a/internal/domain/workflow/workflow.go b/internal/domain/workflow/workflow.go index cb12b3265..bb72fba16 100644 --- a/internal/domain/workflow/workflow.go +++ b/internal/domain/workflow/workflow.go @@ -96,9 +96,6 @@ type TaskContext struct { prReview *prReviewState Bus *events.Bus // nil-safe via Emit Log *slog.Logger - // CustomStages is retained for source compatibility only. Repository Go - // stages are no longer executed; StageRepoStages rejects their presence. - CustomStages func(dir string) ([]Stage, error) // SkillBody is the Markdown body of the loaded SKILL.md for this // workflow's matching skill, injected into agent context. Empty // when no skill is found (backward compatible). diff --git a/internal/infrastructure/configuration/setup/secretref.go b/internal/infrastructure/configuration/setup/secretref.go index 0db730004..ccec895c0 100644 --- a/internal/infrastructure/configuration/setup/secretref.go +++ b/internal/infrastructure/configuration/setup/secretref.go @@ -9,9 +9,8 @@ import ( ) // engineNameRe is the shape a secret engine name must have. Engine names are -// identifiers -- "env", "bws", "builtin" -- and for operator-supplied engines -// they are also Yaegi plugin filenames, so this is deliberately no tighter than -// an identifier. +// identifiers -- "env", "bws", "vault" -- and an installed extension's package +// name, so this is deliberately no tighter than an identifier. var engineNameRe = regexp.MustCompile(`^[A-Za-z0-9_-]+$`) // ParseSecretRef parses an "engine:key" secret reference. diff --git a/internal/tools/provider/running.go b/internal/tools/provider/running.go index ccfa53f55..5bebff646 100644 --- a/internal/tools/provider/running.go +++ b/internal/tools/provider/running.go @@ -100,8 +100,8 @@ func (r *Registry) Add(ctx context.Context, engine Engine) error { } // Remove stops one running provider and unregisters it, removing the tools it -// indexed. Unlike a Yaegi plugin, an MCP server is a child process with a -// Stop, so a removal really unloads. On a registry that has not started, +// indexed. An MCP server is a child process with a Stop, so a removal really +// unloads. On a registry that has not started, // Remove only unregisters. func (r *Registry) Remove(ctx context.Context, id string) error { r.opMu.Lock() diff --git a/internal/yaegiutil/yaegiutil.go b/internal/yaegiutil/yaegiutil.go deleted file mode 100644 index 482591f5b..000000000 --- a/internal/yaegiutil/yaegiutil.go +++ /dev/null @@ -1,137 +0,0 @@ -// Package yaegiutil holds the interpreter-construction and safe-eval -// helpers shared by every Yaegi-interpreted extension surface in -// archie-core (gate scripts, workflow stages, skill plugins, daemon -// plugins, skill scripts). Each surface differs in what symbol tables it -// loads, what export it resolves, and how it invokes that export, but -// all of them build an interpreter the same way and must recover a -// panic from interpreted code -- including a panic during the call -// itself, not just during eval -- rather than let it take down the -// daemon. -package yaegiutil - -import ( - "fmt" - "reflect" - "strings" - "time" - - "github.com/traefik/yaegi/interp" - "github.com/traefik/yaegi/stdlib" -) - -// New returns a Yaegi interpreter with the standard library and any -// extraSymbols loaded. Each interpreted file must get its own -// interpreter when it declares package main -- Yaegi cannot co-evaluate -// two package-main files with colliding symbols (e.g. two Stage() -// functions) in the same interpreter. -func New(opts interp.Options, extraSymbols ...map[string]map[string]reflect.Value) (*interp.Interpreter, error) { - i := interp.New(opts) - if err := i.Use(stdlib.Symbols); err != nil { - return nil, fmt.Errorf("yaegi: load stdlib symbols: %w", err) - } - for _, s := range extraSymbols { - if err := i.Use(s); err != nil { - return nil, fmt.Errorf("yaegi: load symbols: %w", err) - } - } - return i, nil -} - -// evalTimeout bounds the Yaegi Eval(src) call. Yaegi's Eval is not -// cancellable mid-execution, so a plugin whose package-level init -// blocks forever would hang the daemon without this guard. On timeout -// the goroutine leaks (known limitation), but the daemon continues. -const evalTimeout = 3 * time.Second - -// Resolve evaluates src in i and type-asserts exportPath's value -// (e.g. "main.Stage", "gate.Check") to T. It does not itself recover -// panics -- wrap the call that invokes the returned T in Safe, since a -// panic can happen either during Eval (e.g. an init()) or during the -// caller's later invocation of the resolved function. -// -// The Eval call is guarded by evalTimeout: if package-level init code -// blocks forever (e.g. select{} in init()), Resolve returns an error -// instead of hanging the caller indefinitely. The underlying Yaegi -// goroutine cannot be cancelled and will leak; this is an accepted -// trade-off for daemon availability. -func Resolve[T any](i *interp.Interpreter, src, exportPath string) (result T, err error) { - done := make(chan error, 1) - go func() { - _, evalErr := i.Eval(src) - done <- evalErr - }() - - select { - case evalErr := <-done: - if evalErr != nil { - return result, fmt.Errorf("evaluate: %w", evalErr) - } - case <-time.After(evalTimeout): - return result, fmt.Errorf("evaluate: timed out after %v", evalTimeout) - } - - v, err := i.Eval(exportPath) - if err != nil { - return result, fmt.Errorf("does not export %s: %w", exportPath, err) - } - fn, ok := v.Interface().(T) - if !ok { - return result, fmt.Errorf("%s is %T, want %s", exportPath, v.Interface(), reflect.TypeFor[T]()) - } - if err := checkComplete(fn); err != nil { - return result, fmt.Errorf("%s %w", exportPath, err) - } - return fn, nil -} - -// checkComplete rejects a Yaegi interface wrapper that is missing a method -// implementation. Yaegi type-checks "var X Iface = impl{}" and refuses an -// incomplete impl before it ever builds a wrapper, but the generated wrapper -// type is itself exported into the symbol table, so interpreted code can build -// one directly ("var X = pkg._Iface{WName: ...}"). Struct-literal semantics -// leave an omitted method nil, the wrapper still satisfies the interface -// statically, and the omission surfaces as a nil-call panic at first use. -// Values that are not wrappers (plain funcs, ordinary Go types) pass through. -func checkComplete(v any) error { - rv := reflect.ValueOf(v) - for rv.Kind() == reflect.Pointer && !rv.IsNil() { - rv = rv.Elem() - } - if rv.Kind() != reflect.Struct { - return nil - } - rt := rv.Type() - // Every Yaegi wrapper carries the interpreted value alongside its methods. - if _, isWrapper := rt.FieldByName("IValue"); !isWrapper { - return nil - } - - var missing []string - for i := range rt.NumField() { - f := rt.Field(i) - if f.Type.Kind() != reflect.Func || !strings.HasPrefix(f.Name, "W") { - continue - } - if rv.Field(i).IsNil() { - missing = append(missing, strings.TrimPrefix(f.Name, "W")) - } - } - if len(missing) > 0 { - return fmt.Errorf("does not implement %s", strings.Join(missing, ", ")) - } - return nil -} - -// Safe runs fn and recovers any panic -- interpreted code is untrusted -// relative to the daemon's own logic, so a nil dereference or -// out-of-range index inside it must become an error, not a crash. -// label identifies the interpreted source in the resulting error. -func Safe[R any](label string, fn func() (R, error)) (result R, err error) { - defer func() { - if r := recover(); r != nil { - var zero R - result, err = zero, fmt.Errorf("yaegi: %s panicked: %v", label, r) - } - }() - return fn() -}