sqlite

package
v2.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2026 License: MIT Imports: 28 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CanonicalDatabasePath

func CanonicalDatabasePath(path string) (string, error)

func DefaultTestUIPath

func DefaultTestUIPath(root string) string

func V16Identity

func V16Identity() (version, fingerprint string)

V16Identity returns the only legacy schema accepted by the v2 migrator.

func VerifyV16Runner

func VerifyV16Runner(ctx context.Context, runner V16Runner) error

VerifyV16Runner validates an exact v16 schema through the package SQL runner contract. It is internal migration infrastructure.

Types

type ExportedV16State

type ExportedV16State struct {
	Session        []byte
	Prompt         []byte
	ForkOperations []internalstorage.ForkOperationRecord
	Threads        int
	Entries        int
}

ExportedV16State is the strict logical state written by the v2 migrator.

func ExportV16State

func ExportV16State(ctx context.Context, runner V16Runner) (ExportedV16State, error)

ExportV16State decodes canonical v16 thread, journal, and prompt data from one already-validated read snapshot.

type MaintenanceError

type MaintenanceError struct {
	Reason      MaintenanceErrorReason
	Retryable   bool
	SafeToRetry bool
	Err         error
}

func (*MaintenanceError) Error

func (e *MaintenanceError) Error() string

func (*MaintenanceError) Unwrap

func (e *MaintenanceError) Unwrap() error

type MaintenanceErrorReason

type MaintenanceErrorReason string
const (
	MaintenanceErrorInvalidRequest MaintenanceErrorReason = "invalid_request"
	MaintenanceErrorCancelled      MaintenanceErrorReason = "cancelled"
	MaintenanceErrorBusy           MaintenanceErrorReason = "busy"
	MaintenanceErrorPermission     MaintenanceErrorReason = "permission_denied"
	MaintenanceErrorIO             MaintenanceErrorReason = "io_error"
	MaintenanceErrorCorrupt        MaintenanceErrorReason = "corrupt"
	MaintenanceErrorStale          MaintenanceErrorReason = "inspection_stale"
	MaintenanceErrorLeaseMismatch  MaintenanceErrorReason = "lease_policy_mismatch"
)

type MaintenanceInspection

type MaintenanceInspection struct {
	Kind                 MaintenanceStoreKind
	State                MaintenanceState
	Exists               bool
	Empty                bool
	Observed             storage.StoreSchemaIdentity
	Current              storage.StoreSchemaIdentity
	Migratable           []storage.StoreSchemaMigrationSource
	PersistedLeasePolicy *sessiontree.LeasePolicy
	RequestedLeasePolicy sessiontree.LeasePolicy
	LeasePolicyMatches   bool
	AutomaticMigration   bool
	RequiresExclusive    bool
	Retryable            bool
	SafeToRetry          bool
	Reason               string
	SafeDetail           string
}

func Inspect

func Inspect(ctx context.Context, path string, requested sessiontree.LeasePolicy) (MaintenanceInspection, error)

type MaintenancePhase

type MaintenancePhase string
const (
	MaintenancePhasePreflight MaintenancePhase = "preflight"
	MaintenancePhaseWaiting   MaintenancePhase = "waiting_for_exclusive_access"
	MaintenancePhaseMigrating MaintenancePhase = "migrating"
	MaintenancePhaseVerifying MaintenancePhase = "verifying"
)

type MaintenanceProgress

type MaintenanceProgress struct {
	Sequence     uint64
	Phase        MaintenancePhase
	Status       MaintenanceStatus
	Step         int
	Total        int
	SafeToCancel bool
	Committed    bool
	RolledBack   bool
	Retryable    bool
	SafeToRetry  bool
	Reason       string
}

type MaintenanceState

type MaintenanceState string
const (
	MaintenanceStateMissing          MaintenanceState = "missing"
	MaintenanceStateEmpty            MaintenanceState = "empty"
	MaintenanceStateCurrent          MaintenanceState = "current"
	MaintenanceStateUpgradeable      MaintenanceState = "upgradeable"
	MaintenanceStateUnsupportedOlder MaintenanceState = "unsupported_older"
	MaintenanceStateFuture           MaintenanceState = "future"
	MaintenanceStateDrifted          MaintenanceState = "drifted"
	MaintenanceStateCorrupt          MaintenanceState = "corrupt"
	MaintenanceStateBusy             MaintenanceState = "busy"
	MaintenanceStatePermissionDenied MaintenanceState = "permission_denied"
	MaintenanceStateIOError          MaintenanceState = "io_error"
)

