client

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: 25 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 client provides the authenticated Taskronin unix-socket API client.

Index

Constants

View Source
const PendingResendWindow = 7*24*time.Hour - time.Hour

PendingResendWindow bounds a resendable pending request's age: the server's idempotency retention (service.IdemTTL, 7 d) minus a 1-hour safety margin.

AIDEV-NOTE: final review A-Minor-3. CreatedAt is stamped when the file is saved, up to the 20 s call budget AFTER the server committed, while the server forgets rows 7 d after the commit. Without the margin, a resend of an op without If-Match (add, log, focus, undo/redo/revert) near 7 d could re-execute instead of replaying; undo/redo would hit a different stack entry. Keep this in step with service.IdemTTL (pending_test.go asserts it).

Variables

View Source
var (
	ErrNotSent            = errors.New("request not sent")
	ErrOutcomeUnknown     = errors.New("request outcome unknown")
	ErrGenerationMismatch = errors.New("database generation changed")
	ErrTokenFile          = errors.New("token file unusable")
	ErrPendingExpired     = errors.New("pending request too old to resend safely (the server keeps idempotency records for 7 days)")
	ErrActorMismatch      = errors.New("pending request belongs to another actor")
)

Failure classes used by the CLI and pending-request recovery.

Functions

func IsCode

func IsCode(err error, code domain.Code) bool

IsCode reports whether err contains an API problem with code.

Types

type BlockQuery

type BlockQuery struct {
	From, To *civil.Date
	Task     *int64
}

BlockQuery filters blocks by date or a concrete task.

type Client

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

Client is safe for concurrent calls. Its options and credentials are immutable.

func New

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

New checks and reads the private token file without performing network I/O.

func NewFromConfig

func NewFromConfig(cfg *config.Client, channel string, pending *PendingStore) (*Client, error)

NewFromConfig uses the resolved client configuration and supplied channel.

func (*Client) AIChanges

func (c *Client) AIChanges(ctx context.Context, all bool, p PageQuery) (*api.AIChanges, error)

AIChanges reads token changes and the owner's review progress.

func (*Client) AcceptNew

func (c *Client) AcceptNew(ctx context.Context, m Mut, r api.AcceptNewRequest) (*api.OpResponse, error)

AcceptNew accepts new tasks atomically using the per-item ETags; m.IfMatch is unused.

func (*Client) Actor

func (c *Client) Actor(ctx context.Context) (string, error)

Actor returns the actor cached alongside the database generation.

func (*Client) AddEntry

func (c *Client) AddEntry(ctx context.Context, m Mut, r api.AddEntryRequest) (*api.OpResponse, error)

AddEntry logs work against an explicit task or as a standalone entry.

func (*Client) AddTask

func (c *Client) AddTask(ctx context.Context, m Mut, r api.AddTaskRequest) (*api.OpResponse, error)

AddTask captures a task with optional owner placement.

func (*Client) Backups

func (c *Client) Backups(ctx context.Context) (*api.BackupStatus, error)

Backups returns backup health and the snapshot inventory.

func (*Client) BlockTask

func (c *Client) BlockTask(ctx context.Context, m Mut, id int64, r api.BlockRequest) (*api.OpResponse, error)

BlockTask schedules a block for a task.

func (*Client) ChangePassword

func (c *Client) ChangePassword(ctx context.Context, r api.PasswordRequest) error

ChangePassword changes the owner password without saving or replaying it.

func (*Client) Clock

func (c *Client) Clock(ctx context.Context) (*api.Clock, error)

Clock reads the server clock and instance settings.

func (*Client) CompleteTask

func (c *Client) CompleteTask(ctx context.Context, m Mut, id int64, r api.CompleteRequest) (*api.OpResponse, error)

CompleteTask completes a task and records its completion entry.

func (*Client) CreateToken

func (c *Client) CreateToken(ctx context.Context, r api.CreateTokenRequest) (*api.TokenCreated, error)

CreateToken returns a new token and its one-time secret.

func (*Client) Day

func (c *Client) Day(ctx context.Context, d civil.Date) (*api.Day, error)

Day reads the recap for a civil date.

func (*Client) DeferTask

func (c *Client) DeferTask(ctx context.Context, m Mut, id int64, r api.DeferRequest) (*api.OpResponse, error)

DeferTask sets or clears the task's deferral.

func (*Client) DeleteEntry

func (c *Client) DeleteEntry(ctx context.Context, m Mut, id int64) (*api.OpResponse, error)

