gate

package
v0.3.26 Latest Latest
Warning

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

Go to latest
Published: Jun 15, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package gate runs a quest's auto gates and records their observed results. qm is the verifier of auto gates: it runs the check and reads the verdict. The agent never passes a gate; the human checks toggle gates and stamps done. Supported auto gates are cmd:<shell> plus a small set of GitHub PR gates backed by structured gh JSON. Results are transient and observed, so they live in a runtime sidecar (sidecar.go), never in the quest JSON.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type QuestResults

type QuestResults struct {
	QuestID string            `json:"quest_id"`
	Gates   map[string]Result `json:"gates"`
}

QuestResults is the latest auto-gate results for one quest, keyed by gate name. It is observed, transient runtime state — it lives in the sidecar, never in the quest JSON.

func (QuestResults) RanAtMap added in v0.3.21

func (q QuestResults) RanAtMap() map[string]time.Time

RanAtMap projects the results to gate-name → observation time, so renderers can show how fresh each verdict is. Zero times (legacy sidecar files) are omitted.

func (QuestResults) StatusMap

func (q QuestResults) StatusMap() map[string]string

StatusMap projects the results to gate-name → status string, the shape the renderer overlays onto the detail pane (pass/fail/error).

type Result

type Result struct {
	Gate   string    `json:"gate"`
	Status Status    `json:"status"`
	Output string    `json:"output,omitempty"` // combined stdout+stderr (snippet)
	RanAt  time.Time `json:"ran_at"`
}

Result is one auto-gate run's observed outcome.

func RunCheck

func RunCheck(name, check, worktree string) Result

RunCheck runs a gate's check in worktree and classifies the verdict. The shell for cmd:<shell> checks and gh for github:* checks run with worktree as their working directory. The runner fabricates nothing; it only observes the check the quest authored.

func (Result) Misconfigured

func (r Result) Misconfigured() bool

Misconfigured reports whether the result is a broken check rather than a real failure — surfaced distinctly so it announces itself instead of masquerading as the gate being unmet.

type Sidecar

type Sidecar struct {
	// contains filtered or unexported fields
}

Sidecar is the runtime store of auto-gate results, one JSON file per quest at <dir>/<id>.json. dir is under qm's dotfiles (a sibling of the quest store), never a repo. The quest JSON is never touched by a check run.

func NewSidecar

func NewSidecar(dir string) *Sidecar

NewSidecar returns a sidecar rooted at dir (created lazily on Save).

func (*Sidecar) Dir

func (s *Sidecar) Dir() string

Dir returns the sidecar's root directory.

func (*Sidecar) Load

func (s *Sidecar) Load(questID string) (QuestResults, error)

Load reads a quest's results, returning empty (not an error) when none have been recorded yet.

func (*Sidecar) Save

func (s *Sidecar) Save(questID string, results []Result) error

Save writes the latest results for a quest atomically (tmp + rename).

type Status

type Status string

Status is the verdict of an auto-gate run.

const (
	// StatusPass means the check ran and exited zero.
	StatusPass Status = "pass"
	// StatusFail means the check ran and exited nonzero — legitimately unmet.
	StatusFail Status = "fail"
	// StatusError means the check did not execute to a real verdict: a broken
	// or misconfigured check (command not found, not executable, unsupported
	// check type). It must never be mistaken for a real failure.
	StatusError Status = "error"
)

Jump to

Keyboard shortcuts

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