internal/infra/pg/generationreplay.go
internal/infra/pg · 104 lines · 3 declarations · source
Declarations
method FactStore.ReplayGeneration
func (s *FactStore) ReplayGeneration(ctx context.Context, schema Schema, scope, source string) (GenerationResult, bool, error)
A published generation is an accepted outcome, not permission to ask the model again. This also fences an old in-flight extraction: ordinary writes refuse a source with a generation pointer.
method FactStore.FinishGeneration
func (s *FactStore) FinishGeneration(ctx context.Context, schema Schema, scope, source string) error
Availability switches in ApplyGeneration; completing backlog bookkeeping is retryable afterwards. Keeping the watermark lock out of model preparation and fact publication avoids holding a whole project's ingestion queue while a source is reinterpreted. The same operation key finishes this step without another model call if the process or its output stream fails after publication.
func finishGenerationTx
func finishGenerationTx(ctx context.Context, tx pgx.Tx, schema Schema, scope, source string) error
Orphaned job cancellation uses the same bookkeeping in its control transaction. Its job row has no erasure foreign key and this path holds no fact/source advisory lock across the watermark.