workstore

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2026 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Overview

Package workstore provides memory, SQLite, and PostgreSQL backends for durable terminal-work intent, claims, retry, and quarantine (requirements 8.1–8.9).

Migrations use direct/admin connections; runtime pools verify schema only (design D12).

Index

Constants

View Source
const BaselineMigrationName = "20260718153000"
View Source
const MaxQueryLimit = terminalwork.MaxQueryLimit
View Source
const RuntimeGenerationIDMigrationName = "20260721093000"
View Source
const RuntimeInstanceIDMigrationName = "20260721104500"

Variables

View Source
var (
	ErrIdentityCollision    = errors.New("terminalwork/workstore: identity collision")
	ErrNotFound             = errors.New("terminalwork/workstore: not found")
	ErrConflict             = sdk.ErrConflict
	ErrQueryTooBroad        = terminalwork.ErrQueryTooBroad
	ErrQueryLimitExceeded   = terminalwork.ErrQueryLimitExceeded
	ErrUniqueRaceMissingRow = errors.New("terminalwork/workstore: unique race missing winner row")
)

Functions

func HasSelectiveBound

func HasSelectiveBound(q Query) bool

func Migrate

func Migrate(ctx context.Context, db *bun.DB) error

func ValidateQuery

func ValidateQuery(q Query) error

func VerifySchema

func VerifySchema(ctx context.Context, db *bun.DB) error

Types

type ClaimDueCommand

type ClaimDueCommand = terminalwork.ClaimDueCommand

Command types are owned by the core terminalwork package (hexagonal port).

type CompleteCommand

type CompleteCommand = terminalwork.CompleteCommand

Command types are owned by the core terminalwork package (hexagonal port).

type DurableConfig

type DurableConfig struct {
	StoreID         string
	DefaultPageSize int
	MaxPageSize     int
	Now             func() time.Time
}

type DurableStore

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

func NewDurableStore

func NewDurableStore(ctx context.Context, db *bun.DB, cfg DurableConfig) (*DurableStore, error)

func OpenStore

func OpenStore(ctx context.Context, db *bun.DB, cfg DurableConfig) (*DurableStore, error)

func (*DurableStore) AppendIntent

func (s *DurableStore) AppendIntent(ctx context.Context, rec terminalwork.WorkRecord) error

func (*DurableStore) AppendIntentOutcome

AppendIntentOutcome implements the definitive insert-vs-replay seam.

func (*DurableStore) CheckReadiness

func (s *DurableStore) CheckReadiness(ctx context.Context) error

func (*DurableStore) ClaimDue

func (*DurableStore) Close

func (s *DurableStore) Close() error

func (*DurableStore) Complete

func (s *DurableStore) Complete(ctx context.Context, cmd CompleteCommand) error

func (*DurableStore) GetBySourceKey

func (*DurableStore) GetByWorkID

func (s *DurableStore) GetByWorkID(ctx context.Context, workID string) (terminalwork.WorkRecord, error)

func (*DurableStore) List

func (s *DurableStore) List(ctx context.Context, q Query) (Page, error)

func (*DurableStore) LookupIntent

func (s *DurableStore) LookupIntent(ctx context.Context, workID string) (terminalwork.WorkRecord, bool, error)

LookupIntent implements terminalworkapp.IntentLookup.

func (*DurableStore) PromotePending

func (s *DurableStore) PromotePending(ctx context.Context, cmd PromotePendingCommand) error

func (*DurableStore) Quarantine

func (s *DurableStore) Quarantine(ctx context.Context, cmd QuarantineCommand) error

func (*DurableStore) RenewClaim

func (s *DurableStore) RenewClaim(ctx context.Context, cmd RenewClaimCommand) error

func (*DurableStore) ScheduleRetry

func (s *DurableStore) ScheduleRetry(ctx context.Context, cmd ScheduleRetryCommand) error

type MemoryConfig

type MemoryConfig struct {
	StoreID         string
	State           *MemoryState
	DefaultPageSize int
	MaxPageSize     int
	Now             func() time.Time
}

type MemoryState

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

func NewMemoryState

func NewMemoryState() *MemoryState

type MemoryStore

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

func NewMemoryStore

func NewMemoryStore(cfg MemoryConfig) (*MemoryStore, error)

func (*MemoryStore) AppendIntent

func (s *MemoryStore) AppendIntent(ctx context.Context, rec terminalwork.WorkRecord) error

func (*MemoryStore) AppendIntentOutcome

AppendIntentOutcome implements the definitive insert-vs-replay seam.

func (*MemoryStore) CheckReadiness

func (s *MemoryStore) CheckReadiness(ctx context.Context) error

func (*MemoryStore) ClaimDue

func (*MemoryStore) Close

func (s *MemoryStore) Close() error

func (*MemoryStore) Complete

func (s *MemoryStore) Complete(ctx context.Context, cmd CompleteCommand) error

func (*MemoryStore) GetBySourceKey

func (*MemoryStore) GetByWorkID

func (s *MemoryStore) GetByWorkID(ctx context.Context, workID string) (terminalwork.WorkRecord, error)

func (*MemoryStore) List

func (s *MemoryStore) List(ctx context.Context, q Query) (Page, error)

func (*MemoryStore) LookupIntent

func (s *MemoryStore) LookupIntent(ctx context.Context, workID string) (terminalwork.WorkRecord, bool, error)

LookupIntent implements terminalworkapp.IntentLookup.

func (*MemoryStore) PromotePending

func (s *MemoryStore) PromotePending(ctx context.Context, cmd PromotePendingCommand) error

func (*MemoryStore) Quarantine

func (s *MemoryStore) Quarantine(ctx context.Context, cmd QuarantineCommand) error

func (*MemoryStore) RenewClaim

func (s *MemoryStore) RenewClaim(ctx context.Context, cmd RenewClaimCommand) error

func (*MemoryStore) ScheduleRetry

func (s *MemoryStore) ScheduleRetry(ctx context.Context, cmd ScheduleRetryCommand) error

type Page

type Page = terminalwork.ListPage

Query/Page and bounds are owned by the core terminalwork package (hexagonal port).

type PromotePendingCommand

type PromotePendingCommand = terminalwork.PromotePendingCommand

Command types are owned by the core terminalwork package (hexagonal port).

type QuarantineCommand

type QuarantineCommand = terminalwork.QuarantineCommand

Command types are owned by the core terminalwork package (hexagonal port).

type Query

type Query = terminalwork.ListQuery

Query/Page and bounds are owned by the core terminalwork package (hexagonal port).

type RenewClaimCommand

type RenewClaimCommand = terminalwork.RenewClaimCommand

Command types are owned by the core terminalwork package (hexagonal port).

type ScheduleRetryCommand

type ScheduleRetryCommand = terminalwork.ScheduleRetryCommand

Command types are owned by the core terminalwork package (hexagonal port).

Jump to

Keyboard shortcuts

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