gates

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jul 8, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HasCriterion

func HasCriterion(requirementsDoc, id string) bool

HasCriterion reports whether id (e.g. "1.2") is a valid criterion address in the given requirements document.

func HasErrors

func HasErrors(findings []Finding) bool

Types

type CheckCtx

type CheckCtx struct {
	Root             string
	Slug             string
	Tasks            []core.TaskRow
	Status           map[string]core.TaskRunStatus // marker-derived (tasks.md truth)
	Evidence         map[string]core.EvidenceRecord
	MaxContextTokens int

	// W4 gate inputs. Gate bodies stay pure over CheckCtx: the caller reads
	// files and state, the gates never touch disk. Zero values disable the
	// gate (parity: an empty CheckCtx yields no findings).
	StateLoaded          bool                          // caller loaded state.json for this spec
	StateTaskStatus      map[string]core.TaskRunStatus // machine truth from state.json
	ApprovedRequirements bool
	ApprovedDesign       bool
	ApproveTarget        string // the gate being approved ("design" arms the design-stub gate)
	RequirementsDoc      string // requirements.md bytes ("" = not provided)
	RequirementsStub     string // the scaffold stub to compare against (ADR-10 single source)
	DesignDoc            string
	DesignStub           string

	// Criteria gate inputs (spec 04 R6, opt-in). CriteriaRequired mirrors
	// config criteria.required; CriteriaUnmet lists acceptance-criterion ids
	// with no current passing record. Both zero ⇒ gate disabled.
	CriteriaRequired bool
	CriteriaUnmet    []string

	// Review gate inputs (spec 09 R3/R4/R5, opt-in). ReviewRequired mirrors
	// config review.required. The caller reads review_report.md, parses it, and
	// fills these — the gate never touches disk. ReviewParseErr non-empty means
	// the report is missing or malformed (fail closed). ReviewExpectedHead is the
	// current git HEAD the approval must be fresh against. All zero ⇒ disabled.
	ReviewRequired     bool
	ReviewParseErr     string
	ReviewVerdict      string
	ReviewHead         string
	ReviewFindings     string
	ReviewExpectedHead string

	// Program-link gate input (spec 12 R5). When the gate under approval is the
	// execution transition, the caller fills ProgramDepsIncomplete with the
	// cross-spec dependencies that are not yet complete; a non-empty list refuses
	// the approval. Empty ⇒ disabled (planning phases are never program-gated).
	ProgramDepsIncomplete []string
}

type CriterionID

type CriterionID struct {
	Req int
	Sub int
}

CriterionID names a single acceptance criterion of a requirement, addressed as "<req>.<sub>" (e.g. "1.2" = the second criterion of requirement R1).

func CriterionIDs

func CriterionIDs(requirementsDoc string) []CriterionID

CriterionIDs enumerates the acceptance-criterion ids declared in an EARS requirements document, in document order. It reuses the same bullet-oriented reading as the EARS gate so there is a single source of truth for what counts as a requirement (spec 04 R2, design note "one parser, no second source").

A requirement is a top-level bullet whose text begins with an "R<n>" id. Its acceptance criteria are the more-indented sub-bullets beneath it, numbered 1..k in order. A requirement with no sub-bullets is itself a single criterion "<r>.1", so the flat one-bullet-per-requirement style still yields addressable ids.

func (CriterionID) String

func (c CriterionID) String() string

String renders the "<req>.<sub>" address used on the command line and in evidence records.

type Finding

type Finding struct {
	Gate     string   `json:"gate"`
	Severity Severity `json:"severity"`
	Message  string   `json:"message"`
}

type Gate

type Gate interface {
	Name() string
	Run(CheckCtx) []Finding
}

type Registry

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

func CoreRegistry

func CoreRegistry() Registry

func NewRegistry

func NewRegistry() Registry

func (Registry) Names

func (r Registry) Names() []string

func (*Registry) Register

func (r *Registry) Register(gate Gate)

func (Registry) Run

func (r Registry) Run(ctx CheckCtx) []Finding

type Severity

type Severity string
const (
	Info  Severity = "info"
	Warn  Severity = "warn"
	Error Severity = "error"
)

Directories

Path Synopsis
Package security implements the opt-in deterministic security gate (spec 05).
Package security implements the opt-in deterministic security gate (spec 05).

Jump to

Keyboard shortcuts

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