service

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: 30 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 service implements Taskronin's authorization and transactional rules.

Index

Constants

View Source
const (
	// MaxSearchQueryBytes bounds the raw input before FTS tokenization.
	MaxSearchQueryBytes = 1024
	// MaxSearchQueryTerms bounds the whitespace-separated terms before quoting.
	MaxSearchQueryTerms = 64
)

AIDEV-NOTE: DF30: every client reaches FTS through ftsQuery, so these caps bound query cost for the API, MCP, CLI, TUI and web alike.

View Source
const (
	// SessionIdle is the maximum time a web session may remain inactive.
	SessionIdle = 7 * 24 * time.Hour
	// SessionMax is the absolute lifetime of a web session.
	SessionMax = 30 * 24 * time.Hour
)
View Source
const Gap int64 = 1 << 16

Gap is the default spacing between task ranks.

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

IdemTTL is the retention period for an idempotency record.

View Source
const LongOpBudget = 10 * time.Minute

LongOpBudget bounds backups and exports, which also abort on caller cancellation or shutdown.

View Source
const OpBudget = 15 * time.Second

OpBudget bounds an ordinary operation, including writer admission and views.

Variables

This section is empty.

Functions

func CheckAll

func CheckAll(ctx context.Context, q store.Q, now time.Time, z civil.Zone) error

CheckAll checks all structural and time-dependent invariants, joining violations.

func CheckStructural

func CheckStructural(ctx context.Context, q store.Q) error

CheckStructural checks I1a, I2, I3, I4, I5, I7 and I8 across the whole store. It resolves moments in the database's persisted tz_last_seen zone.

func CheckTimeDependent

func CheckTimeDependent(ctx context.Context, q store.Q, now time.Time, z civil.Zone) error

CheckTimeDependent checks I1b and I6 across the whole store at now in z.

Types

type AIChanges

type AIChanges struct {
	ReviewedThrough domain.OpSeq
	Unreviewed      int
	Ops             []OpSummary
	NextCursor      string
}

AIChanges contains review progress and a page of token or retention-lowering operations.

type AcceptItem

type AcceptItem struct {
	ID     domain.TaskID
	Expect domain.Expect
}

AcceptItem identifies a new task and the version seen by the caller.

type AcceptNewIn

type AcceptNewIn struct{ Items []AcceptItem }

AcceptNewIn supplies the tasks to accept atomically from triage.

type AddEntryIn

type AddEntryIn struct {
	TaskID   sql.Null[domain.TaskID] // Invalid means standalone.
	Title    string
	Notes    string
	WorkDate civil.Date             // Zero means today.
	At       sql.Null[civil.Minute] // Optional display/sort minute, 0..1439.
}

AddEntryIn supplies work to log against an explicit task or standalone.

type AddPlacement

type AddPlacement struct {
	How   string // top|bottom|before|after|defer|block|now
	Ref   domain.TaskID
	Defer domain.Moment
	Block domain.BlockSpan
}

AddPlacement describes a placement to apply while creating a task.

type AddTaskIn

type AddTaskIn struct {
	Title, Notes string
	Due          *domain.Moment
	Tags         []string
	Project      string
	Priority     domain.Priority
	Place        *AddPlacement
}

AddTaskIn supplies a new task's content and optional placement.

type BackupHealth

type BackupHealth struct {
	LastSuccessAt sql.Null[time.Time]
	LastError     string
	Healthy       bool
}

BackupHealth describes the last backup and whether it is recent and successful.

type BackupStatusView

type BackupStatusView struct {
	Dir       string
	Snapshots []backup.SnapshotInfo
	BackupHealth
	Warning string
}

BackupStatusView describes the configured snapshots and the latest backup health.

type Banner struct{ Kind, Message string }

Banner is a dashboard notice with a stable machine-readable kind.

type BlockIn

type BlockIn struct {
	TaskID domain.TaskID
	Expect domain.Expect
	Span   domain.BlockSpan
}

BlockIn identifies a task, its expected version, and the interval to schedule.

type BlockRef

type BlockRef struct {
	BlockID domain.BlockID
	Expect  domain.Expect
}

BlockRef identifies a block and its expected version.

type ChangePasswordIn

type ChangePasswordIn struct{ Current, New string }

ChangePasswordIn supplies the current and replacement owner passwords.

type ClockView

type ClockView struct {
	Now         time.Time
	Today       civil.Date
	Zone        string
	WeekStart   time.Weekday
	DueSoonDays int
	Generation  domain.Generation
}

ClockView supplies the server's civil-time reference and database generation.

type CompleteIn

