postgres

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2026 License: MIT Imports: 20 Imported by: 0

Documentation

Overview

Package postgres implements Knowl operational state and search projections with PostgreSQL-native transactions and full-text search.

Package postgres implements Knowl operational state and search projections with PostgreSQL-native transactions and full-text search.

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, dsn string) (*Store, error)

Open opens a PostgreSQL operational store and runs its embedded migrations.

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) ClaimReady

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

ClaimReady atomically grants a work lease using database-level row locking.

func (*Store) Close

func (store *Store) Close() error

Close closes the underlying database connection pool.

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) DSN

func (store *Store) DSN() string

DSN returns the configured connection string.

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) 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 a stable redacted failure class.

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) 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) 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) 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) 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) 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) Search

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

Search returns bounded, untrusted PostgreSQL full-text 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.

Jump to

Keyboard shortcuts

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