compose

package
v0.0.1-alpha.2 Latest Latest
Warning

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

Go to latest
Published: Jul 25, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package compose implements the spec→ship phase machine (ADR-0002) that enforces the house gates: grill → spec → implement → verify → review → finish. The machine's job is to make the gates unskippable — a phase cannot be left until its gate is satisfied, so "no code before an approved spec" and "no finish with an open Advisor finding" are structural rather than advisory.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrGateBlocked means the current phase's gate is not satisfied yet.
	ErrGateBlocked = errors.New("compose: phase gate blocked")
	// ErrTDDViolation means production code was attempted before a failing test.
	ErrTDDViolation = errors.New("compose: TDD violation")
	// ErrWrongPhase means the operation is not valid in the current phase.
	ErrWrongPhase = errors.New("compose: wrong phase")
)

Sentinel errors. Callers use errors.Is to distinguish a blocked gate (retry after satisfying it) from a TDD violation (the caller did something in the wrong order).

Functions

This section is empty.

Types

type Finding

type Finding struct {
	ID       string
	Detail   string
	Resolved bool
}

Finding is one Advisor review finding.

type Phase

type Phase int

Phase is one step of the compose workflow.

const (
	PhaseGrill Phase = iota
	PhaseSpec
	PhaseImplement
	PhaseVerify
	PhaseReview
	PhaseFinish
)

func Phases

func Phases() []Phase

Phases returns the ordered phase sequence.

func (Phase) String

func (p Phase) String() string

type Session

type Session struct {
	// Root is the project root; feature documents live under
	// <Root>/docs/compose/spec/.
	Root string
	// Feature names the feature being composed.
	Feature string
	// contains filtered or unexported fields
}

Session is one feature's walk through the compose phases.

func NewSession

func NewSession(root, feature string) *Session

NewSession starts a compose session for feature, rooted at root.

func (*Session) AddFinding

func (s *Session) AddFinding(id, detail string)

AddFinding records an Advisor finding. Open findings block finish.

func (*Session) AddTask

func (s *Session) AddTask(id, title string) error

AddTask registers an implementable task in the implement phase.

func (*Session) Advance

func (s *Session) Advance() error

Advance moves to the next phase if the current phase's gate is satisfied, otherwise returns ErrGateBlocked and stays put.

func (*Session) ApproveSpec

func (s *Session) ApproveSpec() error

ApproveSpec marks the written spec approved, opening the implement gate.

func (*Session) CompleteGrill

func (s *Session) CompleteGrill(notes string) error

CompleteGrill records the clarifying notes from the grill phase and advances to spec. Empty notes mean the grill did not actually happen.

func (*Session) Current

func (s *Session) Current() Phase

Current returns the active phase.

func (*Session) GrillNotes

func (s *Session) GrillNotes() string

GrillNotes returns the recorded grill notes.

func (*Session) MarkTaskGreen

func (s *Session) MarkTaskGreen(id string) error

MarkTaskGreen records that a task's tests now pass. Requires production code, which in turn required a red test.

func (*Session) OpenFindings

func (s *Session) OpenFindings() []Finding

OpenFindings returns the unresolved findings.

func (*Session) RecordAdvisorRun

func (s *Session) RecordAdvisorRun() error

RecordAdvisorRun records that the Advisor review pass actually ran. Zero findings only counts when the Advisor ran (T-081).

func (*Session) RecordFailingTest

func (s *Session) RecordFailingTest(id string) error

RecordFailingTest records that a failing (red) test was shown for a task — the precondition for writing production code.

func (*Session) RecordProductionCode

func (s *Session) RecordProductionCode(id string) error

RecordProductionCode records production code for a task. It is refused unless a failing test was recorded first (TDD gate, T-081).

func (*Session) RecordVerifyPass

func (s *Session) RecordVerifyPass() error

RecordVerifyPass records the verify phase's evidence (build/tests green).

func (*Session) ResolveFinding

func (s *Session) ResolveFinding(id string) bool

ResolveFinding marks a finding resolved, reporting whether the id was found.

func (*Session) SpecPath

func (s *Session) SpecPath() string

SpecPath is where this feature's spec document lives.

func (*Session) Tasks

func (s *Session) Tasks() []Task

Tasks returns the registered tasks.

func (*Session) WriteSpec

func (s *Session) WriteSpec(body string) error

WriteSpec writes the feature spec document. Writing is not approval — the spec gate still requires ApproveSpec.

type Task

type Task struct {
	ID    string
	Title string
	// FailingTest records that a red test was shown for this task.
	FailingTest bool
	// ProductionCode records that production code was written (only legal after
	// FailingTest).
	ProductionCode bool
	// Green records that the task's tests now pass.
	Green bool
}

Task is one implementable unit inside the implement phase. The TDD gate tracks its red→green progression.

Jump to

Keyboard shortcuts

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