sqlite

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2026 License: MIT Imports: 24 Imported by: 0

Documentation

Overview

Package sqlite will provide the SQLite operational store and search projection.

Package sqlite implements Knowl operational state and search projections using the same modernc.org/sqlite engine as Balda.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrConflict           = errors.New("knowl operation conflict")
	ErrNotFound           = app.ErrOperationNotFound
	ErrInvalidState       = errors.New("knowl operation state transition is invalid")
	ErrLeaseConflict      = app.ErrApplyLeaseConflict
	ErrInvalidQuery       = errors.New("knowl search query is invalid")
	ErrProjectionNotReady = errors.New("knowl projection is not ready")
	ErrProjectionDrift    = errors.New("knowl projection drift detected")
)

Functions

This section is empty.

Types

type ProjectionState

type ProjectionState struct {
	Scope          knowl.ScopeRef
	SchemaDigest   string
	SnapshotDigest string
	PageCount      int
	LinkCount      int
	ReadyAt        time.Time
}

ProjectionState describes the last canonical snapshot projected for a scope.

type Store

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

Store implements app.OperationStore and app.SearchIndex.

func Open

func Open(ctx context.Context, path string) (*Store, error)

Open opens or creates a Knowl SQLite operational store and runs migrations.

func (*Store) BeginSync added in v0.3.0

func (store *Store) BeginSync(ctx context.Context, request app.BeginSyncRequest) (knowl.SyncRun, bool, error)

func (*Store) CheckProjection

func (store *Store) CheckProjection(ctx context.Context, snapshot knowl.WorkspaceSnapshot) error

CheckProjection verifies that a projection represents the supplied snapshot.

func (*Store) ClaimOperation added in v0.4.0

func (store *Store) ClaimOperation(ctx context.Context, scope knowl.ScopeRef, id knowl.OperationID, lease knowl.WorkLease) (knowl.WorkClaim, error)

ClaimOperation atomically grants a work lease for one specific claimable operation.

func (*Store) ClaimReady

func (store *Store) ClaimReady(ctx context.Context, scope knowl.ScopeRef, lease knowl.WorkLease) (knowl.WorkClaim, error)

ClaimReady atomically grants a work lease for the first claimable operation.

func (*Store) Close

func (store *Store) Close() error

Close closes the underlying database.

func (*Store) CommitOutcome

func (store *Store) CommitOutcome(ctx context.Context, id knowl.OperationID, commit knowl.ContentCommit) error

CommitOutcome marks a canonical content commit as complete.

func (*Store) DescriptorFailures

func (store *Store) DescriptorFailures(ctx context.Context, scope knowl.ScopeRef, limit int) ([]knowl.OperationID, error)

DescriptorFailures lists non-terminal operations whose durable inputs cannot be validated.

func (*Store) DocumentState added in v0.3.0

func (store *Store) DocumentState(ctx context.Context, scope knowl.ScopeRef, sourceID knowl.SourceID, documentID knowl.DocumentID) (knowl.DocumentState, error)

func (*Store) DocumentStates added in v0.3.0

func (store *Store) DocumentStates(ctx context.Context, scope knowl.ScopeRef, sourceID knowl.SourceID, options app.DocumentListOptions) ([]knowl.DocumentState, error)

func (*Store) Execution

func (store *Store) Execution(ctx context.Context, scope knowl.ScopeRef, id knowl.OperationID) (knowl.ExecutionDescriptor, error)

Execution returns the validated durable descriptor for one scoped operation.

func (*Store) Fail

func (store *Store) Fail(ctx context.Context, id knowl.OperationID, failure knowl.Failure) error

Fail records stable redacted failure metadata.

func (*Store) FailClaim added in v0.4.0

func (store *Store) FailClaim(ctx context.Context, scope knowl.ScopeRef, id knowl.OperationID, token string, failure knowl.Failure) error

FailClaim terminalizes work only while the caller still owns a live lease.

func (*Store) FailSync added in v0.3.0

func (store *Store) FailSync(ctx context.Context, scope knowl.ScopeRef, id knowl.SyncRunID, failureClass string, failedAt time.Time) (knowl.SyncRun, error)

func (*Store) FinalizeSync added in v0.3.0

func (store *Store) FinalizeSync(ctx context.Context, finalization app.SyncFinalization) (knowl.SyncRun, error)
func (store *Store) Links(ctx context.Context, scope knowl.ScopeRef, page knowl.PageID, limits knowl.ReadLimits) ([]knowl.LinkReference, error)

Links returns bounded, untrusted graph references.

func (*Store) MarkApplying

func (store *Store) MarkApplying(ctx context.Context, id knowl.OperationID, lease knowl.Lease) error

MarkApplying claims an operation with a lease.

func (*Store) MarkAwaitingReview

func (store *Store) MarkAwaitingReview(ctx context.Context, id knowl.OperationID) error

MarkAwaitingReview marks an operation that needs explicit apply.

func (*Store) MarkContentCommitted added in v0.3.0

func (store *Store) MarkContentCommitted(ctx context.Context, generation app.SyncGeneration) (knowl.SyncRun, error)

func (*Store) MarkProjected added in v0.3.0

