Skip to main content

internal/infra/pg/embeddinggeneration.go

internal/infra/pg · 257 lines · 12 declarations · source

Declarations

const embeddingGenerationSQL

const embeddingGenerationSQL = `SELECT g.generation_id::text,g.scope,g.operation_key::text,
g.model_name,g.model_revision,g.endpoint_hash,g.dimensions,b.through_offset,g.through_offset,b.covered_through_offset,
b.after_offset,b.after_ordinal,b.state,coalesce(a.generation_id=g.generation_id,false),b.examined,b.stored,g.created_at
FROM {schema}.embedding_generation g JOIN {schema}.embedding_build b USING(scope,generation_id)
LEFT JOIN {schema}.embedding_active a USING(scope)`

source

func scanEmbeddingGeneration

func scanEmbeddingGeneration(row pgx.Row) (EmbeddingGeneration, error)

source

method MessageEmbeddingStore.Generation

func (s *MessageEmbeddingStore) Generation(ctx context.Context, scope, id string) (EmbeddingGeneration, error)

source

method MessageEmbeddingStore.Active

func (s *MessageEmbeddingStore) Active(ctx context.Context, scope string) (EmbeddingGeneration, error)

source

func embeddingProjectLock

func embeddingProjectLock(ctx context.Context, tx pgx.Tx, schema Schema, scope string) error

source

func embeddingAudit

func embeddingAudit(ctx context.Context, tx pgx.Tx, schema Schema, scope, actor, operation string, magnitude int64) error

source

func embeddingPartitionName

func embeddingPartitionName(id string) string

source

func embeddingIndexExpression

func embeddingIndexExpression(column string, dimensions int) (string, string)

source

method MessageEmbeddingStore.Start

func (s *MessageEmbeddingStore) Start(ctx context.Context, scope, key, actor string, model EmbeddingModel) (EmbeddingGeneration, error)

Start captures a finite log boundary and allocates a dimension-specific index. Its operation key survives lost output. Model identity never changes within a generation, including after pruning.

source

method MessageEmbeddingStore.Activate

func (s *MessageEmbeddingStore) Activate(ctx context.Context, scope, id, actor string) error

Activation independently checks surviving authoritative messages, not a worker's progress claim. The project policy lock serializes activation, cancellation, allocation and pruning.

source

method MessageEmbeddingStore.Cancel

func (s *MessageEmbeddingStore) Cancel(ctx context.Context, scope, id, actor string) error

source

method MessageEmbeddingStore.Prune

func (s *MessageEmbeddingStore) Prune(ctx context.Context, scope, id, actor string, limit int) (int, error)

Prune deletes at most one page from a non-active, non-building generation. Only its empty, catalog-validated partition is dropped; the operation key remains as a content-free tombstone.

source