verify

package
v0.26.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 4, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNoConfig = errors.New("no .moa/verify.json found — create one to define verification checks")

ErrNoConfig is returned by Execute when the project has no .moa/verify.json. Callers that gate on check results (e.g. the goal verifier) use it to tell "no checks defined" apart from "checks defined but failing".

Functions

func FormatResult

func FormatResult(r Result) string

FormatResult produces a human-readable summary. Only failed checks include their output.

func NewTool

func NewTool(sessionCWD string, allowed PathChecker) core.Tool

NewTool creates the verify tool. sessionCWD is the workspace root used to locate .moa/verify.json when a call does not name a directory; allowed bounds which other directories a call may target (nil means no bound).

func ResolveWorkDir added in v0.24.0

func ResolveWorkDir(sessionCWD, dir string, allowed PathChecker) (string, error)

ResolveWorkDir resolves an optional working-directory override against the session's CWD.

An empty dir keeps the session CWD. A relative dir resolves against it. The result must exist, be a directory, and pass allowed: running a .moa/verify.json means running the shell commands it contains, so accepting any directory would turn verify into a way out of the sandbox. In unrestricted (YOLO) mode the policy allows everything, so this only constrains sessions that asked to be constrained.

Types

type Check

type Check struct {
	Name    string `json:"name"`
	Command string `json:"command"`
	Timeout string `json:"timeout,omitempty"` // Go duration string, default "5m"
}

Check defines a single verification step.

type CheckResult

type CheckResult struct {
	Name     string
	Command  string
	Passed   bool
	Output   string // combined stdout+stderr
	ExitCode int
	TimedOut bool
	Elapsed  time.Duration
}

CheckResult holds the outcome of a single check execution.

type Config

type Config struct {
	Checks []Check `json:"checks"`
}

Config holds the verification configuration loaded from .moa/verify.json.

func LoadConfig

func LoadConfig(cwd string) (*Config, error)

LoadConfig reads .moa/verify.json from cwd. Returns (nil, nil) if the file doesn't exist (feature disabled). Returns (nil, error) if the file exists but is invalid.

func (*Config) Validate

func (c *Config) Validate() error

Validate checks for structural errors. Returns an actionable error referencing the check index/name for the first problem found.

type PathChecker added in v0.24.0

type PathChecker interface {
	IsAllowed(realPath string) bool
}

PathChecker reports whether a directory may be used as a verify working directory. *tool.PathPolicy satisfies it; taking the interface keeps pkg/verify from depending on pkg/tool.

type Result

type Result struct {
	Checks  []CheckResult
	AllPass bool
}

Result holds the outcome of all checks.

func Execute

func Execute(ctx context.Context, cwd string) (Result, error)

Execute is the single entry point for running verification. Both the verify tool and the TUI /verify command call this.

func ExecuteWithConfig

func ExecuteWithConfig(ctx context.Context, cwd string, cfg Config) Result

ExecuteWithConfig runs verification with a pre-loaded config. Used by the tool to support check filtering.

func Run

func Run(ctx context.Context, cwd string, cfg Config) Result

Run executes all checks sequentially. If the parent ctx is cancelled, remaining checks are skipped.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL