Files
archie/internal/gate/gateeval/yaegi.go
T
sam f73b2d1c8c feat: memory manager sync/prefetch/scan/shutdown + broad in-flight epic work
Checkpoint commit covering concurrent work across several archie-core-abg
epics to avoid losing in-progress state:

- Memory manager (18.7-18.16): background sync pipeline, prefetch with
  timeout, memory-write notification, threat scanning, shutdown drain
  with abandoned-write tracking, frozen snapshot pattern. Wired
  ScanContent and NotifyMemoryToolWrite into HandleToolCall so scanning
  and notification actually apply to writes, not just exist as unused
  primitives.
- Fixed a literal unresolved merge-conflict that had been committed to
  internal/memory/scrubber/scrubber.go.
- Tool provider/registry, MCP client/transport (stdio, HTTP, SSE),
  multimodal results, disclosure.
- Pairing device auth store, rate limiting.
- Gateway compression, session store, tasks.
- Various workflow, plugin host, and agentexec updates.
2026-07-27 03:34:46 +10:00

51 lines
1.7 KiB
Go

// Package gateeval evaluates a repo's .archie/gate.go via Yaegi. Split
// from internal/gate (which only declares the GateContext/Finding types)
// because the generated symbol table in gateextract imports internal/gate --
// this package sits above both to avoid the resulting import cycle.
package gateeval
import (
"errors"
"fmt"
"os"
"path/filepath"
"github.com/traefik/yaegi/interp"
"github.com/samcharles93/archie-core/internal/gate"
"github.com/samcharles93/archie-core/internal/gate/gateextract"
"github.com/samcharles93/archie-core/internal/yaegiutil"
)
// scriptPath is the per-repo custom gate script, relative to the
// worktree root.
const scriptPath = ".archie/gate.go"
// Evaluate loads and runs the repo's .archie/gate.go against gctx. A
// missing script is not an error -- it returns (nil, nil), meaning no
// custom gate is configured for this repo. The script runs in-process
// (interpreted, not sandboxed), so a panic inside it -- nil dereference,
// out-of-range index -- is recovered and returned as an error rather than
// taking down the daemon.
func Evaluate(gctx gate.GateContext) ([]gate.Finding, error) {
src, err := os.ReadFile(filepath.Join(gctx.Dir, scriptPath))
if err != nil {
if errors.Is(err, os.ErrNotExist) {
return nil, nil
}
return nil, fmt.Errorf("read %s: %w", scriptPath, err)
}
return yaegiutil.Safe(scriptPath, func() ([]gate.Finding, error) {
i, err := yaegiutil.New(interp.Options{}, gateextract.Symbols)
if err != nil {
return nil, err
}
check, err := yaegiutil.Resolve[func(gate.GateContext) []gate.Finding](i, string(src), "gate.Check")
if err != nil {
return nil, fmt.Errorf("%s: %w", scriptPath, err)
}
return check(gctx), nil
})
}