types

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Mar 8, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package types defines core data structures for the arc issue tracker.

Index

Constants

View Source
const MaxPrefixLength = 15

MaxPrefixLength is the maximum allowed workspace prefix length. Must match workspace.MaxPrefixLength (kept separate to avoid circular imports).

Variables

This section is empty.

Functions

This section is empty.

Types

type BlockedIssue

type BlockedIssue struct {
	Issue
	BlockedByCount int      `json:"blocked_by_count"`
	BlockedBy      []string `json:"blocked_by"`
}

BlockedIssue extends Issue with blocking information.

type Comment

type Comment struct {
	ID          int64       `json:"id"`
	IssueID     string      `json:"issue_id"`
	Author      string      `json:"author"`
	Text        string      `json:"text"`
	CommentType CommentType `json:"comment_type"`
	CreatedAt   time.Time   `json:"created_at"`
	UpdatedAt   time.Time   `json:"updated_at"`
}

Comment represents a comment on an issue.

type CommentType added in v0.7.0

type CommentType string

CommentType distinguishes between regular comments and inline plans.

const (
	CommentTypeComment CommentType = "comment"
	CommentTypePlan    CommentType = "plan"
)

func (CommentType) IsValid added in v0.7.0

func (c CommentType) IsValid() bool

IsValid checks if the comment type value is valid.

type Dependency

type Dependency struct {
	IssueID     string         `json:"issue_id"`
	DependsOnID string         `json:"depends_on_id"`
	Type        DependencyType `json:"type"`
	CreatedAt   time.Time      `json:"created_at"`
	CreatedBy   string         `json:"created_by,omitempty"`
}

Dependency represents a relationship between issues.

type DependencyType

type DependencyType string

DependencyType categorizes the relationship.

const (
	DepBlocks         DependencyType = "blocks"
	DepParentChild    DependencyType = "parent-child"
	DepRelated        DependencyType = "related"
	DepDiscoveredFrom DependencyType = "discovered-from"
)

func AllDependencyTypes

func AllDependencyTypes() []DependencyType

AllDependencyTypes returns all valid dependency type values.

func (DependencyType) AffectsReadyWork

func (d DependencyType) AffectsReadyWork() bool

AffectsReadyWork returns true if this dependency type blocks work.

func (DependencyType) IsValid

func (d DependencyType) IsValid() bool

IsValid checks if the dependency type value is valid.

type Event

type Event struct {
	ID        int64     `json:"id"`
	IssueID   string    `json:"issue_id"`
	EventType EventType `json:"event_type"`
	Actor     string    `json:"actor"`
	OldValue  *string   `json:"old_value,omitempty"`
	NewValue  *string   `json:"new_value,omitempty"`
	Comment   *string   `json:"comment,omitempty"`
	CreatedAt time.Time `json:"created_at"`
}

Event represents an audit trail entry.

type EventType

type EventType string

EventType categorizes audit trail events.

const (
	EventCreated           EventType = "created"
	EventUpdated           EventType = "updated"
	EventStatusChanged     EventType = "status_changed"
	EventCommented         EventType = "commented"
	EventClosed            EventType = "closed"
	EventReopened          EventType = "reopened"
	EventDependencyAdded   EventType = "dependency_added"
	EventDependencyRemoved EventType = "dependency_removed"
	EventLabelAdded        EventType = "label_added"
	EventLabelRemoved      EventType = "label_removed"
)

type Issue