type MaintenanceStatus

type MaintenanceStatus string
const (
	MaintenanceStatusRunning   MaintenanceStatus = "running"
	MaintenanceStatusReady     MaintenanceStatus = "ready"
	MaintenanceStatusFailed    MaintenanceStatus = "failed"
	MaintenanceStatusCancelled MaintenanceStatus = "cancelled"
)

type MaintenanceStoreKind

type MaintenanceStoreKind string
const (
	MaintenanceStoreKindUnknown MaintenanceStoreKind = "unknown"
	MaintenanceStoreKindFloret  MaintenanceStoreKind = "floret"
)

type MaintenanceVerification

type MaintenanceVerification struct {
	Inspection MaintenanceInspection
	Checks     []VerificationCheck
}

func Verify

type MigrationMode

type MigrationMode string
const (
	MigrationModePlan  MigrationMode = "plan"
	MigrationModeApply MigrationMode = "apply"
)

type MigrationRequest

type MigrationRequest struct {
	Mode           MigrationMode
	ExpectedSchema storage.StoreSchemaIdentity
	LeasePolicy    sessiontree.LeasePolicy
	Progress       func(MaintenanceProgress)
}

type MigrationResult

type MigrationResult struct {
	Mode        MigrationMode
	Before      MaintenanceInspection
	After       MaintenanceInspection
	Steps       []MigrationStep
	Status      MaintenanceStatus
	Changed     bool
	Committed   bool
	RolledBack  bool
	Retryable   bool
	SafeToRetry bool
	Reason      string
}

func Migrate

func Migrate(ctx context.Context, path string, request MigrationRequest) (result MigrationResult, resultErr error)

type MigrationStep

type MigrationStep struct {
	From storage.StoreSchemaIdentity
	To   storage.StoreSchemaIdentity
	Code string
}

type OpenPrecondition

type OpenPrecondition struct {
	State    MaintenanceState
	Observed storage.StoreSchemaIdentity
}

OpenPrecondition binds a Store open to a previously observed maintenance state. It is internal to Floret's public runtime adapter.

type Option

type Option func(*options)

func WithAuthorityClock

func WithAuthorityClock(now func() time.Time) Option

func WithLeasePolicy

func WithLeasePolicy(policy sessiontree.LeasePolicy) Option

func WithOpenPrecondition

func WithOpenPrecondition(precondition OpenPrecondition) Option

type Store

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

func Open

func Open(path string, opts ...Option) (*Store, error)

func OpenContext

func OpenContext(ctx context.Context, path string, opts ...Option) (*Store, error)

func (*Store) AcquireTurnLease

func (s *Store) AcquireTurnLease(ctx context.Context, request sessiontree.TurnLease) (sessiontree.TurnLease, error)

func (*Store) ActiveToolset

func (s *Store) ActiveToolset(ctx context.Context, promptScopeID, provider, model string) (cache.ToolsetSnapshot, bool, error)

func (*Store) ActiveTurnLease

func (s *Store) ActiveTurnLease(ctx context.Context, threadID string) (sessiontree.TurnLease, bool, error)

func (*Store) Append

func (*Store) AppendProviderRequest

func (s *Store) AppendProviderRequest(ctx context.Context, req cache.ProviderRequestRecord) error

func (*Store) AppendProviderResponse

func (s *Store) AppendProviderResponse(ctx context.Context, resp cache.ProviderResponseRecord) error

func (*Store) AppendSegment

func (s *Store) AppendSegment(ctx context.Context, seg cache.Segment) error

func (*Store) AppendToolset

func (s *Store) AppendToolset(ctx context.Context, snap cache.ToolsetSnapshot) error

func (*Store) Approval

func (s *Store) Approval(ctx context.Context, approvalID string) (sessiontree.ApprovalRecord, error)

func (*Store) ArtifactClosure

func (s *Store) ArtifactClosure(ctx context.Context, req sessiontree.ArtifactClosureRequest) (artifact.Closure, error)

func (*Store) AuthorityLeasePolicy