DeleteEntry soft-deletes an entry.

func (*Client) DeleteTask

func (c *Client) DeleteTask(ctx context.Context, m Mut, id int64) (*api.OpResponse, error)

DeleteTask soft-deletes a task.

func (*Client) DropTask

func (c *Client) DropTask(ctx context.Context, m Mut, id int64) (*api.OpResponse, error)

DropTask closes a task without a completion entry.

func (*Client) Export

func (c *Client) Export(ctx context.Context, w io.Writer) error

Export streams the portable document within an eleven-minute total budget.

func (*Client) Generation

func (c *Client) Generation(ctx context.Context) (string, error)

Generation lazily fetches and caches the database generation with the actor.

func (*Client) GetBlock

func (c *Client) GetBlock(ctx context.Context, id int64) (*api.Block, error)

GetBlock reads a block with both entity and task ETags.

func (*Client) GetEntry

func (c *Client) GetEntry(ctx context.Context, id int64) (*api.Entry, error)

GetEntry reads an entry with its linked task's title.

func (*Client) GetOp

func (c *Client) GetOp(ctx context.Context, opID string) (*api.OpDetail, error)

GetOp reads an operation and its audit events.

func (*Client) GetTask

func (c *Client) GetTask(ctx context.Context, id int64) (*api.TaskDetail, error)

GetTask reads a task and its associated records.

func (*Client) Health

func (c *Client) Health(ctx context.Context) error

Health checks the server's unversioned health endpoint.

func (*Client) ListBlocks

func (c *Client) ListBlocks(ctx context.Context, q BlockQuery) ([]api.Block, error)

ListBlocks reads blocks by date or concrete task.

func (*Client) ListEntries

func (c *Client) ListEntries(ctx context.Context, q EntryQuery) (*api.Page[api.Entry], error)

ListEntries reads work and completion entries.

func (*Client) ListOps

func (c *Client) ListOps(ctx context.Context, q OpsQuery) (*api.Page[api.OpSummary], error)

ListOps reads a page of operations matching the actor, op ID prefix and sequence filters.

func (*Client) ListTasks

func (c *Client) ListTasks(ctx context.Context, q TaskQuery) (*api.Page[api.Task], error)

ListTasks reads a task view with optional filters and pagination.

func (*Client) MarkManual

func (c *Client) MarkManual(ctx context.Context, m Mut, id int64) (*api.OpResponse, error)

MarkManual adds a manual triage reason to a task.

func (*Client) PlaceTask

func (c *Client) PlaceTask(ctx context.Context, m Mut, id int64, r api.PlaceRequest) (*api.OpResponse, error)

PlaceTask places a task and acknowledges its triage reasons.

func (*Client) Reblock

func (c *Client) Reblock(ctx context.Context, m Mut, blockID int64, r api.ReblockRequest) (*api.OpResponse, error)

Reblock reschedules a block using both block and task preconditions.

func (*Client) Redo

func (c *Client) Redo(ctx context.Context, m Mut) (*api.OpResponse, error)

Redo reapplies the latest undone operation on the caller's stack.

func (*Client) RefreshGeneration

func (c *Client) RefreshGeneration(ctx context.Context) (string, error)

RefreshGeneration invalidates the cached identity and fetches it again.

func (*Client) RelinkEntry

func (c *Client) RelinkEntry(ctx context.Context, m Mut, id int64, r api.RelinkRequest) (*api.OpResponse, error)

RelinkEntry changes or clears an entry's task link.

func (*Client) ReopenTask

func (c *Client) ReopenTask(ctx context.Context, m Mut, id int64, r api.ReopenRequest) (*api.OpResponse, error)

ReopenTask reopens a closed task, optionally removing its completion entry.

func (*Client) Report

func (c *Client) Report(ctx context.Context, q ReportQuery) (*api.Report, error)

Report reads work over a date range with optional current task sections.

func (*Client) Resend

func (c *Client) Resend(ctx context.Context, p PendingRequest) (*ResendResult, error)

Resend checks expiry, generation and actor before retrying the saved request. The caller discards a success or marks a definitive failure; Resend never changes pending files, including after another uncertain outcome. A request whose age reaches PendingResendWindow is refused with ErrPendingExpired.

func (*Client) Revert

func (c *Client) Revert(ctx context.Context, m Mut, opID string) (*api.OpResponse, error)

Revert reverses an operation by its operation ID.

func (*Client) ReviewAIChanges