type Issue struct {
	// Core Identification
	ID          string `json:"id"`
	WorkspaceID string `json:"workspace_id"`
	ParentID    string `json:"parent_id,omitempty"` // For hierarchical child IDs (e.g., parent-id.1)

	// Issue Content
	Title       string `json:"title"`
	Description string `json:"description,omitempty"`

	// Status & Workflow
	Status    Status    `json:"status"`
	Priority  int       `json:"priority"` // 0 (critical) - 4 (backlog)
	Rank      int       `json:"rank"`     // 0 = unranked (sorts last), 1+ = lower rank = work on first
	IssueType IssueType `json:"issue_type"`

	// Assignment
	Assignee string `json:"assignee,omitempty"`

	// Timestamps
	CreatedAt   time.Time  `json:"created_at"`
	UpdatedAt   time.Time  `json:"updated_at"`
	ClosedAt    *time.Time `json:"closed_at,omitempty"`
	CloseReason string     `json:"close_reason,omitempty"`

	// External Integration
	ExternalRef string `json:"external_ref,omitempty"` // e.g., "gh-9", "jira-ABC"

	// Relational Data (populated for detail views)
	Labels       []string      `json:"labels,omitempty"`
	Dependencies []*Dependency `json:"dependencies,omitempty"`
	Comments     []*Comment    `json:"comments,omitempty"`
}

Issue represents a trackable work item.

func (*Issue) SetDefaults

func (i *Issue) SetDefaults()

SetDefaults applies default values for missing fields.

func (*Issue) Validate

func (i *Issue) Validate() error

Validate checks if the issue has valid field values.

type IssueDetails

type IssueDetails struct {
	Issue
	Labels       []string      `json:"labels,omitempty"`
	Dependencies []*Dependency `json:"dependencies,omitempty"`
	Dependents   []*Dependency `json:"dependents,omitempty"`
	Comments     []*Comment    `json:"comments,omitempty"`
	PlanContext  *PlanContext  `json:"plan_context,omitempty"`
}

IssueDetails extends Issue with full relational data.

type IssueFilter

type IssueFilter struct {
	WorkspaceID string     // Required: filter by workspace
	Status      *Status    // Filter by status
	Priority    *int       // Filter by priority
	IssueType   *IssueType // Filter by issue type
	Assignee    *string    // Filter by assignee
	Labels      []string   // AND semantics: issue must have ALL these labels
	ParentID    string     // Filter by parent issue (via parent-child dependency)
	Query       string     // Full-text search in title/description
	IDs         []string   // Filter by specific issue IDs
	Limit       int        // Maximum results to return
	Offset      int        // Pagination offset
}

IssueFilter is used to filter issue queries.

type IssueType

type IssueType string

IssueType categorizes the kind of work.

const (
	TypeBug     IssueType = "bug"
	TypeFeature IssueType = "feature"
	TypeTask    IssueType = "task"
	TypeEpic    IssueType = "epic"
	TypeChore   IssueType = "chore"
)

func AllIssueTypes

func AllIssueTypes() []IssueType

AllIssueTypes returns all valid issue type values.

func (IssueType) IsValid

func (t IssueType) IsValid() bool

IsValid checks if the issue type is valid.

type Label

type Label struct {
	Name        string `json:"name"`
	Color       string `json:"color,omitempty"`
	Description string `json:"description,omitempty"`
}

Label represents a global tag that can be applied to issues.

type OpenChildrenError added in v0.11.0

type OpenChildrenError struct {
	IssueID  string  // The issue that cannot be closed
	Children []Issue // The open child issues
}

OpenChildrenError is returned when attempting to close an issue that has open child issues.

func (*OpenChildrenError) Error added in v0.11.0

func (e *OpenChildrenError) Error() string

Error implements the error interface.

type Plan added in v0.7.0

type Plan struct {
	ID          string    `json:"id"` // plan.xxxxx format
	WorkspaceID string    `json:"workspace_id"`
	Title       string    `json:"title"`
	Content     string    `json:"content"`
	CreatedAt   time.Time `json:"created_at"`
	UpdatedAt   time.Time `json:"updated_at"`
	// LinkedIssues contains issue IDs linked to this plan (populated on detail views)
	LinkedIssues []string `json:"linked_issues,omitempty"`
}

Plan represents a shared plan that can be linked to multiple issues.

func (*Plan) Validate added in v0.7.0

func (p *Plan) Validate() error

Validate checks if the plan has valid field values.

type PlanContext added in v0.7.0