type CompleteIn struct {
	ID       domain.TaskID
	Expect   domain.Expect
	As       *string
	Date     civil.Date // Zero means today; never future.
	LogTitle string     // Empty means the final task title.
	LogNotes string
}

CompleteIn supplies a task completion, optional retitle and completion log text.

type CreateTokenIn

type CreateTokenIn struct {
	Name             string
	Scopes           domain.Scopes
	ExpiresAt        sql.Null[time.Time]
	MutationsPerHour int
}

CreateTokenIn describes a named non-owner token and its limits.

type DayView

type DayView struct {
	Date              civil.Date
	Blocks            []domain.BlockView
	Entries, Unlinked []domain.EntryView
	Interruptions     []domain.Interruption
}

DayView contains a day's blocks and live entries, including its standalone subset.

type DeferIn

type DeferIn struct {
	ID     domain.TaskID
	Expect domain.Expect
	Until  *domain.Moment
}

DeferIn identifies a task and its defer moment; nil clears the defer.

type Effect

type Effect struct {
	Kind     EffectKind
	TaskID   domain.TaskID
	BlockID  domain.BlockID
	EntryID  domain.EntryID
	Reason   domain.TriageReason
	Via      string
	From, To string
}

Effect is a user-visible consequence reconstructed from persisted events.

type EffectKind

type EffectKind string

EffectKind names a user-visible consequence of an operation.

const (
	// EffCreated denotes a new task.
	EffCreated EffectKind = "created"
	// EffUpdated denotes a task field or tag change.
	EffUpdated EffectKind = "updated"
	// EffRetitled denotes a task title change.
	EffRetitled EffectKind = "retitled"
	// EffPlaced denotes task placement.
	EffPlaced EffectKind = "placed"
	// EffMoved denotes task reordering.
	EffMoved EffectKind = "moved"
	// EffDeferred denotes a task deferral.
	EffDeferred EffectKind = "deferred"
	// EffUndeferred denotes a cleared deferral.
	EffUndeferred EffectKind = "undeferred"
	// EffDueSet denotes a due moment change.
	EffDueSet EffectKind = "due_set"
	// EffDueCleared denotes a cleared due moment.
	EffDueCleared EffectKind = "due_cleared"
	// EffBlocked denotes a new scheduled block.
	EffBlocked EffectKind = "blocked"
	// EffBlockMoved denotes a rescheduled block.
	EffBlockMoved EffectKind = "block_moved"
	// EffBlockCancelled denotes a cancelled or deleted block.
	EffBlockCancelled EffectKind = "block_cancelled"
	// EffBlockResolved denotes an automatically resolved block.
	EffBlockResolved EffectKind = "block_resolved"
	// EffBlockRestored denotes a block returned to planned status or undeleted.
	EffBlockRestored EffectKind = "block_restored"
	// EffOutcomeSet denotes an explicit block outcome.
	EffOutcomeSet EffectKind = "outcome_set"
	// EffSlipped denotes a newly slipped block.
	EffSlipped EffectKind = "slipped"
	// EffUnslipped denotes a cleared slip.
	EffUnslipped EffectKind = "unslipped"
	// EffReasonAdded denotes a new triage reason.
	EffReasonAdded EffectKind = "reason_added"
	// EffReasonRemoved denotes a removed triage reason.
	EffReasonRemoved EffectKind = "reason_removed"
	// EffFocusSet denotes a focused task.
	EffFocusSet EffectKind = "focus_set"
	// EffFocusCleared denotes cleared focus.
	EffFocusCleared EffectKind = "focus_cleared"
	// EffInterrupted denotes a focus interruption.
	EffInterrupted EffectKind = "interrupted"
	// EffEntryLogged denotes a new log entry.
	EffEntryLogged EffectKind = "entry_logged"
	// EffEntryUpdated denotes edited log content.
	EffEntryUpdated EffectKind = "entry_updated"
	// EffEntryRelinked denotes a changed task link.
	EffEntryRelinked EffectKind = "entry_relinked"
	// EffEntryDeleted denotes a tombstoned entry.
	EffEntryDeleted EffectKind = "entry_deleted"
	// EffEntryRestored denotes a restored entry.
	EffEntryRestored EffectKind = "entry_restored"
	// EffCompleted denotes a completed task.
	EffCompleted EffectKind = "completed"
	// EffReopened denotes a reopened task.
	EffReopened EffectKind = "reopened"
	// EffDropped denotes a dropped task.
	EffDropped EffectKind = "dropped"
	// EffDeleted denotes a tombstoned task.
	EffDeleted EffectKind = "deleted"
	// EffUndeleted denotes a restored task.
	EffUndeleted EffectKind = "undeleted"
	// EffReverted denotes a revert, undo or redo operation.
	EffReverted EffectKind = "reverted"
	// EffReviewed denotes acknowledged AI changes.
	EffReviewed EffectKind = "reviewed"
	// EffPurged denotes permanently scrubbed content.
	EffPurged EffectKind = "purged"
)

