store

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package store owns all SQL and is the only package that imports the SQLite driver. It exposes domain types; callers never see *sql.Row.

Index

Constants

View Source
const StaleAfter = 7 * 24 * time.Hour

StaleAfter is how long an in-progress ticket may go untouched before get_context flags it (design open question #3).

Variables

View Source
var ErrNotFound = errors.New("not found")

ErrNotFound is returned when a ticket key does not resolve.

Functions

This section is empty.

Types

type BlockedTicket

type BlockedTicket struct {
	Key       string
	Title     string
	BlockedOn []domain.Link // tickets this one is blocked by (incoming blocks)
}

BlockedTicket names a blocked ticket and what it is blocked on.

type ContextReport

type ContextReport struct {
	Project    string // "" means all projects
	InProgress []ContextTicket
	Blocked    []BlockedTicket
	NextUp     []ContextTicket
	BacklogN   int
	DoneN      int
}

ContextReport is the structured backing for the get_context tool.

type ContextTicket

type ContextTicket struct {
	Key          string
	Title        string
	Priority     domain.Priority
	Status       domain.Status
	ParentKey    string
	LastActivity string // RFC3339-ish display time of last comment
	LastComment  string
	Stale        bool // in_progress/in_review and untouched beyond StaleAfter
	StaleDays    int  // whole days since updated_at, when Stale
}

ContextTicket is a ticket plus its most recent worklog excerpt.

type CreateParams

type CreateParams struct {
	Title       string
	Description string
	Project     string
	ParentKey   string
	Priority    domain.Priority
	Labels      []string
}

CreateParams carries the inputs for creating a ticket.

type SearchParams

type SearchParams struct {
	Query   string
	Status  string
	Project string
	Label   string
	Limit   int
}

SearchParams filters and full-text-searches tickets.

type SearchResult

type SearchResult struct {
	Key          string
	Title        string
	Status       domain.Status
	Priority     domain.Priority
	CommentCount int
	MatchedTitle bool // matched in title/description
	MatchedBody  bool // matched in a comment
	Snippet      string
}

SearchResult is a compact match for list rendering.

type Store

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

Store wraps a SQLite connection pool.

func Open

func Open(path string) (*Store, error)

Open opens (creating if needed) the database at path, applies pragmas and migrations, and returns a ready Store.

func (*Store) AddComment

func (s *Store) AddComment(ctx context.Context, key, author, body string) (int, error)

AddComment appends a worklog entry and touches the ticket's updated_at. Returns the new total comment count.

func (*Store) AllTickets

func (s *Store) AllTickets(ctx context.Context, project string) ([]domain.Ticket, error)

AllTickets returns every ticket (optionally filtered by project) as lightweight records — no comments, links, or subtasks loaded. Ordered by priority then most-recently-updated, suitable for the read-only board.

func (*Store) Backup

func (s *Store) Backup(ctx context.Context, dest string) error

Backup writes a consistent copy of the database to dest using VACUUM INTO. dest must not already exist.

func (*Store) Close

func (s *Store) Close() error

Close releases the database.

func (*Store) ContextReport

func (s *Store) ContextReport(ctx context.Context, project string) (ContextReport, error)

ContextReport assembles the working-state report. project == "" spans all.

func (*Store) CreateTicket

func (s *Store) CreateTicket(ctx context.Context, p CreateParams) (t domain.Ticket, existed bool, err error)

CreateTicket inserts a new ticket, allocating its key atomically from the project counter. If an open (non-terminal) ticket in the same project has a byte-identical title, that ticket is returned with existed=true and nothing is inserted — duplicates poison get_context, and agents retry.

func (*Store) GetTicketFull

func (s *Store) GetTicketFull(ctx context.Context, key string) (domain.Ticket, error)

GetTicketFull returns a ticket with its comments, subtasks, and links.

func (*Store) Search

func (s *Store) Search(ctx context.Context, p SearchParams) ([]SearchResult, error)

Search runs full-text search across ticket title/description and comment bodies, merges hits per ticket, applies filters, and ranks by bm25.

func (*Store) UpdateTicket

func (s *Store) UpdateTicket(ctx context.Context, p UpdateParams) (domain.Ticket, string, error)

UpdateTicket applies a partial update, validating status transitions through the FSM and recording any links. Returns the refreshed ticket and a short human-readable summary of what changed.

type UpdateParams

type UpdateParams struct {
	Key         string
	Status      *domain.Status
	Priority    *domain.Priority
	Title       *string
	Description *string
	Labels      *[]string
	LinkBlocks  string
	LinkRelates string
}

UpdateParams carries a partial update. Nil pointers mean "leave unchanged".

Jump to

Keyboard shortcuts

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