func (s *Store) AuthorityLeasePolicy() sessiontree.LeasePolicy

func (*Store) CanonicalTurnEntries

func (s *Store) CanonicalTurnEntries(ctx context.Context, threadID, turnID, runID string) ([]sessiontree.Entry, bool, error)

func (*Store) Close

func (s *Store) Close() error

func (*Store) CompareAndSwapAgentTodoState

func (s *Store) CompareAndSwapAgentTodoState(ctx context.Context, state sessiontree.AgentTodoState, expectedVersion int64) (sessiontree.AgentTodoState, error)

func (*Store) CreateThread

func (s *Store) CreateThread(ctx context.Context, meta sessiontree.ThreadMeta) (sessiontree.ThreadMeta, error)

func (*Store) CreateThreadWithInitialEntry

func (s *Store) CreateThreadWithInitialEntry(ctx context.Context, meta sessiontree.ThreadMeta, initial sessiontree.Entry) (sessiontree.ThreadMeta, sessiontree.Entry, error)

func (*Store) DBPath

func (s *Store) DBPath() string

func (*Store) DeleteMetadata

func (s *Store) DeleteMetadata(ctx context.Context, namespace, id string) error

func (*Store) DeletePromptScopes

func (s *Store) DeletePromptScopes(ctx context.Context, promptScopeIDs ...string) error

func (*Store) DeleteProviderState

func (s *Store) DeleteProviderState(ctx context.Context, threadID string) error

func (*Store) DeleteRootTree

func (s *Store) DeleteRootTree(ctx context.Context, rootThreadID string) (sessiontree.DeleteRootTreeResult, error)

func (*Store) Entries

func (s *Store) Entries(ctx context.Context, threadID string) ([]sessiontree.Entry, error)

func (*Store) Entry

func (s *Store) Entry(ctx context.Context, threadID, entryID string) (sessiontree.Entry, error)

func (*Store) Fork

func (*Store) ForkOperation

func (s *Store) ForkOperation(ctx context.Context, operationID string) (storage.ForkOperationRecord, error)

func (*Store) ForkWithInitialEntry

func (s *Store) ForkWithInitialEntry(ctx context.Context, opts sessiontree.ForkOptions, initial sessiontree.Entry) (sessiontree.ThreadMeta, sessiontree.Entry, error)

func (*Store) InspectSubAgentThreadAuthority

func (s *Store) InspectSubAgentThreadAuthority(ctx context.Context, parentThreadID, childThreadID string) (sessiontree.SubAgentThreadAuthoritySnapshot, error)

func (*Store) InspectThreadAuthority

func (s *Store) InspectThreadAuthority(ctx context.Context, threadID string) (sessiontree.ThreadAuthoritySnapshot, error)

func (*Store) LatestPressureAnchor

func (s *Store) LatestPressureAnchor(ctx context.Context, promptScopeID, providerName, model string) (cache.PressureAnchorState, bool, error)

func (*Store) ListMetadata

func (s *Store) ListMetadata(ctx context.Context, namespace string) ([]storage.MetadataRecord, error)

func (*Store) ListSubAgentInputs

func (s *Store) ListSubAgentInputs(ctx context.Context, childThreadID string, state sessiontree.SubAgentInputState) ([]sessiontree.SubAgentInputRecord, error)

func (*Store) ListThreads

func (*Store) Metadata

func (s *Store) Metadata(ctx context.Context, namespace, id string) (storage.MetadataRecord, error)

func (*Store) MoveLeaf

func (s *Store) MoveLeaf(ctx context.Context, threadID, entryID string) error

func (*Store) Path

func (s *Store) Path(ctx context.Context, threadID, leafID string) ([]sessiontree.Entry, error)

func (*Store) PathPage

func (s *Store) PathPage(ctx context.Context, threadID, leafID, beforeEntryID string, limit int) (sessiontree.PathPage, error)

func (*Store) PendingAutomaticThreadTitles

func (s *Store) PendingAutomaticThreadTitles(ctx context.Context) ([]sessiontree.ThreadMeta, error)

func (*Store) PrepareForkOperation

func (s *Store) PrepareForkOperation(ctx context.Context, rec storage.ForkOperationRecord) (storage.ForkOperationRecord, bool, error)

func (*Store) ProviderRequests