func EffectKinds

func EffectKinds() []EffectKind

EffectKinds returns every defined operation effect kind.

type EntryRef

type EntryRef struct {
	ID     domain.EntryID
	Expect domain.Expect
}

EntryRef identifies an entry and its expected version.

type EventView

type EventView struct {
	ID            domain.EventID
	Op            OpSummary
	Entity        domain.EntityKind
	EntityID      int64
	Action        domain.Action
	Before, After json.RawMessage
}

EventView pairs an audit event with its operation, omitting operation effects.

type HistoryIn

type HistoryIn struct {
	TaskID domain.TaskID
	Limit  int
	Cursor string
}

HistoryIn selects a task's events with an optional event ID cursor.

type Idem

type Idem struct {
	Key, Method, Route string
	Body               []byte
}

Idem identifies a canonical mutation request for idempotency.

type ListAIChangesIn

type ListAIChangesIn struct {
	IncludeReviewed bool
	Limit           int
	Cursor          string
}

ListAIChangesIn selects unreviewed operations, or all matching operations when requested.

type ListBlocksIn

type ListBlocksIn struct {
	From, To civil.Date
	TaskID   sql.Null[domain.TaskID]
}

ListBlocksIn selects live blocks by date and optionally by task.

type ListEntriesIn

type ListEntriesIn struct {
	From, To       civil.Date
	TaskID         *sql.Null[domain.TaskID]
	IncludeDeleted bool
	Limit          int
	Cursor         string
}

ListEntriesIn selects entries by date and task, with optional tombstones and paging.

type ListOpsIn

type ListOpsIn struct {
	Actor    string
	OpPrefix string // 1 to 32 lowercase hex characters; empty means any.
	SinceSeq domain.OpSeq
	Limit    int
	Cursor   string
}

ListOpsIn filters operations by actor, op ID prefix and exclusive lower sequence bound.

type ListTasksIn

type ListTasksIn struct {
	View         domain.View
	Tag, Project string
	Limit        int
	Cursor       string
}

ListTasksIn selects a task classification, optional filters and a keyset page.

type LoginIn

type LoginIn struct{ RemoteKey, Password, OldCookie string }

LoginIn supplies the password, password-gate key and session to replace.

type MarkAIReviewedIn

type MarkAIReviewedIn struct {
	Through domain.OpSeq
}

MarkAIReviewedIn acknowledges AI changes through an inclusive operation sequence.

type MarkManualIn

type MarkManualIn struct {
	ID     domain.TaskID
	Expect domain.Expect
}

MarkManualIn identifies a task and its expected version.

type Meta

type Meta struct {
	Actor domain.Actor
	Idem  Idem
	Gen   domain.Generation
}

Meta accompanies each mutation with its caller and request identity.

type OpDetail

type OpDetail struct {
	Op     OpSummary
	Events []EventView
}

OpDetail contains an operation summary and its events in event ID order.

type OpResult

type OpResult struct {
	OpID                        domain.OpID
	Created, Replayed, NoChange bool
	Refs                        []domain.EntityRef
	Task                        *domain.TaskView
	Entry                       *domain.EntryView
	Block                       *domain.BlockView
	Token                       *domain.Token
	Tasks                       []domain.TaskView
	Effects                     []Effect
	Warnings                    []string
}

OpResult describes a committed operation and its current entity representations.

type OpSummary

type OpSummary struct {
	Seq        domain.OpSeq
	OpID       domain.OpID
	Kind       domain.OpKind
	Actor      string
	Channel    domain.Channel
	At         time.Time
	State      domain.OpState
	Revertible bool
	Via        string
	TaskIDs    []domain.TaskID
	Effects    []Effect
}

OpSummary describes a persisted operation and its user-visible consequences.

type Options

type Options struct {
	Store       *store.Store
	Clock       clock.Clock
	Zone        civil.Zone
	WeekStart   time.Weekday
	DueSoonDays int
	SlipGrace   time.Duration
	UndoDepth   int
	Backups     *backup.Manager
	Ledger      *backup.Ledger
	Passwords   *auth.PasswordGate
	Logger      *slog.Logger
	// OpBudget overrides the ordinary runner budget; zero uses the default OpBudget.
	OpBudget time.Duration
}

Options supplies the service's dependencies and policy settings.

type Page

type Page[T any] struct {
	Items      []T
	NextCursor string
}

