internal/infra/pg/factgeneration.go
internal/infra/pg · 294 lines · 9 declarations · source
Declarations
type GenerationResult
type GenerationResult struct {
ID string `json:"generation_id"`
SourceID string `json:"source_observation_id"`
Version string `json:"extractor_version"`
AppliedAt time.Time `json:"applied_at"`
Messages int `json:"messages_read"`
Asserted int `json:"facts_asserted"`
Retired int `json:"facts_retired"`
Rejected int `json:"claims_rejected"`
Retracted int `json:"claims_retracted"`
RefusedRole int `json:"claims_refused_by_role"`
Replayed bool `json:"replayed"`
}
GenerationResult records what committed, not the current number of surviving rows after erasure. It contains no statements or model diagnostics and is safe for operator progress output.
type GenerationPlan
type GenerationPlan struct {
Claims []domain.Claim
Rejected []domain.RejectedClaim
Job *GenerationJobGuard `json:"-"`
}
method FactStore.FindGeneration
func (s *FactStore) FindGeneration(ctx context.Context, schema Schema, scope, source, key, version string) (GenerationResult, bool, error)
func validGenerationRequest
func validGenerationRequest(scope, source, key, version string) error
func findGenerationTx
func findGenerationTx(ctx context.Context, tx pgx.Tx, schema Schema, scope, source, key, version string) (GenerationResult, bool, error)
method FactStore.ApplyGeneration
func (s *FactStore) ApplyGeneration(ctx context.Context, schema Schema, snapshot GenerationSnapshot, key, version, principal string, plan GenerationPlan) (GenerationResult, error)
ApplyGeneration is one source's atomic cutover. The caller has already spent the model budget; source/revision comparison, policy checks, retirement, new facts, provenance and audit all commit together. A failed cutover leaves the previously readable generation untouched.
func retireGenerationTx
func retireGenerationTx(ctx context.Context, tx pgx.Tx, schema Schema, scope, source string, out *GenerationResult) ([]string, error)
func recordGenerationFactTx
func recordGenerationFactTx(ctx context.Context, tx pgx.Tx, schema Schema, scope, source, generation, id, disposition string) error
func rejectGenerationTx
func rejectGenerationTx(ctx context.Context, tx pgx.Tx, schema Schema, scope, source, owner, version string, r domain.RejectedClaim) error