domain

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package domain holds the core ticket types and the status state machine. It knows nothing about MCP, SQLite, or any transport — it is pure data and rules, imported by store, cli, and mcptools alike.

Index

Constants

View Source
const ClaimTTL = 30 * time.Minute

ClaimTTL is how long a soft claim stays active without renewal. After this, the claim is considered stale and another agent may take the ticket — so a crashed or abandoned agent never blocks work indefinitely.

Variables

This section is empty.

Functions

func ValidateTransition

func ValidateTransition(key string, from, to Status) error

ValidateTransition returns nil if the move is legal, otherwise an error whose message tells the agent what it can do instead. Every validation error must be self-correcting prompt material.

Types

type Comment

type Comment struct {
	ID        int64
	TicketID  int64
	Author    string
	Body      string
	CreatedAt time.Time
}

Comment is an append-only worklog entry. There is no edit or delete.

type Link struct {
	Kind    LinkKind
	ToKey   string
	ToTitle string
}

Link is a directed relationship to another ticket, with the far ticket's key and title resolved for rendering.

type LinkKind

type LinkKind string

LinkKind enumerates the relationship types between tickets.

const (
	LinkBlocks  LinkKind = "blocks"
	LinkRelates LinkKind = "relates"
)

type Priority

type Priority int

Priority is an ordered severity; lower sorts first.

const (
	Critical Priority = iota // 0
	High                     // 1
	Normal                   // 2
	Low                      // 3
)

func ParsePriority

func ParsePriority(s string) (Priority, error)

ParsePriority maps a name to a Priority. Empty defaults to Normal.

func (Priority) String

func (p Priority) String() string

type Status

type Status string

Status is a ticket's position in the fixed workflow. The state machine is intentionally not configurable in v0.

const (
	Backlog    Status = "backlog"
	Todo       Status = "todo"
	InProgress Status = "in_progress"
	InReview   Status = "in_review"
	Blocked    Status = "blocked"
	Done       Status = "done"
	WontDo     Status = "wont_do"
)

func ParseStatus

func ParseStatus(s string) (Status, error)

ParseStatus validates a status string.

func (Status) CanTransition

func (s Status) CanTransition(to Status) bool

CanTransition reports whether moving from s to to is legal.

func (Status) IsTerminal

func (s Status) IsTerminal() bool

IsTerminal reports whether no transitions leave this status.

type Subtask

type Subtask struct {
	Key    string
	Title  string
	Status Status
}

Subtask is a lightweight view of a child ticket for rendering parents.

type Ticket

type Ticket struct {
	ID          int64
	Key         string
	Project     string
	Title       string
	Description string
	Status      Status
	Priority    Priority
	ParentID    *int64
	ParentKey   string // populated on read for rendering convenience
	Labels      []string
	CreatedAt   time.Time
	UpdatedAt   time.Time

	// ClaimedBy is the advisory owner (agent id); empty when unclaimed.
	// ClaimedAt drives TTL expiry of the soft claim.
	ClaimedBy string
	ClaimedAt time.Time

	// Populated only by GetTicketFull / context queries.
	Comments []Comment
	Subtasks []Subtask
	Links    []Link

	// CommentCount is set by lightweight list queries (e.g. the board) that
	// do not load the full Comments slice.
	CommentCount int
}

Ticket is the central record. Labels live as a decoded slice here even though the store persists them as a JSON column.

func (Ticket) ClaimActiveAt added in v0.2.0

func (k Ticket) ClaimActiveAt(t time.Time) bool

ClaimActiveAt reports whether the claim is held and not yet expired at t.

Jump to

Keyboard shortcuts

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