Page is a result page; an empty NextCursor denotes the last page.

type PlaceIn

type PlaceIn struct {
	ID     domain.TaskID
	Expect domain.Expect
	How    domain.PlaceHow
	Ref    domain.TaskID
}

PlaceIn identifies a task, its expected version and its requested position.

type PurgeLiveIn

type PurgeLiveIn struct {
	Target      string // "task" or "entry"
	ID          int64
	WithEntries bool
}

PurgeLiveIn identifies an offline purge target and whether to include all linked entries.

type PurgeLiveResult

type PurgeLiveResult struct {
	TaskIDs, EntryIDs, LinkedNotIncluded []int64
	Changed                              bool
}

PurgeLiveResult reports the selected set, excluded linked entries and any committed change.

type ReblockIn

type ReblockIn struct {
	BlockID            domain.BlockID
	Expect, TaskExpect domain.Expect
	Span               domain.BlockSpan
}

ReblockIn supplies a new span and preconditions for both the block and its task.

type RelinkEntryIn

type RelinkEntryIn struct {
	ID     domain.EntryID
	Expect domain.Expect
	TaskID sql.Null[domain.TaskID]
}

RelinkEntryIn identifies an entry and its new task; invalid TaskID means standalone.

type ReopenIn

type ReopenIn struct {
	ID          domain.TaskID
	Expect      domain.Expect
	RemoveEntry bool
}

ReopenIn identifies a closed task and whether to remove its completion entry.

type ReplayMode

type ReplayMode uint8

ReplayMode selects whether ledger replay reconciles time-dependent state.

const (
	// ReplayLive reconciles the live database before replaying purge intents.
	ReplayLive ReplayMode = iota + 1
	// ReplayHistorical preserves a snapshot's point-in-time state.
	ReplayHistorical ReplayMode = iota + 1
)

type Report

type Report struct {
	From, To     civil.Date
	Tag, Project string
	Days         []ReportDay
	Tasks        map[domain.TaskID]ReportTask
	Todo         *ReportTodo
	Upcoming     []domain.TaskView
}

Report contains ascending nonempty days and optional current task sections.

type ReportDay

type ReportDay struct {
	Date  civil.Date
	Lines []ReportLine
}

ReportDay groups entries by work date in display order.

type ReportIn

type ReportIn struct {
	From, To       civil.Date
	Tag, Project   string
	Todo, Upcoming bool
}

ReportIn selects the work date range, task filters and optional current views.

type ReportLine

type ReportLine struct {
	EntryID  domain.EntryID
	Kind     domain.EntryKind
	Title    string
	Notes    string
	TaskID   sql.Null[domain.TaskID]
	Time     sql.Null[civil.Minute]
	Reopened bool
}

ReportLine is a live work or completion entry within a report day.

type ReportTask

type ReportTask struct {
	Title   string
	Status  domain.TaskStatus
	Deleted bool
}

ReportTask supplies the current task annotation for historical entries.

type ReportTodo

type ReportTodo struct{ Triage, Backlog []domain.TaskView }

ReportTodo contains current triage and backlog tasks in their view order.

type ResetPasswordIn

type ResetPasswordIn struct {
	NewPassword string
	OwnerSecret [32]byte
}

ResetPasswordIn supplies a replacement password and a freshly minted owner secret.

type RevertIn

type RevertIn struct{ OpID domain.OpID }

RevertIn identifies the operation to reverse.

type RevokeTokenIn

type RevokeTokenIn struct{ ID domain.TokenID }

RevokeTokenIn identifies a non-owner token to revoke.

type SearchHit

type SearchHit struct {
	Kind     string
	ID       int64
	TaskID   sql.Null[domain.TaskID]
	Title    string
	Snippet  string
	Status   domain.TaskStatus
	WorkDate sql.Null[civil.Date]
}

SearchHit is a live task or entry ranked by full-text relevance.

type SearchIn

type SearchIn struct {
	Query, Kind string
	Limit       int
	Cursor      string
}

SearchIn selects literal full-text terms, entity kinds and an offset page.

type Service

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

Service coordinates operations on a single database.

func New

func New(o Options) (*Service, error)

New loads the database identity and initializes the service.

func (*Service) AcceptNew

func (s *Service) AcceptNew(ctx context.Context, m Meta, in AcceptNewIn) (*OpResult, error)

AcceptNew places tasks whose only triage reason is new at the bottom in new-sequence order.

func (*Service) AddEntry

func (s *Service) AddEntry(ctx context.Context, m Meta, in AddEntryIn) (*OpResult, error)

AddEntry records work, warning when the linked task is done or dropped.

func (*Service) AddTask

