domain

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2026 License: CC0-1.0 Imports: 16 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package domain defines the shared vocabulary for Taskronin entities and operations.

Index

Constants

View Source
const DeferFutureDetail = "defer must be in the future"

DeferFutureDetail is the stable validation detail shared with API clients.

Variables

TriageOrder lists reasons from highest to lowest priority.

Functions

func BlockSpanText

func BlockSpanText(text string) string

BlockSpanText uses an en dash for the clock range in a block effect payload. An optional ISO date is preserved for the caller to format.

func EffectImplied

func EffectImplied(kind string, deleted, undeleted bool) bool

EffectImplied reports whether a deletion or restore of the same task already accounts for this effect in the operation's display. AIDEV-NOTE: J§4.4 is shared by cli.printOp, cli.printAIChanges and web.flashLines.

func EncodeCursor

func EncodeCursor(c Cursor) string

EncodeCursor returns unpadded base64url JSON, using the offset form when Keys is nil and ID is zero. Keys must be JSON-encodable; otherwise it panics.

func FormatETag

func FormatETag(g Generation, v Version) string

FormatETag returns the quoted strong ETag for g and v.

func ParseTokenExpiry

func ParseTokenExpiry(s string, now time.Time, zone civil.Zone) (sql.Null[time.Time], error)

ParseTokenExpiry parses the token expiry grammar shared by `tkr token create --expires` and `tkr init --mcp-token`: "never" (no expiry, an invalid sql.Null), a whole number of hours or days ("12h", "30d"; 1h to 100 years after now), or a date YYYY-MM-DD, which expires at 00:00 of that day in zone. The expiry must be after now. Errors are user-facing predicates ("must be ...") for the caller to prefix with the flag or prompt name.

AIDEV-NOTE: final review B-I3. One grammar for both commands: init used to accept Go durations (720h, 1h30m) but not the "30d" that token create suggests. Keep the two call sites on this function.

func ValidOpIDPrefix

func ValidOpIDPrefix(s string) bool

ValidOpIDPrefix reports whether s is 1 to 32 lowercase hex characters, the leading part of an op ID as `tkr` prints it.

Types

type Action

type Action string

Action identifies the change recorded in an event.

const (
	// ActInsert inserts an entity.
	ActInsert Action = "insert"
	// ActUpdate updates entity fields.
	ActUpdate Action = "update"
	// ActMove changes task ordering.
	ActMove Action = "move"
	// ActTombstone marks an entity deleted.
	ActTombstone Action = "tombstone"
	// ActUntombstone restores a deleted entity.
	ActUntombstone Action = "untombstone"
	// ActAdd adds a member to a collection.
	ActAdd Action = "add"
	// ActRemove removes a member from a collection.
	ActRemove Action = "remove"
	// ActSet replaces a value or set.
	ActSet Action = "set"
	// ActRevoke revokes a token.
	ActRevoke Action = "revoke"
	// ActPurge purges entity content.
	ActPurge Action = "purge"
)

type Actor

type Actor struct {
	Kind             ActorKind
	TokenID          TokenID // zero for system and web-session owner
	TokenName        string  // set only for ActorToken
	Scopes           Scopes
	Channel          Channel
	MutationsPerHour int    // zero means unlimited
	RemoteKey        string // "socket" or client IP; password-gate bucket key
}

Actor describes the authenticated caller of an operation.

func SystemActor

func SystemActor() Actor

SystemActor returns the internal actor with channel system and no scopes.

func (Actor) IsAI

func (a Actor) IsAI() bool

IsAI reports whether the actor is a non-owner token.

func (Actor) Key

func (a Actor) Key() string

Key returns the persisted actor key: owner, token:<name>, or system.

type ActorKind

type ActorKind uint8

ActorKind identifies the authority behind an operation.

const (
	// ActorOwner denotes the human owner.
	ActorOwner ActorKind = iota + 1
	// ActorToken denotes a named non-owner token.
	ActorToken ActorKind = iota + 1
	// ActorSystem denotes an internal operation.
	ActorSystem ActorKind = iota + 1
)