func (c *Client) ReviewAIChanges(ctx context.Context, m Mut, r api.ReviewRequest) (*api.OpResponse, error)

ReviewAIChanges advances the owner's AI review watermark.

func (*Client) RevokeToken

func (c *Client) RevokeToken(ctx context.Context, m Mut, id int64) (*api.TokenInfo, error)

RevokeToken revokes a non-owner token with keyed retry semantics.

func (*Client) RunBackup

func (c *Client) RunBackup(ctx context.Context) (*api.Snapshot, error)

RunBackup requests a manual snapshot with an eleven-minute total budget.

func (*Client) Search

func (c *Client) Search(ctx context.Context, q SearchQuery) (*api.Page[api.SearchHit], error)

Search searches tasks or entries with pagination.

func (*Client) SetDue

func (c *Client) SetDue(ctx context.Context, m Mut, id int64, r api.DueRequest) (*api.OpResponse, error)

SetDue sets or clears the task's due moment.

func (*Client) SetFocus

func (c *Client) SetFocus(ctx context.Context, m Mut, r api.FocusRequest) (*api.OpResponse, error)

SetFocus sets or clears today's focus without an entity precondition.

func (*Client) SetOutcome

func (c *Client) SetOutcome(ctx context.Context, m Mut, blockID int64, r api.OutcomeRequest) (*api.OpResponse, error)

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

func (*Client) Settings

func (c *Client) Settings(ctx context.Context) (*api.Settings, error)

Settings reads the instance's mutable settings.

func (*Client) Status

func (c *Client) Status(ctx context.Context, ifNoneMatch string) (*api.Status, string, bool, error)

Status reads the compact status, optionally reusing a cached representation.

func (*Client) Tags

func (c *Client) Tags(ctx context.Context) ([]api.TagCount, error)

Tags counts tags on open tasks.

func (*Client) TaskHistory

func (c *Client) TaskHistory(ctx context.Context, id int64, p PageQuery) (*api.Page[api.EventView], error)

TaskHistory reads a page of a task's audit events.

func (*Client) Today

func (c *Client) Today(ctx context.Context, ifNoneMatch string) (*api.Today, string, bool, error)

Today reads the dashboard, optionally reusing a cached representation.

func (*Client) Tokens

func (c *Client) Tokens(ctx context.Context) ([]api.TokenInfo, error)

Tokens lists public token metadata without credentials.

func (*Client) Unblock

func (c *Client) Unblock(ctx context.Context, m Mut, blockID int64) (*api.OpResponse, error)

Unblock cancels an unstarted block or resolves one that has started.

func (*Client) UndeleteEntry

func (c *Client) UndeleteEntry(ctx context.Context, m Mut, id int64) (*api.OpResponse, error)

UndeleteEntry restores a soft-deleted entry.

func (*Client) UndeleteTask

func (c *Client) UndeleteTask(ctx context.Context, m Mut, id int64) (*api.OpResponse, error)

UndeleteTask restores a soft-deleted task.

func (*Client) Undo

func (c *Client) Undo(ctx context.Context, m Mut) (*api.OpResponse, error)

Undo reverses the latest undoable operation on the caller's stack.

func (*Client) Upcoming

func (c *Client) Upcoming(ctx context.Context) (*api.Upcoming, error)

Upcoming reads deferred and soon-due tasks.

func (*Client) UpdateEntry

func (c *Client) UpdateEntry(ctx context.Context, m Mut, id int64, r api.UpdateEntryRequest) (*api.OpResponse, error)

UpdateEntry patches an entry's content, work date and time.

func (*Client) UpdateSettings

func (c *Client) UpdateSettings(ctx context.Context, r api.SettingsRequest) (*api.Settings, error)

UpdateSettings changes retention; lowering requires password re-entry.

func (*Client) UpdateTask

func (c *Client) UpdateTask(ctx context.Context, m Mut, id int64, r api.UpdateTaskRequest) (*api.OpResponse, error)

UpdateTask patches task content and metadata.

func (*Client) WhoAmI

func (c *Client) WhoAmI(ctx context.Context) (*api.WhoAmI, error)

WhoAmI reads the authenticated actor, scopes and current database generation.

type EntryQuery

type EntryQuery struct {
	From, To                   *civil.Date
	Task                       *int64
	Standalone, IncludeDeleted bool
	PageQuery
}

EntryQuery filters entries by date, task, standalone state and deletion state.

type Mut

type Mut struct {
	IfMatch string
	Key     string
}