func (s *Service) AddTask(ctx context.Context, m Meta, in AddTaskIn) (*OpResult, error)

AddTask captures a task in triage, or applies an owner-requested placement.

func (*Service) Authenticate

func (s *Service) Authenticate(ctx context.Context, cookie string) (WebAuth, error)

Authenticate checks session lifetimes and queues successful activity in memory.

func (*Service) AuthenticateToken

func (s *Service) AuthenticateToken(ctx context.Context, bearer string, verifiedSocket bool, ch domain.Channel, remoteKey string) (domain.Actor, error)

AuthenticateToken checks a bearer and records successful use in memory.

func (*Service) BackupStatus

func (s *Service) BackupStatus(ctx context.Context, a domain.Actor) (BackupStatusView, error)

BackupStatus returns the snapshot inventory and the same backup warning used by Today.

func (*Service) BeginShutdown

func (s *Service) BeginShutdown()

BeginShutdown closes admission and cancels long operations observing stopCtx.

func (*Service) Block

func (s *Service) Block(ctx context.Context, m Meta, in BlockIn) (*OpResult, error)

Block schedules an open task and acknowledges its triage reasons.

func (*Service) ChangePassword

func (s *Service) ChangePassword(ctx context.Context, m Meta, in ChangePasswordIn) error

ChangePassword verifies the owner password and invalidates all web sessions.

func (*Service) Clock

func (s *Service) Clock(ctx context.Context, a domain.Actor) (ClockView, error)

Clock returns the time reference for any authenticated actor, regardless of scopes.

func (*Service) Complete

func (s *Service) Complete(ctx context.Context, m Meta, in CompleteIn) (*OpResult, error)

Complete closes and places an open task, logging its completion on Date.

func (*Service) CreateToken

func (s *Service) CreateToken(ctx context.Context, m Meta, in CreateTokenIn) (TokenCreated, error)

CreateToken creates a non-revertible token; retries cannot retrieve its secret.

func (*Service) Day

func (s *Service) Day(ctx context.Context, a domain.Actor, d civil.Date) (DayView, error)

Day returns a reconciled recap of the given civil date.

func (*Service) Defer

func (s *Service) Defer(ctx context.Context, m Meta, in DeferIn) (*OpResult, error)

Defer acknowledges triage and sets or clears a task's defer moment.

func (*Service) Delete

func (s *Service) Delete(ctx context.Context, m Meta, in TaskRef) (*OpResult, error)

Delete tombstones a task, closing planned blocks and clearing triage and focus.

func (*Service) DeleteEntry

func (s *Service) DeleteEntry(ctx context.Context, m Meta, in EntryRef) (*OpResult, error)

DeleteEntry tombstones an entry unless it completes a currently done task.

func (*Service) Drain

func (s *Service) Drain(ctx context.Context) error

Drain waits for accepted operations and jobs, or ctx. BeginShutdown closes admission before draining; a canceled drain never cancels accepted operations.

func (*Service) Drop

func (s *Service) Drop(ctx context.Context, m Meta, in TaskRef) (*OpResult, error)

Drop closes and places an open task without logging completion.

func (*Service) ExpireIdempotency

func (s *Service) ExpireIdempotency(ctx context.Context) (int, error)

ExpireIdempotency removes records strictly older than IdemTTL without events.

func (*Service) ExpireSessions

func (s *Service) ExpireSessions(ctx context.Context) (int, error)

ExpireSessions persists pending activity and deletes sessions at absolute or idle expiry.

func (*Service) Export

func (s *Service) Export(ctx context.Context, a domain.Actor, w io.Writer) error

Export streams a portable JSON export from one reader transaction for an administrator. It checks cancellation between rows but cannot interrupt a blocked Write. Callers with blocking writers must interrupt them when Stopping closes or their context is canceled. Writer errors are returned unchanged.

func (*Service) FlushUsage

func (s *Service) FlushUsage(ctx context.Context) error

FlushUsage persists coalesced token and session activity, including after Drain.

func (*Service) Generation

func (s *Service) Generation() domain.Generation

Generation returns the cached database generation without authorization.

func (*Service) GetBlock

func (s *Service) GetBlock(ctx context.Context, a domain.Actor, id domain.BlockID) (domain.BlockView, error)

GetBlock returns a block, including a tombstone, with its task and interval state.

func (*Service) GetEntry

func (s *Service) GetEntry(ctx context.Context, a domain.Actor, id domain.EntryID) (domain.EntryView, error)

GetEntry returns an entry, including a tombstone, with its linked task's title.

func (*Service) GetOp

func (s *Service) GetOp(ctx context.Context, a domain.Actor, id domain.OpID) (OpDetail, error)