type BlockID

type BlockID int64

BlockID identifies a time block.

type BlockSpan

type BlockSpan struct {
	Date  civil.Date
	Start civil.Minute
	End   civil.EndMinute
}

BlockSpan is the half-open interval [Start, End) on Date, with 0 <= Start < End <= 1440.

func (BlockSpan) String

func (b BlockSpan) String() string

String returns YYYY-MM-DD HH:MM-HH:MM, allowing 24:00 as the end.

type BlockStatus

type BlockStatus string

BlockStatus is the lifecycle state of a time block.

const (
	// BlockPlanned marks a scheduled block.
	BlockPlanned BlockStatus = "planned"
	// BlockDone marks a block with task completion.
	BlockDone BlockStatus = "done"
	// BlockWorked marks a block with work recorded.
	BlockWorked BlockStatus = "worked"
	// BlockMissed marks a block without work.
	BlockMissed BlockStatus = "missed"
	// BlockCancelled marks a cancelled block.
	BlockCancelled BlockStatus = "cancelled"
)

func (BlockStatus) Valid

func (s BlockStatus) Valid() bool

Valid reports whether s is a declared block status.

type BlockView

type BlockView struct {
	TimeBlock
	TaskTitle    string
	TaskVersion  Version // task precondition for reblock (R4-7)
	Current      bool    // planned and [start,end) contains now
	Started      bool    // start instant <= now
	Ended        bool    // end instant <= now
	NeedsReblock bool    // planned, ended, no non-deleted entry for (task, date)
}

BlockView adds the associated task and derived interval state to a block.

type CancelReason

type CancelReason string

CancelReason explains a block cancellation.

const (
	// CancelUser denotes an explicit cancellation.
	CancelUser CancelReason = "user"
	// CancelTaskClosed denotes cancellation when a task closes.
	CancelTaskClosed CancelReason = "task_closed"
	// CancelDeferred denotes cancellation when a task is deferred.
	CancelDeferred CancelReason = "deferred"
	// CancelRescheduled denotes cancellation when a block is rescheduled.
	CancelRescheduled CancelReason = "rescheduled"
)

func (CancelReason) Valid

func (r CancelReason) Valid() bool

Valid reports whether r is a declared cancellation reason.

type Channel

type Channel string

Channel identifies the calling interface. It is informational, except that token management refuses the trusted, in-process web channel.

const (
	// ChanCLI denotes the command-line interface.
	ChanCLI Channel = "cli"
	// ChanTUI denotes the terminal interface.
	ChanTUI Channel = "tui"
	// ChanWeb denotes the in-process web interface.
	ChanWeb Channel = "web"
	// ChanMCP denotes the MCP interface.
	ChanMCP Channel = "mcp"
	// ChanAPI denotes the HTTP API.
	ChanAPI Channel = "api"
	// ChanSystem denotes an internal operation.
	ChanSystem Channel = "system"
)

func (Channel) Valid

func (c Channel) Valid() bool

Valid reports whether c is a declared channel.

type Code

type Code string

Code is a stable service error code.

