provenance

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2026 License: AGPL-3.0 Imports: 7 Imported by: 0

Documentation

Overview

Package provenance provides field-level tracking of data sources and modifications.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AuditResult

type AuditResult struct {
	Valid       bool
	Issues      []string
	Warnings    []string
	Coverage    float64  // Percentage of fields with provenance
	Conflicts   int      // Number of unresolved conflicts
	MissingData []string // Fields without provenance
}

AuditResult contains audit findings.

type ConflictInfo

type ConflictInfo struct {
	Sources        []catalogmeta.SourceID // Sources that had conflicting values
	Values         []any                  // The conflicting values
	Resolution     string                 // How the conflict was resolved
	SelectedSource catalogmeta.SourceID   // Which source was selected
}

ConflictInfo describes a conflict that was resolved.

type Field

type Field struct {
	Current   Provenance     // Current value and its source
	History   []Provenance   // Historical values
	Conflicts []ConflictInfo // Any conflicts that were resolved
}

Field contains provenance history for a single field.

type Map

type Map map[string][]Provenance // key is "resourceType:resourceID:fieldPath"

Map tracks provenance for multiple resources.

type Provenance

type Provenance struct {
	Source           catalogmeta.SourceID            // Source that provided the value (e.g., "providers", "models_dev_git")
	Field            string                          // Field path
	Value            any                             // The actual value
	Timestamp        time.Time                       // When the value was set
	ObservationID    string                          // Stable identity of the winning source observation
	ObservedAt       time.Time                       // When the winning source was observed
	Revision         catalogmeta.ObservationRevision // Exact revision of the winning observation
	EvidenceChecksum string                          // Digest binding the winning normalized evidence
	Rejections       []Rejection                     // Higher-authority observations rejected before selection
	Authority        float64                         // Authority score (0.0 to 1.0)
	Confidence       float64                         // Confidence in the value (0.0 to 1.0)
	Reason           string                          // Reason for selecting this value
	PreviousValue    any                             // Previous value if updated
}

Provenance tracks the origin and history of a field value.

type ProvenanceFile added in v0.0.23

type ProvenanceFile struct {
	Provenance Map `yaml:"provenance"`
}

ProvenanceFile represents a provenance file stored on disk.

func Load added in v0.0.23

func Load(path string) (*ProvenanceFile, error)

Load reads provenance data from a YAML file. Returns nil, nil if the file doesn't exist (not an error).

type Rejection added in v0.1.0

type Rejection struct {
	Source catalogmeta.SourceID // Source whose field observation was rejected
	Reason string               // Stable human-readable validation or applicability reason
}

Rejection records why a higher-authority field observation did not win.

type Report

type Report struct {
	Resources map[string]ResourceProvenance // key is "resourceType:resourceID"
}

Report generates a human-readable provenance report.

func GenerateReport

func GenerateReport(provenance Map) *Report

GenerateReport creates a provenance report from a Map.

func (*Report) String

func (r *Report) String() string

String generates a string representation of the provenance report.

type ResourceProvenance

type ResourceProvenance struct {
	Type   catalogmeta.ResourceType // Resource type (e.g., "model", "provider", "author")
	ID     string
	Fields map[string]Field
}

ResourceProvenance contains provenance for a single resource.

type Tracker

type Tracker interface {
	// Track records provenance for a field
	Track(resourceType catalogmeta.ResourceType, resourceID string, field string, history Provenance)

	// Find retrieves provenance for a specific field
	FindByField(resourceType catalogmeta.ResourceType, resourceID string, field string) []Provenance

	// FindByResource retrieves all provenance for a resource
	FindByResource(resourceType catalogmeta.ResourceType, resourceID string) map[string][]Provenance

	// Map returns the complete provenance map
	Map() Map

	// Clear removes all provenance data
	Clear()
}

Tracker manages provenance tracking during reconciliation.

func NewTracker

func NewTracker(enabled bool) Tracker

NewTracker creates a new provenance tracker.

Jump to

Keyboard shortcuts

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