GetOp returns an operation and its ordered events, or not_found if absent.

func (*Service) GetTask

func (s *Service) GetTask(ctx context.Context, a domain.Actor, id domain.TaskID) (domain.TaskDetail, error)

GetTask returns a task, including a tombstone, and its non-deleted related records.

func (*Service) History

func (s *Service) History(ctx context.Context, a domain.Actor, in HistoryIn) (Page[EventView], error)

History returns a task's audit events, including derived events, newest first.

func (*Service) ListAIChanges

func (s *Service) ListAIChanges(ctx context.Context, a domain.Actor, in ListAIChangesIn) (AIChanges, error)

ListAIChanges returns AI changes newest first, with the total unreviewed count.

func (*Service) ListBlocks

func (s *Service) ListBlocks(ctx context.Context, a domain.Actor, in ListBlocksIn) ([]domain.BlockView, error)

ListBlocks returns live blocks ordered by date, start minute and ID.

func (*Service) ListEntries

func (s *Service) ListEntries(ctx context.Context, a domain.Actor, in ListEntriesIn) (Page[domain.EntryView], error)

ListEntries returns a page of entries, newest days and timed entries first.

func (*Service) ListOps

func (s *Service) ListOps(ctx context.Context, a domain.Actor, in ListOpsIn) (Page[OpSummary], error)

ListOps returns matching operations in descending sequence order.

func (*Service) ListTags

func (s *Service) ListTags(ctx context.Context, a domain.Actor) ([]TagCount, error)

ListTags returns positive open-task counts in case-insensitive tag order.

func (*Service) ListTasks

func (s *Service) ListTasks(ctx context.Context, a domain.Actor, in ListTasksIn) (Page[domain.TaskView], error)

ListTasks returns one filtered page, reconciling the time-dependent views first.

func (*Service) ListTokens

func (s *Service) ListTokens(ctx context.Context, a domain.Actor) ([]domain.Token, error)

ListTokens returns all token metadata with secret hashes removed.

func (*Service) Login

func (s *Service) Login(ctx context.Context, in LoginIn) (Session, error)

Login verifies the owner password and atomically replaces any presented session.

func (*Service) Logout

func (s *Service) Logout(ctx context.Context, cookie string) error

Logout deletes the presented session, if present.

func (*Service) MarkAIReviewed

func (s *Service) MarkAIReviewed(ctx context.Context, m Meta, in MarkAIReviewedIn) (*OpResult, error)

MarkAIReviewed advances the owner's review watermark without permitting reversal.

func (*Service) MarkManual

func (s *Service) MarkManual(ctx context.Context, m Meta, in MarkManualIn) (*OpResult, error)

MarkManual adds an explicit triage reason, preserving an existing reason.

func (*Service) Place

func (s *Service) Place(ctx context.Context, m Meta, in PlaceIn) (*OpResult, error)

Place acknowledges all triage reasons and optionally changes a task's rank.

func (*Service) PurgeLive

func (s *Service) PurgeLive(ctx context.Context, m Meta, in PurgeLiveIn) (PurgeLiveResult, error)

PurgeLive durably records an intent and scrubs its exact set in one writer transaction. The offline caller holds the instance lock and verifies the owner's password; it must finish checkpointing, backup scrubbing and recovery-file cleanup afterwards.

func (*Service) ReapplyLedger

func (s *Service) ReapplyLedger(ctx context.Context) error

ReapplyLedger replays the configured ledger in live mode without appending records.

func (*Service) Reblock

func (s *Service) Reblock(ctx context.Context, m Meta, in ReblockIn) (*OpResult, error)

Reblock reschedules a block and acknowledges its task's triage reasons.

func (*Service) Reconcile

func (s *Service) Reconcile(ctx context.Context) error

Reconcile performs time-dependent maintenance only when the reader finds work.

func (*Service) RecordSystemOp

func (s *Service) RecordSystemOp(ctx context.Context, kind domain.OpKind, after json.RawMessage) (*OpResult, error)

RecordSystemOp records an offline restore or import without reconciling historical state. The caller supplies a content-free JSON object describing the operation.

func (*Service) Redo

func (s *Service) Redo(ctx context.Context, m Meta) (*OpResult, error)

Redo reverses the active reversal of the caller's newest redo entry.

func (*Service) RelinkEntry

func (s *Service) RelinkEntry(ctx context.Context, m Meta, in RelinkEntryIn) (*OpResult, error)

RelinkEntry attaches a work entry to a task or makes it standalone.

func (*Service) Reopen

func (s *Service) Reopen(ctx context.Context, m Meta, in ReopenIn) (*OpResult, error)