const (
	// CodeMalformed denotes malformed input (400).
	CodeMalformed Code = "malformed"
	// CodeUnauthenticated denotes missing or invalid authentication (401).
	CodeUnauthenticated Code = "unauthenticated"
	// CodeForbidden denotes insufficient authority (403).
	CodeForbidden Code = "forbidden"
	// CodePeerRejected denotes a rejected socket peer (403).
	CodePeerRejected Code = "peer_rejected"
	// CodePasswordRequired denotes missing password confirmation (403).
	CodePasswordRequired Code = "password_required"
	// CodePasswordInvalid denotes invalid password confirmation (403).
	CodePasswordInvalid Code = "password_invalid"
	// CodeNotFound denotes an unknown entity (404).
	CodeNotFound Code = "not_found"
	// CodeDeleted denotes a mutation involving a tombstoned entity (409).
	CodeDeleted Code = "deleted"
	// CodeConflict denotes a state or invariant conflict (409).
	CodeConflict Code = "conflict"
	// CodeRevertConflict denotes conflicting changes that prevent revert (409).
	CodeRevertConflict Code = "revert_conflict"
	// CodeNotRevertible denotes an operation that cannot be reverted (409).
	CodeNotRevertible Code = "not_revertible"
	// CodePrecondition denotes a stale entity precondition (412).
	CodePrecondition Code = "precondition_failed"
	// CodeTooLarge denotes an oversized request body (413).
	CodeTooLarge Code = "body_too_large"
	// CodeUnsupportedMedia denotes an unsupported content type (415).
	CodeUnsupportedMedia Code = "unsupported_media_type"
	// CodeValidation denotes invalid field values (422).
	CodeValidation Code = "validation"
	// CodeIdemMismatch denotes a reused idempotency key with different input (422).
	CodeIdemMismatch Code = "idempotency_mismatch"
	// CodeNothingToUndo denotes an empty undo stack (409).
	CodeNothingToUndo Code = "nothing_to_undo"
	// CodeNothingToRedo denotes an empty redo stack (409).
	CodeNothingToRedo Code = "nothing_to_redo"
	// CodePreconditionReq denotes a missing precondition (428).
	CodePreconditionReq Code = "precondition_required"
	// CodeIdemRequired denotes a missing idempotency key (428).
	CodeIdemRequired Code = "idempotency_key_required"
	// CodeGenerationMismatch denotes a precondition for a different database generation (412).
	CodeGenerationMismatch Code = "generation_mismatch"
	// CodeRateLimited denotes a rate limit (429).
	CodeRateLimited Code = "rate_limited"
	// CodeInternal denotes an internal failure (500).
	CodeInternal Code = "internal"
	// CodeBusy denotes temporary unavailability (503).
	CodeBusy Code = "busy"
)

func ErrorCodes

func ErrorCodes() []Code

ErrorCodes returns every defined service error code. Adapter drift tests also check this catalog against the declarations so additions cannot be omitted.

type Cursor

type Cursor struct {
	Keys   []any
	ID     int64
	Offset int
}

Cursor describes either a keyset position or an offset position. Lists validate their own key types, ranges, and pagination mode.

func DecodeCursor

func DecodeCursor(s string) (Cursor, error)

DecodeCursor parses one version-1 cursor with exact field names and preserves numbers in Keys as json.Number. Invalid input returns CodeMalformed.

type DuePhase

type DuePhase string

DuePhase is a task's due state or acknowledged due state.

const (
	// DueNone denotes neither due nor overdue.
	DueNone DuePhase = "none"
	// DueDue denotes a due task.
	DueDue DuePhase = "due"
	// DueOverdue denotes an overdue task.
	DueOverdue DuePhase = "overdue"
)

func (DuePhase) Valid

func (p DuePhase) Valid() bool

Valid reports whether p is a declared due phase.

type EntityKind

type EntityKind string

EntityKind identifies the entity affected by an event.

const (
	// EntTask denotes a task.
	EntTask EntityKind = "task"
	// EntTriage denotes a task triage reason.
	EntTriage EntityKind = "triage"
	// EntTaskTags denotes a task's tag set.
	EntTaskTags EntityKind = "task_tags"
	// EntEntry denotes a log entry.
	EntEntry EntityKind = "entry"
	// EntBlock denotes a time block.
	EntBlock EntityKind = "block"
	// EntFocus denotes the singleton focus row.
	EntFocus EntityKind = "focus"
	// EntInterruption denotes an interruption.
	EntInterruption EntityKind = "interruption"
	// EntToken denotes an authentication token.
	EntToken EntityKind = "token"
	// EntSetting denotes a setting.
	EntSetting EntityKind = "setting"
	// EntAuth denotes authentication configuration.
	EntAuth EntityKind = "auth"
)

type EntityRef

type EntityRef struct {
	Entity EntityKind
	ID     int64
}

EntityRef identifies an entity by kind and ID.

