Documentation
¶
Overview ¶
Package provenance provides field-level tracking of data sources and modifications.
Index ¶
- func ModelResourceID(providerID, modelID string) string
- func ParseModelResourceID(resourceID string) (providerID, modelID string, ok bool)
- type AuditResult
- type ConflictInfo
- type Entry
- type Field
- type File
- type Map
- type Rejection
- type Report
- type ResourceProvenance
- type Tracker
- func (p *Tracker) Clear()
- func (p *Tracker) FindByField(resourceType evidence.ResourceType, resourceID string, field string) []Entry
- func (p *Tracker) FindByResource(resourceType evidence.ResourceType, resourceID string) map[string][]Entry
- func (p *Tracker) Map() Map
- func (p *Tracker) Track(resourceType evidence.ResourceType, resourceID string, field string, ...)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ModelResourceID ¶ added in v0.2.0
ModelResourceID returns the durable provider-scoped identity for model provenance. It escapes opaque provider and model identifiers independently. This prevents slashes, colons, or percent signs from causing key collisions.
func ParseModelResourceID ¶ added in v0.2.0
ParseModelResourceID decodes an identity produced by ModelResourceID.
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 []evidence.SourceID // Sources that had conflicting values
Values []any // The conflicting values
Resolution string
SelectedSource evidence.SourceID
}
ConflictInfo describes the selected resolution for a conflict.
type Entry ¶ added in v0.2.0
type Entry struct {
Source evidence.SourceID
Field string
Value any
Timestamp time.Time
ObservationID string
ObservedAt time.Time
Revision evidence.ObservationRevision
EvidenceChecksum string
ProviderBindingID string `json:"ProviderBindingID,omitempty" yaml:"providerbindingid,omitempty"`
ProviderBindingRevision string `json:"ProviderBindingRevision,omitempty" yaml:"providerbindingrevision,omitempty"`
Rejections []Rejection
// Authority ranges from 0.0 to 1.0.
Authority float64
// Confidence ranges from 0.0 to 1.0.
Confidence float64
Reason string
PreviousValue any
}
Entry records the origin and history of one field value.
func (Entry) MarshalJSON ¶ added in v0.2.0
MarshalJSON makes interface-valued evidence independent of its concrete Go type. Immutable catalog payloads require this normalization. Decoding replaces source structs in Value and PreviousValue with generic JSON maps. Re-encoding must still reproduce the exact generation bytes.
func (Entry) MarshalYAML ¶ added in v0.4.0
MarshalYAML uses the same canonical dynamic-value shape as MarshalJSON so a human catalog workspace can reproduce the exact immutable catalog payload.
type Field ¶
type Field struct {
Current Entry // Current value and its source
History []Entry // Historical values
Conflicts []ConflictInfo
}
Field contains provenance history for a single field.
type File ¶ added in v0.2.0
type File struct {
Provenance Map `yaml:"provenance"`
}
File represents provenance stored on disk.
func DecodeYAML ¶ added in v0.17.0
DecodeYAML reads provenance without changing the YAML scalar rules. It parses independent entries in the generated block map in bounded batches. Other layouts and documents with anchors use the original whole-file parser.
type Rejection ¶ added in v0.1.0
type Rejection struct {
Source evidence.SourceID
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 ¶
GenerateReport creates a provenance report from a Map.
type ResourceProvenance ¶
type ResourceProvenance struct {
Type evidence.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 struct {
// contains filtered or unexported fields
}
Tracker records and queries field-level provenance.
func NewTracker ¶
NewTracker creates a new provenance tracker.
func (*Tracker) FindByField ¶
func (p *Tracker) FindByField(resourceType evidence.ResourceType, resourceID string, field string) []Entry
FindByField retrieves provenance for a specific field.
func (*Tracker) FindByResource ¶
func (p *Tracker) FindByResource(resourceType evidence.ResourceType, resourceID string) map[string][]Entry
FindByResource retrieves all provenance for a resource.