Reopen opens a done or dropped task without restoring blocks or placing it.

func (*Service) ReplayLedger

func (s *Service) ReplayLedger(ctx context.Context, recs []backup.LedgerRecord, mode ReplayMode) (*OpResult, error)

ReplayLedger applies the union of valid ledger records as one system operation. Missing IDs are skipped. Historical replay cancels target tasks' planned blocks without deriving outcomes or reconciling unrelated historical state.

func (*Service) Report

func (s *Service) Report(ctx context.Context, a domain.Actor, in ReportIn) (Report, error)

Report reads work history, reconciling first only when current views are requested.

func (*Service) ResetPasswordOffline

func (s *Service) ResetPasswordOffline(ctx context.Context, in ResetPasswordIn) (domain.TokenID, error)

ResetPasswordOffline rotates all credentials atomically; callers must hold the offline instance lock.

func (*Service) Revert

func (s *Service) Revert(ctx context.Context, m Meta, in RevertIn) (*OpResult, error)

Revert reverses one operation and records a new undoable operation.

func (*Service) RevokeToken

func (s *Service) RevokeToken(ctx context.Context, m Meta, in RevokeTokenIn) (domain.Token, error)

RevokeToken revokes a non-owner token, or returns its unchanged revoked metadata.

func (*Service) RunBackup

func (s *Service) RunBackup(ctx context.Context, a domain.Actor, kind backup.Kind) (backup.SnapshotInfo, error)

RunBackup takes a snapshot for an administrator or the system scheduler, then rotates it. Backup bookkeeping is maintenance: it creates no events or idempotency records.

func (*Service) Search

func (s *Service) Search(ctx context.Context, a domain.Actor, in SearchIn) (Page[SearchHit], error)

Search returns matching live rows without reconciling time-dependent state.

func (*Service) SetDue

func (s *Service) SetDue(ctx context.Context, m Meta, in SetDueIn) (*OpResult, error)

SetDue changes a task's due moment and resets its due acknowledgement.

func (*Service) SetFocus

func (s *Service) SetFocus(ctx context.Context, m Meta, in SetFocusIn) (*OpResult, error)

SetFocus changes or clears today's focus without placing the target task.

func (*Service) SetOutcome

func (s *Service) SetOutcome(ctx context.Context, m Meta, in SetOutcomeIn) (*OpResult, error)

SetOutcome overrides a block's outcome or restores automatic resolution.

func (*Service) Settings

func (s *Service) Settings(ctx context.Context, a domain.Actor) (SettingsView, error)

Settings returns the persisted backup retention settings.

func (*Service) Status

func (s *Service) Status(ctx context.Context, a domain.Actor) (StatusView, error)

Status reconciles state and reads compact focus, due, triage and warning data.

func (*Service) Stopping

func (s *Service) Stopping() <-chan struct{}

Stopping closes when shutdown begins so callers can interrupt blocking I/O.

func (*Service) SyncTimezone

func (s *Service) SyncTimezone(ctx context.Context, name string) (previous string, changed bool, err error)

SyncTimezone persists the configured zone without an operation or event and remembers a change for dashboard notices throughout this service's lifetime.

func (*Service) Today

func (s *Service) Today(ctx context.Context, a domain.Actor) (TodayView, error)

Today reconciles time-dependent state and reads a consistent dashboard snapshot.

func (*Service) Unblock

func (s *Service) Unblock(ctx context.Context, m Meta, in BlockRef) (*OpResult, error)

Unblock ends a planned block without acknowledging the task's triage reasons.

func (*Service) Undelete

func (s *Service) Undelete(ctx context.Context, m Meta, in TaskRef) (*OpResult, error)

Undelete restores a tombstoned task and requests manual triage if it is open.

func (*Service) UndeleteEntry

func (s *Service) UndeleteEntry(ctx context.Context, m Meta, in EntryRef) (*OpResult, error)

UndeleteEntry restores a tombstoned entry, leaving live entries unchanged.

func (*Service) Undo

func (s *Service) Undo(ctx context.Context, m Meta) (*OpResult, error)

Undo reverses the newest operation on the caller's undo stack.

func (*Service) Upcoming

func (s *Service) Upcoming(ctx context.Context, a domain.Actor) (UpcomingView, error)

Upcoming returns reconciled deferred tasks and non-overdue tasks due soon.

func (*Service) UpdateEntry

func (s *Service) UpdateEntry(ctx context.Context, m Meta, in UpdateEntryIn) (*OpResult, error)

UpdateEntry edits work entries, or just the notes of completion entries.

func (*Service) UpdateSettings

func (s *Service) UpdateSettings(ctx context.Context, m Meta, in UpdateSettingsIn) (SettingsView, error)