type EntryID

type EntryID int64

EntryID identifies a log entry.

type EntryKind

type EntryKind string

EntryKind distinguishes work from completion log entries.

const (
	// EntryWork records work on a task or standalone activity.
	EntryWork EntryKind = "work"
	// EntryComplete records task completion.
	EntryComplete EntryKind = "complete"
)

func (EntryKind) Valid

func (k EntryKind) Valid() bool

Valid reports whether k is a declared entry kind.

type EntryView

type EntryView struct {
	LogEntry
	TaskTitle string // empty for standalone entries
}

EntryView adds the linked task's title to a log entry.

type Error

type Error struct {
	Code       Code
	Detail     string // safe for users; never contains secrets
	Fields     []FieldError
	Conflicts  []RevertConflict
	Current    any // current representation for a failed precondition
	RetryAfter time.Duration
	Err        error // wrapped cause; logged, never sent
}

Error carries a service error's safe detail, structured context, and private cause.

func AsError

func AsError(err error) (*Error, bool)

AsError finds a wrapped domain error, or returns an internal error with err as its private cause and false.

func Errorf

func Errorf(code Code, format string, args ...any) *Error

Errorf constructs an error with a formatted, user-safe detail.

func ValidationError

func ValidationError(fields ...FieldError) *Error

ValidationError constructs a validation error with the supplied field failures.

func (*Error) Error

func (e *Error) Error() string

Error returns the code and safe detail, without the private cause.

func (*Error) Unwrap

func (e *Error) Unwrap() error

Unwrap returns the private cause for errors.Is and errors.As.

type Event

type Event struct {
	ID       EventID
	OpID     OpID
	Entity   EntityKind
	EntityID int64            // task ID for triage/tags; 1 for focus; 0 for setting
	TaskID   sql.Null[TaskID] // denormalized for task history
	Action   Action
	Before   json.RawMessage // changed columns only; null for insert/add
	After    json.RawMessage // changed columns only; null for tombstone-less removes
	Derived  bool            // recompute effects; revert re-derives them
}

Event records changed fields for an operation's effect on one entity.

type EventID

type EventID int64

EventID identifies an event.

type Expect

type Expect struct {
	Gen     Generation
	Version Version
}

Expect is the generation and row version required by an entity precondition.

func ParseETag

func ParseETag(s string) (Expect, error)

ParseETag parses exactly one strong entity ETag with a positive row version.

type FieldError

type FieldError struct{ Field, Message string }

FieldError identifies a field and its validation failure.

type Focus

type Focus struct {
	TaskID  sql.Null[TaskID]
	Date    sql.Null[civil.Date]
	SetAt   sql.Null[time.Time]
	Version Version
}

Focus is the singleton current-focus row.

type Generation

type Generation string

Generation identifies a database generation with 16 lowercase hex characters.

func NewGeneration

func NewGeneration() Generation

NewGeneration returns a cryptographically random database generation.

type Interruption

type Interruption struct {
	ID          InterruptionID
	At          time.Time
	Date        civil.Date
	FromTaskID  sql.Null[TaskID]
	FromBlockID sql.Null[BlockID]
	ToTaskID    TaskID
	OpID        OpID
	DeletedAt   sql.Null[time.Time]
}

Interruption records a switch of focus away from a task or block.

type InterruptionID

type InterruptionID int64

InterruptionID identifies an interruption.

type LogEntry

type LogEntry struct {
	ID          EntryID
	TaskID      sql.Null[TaskID]
	Kind        EntryKind
	Title       string
	Notes       string
	WorkDate    civil.Date
	OccurredMin sql.Null[civil.Minute]
	Reopened    bool
	CreatedAt   time.Time
	UpdatedAt   time.Time
	DeletedAt   sql.Null[time.Time]
	PurgedAt    sql.Null[time.Time]
	Version     Version
}

LogEntry records work or completion, optionally linked to a task.

type Moment

type Moment struct {
	Date civil.Date
	Min  sql.Null[civil.Minute]
}

