Skip to main content

internal/infra/pg/recordcorrection.go

internal/infra/pg · 157 lines · 7 declarations · source

Declarations

const CuratedExtractorVersion

const CuratedExtractorVersion = "curated/v1"

source

type RecordCorrection

type RecordCorrection struct {
RecordMutation
Object string `json:"object"`
Statement string `json:"statement"`
ValidFrom time.Time `json:"valid_from,omitempty"`
}

source

type CorrectedRecord

type CorrectedRecord struct {
OriginalID string `json:"original_id"`
ID string `json:"id"`
Version string `json:"version"`
SourceObservationID string `json:"source_observation_id"`
}

source

type CorrectionBatch

type CorrectionBatch struct {
Records []CorrectedRecord `json:"records"`
}

source

method RecordStore.Correct

func (s *RecordStore) Correct(ctx context.Context, scope, principal string, requests []RecordCorrection) (CorrectionBatch, error)

Correct preserves subject and relation. Its independent authored source replaces only a current target, never rewrites a transcript, and makes no provider call while holding database locks.

source

method RecordStore.correctTx

func (s *RecordStore) correctTx(ctx context.Context, tx pgx.Tx, scope, principal string, requests []RecordCorrection) (CorrectionBatch, error)

The caller owns commit, so promoting feedback can withdraw the target, assert the replacement and mark the feedback promoted in one transaction. Split out rather than duplicated: a second copy of this body would be a second definition of what a correction is, and the day they diverged, one of the two would be producing records the rebuild and the retraction ledger did not agree about.

source

method FactStore.ReplayCurated

func (s *FactStore) ReplayCurated(ctx context.Context, schema Schema, scope, observationID string) (bool, error)

ReplayCurated refuses missing/changed authored instructions instead of letting model extraction replace human input. Its immutable source claim and original citation ID commit or fail together.

source