UpdateSettings applies retention floors and records password-authorized reductions.

func (*Service) UpdateTask

func (s *Service) UpdateTask(ctx context.Context, m Meta, in UpdateTaskIn) (*OpResult, error)

UpdateTask edits a task's content and tags without placing it.

func (*Service) WhoAmI

func (s *Service) WhoAmI(ctx context.Context, a domain.Actor) (WhoAmIView, error)

WhoAmI returns the supplied authenticated identity, regardless of scopes.

func (*Service) Zone

func (s *Service) Zone() civil.Zone

Zone returns the service's configured civil time zone.

type Session

type Session struct {
	CookieValue, CSRFToken string
	ExpiresAt              time.Time
}

Session contains the credentials and absolute expiration of a new web session.

type SetDueIn

type SetDueIn struct {
	ID     domain.TaskID
	Expect domain.Expect
	Due    *domain.Moment
}

SetDueIn identifies a task and its new due moment; nil clears the due.

type SetFocusIn

type SetFocusIn struct {
	TaskID    sql.Null[domain.TaskID]
	Interrupt bool
}

SetFocusIn supplies an optional focus target and an explicit interruption request.

type SetOutcomeIn

type SetOutcomeIn struct {
	BlockID domain.BlockID
	Expect  domain.Expect
	Outcome domain.UserOutcome
}

SetOutcomeIn identifies a block, its expected version, and an outcome policy.

type SettingsView

type SettingsView struct{ KeepDaily, KeepWeekly int }

SettingsView contains the configurable backup retention counts.

type StatusBlock

type StatusBlock struct {
	ID     domain.BlockID
	TaskID domain.TaskID
	Title  string
	End    civil.EndMinute
}

StatusBlock is a compact reference to the current block and its end time.

type StatusTask

type StatusTask struct {
	ID    domain.TaskID
	Title string
}

StatusTask is a compact task reference for the status line.

type StatusView

type StatusView struct {
	Focus                    *StatusTask
	CurrentBlock             *StatusBlock
	Triage, Due, AI          int
	BackupWarn, PurgeWarning bool
}

StatusView contains the task, counts and warnings shown in a status line.

type TagCount

type TagCount struct {
	Name  string
	Count int
}

TagCount counts the open, non-deleted tasks carrying a tag.

type TaskRef

type TaskRef struct {
	ID     domain.TaskID
	Expect domain.Expect
}

TaskRef identifies a task and its expected version.

type TodayView

type TodayView struct {
	Clock         ClockView
	Focus         *domain.TaskView
	CurrentBlock  *domain.BlockView
	Blocks        []domain.BlockView
	TriageCount   int
	TriageTop     []domain.TaskView
	Overdue       []domain.TaskView
	DueSoon       []domain.TaskView
	Entries       []domain.EntryView
	Interruptions []domain.Interruption
	AIChanges     int
	Backup        BackupHealth
	Banners       []Banner
}

TodayView collects the current day's planning, work and service notices.

type TokenCreated

type TokenCreated struct {
	Token  domain.Token
	Secret string
}

TokenCreated returns public metadata and the bearer secret shown only once.

type UpcomingView

type UpcomingView struct{ Deferred, DueSoon []domain.TaskView }

UpcomingView contains future deferrals and non-deferred tasks due soon.

type UpdateEntryIn

type UpdateEntryIn struct {
	ID       domain.EntryID
	Expect   domain.Expect
	Title    *string
	Notes    *string
	WorkDate *civil.Date
	At       *sql.Null[civil.Minute] // Non-nil invalid Null clears the time.
}

UpdateEntryIn supplies optional changes to an entry's content and work date.

type UpdateSettingsIn

type UpdateSettingsIn struct {
	KeepDaily, KeepWeekly *int
	Password              string
}

UpdateSettingsIn changes optional retention counts, requiring a password to lower either.

type UpdateTaskIn

type UpdateTaskIn struct {
	ID                    domain.TaskID
	Expect                domain.Expect
	Title, Notes, Project *string          // Nil leaves unchanged; empty Project clears.
	Priority              *domain.Priority // PriorityNone clears.
	TagsAdd, TagsRemove   []string
}

UpdateTaskIn supplies optional task fields and case-insensitive tag changes.

type WebAuth

type WebAuth struct {
	Actor     domain.Actor
	CSRFToken string
}

WebAuth contains the authenticated web owner and the session's CSRF token.

type WhoAmIView

type WhoAmIView struct {
	Actor      domain.Actor
	Generation domain.Generation
}

WhoAmIView identifies the authenticated caller and current database generation.

Jump to

Keyboard shortcuts

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