Moment is a due or deferral date with an optional minute (0..1439).

func (Moment) String

func (m Moment) String() string

String returns YYYY-MM-DD, followed by HH:MM when the minute is present.

type OpID

type OpID [16]byte

OpID is a random operation identifier, stored as 32 lowercase hex characters.

func NewOpID

func NewOpID() OpID

NewOpID returns a cryptographically random operation identifier.

func ParseOpID

func ParseOpID(s string) (OpID, error)

ParseOpID parses exactly 32 lowercase hex characters.

func (OpID) IsZero

func (id OpID) IsZero() bool

IsZero reports whether id is the zero identifier.

func (OpID) MarshalText

func (id OpID) MarshalText() ([]byte, error)

MarshalText encodes id as 32 lowercase hex characters.

func (*OpID) Scan

func (id *OpID) Scan(src any) error

Scan implements sql.Scanner from a string or byte slice.

func (OpID) String

func (id OpID) String() string

String returns the 32-character lowercase hex representation.

func (*OpID) UnmarshalText

func (id *OpID) UnmarshalText(text []byte) error

UnmarshalText decodes exactly 32 lowercase hex characters.

func (OpID) Value

func (id OpID) Value() (driver.Value, error)

Value implements driver.Valuer using the lowercase hex representation.

type OpKind

type OpKind string

OpKind names an operation as <area>.<verb>.

const (
	// OpTaskAdd captures a task.
	OpTaskAdd OpKind = "task.add"
	// OpTaskUpdate updates task fields.
	OpTaskUpdate OpKind = "task.update"
	// OpTaskDue changes a task's due moment.
	OpTaskDue OpKind = "task.due"
	// OpTaskPlace places a task in the task order.
	OpTaskPlace OpKind = "task.place"
	// OpTaskAcceptNew acknowledges a new task.
	OpTaskAcceptNew OpKind = "task.accept_new"
	// OpTaskDefer changes a task's deferral.
	OpTaskDefer OpKind = "task.defer"
	// OpTaskManual requests manual triage.
	OpTaskManual OpKind = "task.manual"
	// OpTaskComplete completes a task.
	OpTaskComplete OpKind = "task.complete"
	// OpTaskReopen reopens a task.
	OpTaskReopen OpKind = "task.reopen"
	// OpTaskDrop drops a task.
	OpTaskDrop OpKind = "task.drop"
	// OpTaskDelete tombstones a task.
	OpTaskDelete OpKind = "task.delete"
	// OpTaskUndelete restores a tombstoned task.
	OpTaskUndelete OpKind = "task.undelete"
	// OpBlockCreate creates a time block.
	OpBlockCreate OpKind = "block.create"
	// OpBlockReblock reschedules a block.
	OpBlockReblock OpKind = "block.reblock"
	// OpBlockUnblock cancels a block.
	OpBlockUnblock OpKind = "block.unblock"
	// OpBlockOutcome changes a block's outcome policy.
	OpBlockOutcome OpKind = "block.outcome"
	// OpEntryAdd adds a log entry.
	OpEntryAdd OpKind = "entry.add"
	// OpEntryUpdate updates a log entry.
	OpEntryUpdate OpKind = "entry.update"
	// OpEntryRelink changes an entry's task link.
	OpEntryRelink OpKind = "entry.relink"
	// OpEntryDelete tombstones a log entry.
	OpEntryDelete OpKind = "entry.delete"
	// OpEntryUndelete restores a tombstoned log entry.
	OpEntryUndelete OpKind = "entry.undelete"
	// OpFocusSet changes the current focus.
	OpFocusSet OpKind = "focus.set"
	// OpRevert reverts an operation.
	OpRevert OpKind = "op.revert"
	// OpUndo undoes an operation on the actor's stack.
	OpUndo OpKind = "op.undo"
	// OpRedo redoes an operation on the actor's stack.
	OpRedo OpKind = "op.redo"
	// OpAIReview acknowledges AI changes.
	OpAIReview OpKind = "ai.review"
	// OpTokenCreate creates an authentication token.
	OpTokenCreate OpKind = "token.create"
	// OpTokenRevoke revokes an authentication token.
	OpTokenRevoke OpKind = "token.revoke"
	// OpSettingsUpdate updates settings.
	OpSettingsUpdate OpKind = "settings.update"
	// OpSettingsRetentionLowered records a retention reduction.
	OpSettingsRetentionLowered OpKind = "settings.retention_lowered"
	// OpAuthPassword changes the owner's password.
	OpAuthPassword OpKind = "auth.password"
	// OpPurgeTask purges task content.
	OpPurgeTask OpKind = "purge.task"
	// OpPurgeEntry purges entry content.
	OpPurgeEntry OpKind = "purge.entry"
	// OpSystemReconcile reconciles time-dependent state.
	OpSystemReconcile OpKind = "system.reconcile"
	// OpSystemLedgerReplay reapplies purge-ledger records.
	OpSystemLedgerReplay OpKind = "system.ledger_replay"
	// OpSystemImport records an import.
	OpSystemImport OpKind = "system.import"
	// OpSystemRestore records a restore.
	OpSystemRestore OpKind = "system.restore"
)