type PlanContext struct {
	// InlinePlan is a plan comment directly on this issue
	InlinePlan *Comment `json:"inline_plan,omitempty"`
	// ParentPlan is a plan inherited from a parent issue
	ParentPlan *Comment `json:"parent_plan,omitempty"`
	// ParentIssueID is the ID of the parent issue if ParentPlan is set
	ParentIssueID string `json:"parent_issue_id,omitempty"`
	// SharedPlans are standalone plans linked to this issue
	SharedPlans []*Plan `json:"shared_plans,omitempty"`
}

PlanContext aggregates all plans relevant to an issue. It supports three patterns: 1. InlinePlan: A plan comment directly on the issue 2. ParentPlan: A plan inherited from a parent issue (via parent-child dependency) 3. SharedPlans: Standalone plans linked to this issue

func (*PlanContext) HasPlan added in v0.7.0

func (pc *PlanContext) HasPlan() bool

HasPlan returns true if any plan is available in this context.

type SortPolicy

type SortPolicy string

SortPolicy defines how ready work should be sorted.

const (
	// SortPolicyHybrid sorts recent issues (<48h) by priority/rank, older issues by age.
	// This prevents backlog starvation while keeping high-priority recent work visible.
	SortPolicyHybrid SortPolicy = "hybrid"

	// SortPolicyPriority always sorts by priority → rank → created_at.
	SortPolicyPriority SortPolicy = "priority"

	// SortPolicyOldest always sorts by created_at (oldest first) for backlog clearing.
	SortPolicyOldest SortPolicy = "oldest"
)

func AllSortPolicies

func AllSortPolicies() []SortPolicy

AllSortPolicies returns all valid sort policy values.

func (SortPolicy) IsValid

func (s SortPolicy) IsValid() bool

IsValid checks if the sort policy is valid.

type Statistics

type Statistics struct {
	WorkspaceID      string  `json:"workspace_id"`
	TotalIssues      int     `json:"total_issues"`
	OpenIssues       int     `json:"open_issues"`
	InProgressIssues int     `json:"in_progress_issues"`
	ClosedIssues     int     `json:"closed_issues"`
	BlockedIssues    int     `json:"blocked_issues"`
	DeferredIssues   int     `json:"deferred_issues"`
	ReadyIssues      int     `json:"ready_issues"`
	AvgLeadTimeHours float64 `json:"avg_lead_time_hours,omitempty"`
}

Statistics provides aggregate metrics for a workspace.

type Status

type Status string

Status represents the current state of an issue.

const (
	StatusOpen       Status = "open"
	StatusInProgress Status = "in_progress"
	StatusBlocked    Status = "blocked"
	StatusDeferred   Status = "deferred"
	StatusClosed     Status = "closed"
)

func AllStatuses

func AllStatuses() []Status

AllStatuses returns all valid status values.

func (Status) IsValid

func (s Status) IsValid() bool

IsValid checks if the status value is valid.

type WorkFilter

type WorkFilter struct {
	WorkspaceID string     // Required: filter by workspace
	Status      *Status    // Filter by status
	IssueType   *IssueType // Filter by issue type
	Priority    *int       // Filter by priority
	Assignee    *string    // Filter by assignee
	Unassigned  bool       // Filter for unassigned issues
	Labels      []string   // AND semantics
	SortPolicy  SortPolicy // Sort policy: hybrid (default), priority, oldest
	Limit       int        // Maximum results
}

WorkFilter is used to filter ready work queries.

type Workspace

type Workspace struct {
	ID          string    `json:"id"`             // Short hash ID (e.g., "ws-a1b2")
	Name        string    `json:"name"`           // Display name
	Path        string    `json:"path,omitempty"` // Optional: associated directory path
	Description string    `json:"description,omitempty"`
	Prefix      string    `json:"prefix"` // Issue ID prefix (e.g., "bd")
	CreatedAt   time.Time `json:"created_at"`
	UpdatedAt   time.Time `json:"updated_at"`
}

Workspace represents a project or workspace that contains issues. Replaces the per-repo concept from beads with explicit workspace management.

func (*Workspace) Validate

func (w *Workspace) Validate() error

Validate checks if the workspace has valid field values.

Jump to

Keyboard shortcuts

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