todo

package
v0.34.0 Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidSource = errors.New("not a valid Source")
View Source
var ErrInvalidStatus = errors.New("not a valid Status")

Functions

func ValidateTransition

func ValidateTransition(from, to Status) error

ValidateTransition checks whether a status change is allowed.

Types

type ListFilter

type ListFilter struct {
	Status    *Status
	SessionID string
	Scheme    string // filter by URI scheme
}

ListFilter controls which todo items are returned by List.

type Ref

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

Ref is a typed URI reference for a todo item. Format: "scheme://value" where scheme identifies the action type. Fields are unexported; use Scheme() and Value() getters.

func MustParseRef

func MustParseRef(raw string) Ref

MustParseRef is like ParseRef but panics on error. Use only in tests and initialization code.

func ParseRef

func ParseRef(raw string) (Ref, error)

ParseRef parses a URI string into scheme and value. Schemes are normalized to lowercase. Returns an error if the string is non-empty but has no "://" separator.

func (Ref) GoString

func (r Ref) GoString() string

GoString implements fmt.GoStringer for debugging.

func (Ref) IsEmpty

func (r Ref) IsEmpty() bool

IsEmpty returns true when no ref is set.

func (Ref) MarshalText

func (r Ref) MarshalText() ([]byte, error)

MarshalText implements encoding.TextMarshaler.

func (Ref) Scheme

func (r Ref) Scheme() string

Scheme returns the URI scheme (e.g. "session", "review", "https").

func (Ref) String

func (r Ref) String() string

String returns the wire format "scheme://value".

func (*Ref) UnmarshalText

func (r *Ref) UnmarshalText(data []byte) error

UnmarshalText implements encoding.TextUnmarshaler.

func (Ref) Valid

func (r Ref) Valid() bool

Valid returns true when the ref is either empty or has a scheme. A non-empty value without a scheme is invalid (bare string).

func (Ref) Value

func (r Ref) Value() string

Value returns the scheme-dependent value portion of the URI.

type Source

type Source string

Source identifies who created the todo.

ENUM(

agent
human
system

)

const (
	// SourceAgent is a Source of type agent.
	SourceAgent Source = "agent"
	// SourceHuman is a Source of type human.
	SourceHuman Source = "human"
	// SourceSystem is a Source of type system.
	SourceSystem Source = "system"
)

func ParseSource

func ParseSource(name string) (Source, error)

ParseSource attempts to convert a string to a Source.

func (Source) IsValid

func (x Source) IsValid() bool

IsValid provides a quick way to determine if the typed value is part of the allowed enumerated values

func (Source) String

func (x Source) String() string

String implements the Stringer interface.

type Status

type Status string

Status tracks the lifecycle of a todo item.

ENUM(

pending
acknowledged
completed
dismissed

)

const (
	// StatusPending is a Status of type pending.
	StatusPending Status = "pending"
	// StatusAcknowledged is a Status of type acknowledged.
	StatusAcknowledged Status = "acknowledged"
	// StatusCompleted is a Status of type completed.
	StatusCompleted Status = "completed"
	// StatusDismissed is a Status of type dismissed.
	StatusDismissed Status = "dismissed"
)

func ParseStatus

func ParseStatus(name string) (Status, error)

ParseStatus attempts to convert a string to a Status.

func (Status) IsValid

func (x Status) IsValid() bool

IsValid provides a quick way to determine if the typed value is part of the allowed enumerated values

func (Status) String

func (x Status) String() string

String implements the Stringer interface.

type Store

type Store interface {
	Create(ctx context.Context, t Todo) error
	Get(ctx context.Context, id string) (Todo, error)
	Update(ctx context.Context, id string, status Status) error
	List(ctx context.Context, filter ListFilter) ([]Todo, error)
	CountPending(ctx context.Context) (int, error)
	CountOpen(ctx context.Context) (int, error)
	CountRecentBySession(ctx context.Context, sessionID string, since time.Time) (int, error)
	Delete(ctx context.Context, id string) error
}

Store persists todo items to durable storage.

type Todo

type Todo struct {
	ID          string    `json:"id"`
	SessionID   string    `json:"session_id"`
	Source      Source    `json:"source"`
	Title       string    `json:"title"`
	URI         Ref       `json:"uri"`
	Status      Status    `json:"status"`
	CreatedAt   time.Time `json:"created_at"`
	UpdatedAt   time.Time `json:"updated_at"`
	CompletedAt time.Time `json:"completed_at,omitzero"`
}

Todo represents a single todo item created by an agent or human.

func NewAgentTodo

func NewAgentTodo(id, title, sessionID string, uri Ref) (Todo, error)

NewAgentTodo creates an agent-sourced todo and requires SessionID.

func NewHumanTodo

func NewHumanTodo(id, title string, uri Ref) (Todo, error)

NewHumanTodo creates a human-sourced todo.

func NewSystemTodo

func NewSystemTodo(id, title string, uri Ref) (Todo, error)

NewSystemTodo creates a system-sourced todo.

func (Todo) Validate

func (t Todo) Validate() error

Validate checks that a Todo has internally consistent required fields.

Jump to

Keyboard shortcuts

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