func (OpKind) ReversalLabel

func (k OpKind) ReversalLabel(via, opMark string) string

ReversalLabel describes the net direction of the reversal chain given by via. opMark is the complete optional operation mark, including its CLI styling.

func (OpKind) ReversalText

func (k OpKind) ReversalText(via, opID string) string

ReversalText describes a reversal of the root operation. A caller can omit the operation ID for a compact banner.

func (OpKind) Verb

func (k OpKind) Verb() string

Verb is the human verb for messages (J§4.2); the mirrors in cli, web and tui all use it.

type OpRecord

type OpRecord struct {
	Seq         OpSeq
	ID          OpID
	Kind        OpKind
	Actor       string // Actor.Key()
	Channel     Channel
	At          time.Time
	Scopes      Scopes // permissions required by this operation and its revert
	Revertible  bool
	State       OpState
	RevertsOpID sql.Null[OpID] // set on revert, undo, and redo
	Via         string         // empty, revert, undo, or redo
}

OpRecord is the persisted metadata for an operation.

type OpSeq

type OpSeq int64

OpSeq is the monotonic ops.seq used for ordering and acknowledgement.

type OpState

type OpState string

OpState is an operation's current reversal state.

const (
	// OpActive denotes an active operation.
	OpActive OpState = "active"
	// OpReverted denotes a reverted operation.
	OpReverted OpState = "reverted"
)

type OutcomeSource

type OutcomeSource string

OutcomeSource identifies how a resolved block outcome was selected.

const (
	// OutcomeAuto denotes an automatically derived outcome.
	OutcomeAuto OutcomeSource = "auto"
	// OutcomeUser denotes a user-selected outcome.
	OutcomeUser OutcomeSource = "user"
)

func (OutcomeSource) Valid

func (s OutcomeSource) Valid() bool

Valid reports whether s is a declared outcome source.

type PlaceHow

type PlaceHow string

PlaceHow selects how a task is positioned in the global order.

const (
	// PlaceKeep retains the task's position.
	PlaceKeep PlaceHow = "keep"
	// PlaceTop places the task at the top.
	PlaceTop PlaceHow = "top"
	// PlaceBottom places the task at the bottom.
	PlaceBottom PlaceHow = "bottom"
	// PlaceBefore places the task before another task.
	PlaceBefore PlaceHow = "before"
	// PlaceAfter places the task after another task.
	PlaceAfter PlaceHow = "after"
)

func (PlaceHow) Valid

func (h PlaceHow) Valid() bool

Valid reports whether h is a declared placement mode.

type Priority

type Priority string

Priority is an optional task priority.

const (
	// PriorityNone denotes no priority.
	PriorityNone Priority = ""
	// PriorityH denotes high priority.
	PriorityH Priority = "H"
	// PriorityM denotes medium priority.
	PriorityM Priority = "M"
	// PriorityL denotes low priority.
	PriorityL Priority = "L"
)