func (store *Store) MarkProjected(ctx context.Context, generation app.SyncGeneration) (knowl.SyncRun, error)

func (*Store) Operation

func (store *Store) Operation(ctx context.Context, scope knowl.ScopeRef, id knowl.OperationID) (knowl.Operation, error)

Operation reads one operation within its scope.

func (*Store) Path

func (store *Store) Path() string

Path returns the configured database path.

func (*Store) PrepareSync added in v0.3.0

func (store *Store) PrepareSync(ctx context.Context, prepared app.PreparedSyncState) (knowl.SyncRun, error)

func (*Store) PreparedSync added in v0.3.0

func (store *Store) PreparedSync(ctx context.Context, scope knowl.ScopeRef, id knowl.SyncRunID) (app.PreparedSyncRead, error)

func (*Store) Project

func (store *Store) Project(ctx context.Context, commit knowl.ContentCommit) error

Project indexes a canonical content commit snapshot.

func (*Store) ProjectionStatus

func (store *Store) ProjectionStatus(ctx context.Context, scope knowl.ScopeRef) (ProjectionState, error)

ProjectionStatus returns readiness metadata for a scope.

func (*Store) Rebuild

func (store *Store) Rebuild(ctx context.Context, snapshot knowl.WorkspaceSnapshot) error

Rebuild recreates all projections from canonical Markdown snapshots.

func (*Store) RecordScanPage added in v0.3.0

func (store *Store) RecordScanPage(ctx context.Context, record app.ScanPageRecord) (knowl.SyncRun, error)

func (*Store) ReleaseClaim

func (store *Store) ReleaseClaim(ctx context.Context, scope knowl.ScopeRef, id knowl.OperationID, token string) error

ReleaseClaim makes owned non-terminal work immediately ready again.

func (*Store) RenewClaim

func (store *Store) RenewClaim(ctx context.Context, scope knowl.ScopeRef, id knowl.OperationID, currentToken string, next knowl.WorkLease) error

RenewClaim replaces a live work lease when the caller still owns its token.

func (*Store) Reserve

func (store *Store) Reserve(ctx context.Context, key knowl.OperationKey, meta knowl.OperationMeta) (app.OperationReservation, error)

Reserve creates or returns the operation for one source revision.

func (*Store) ReserveOperation added in v0.4.0

func (store *Store) ReserveOperation(ctx context.Context, identity knowl.OperationIdentity, descriptor knowl.ExecutionDescriptor) (app.OperationReservation, error)

ReserveOperation creates or replays one generic hierarchy operation.

func (*Store) ResumableSyncRuns added in v0.3.0

func (store *Store) ResumableSyncRuns(ctx context.Context, scope knowl.ScopeRef, limit int) ([]knowl.SyncRun, error)

func (*Store) ResumeReady

func (store *Store) ResumeReady(ctx context.Context, scope knowl.ScopeRef, limit int) ([]knowl.OperationID, error)

ResumeReady lists bounded claimable operation IDs without granting ownership.

func (*Store) RetrySourceMaintenance added in v0.4.0

func (store *Store) RetrySourceMaintenance(ctx context.Context, request app.SourceMaintenanceRetryRequest) (app.SourceMaintenanceRetryResult, error)

RetrySourceMaintenance atomically previews or requeues selected terminal current-revision source maintenance operations.

func (*Store) SavePlan

func (store *Store) SavePlan(ctx context.Context, id knowl.OperationID, summary knowl.PlanSummary) error

SavePlan persists a redacted plan digest and advances the operation.

func (*Store) ScanDocuments added in v0.3.0

func (store *Store) ScanDocuments(ctx context.Context, scope knowl.ScopeRef, id knowl.SyncRunID, limit int) ([]knowl.DocumentRef, error)

func (*Store) ScheduleRetry added in v0.4.0

func (store *Store) ScheduleRetry(ctx context.Context, scope knowl.ScopeRef, id knowl.OperationID, token string, failure knowl.Failure, readyAt time.Time) error

ScheduleRetry records a safe transient failure and delays work owned by the current lease holder. The operation remains non-terminal.

func (*Store) Search

func (store *Store) Search(ctx context.Context, scope knowl.ScopeRef, query string, limits knowl.ReadLimits, sources []knowl.SourceID) ([]knowl.PageReference, error)

Search returns bounded, untrusted FTS references.

func (*Store) SelectContext

func (store *Store) SelectContext(ctx context.Context, scope knowl.ScopeRef, source knowl.SourceSummary, limits knowl.ReadLimits) ([]knowl.PageID, error)

SelectContext returns source-relevant pages, one-hop context, the required index control page, and only then deterministic recent fallback pages.

func (*Store) SourceStatus added in v0.3.0

func (store *Store) SourceStatus(ctx context.Context, scope knowl.ScopeRef, sourceID knowl.SourceID) (knowl.SourceStatus, error)

func (*Store) SyncRun added in v0.3.0

func (store *Store) SyncRun(ctx context.Context, scope knowl.ScopeRef, id knowl.SyncRunID) (knowl.SyncRun, error)

Jump to

Keyboard shortcuts

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