domain

package
v1.37.0 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2026 License: AGPL-3.0 Imports: 2 Imported by: 0

Documentation

Overview

Package domain contains pure domain types for the backlog subsystem. It imports only standard library packages — no ent, no headless, no git deps — so it can be imported by any layer (server, adapters, pkg/events) without creating an import cycle with the parent session package.

Index

Constants

View Source
const (
	ReviewVerdictPass         = ReviewOutcomePass
	ReviewVerdictFail         = ReviewOutcomeFail
	ReviewVerdictPartial      = ReviewOutcomePartial
	ReviewVerdictUnverifiable = ReviewOutcomeUnverifiable
)

Backward-compatible aliases so callers can be migrated incrementally. Prefer ReviewOutcome* constants in new code.

View Source
const DefaultBacklogPriority = 3

DefaultBacklogPriority is the default priority assigned to new backlog items when no priority is specified. Lower values indicate higher priority.

Variables

View Source
var (
	ErrACRequired            = errors.New("acceptance criteria required before marking ready")
	ErrPlanRequired          = errors.New("plan must be approved or skip_planning must be true before spawning work session")
	ErrPlanArtifactsRequired = errors.New("plan artifacts path is required when planning is not skipped")
	ErrVerdictRequired       = errors.New("PASS verdict or manual override required before marking done")
	ErrPRRequired            = errors.New("code changes must be shipped via PR before marking done; create a PR or provide override_reason")
)

Sentinel errors for transition guards.

Functions

func CanTransitionBacklog

func CanTransitionBacklog(from, to BacklogStatus) bool

CanTransitionBacklog reports whether a transition from one backlog status to another is permitted.

func TransitionGuard

func TransitionGuard(item BacklogItemTransitionInput, to BacklogStatus) error

TransitionGuard validates business rules before a status transition. It returns nil when the transition is allowed, or a sentinel error when a guard condition is violated. It does NOT check CanTransition — callers must invoke CanTransition separately if structural validity is also required.

func ValidTransitions

func ValidTransitions() map[BacklogStatus]map[BacklogStatus]bool

ValidTransitions returns a deep copy of the authoritative transition table. Callers that need a local snapshot (e.g. for concurrent reads without repeated map lookups) should call this once at construction time.

Types

type AcCriteriaJSON

type AcCriteriaJSON string

AcCriteriaJSON is the JSON-serialized form of []AcCriterion stored in the DB. Using a named type prevents silently passing Description or other string fields where serialized AC criteria are expected.

const AcCriteriaJSONEmpty AcCriteriaJSON = ""

AcCriteriaJSONEmpty is the zero value — an empty criteria list.

func SerializeAcCriteria

func SerializeAcCriteria(criteria []AcCriterion) (AcCriteriaJSON, error)

SerializeAcCriteria serializes acceptance criteria to an AcCriteriaJSON value.

func (AcCriteriaJSON) IsEmpty

func (j AcCriteriaJSON) IsEmpty() bool

IsEmpty reports whether j contains no criteria JSON.

func (AcCriteriaJSON) Parse

func (j AcCriteriaJSON) Parse() ([]AcCriterion, error)

Parse deserializes the criteria from JSON.

type AcCriterion

type AcCriterion struct {
	Index  int      `json:"index"`
	Text   string   `json:"text"`
	Status AcStatus `json:"status"` // pending, in_progress, done, fail
	Note   string   `json:"note,omitempty"`
}

AcCriterion is a single acceptance criterion for a backlog item.

func ParseAcCriteria

func ParseAcCriteria(raw AcCriteriaJSON) ([]AcCriterion, error)

ParseAcCriteria deserializes acceptance criteria from a JSON string.

type AcStatus

type AcStatus string

AcStatus represents the status of a single acceptance criterion.

const (
	AcStatusPending    AcStatus = "pending"
	AcStatusInProgress AcStatus = "in_progress"
	AcStatusDone       AcStatus = "done"
	AcStatusFail       AcStatus = "fail"
)

func (AcStatus) IsValid

func (s AcStatus) IsValid() bool

IsValid reports whether s is a known AC status value.

type BacklogItemTransitionInput

type BacklogItemTransitionInput struct {
	Status            BacklogStatus
	AcCriteria        AcCriteriaJSON // serialized acceptance criteria
	PlanApproved      bool
	SkipPlanning      bool
	PlanArtifactsPath string        // path to plan artifacts written by triage session
	OverallOutcome    ReviewOutcome // from linked ReviewVerdict
	OverrideReason    string
	// HasUnshippedCode is true when a work session made commits in a worktree
	// (LastCommitSha != "") but no PR was ever created (PrURL == "").
	// The review→done guard uses this to block premature done transitions.
	HasUnshippedCode bool
}

BacklogItemTransitionInput carries the fields needed by TransitionGuard.

type BacklogStatus

type BacklogStatus string

BacklogStatus represents the lifecycle state of a backlog item.

const (
	BacklogStatusIdea       BacklogStatus = "idea"
	BacklogStatusRefining   BacklogStatus = "refining"
	BacklogStatusReady      BacklogStatus = "ready"
	BacklogStatusInProgress BacklogStatus = "in_progress"
	BacklogStatusReview     BacklogStatus = "review"
	BacklogStatusPRPending  BacklogStatus = "pr_pending"
	BacklogStatusDone       BacklogStatus = "done"
	BacklogStatusArchived   BacklogStatus = "archived"
)

type CriterionVerdict

type CriterionVerdict struct {
	CriterionIndex int           `json:"criterion_index"`
	Outcome        ReviewOutcome `json:"outcome"`
	Evidence       string        `json:"evidence"`
}

CriterionVerdict holds the review outcome for a single acceptance criterion.

type ReviewOutcome

type ReviewOutcome string

ReviewOutcome is a typed verdict outcome value (PASS, FAIL, PARTIAL, UNVERIFIABLE).

const (
	ReviewOutcomePass         ReviewOutcome = "PASS"
	ReviewOutcomeFail         ReviewOutcome = "FAIL"
	ReviewOutcomePartial      ReviewOutcome = "PARTIAL"
	ReviewOutcomeUnverifiable ReviewOutcome = "UNVERIFIABLE"
)

func AggregateOutcome

func AggregateOutcome(verdicts []CriterionVerdict) ReviewOutcome

AggregateOutcome computes the overall outcome from a slice of CriterionVerdicts. Priority (highest to lowest): FAIL > PARTIAL > UNVERIFIABLE > PASS. Returns FAIL when the slice is empty to prevent auto-approval of empty reviews.

func (ReviewOutcome) IsValid

func (o ReviewOutcome) IsValid() bool

IsValid reports whether o is a recognised review outcome.

Jump to

Keyboard shortcuts

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