func (Priority) Valid

func (p Priority) Valid() bool

Valid reports whether p is a declared priority, including no priority.

type RevertConflict

type RevertConflict struct {
	OpID     OpID
	Kind     OpKind
	Actor    string
	At       time.Time
	Entity   EntityKind
	EntityID int64
}

RevertConflict describes a later operation that conflicts with a revert.

type Scopes

type Scopes uint8

Scopes is a bit set of permissions.

const (
	// ScopeRead permits reading.
	ScopeRead Scopes = 1 << iota
	// ScopeCapture permits capturing tasks and entries.
	ScopeCapture Scopes = 1 << iota
	// ScopeWrite permits ordinary mutations.
	ScopeWrite Scopes = 1 << iota
	// ScopeDestroy permits destructive mutations.
	ScopeDestroy Scopes = 1 << iota
	// ScopeAdmin permits administration.
	ScopeAdmin Scopes = 1 << iota
	// AllScopes contains every declared permission.
	AllScopes Scopes = ScopeRead | ScopeCapture | ScopeWrite | ScopeDestroy | ScopeAdmin
	// MCPDefaultScopes contains the default permissions for MCP tokens.
	MCPDefaultScopes Scopes = ScopeRead | ScopeCapture | ScopeWrite
)

func ParseScopes

func ParseScopes(s string) (Scopes, error)

ParseScopes parses comma-separated permission names; an empty string means no permissions, as used by system operations.

func (Scopes) Has

func (s Scopes) Has(req Scopes) bool

Has reports whether s contains every permission in req.

func (Scopes) String

func (s Scopes) String() string

String returns names in canonical read,capture,write,destroy,admin order.

type TagID

type TagID int64

TagID identifies a tag.

type Task

type Task struct {
	ID            TaskID
	Title, Notes  string
	Status        TaskStatus
	Rank          int64
	LastPlacedAt  sql.Null[time.Time]
	LastPlacedSeq sql.Null[OpSeq] // ordering and acknowledgement use sequence numbers
	DeferDate     sql.Null[civil.Date]
	DeferMin      sql.Null[civil.Minute]
	DueDate       sql.Null[civil.Date]
	DueMin        sql.Null[civil.Minute]
	DueAck        DuePhase
	DueAckDate    sql.Null[civil.Date]
	Project       string // empty means none
	Priority      Priority
	Origin        string // creator's Actor.Key()
	CompletedAt   sql.Null[time.Time]
	CompletedDate sql.Null[civil.Date]
	CreatedAt     time.Time
	UpdatedAt     time.Time
	DeletedAt     sql.Null[time.Time]
	PurgedAt      sql.Null[time.Time] // set by ScrubEntities
	Version       Version
}

Task is the persisted state of a task.

type TaskDetail

type TaskDetail struct {
	TaskView
	Entries       []EntryView // non-deleted, newest first
	Blocks        []BlockView // all non-deleted
	Interruptions []Interruption
}

TaskDetail adds associated live entries, blocks, and interruptions to a task view.

type TaskID

type TaskID int64

TaskID identifies a task.

type TaskStatus

type TaskStatus string

TaskStatus is the lifecycle state of a task.

const (
	// StatusOpen marks an open task.
	StatusOpen TaskStatus = "open"
	// StatusDone marks a completed task.
	StatusDone TaskStatus = "done"
	// StatusDropped marks a dropped task.
	StatusDropped TaskStatus = "dropped"
)

func (TaskStatus) Valid

func (s TaskStatus) Valid() bool

Valid reports whether s is a declared task status.

type TaskView

type TaskView struct {
	Task
	Reasons          []TriageRow // highest first
	Tags             []string    // sorted, case-insensitive
	View             View
	Deferred         bool // defer moment is after now
	DuePhase         DuePhase
	DueSoon          bool // due date is within the configured due-soon window
	SlipsLifetime    int
	SlipsSinceTriage int
}

