Help us shape the future of Go! Take the 2026 Go Developer Survey

cortex

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package cortex wraps the spec-pinned CortexDB PostgreSQL core. Provision is explicit; New never migrates, starts routines, or owns its supplied SQL pool.

Index

Constants

View Source
const Version = "v2.129.0" // eaf996b62f75d5e499d1b9ca7fab470a23700385

Variables

This section is empty.

Functions

func Provision

func Provision(ctx context.Context, db *sql.DB, c Config) error

Provision requires a fresh, dedicated database and privileged migration pool. Runtime identities must be granted only SELECT/INSERT/UPDATE on embeddings, SELECT on collections/identity/tombstones, and SELECT/INSERT on receipts.

func ProvisionDisposalGate

func ProvisionDisposalGate(ctx context.Context, db *sql.DB) error

ProvisionDisposalGate upgrades a previously provisioned retention index with writers stopped, using the migration owner. Refresh role grants afterwards.

func ProvisionRetention

func ProvisionRetention(ctx context.Context, db *sql.DB) error

ProvisionRetention upgrades an existing dedicated index database once, using an owner connection with writers stopped. New databases receive this schema through Provision. Refresh runtime/retention grants before restarting writers.

Types

type Config

type Config struct {
	Tenant, Generation, EmbeddingID string
	Dimensions                      int
}

Config binds one separately provisioned database to exactly one tenant and generation. Rebuild into a new database; switching the host binding is explicit.

type Generations

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

Generations is an immutable host routing table. It never switches the active generation; managed recall reads that decision from the ledger registry.

func NewGenerations

func NewGenerations(indexes ...*Index) (*Generations, error)

func (*Generations) Candidates

func (r *Generations) Candidates(ctx context.Context, t, g, s, q string, n int) ([]model.SearchCandidate, error)

func (*Generations) CheckConnectivity

func (r *Generations) CheckConnectivity(ctx context.Context) error

CheckConnectivity checks configured pools only. It does not establish search coverage, active-generation selection, index integrity or embedding health.

func (*Generations) DescribeRetrieval

func (r *Generations) DescribeRetrieval(ctx context.Context, t, g string) (model.RetrievalIdentity, error)

func (*Generations) DisposeProjection

func (r *Generations) DisposeProjection(ctx context.Context, d model.ProjectionDisposal) error

func (*Generations) Put

func (*Generations) SealProjectionForDisposal

func (r *Generations) SealProjectionForDisposal(ctx context.Context, k model.GenerationKey, fence int64) error

func (*Generations) SetProjectionGate

func (r *Generations) SetProjectionGate(ctx context.Context, k model.GenerationKey, f int64, s bool) error

func (*Generations) VerifyProjection

func (*Generations) VerifyProjectionPages

func (r *Generations) VerifyProjectionPages(ctx context.Context, k model.GenerationKey, fence int64, load model.ProjectionPageLoader) (model.ProjectionCheck, error)

type Index

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

func New

func New(ctx context.Context, db *sql.DB, c Config, embedder model.Embedder) (*Index, error)

func NewRetention

func NewRetention(ctx context.Context, db *sql.DB, config Config) (*Index, error)

NewRetention opens an existing destination for cleanup without configuring an embedding provider. Identity, schema, role and pool checks match New. The caller supplies separately provisioned retention credentials; this does not grant privileges or migrate the index.

func (*Index) Candidates

func (i *Index) Candidates(ctx context.Context, tenant, generation, scope, query string, limit int) ([]model.SearchCandidate, error)

func (*Index) Close

func (i *Index) Close() error

Close has no pool ownership or background routines to release.

func (*Index) DescribeRetrieval

func (i *Index) DescribeRetrieval(_ context.Context, tenant, generation string) (model.RetrievalIdentity, error)

func (*Index) DisposeProjection

func (i *Index) DisposeProjection(ctx context.Context, r model.ProjectionDisposal) error

func (*Index) Lexical

func (i *Index) Lexical() *LexicalIndex

func (*Index) Put

func (*Index) SealProjectionForDisposal

func (i *Index) SealProjectionForDisposal(ctx context.Context, k model.GenerationKey, fence int64) error

SealProjectionForDisposal permanently invalidates a sealed generation's proof. The trusted coordinator must first establish that the ledger generation is retired or abandoned, and enforce authorization, retention policy and holds. This adapter has no ledger connection and cannot establish those conditions.

func (*Index) SetProjectionGate

func (i *Index) SetProjectionGate(ctx context.Context, k model.GenerationKey, fence int64, sealed bool) error

func (*Index) VerifyProjection

func (i *Index) VerifyProjection(ctx context.Context, k model.GenerationKey, fence int64, documents []model.ProjectionDocument) (model.ProjectionCheck, error)

VerifyProjection checks every stored receipt and canonical row, not a sample. The sealed gate is held throughout inspection. It validates vector shape, not semantic embedding quality or reproducibility of an external model.

func (*Index) VerifyProjectionPages

func (i *Index) VerifyProjectionPages(ctx context.Context, k model.GenerationKey, fence int64, load model.ProjectionPageLoader) (model.ProjectionCheck, error)

VerifyProjectionPages retains the sealed gate lock and one destination snapshot across all source pages. Exact cardinalities plus unique expected IDs rule out missing rows, extra rows and orphan receipts without an in-memory set of the entire inventory.

type LexicalIndex

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

LexicalIndex is an explicit lexical read view over a bound generation. Writes still use the generation's configured indexing method. No automatic switch can silently change the retrieval identity retained by PrepareContext.

func (*LexicalIndex) Candidates

func (i *LexicalIndex) Candidates(ctx context.Context, tenant, generation, scope, query string, limit int) ([]model.SearchCandidate, error)

func (*LexicalIndex) DescribeRetrieval

func (i *LexicalIndex) DescribeRetrieval(_ context.Context, tenant, generation string) (model.RetrievalIdentity, error)

func (*LexicalIndex) DisposeProjection

func (i *LexicalIndex) DisposeProjection(ctx context.Context, r model.ProjectionDisposal) error

func (*LexicalIndex) Put

func (*LexicalIndex) SealProjectionForDisposal

func (i *LexicalIndex) SealProjectionForDisposal(ctx context.Context, k model.GenerationKey, fence int64) error

type Router

type Router map[string]*Index

Router is host-provisioned; a tenant must have its own bound Index/database.

func (Router) Candidates

func (r Router) Candidates(ctx context.Context, t, g, s, q string, n int) ([]model.SearchCandidate, error)

func (Router) DescribeRetrieval

func (r Router) DescribeRetrieval(ctx context.Context, t, g string) (model.RetrievalIdentity, error)

func (Router) DisposeProjection

func (r Router) DisposeProjection(ctx context.Context, d model.ProjectionDisposal) error

func (Router) Put

func (Router) SealProjectionForDisposal

func (r Router) SealProjectionForDisposal(ctx context.Context, k model.GenerationKey, fence int64) error

Jump to

Keyboard shortcuts

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