Mut supplies an entity precondition and an optional existing idempotency key.

type OpsQuery

type OpsQuery struct {
	Actor    string
	OpPrefix string
	SinceSeq int64
	PageQuery
}

OpsQuery filters operation history.

type Options

type Options struct {
	Socket    string
	TokenFile string
	Channel   string
	Timeout   time.Duration
	NoRetry   bool // suppress retries and automatic generation refresh
	Pending   *PendingStore
	NewKey    func() string
	Clock     clock.Clock
}

Options configures credentials, request budgets, retries and pending storage.

type OutcomeUnknownError

type OutcomeUnknownError struct {
	Key   string
	Saved bool
	Err   error
}

OutcomeUnknownError indicates that request bytes were written but no complete response was received. Saved reports whether pending persistence succeeded.

func (*OutcomeUnknownError) Error

func (e *OutcomeUnknownError) Error() string

func (*OutcomeUnknownError) Is

func (e *OutcomeUnknownError) Is(target error) bool

Is recognizes the outcome-unknown sentinel.

func (*OutcomeUnknownError) Unwrap

func (e *OutcomeUnknownError) Unwrap() error

Unwrap preserves transport, context and pending-write errors.

type PageQuery

type PageQuery struct {
	Limit  int
	Cursor string
}

PageQuery specifies pagination.

type PendingRequest

type PendingRequest struct {
	Key           string          `json:"key"`
	Method        string          `json:"method"`
	Path          string          `json:"path"`
	IfMatch       string          `json:"if_match"`
	Generation    string          `json:"generation"`
	Actor         string          `json:"actor"`
	Body          json.RawMessage `json:"body"`
	CreatedAt     time.Time       `json:"created_at"`
	LastError     string          `json:"last_error"`
	LastAttemptAt time.Time       `json:"last_attempt_at"`
}

PendingRequest preserves a keyed mutation for guarded, explicit recovery.

type PendingStore

type PendingStore struct {
	Dir   string
	Clock clock.Clock
}

PendingStore stores private, durable request files under Dir.

func (*PendingStore) Age

Age reports how long a request has been pending, using the store's clock.

func (*PendingStore) Discard

func (s *PendingStore) Discard(key string) error

Discard removes a pending request after success or explicit user discard.

func (*PendingStore) List

func (s *PendingStore) List() ([]PendingRequest, error)

List returns pending requests ordered by creation time, oldest first. A missing pending directory is an empty store.

func (*PendingStore) MarkFailed

func (s *PendingStore) MarkFailed(key, lastError string) error

MarkFailed records a definitive failure without replacing the saved mutation or restarting its seven-day expiry window.

func (*PendingStore) Save

func (s *PendingStore) Save(p PendingRequest) error

Save writes <Dir>/<key>.json atomically, assigning the current creation time.

type ProblemError

type ProblemError struct {
	Status  int
	Problem api.Problem
}

ProblemError preserves the complete RFC 9457 problem and HTTP status.

func (*ProblemError) Code

func (e *ProblemError) Code() domain.Code

Code returns the stable domain error code.

func (*ProblemError) Error

func (e *ProblemError) Error() string

func (*ProblemError) Is

func (e *ProblemError) Is(target error) bool

Is recognizes the generation-change sentinel without losing problem details.

type ReportQuery

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

ReportQuery specifies a report range and optional sections.

type ResendResult

type ResendResult struct {
	Op    *api.OpResponse
	Token *api.TokenInfo
}

ResendResult holds exactly one successful keyed response: an operation or revoked token metadata. AIDEV-NOTE: BF18 requires typed revocation recovery; it cannot be decoded as OpResponse. CLI pending retry must render whichever field is populated.

type SearchQuery

type SearchQuery struct {
	Q, Kind string
	PageQuery
}

SearchQuery specifies a search and pagination.

type TaskQuery

type TaskQuery struct {
	View, Tag, Project string
	PageQuery
}

TaskQuery selects a task view and filters.

type TokenFileError

type TokenFileError struct {
	Path string
	Err  error
}

TokenFileError carries the credential path and the failed read or check.

func (*TokenFileError) Error

func (e *TokenFileError) Error() string

func (*TokenFileError) Is

func (e *TokenFileError) Is(target error) bool

Is recognizes the token-file exit class.

func (*TokenFileError) Unwrap

func (e *TokenFileError) Unwrap() error

Unwrap retains the underlying filesystem error.

Jump to

Keyboard shortcuts

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