func (s *Store) ProviderRequests(ctx context.Context, promptScopeID string) ([]cache.ProviderRequestRecord, error)

func (*Store) ProviderResponses

func (s *Store) ProviderResponses(ctx context.Context, promptScopeID string) ([]cache.ProviderResponseRecord, error)

func (*Store) ProviderState

func (s *Store) ProviderState(ctx context.Context, threadID string) (sessiontree.ProviderStateRecord, error)

func (*Store) PutMetadata

func (s *Store) PutMetadata(ctx context.Context, rec storage.MetadataRecord) error

func (*Store) PutProviderState

func (s *Store) PutProviderState(ctx context.Context, record sessiontree.ProviderStateRecord) error

func (*Store) ReadAgentTodoState

func (s *Store) ReadAgentTodoState(ctx context.Context, threadID string) (sessiontree.AgentTodoState, error)

func (*Store) ReadApprovalQueue

func (s *Store) ReadApprovalQueue(ctx context.Context, threadID string) (sessiontree.ApprovalQueue, error)

func (*Store) ReadCanonicalTurn

func (s *Store) ReadCanonicalTurn(ctx context.Context, threadID, turnID string) (sessiontree.CanonicalTurnRead, error)

func (*Store) ReadCompaction

func (s *Store) ReadCompaction(ctx context.Context, threadID, requestID string) (sessiontree.CompactionOperation, bool, error)

func (*Store) ReadSubAgentInput

func (s *Store) ReadSubAgentInput(ctx context.Context, inputID string) (sessiontree.SubAgentInputRecord, bool, error)

func (*Store) ReadTurnAdmission

func (s *Store) ReadTurnAdmission(ctx context.Context, threadID, turnID, runID string) (sessiontree.AdmitTurnResult, bool, error)

func (*Store) ReleaseTurnLease

func (s *Store) ReleaseTurnLease(ctx context.Context, proof sessiontree.TurnLease) error

func (*Store) RenewTurnLease

func (s *Store) RenewTurnLease(ctx context.Context, proof sessiontree.TurnLease) (sessiontree.TurnLease, error)

func (*Store) SchemaVersion

func (s *Store) SchemaVersion(ctx context.Context) (string, error)

func (*Store) Segments

func (s *Store) Segments(ctx context.Context, promptScopeID, provider, model string) ([]cache.Segment, error)

func (*Store) Thread

func (s *Store) Thread(ctx context.Context, threadID string) (sessiontree.ThreadMeta, error)

func (*Store) ThreadTombstone

func (s *Store) ThreadTombstone(ctx context.Context, threadID string) (sessiontree.ThreadTombstone, error)

func (*Store) UpdateThread

func (s *Store) UpdateThread(ctx context.Context, meta sessiontree.ThreadMeta) error

func (*Store) ValidateArtifactForkDestination

func (s *Store) ValidateArtifactForkDestination(ctx context.Context, closure artifact.Closure) error

func (*Store) ValidateInterruptedTurnResolution

func (s *Store) ValidateInterruptedTurnResolution(ctx context.Context, req sessiontree.RecoverInterruptedTurnRequest) error

func (*Store) WaitApprovalDecision

func (s *Store) WaitApprovalDecision(ctx context.Context, approvalID string) (sessiontree.WaitApprovalDecisionResult, error)

type V16Runner

type V16Runner interface {
	ExecContext(context.Context, string, ...any) (sql.Result, error)
	QueryContext(context.Context, string, ...any) (*sql.Rows, error)
	QueryRowContext(context.Context, string, ...any) *sql.Row
}

V16Runner is the SQL surface required to verify and export one legacy v16 transaction. It is intentionally limited to migration infrastructure.

type VerificationCheck

type VerificationCheck struct {
	Code       string
	Passed     bool
	SafeDetail string
}

type WriterAdmission

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

WriterAdmission serializes writers opened by this process for one physical SQLite database while keeping admission responsive to context cancellation.

func NewWriterAdmission

func NewWriterAdmission(path string) (*WriterAdmission, error)

func (*WriterAdmission) Close

func (a *WriterAdmission) Close()

func (*WriterAdmission) Reserve

func (a *WriterAdmission) Reserve(ctx context.Context) (func(), error)

Jump to

Keyboard shortcuts

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