TaskView adds derived state and display metadata to a task.

type TimeBlock

type TimeBlock struct {
	ID            BlockID
	TaskID        TaskID
	Span          BlockSpan
	Status        BlockStatus
	OutcomeSource OutcomeSource // empty while planned or cancelled
	CancelReason  CancelReason  // empty unless cancelled
	Slipped       bool
	SlippedAt     sql.Null[time.Time] // retained after unslip
	SlippedSeq    sql.Null[OpSeq]     // operation that last slipped it
	CreatedAt     time.Time
	ResolvedAt    sql.Null[time.Time] // set on every status change; null while planned
	ResolvedSeq   sql.Null[OpSeq]
	DeletedAt     sql.Null[time.Time] // set only by reverting the creating operation
	Version       Version
}

TimeBlock is a scheduled task interval and its resolution state.

type Token

type Token struct {
	ID               TokenID
	Name             string
	SecretHash       [32]byte
	Scopes           Scopes
	IsOwner          bool
	MutationsPerHour int
	CreatedAt        time.Time
	ExpiresAt        sql.Null[time.Time]
	LastUsedAt       sql.Null[time.Time]
	RevokedAt        sql.Null[time.Time]
}

Token stores authentication token metadata and its secret hash.

type TokenID

type TokenID int64

TokenID identifies an authentication token.

type TriageReason

type TriageReason string

TriageReason explains why a task needs triage.

const (
	// ReasonSlipped marks a slipped task.
	ReasonSlipped TriageReason = "slipped"
	// ReasonOverdue marks an overdue task.
	ReasonOverdue TriageReason = "overdue"
	// ReasonDue marks a due task.
	ReasonDue TriageReason = "due"
	// ReasonContinue marks work to continue.
	ReasonContinue TriageReason = "continue"
	// ReasonSurfaced marks an elapsed deferral.
	ReasonSurfaced TriageReason = "surfaced"
	// ReasonReopened marks a reopened task.
	ReasonReopened TriageReason = "reopened"
	// ReasonManual marks an explicit triage request.
	ReasonManual TriageReason = "manual"
	// ReasonNew marks a newly captured task.
	ReasonNew TriageReason = "new"
)

func (TriageReason) Rank

func (r TriageReason) Rank() int

Rank returns the reason's priority (8 through 1), or zero for an unknown reason.

func (TriageReason) Valid

func (r TriageReason) Valid() bool

Valid reports whether r is a declared triage reason.

type TriageRow

type TriageRow struct {
	TaskID TaskID
	Reason TriageReason
	Since  time.Time // informational
	Seq    OpSeq     // operation that added the reason; used for ordering
}

TriageRow records one reason a task needs triage.

type UserOutcome

type UserOutcome string

UserOutcome is a requested block outcome policy.

const (
	// SetWorked explicitly marks a block worked.
	SetWorked UserOutcome = "worked"
	// SetMissed explicitly marks a block missed.
	SetMissed UserOutcome = "missed"
	// SetAuto restores automatic outcome derivation.
	SetAuto UserOutcome = "auto"
)

func (UserOutcome) Valid

func (o UserOutcome) Valid() bool

Valid reports whether o is a declared user outcome.

type Version

type Version int64

Version is a per-row version, starting at 1.

type View

type View string

View selects a task classification for a list.

const (
	// ViewTriage selects tasks needing triage.
	ViewTriage View = "triage"
	// ViewBacklog selects backlog tasks.
	ViewBacklog View = "backlog"
	// ViewUpcoming selects deferred tasks.
	ViewUpcoming View = "upcoming"
	// ViewDone selects completed tasks.
	ViewDone View = "done"
	// ViewDropped selects dropped tasks.
	ViewDropped View = "dropped"
	// ViewDeleted selects deleted tasks.
	ViewDeleted View = "deleted"
	// ViewAll selects all tasks.
	ViewAll View = "all"
)

func (View) Valid

func (v View) Valid() bool

Valid reports whether v is a declared task view.

Jump to

Keyboard shortcuts

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