authority

package
v0.1.1 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: 3 Imported by: 0

Documentation

Overview

Package authority manages source authority for catalog data reconciliation.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MatchesPattern

func MatchesPattern(fieldPath, pattern string) bool

MatchesPattern checks if a field path matches a pattern (supports * wildcards).

Types

type AttributePolicy added in v0.1.0

type AttributePolicy struct {
	Resource       sources.ResourceType
	Path           string
	AuthorityOrder []sources.ID
	Merge          MergePolicy
	Empty          EmptyPolicy
	Rationale      string
}

AttributePolicy is the complete merge contract for one canonical field family.

func CanonicalPolicies added in v0.1.0

func CanonicalPolicies(resource sources.ResourceType) []AttributePolicy

CanonicalPolicies returns a caller-owned policy inventory for a canonical resource.

func FindCanonicalPolicy added in v0.1.0

func FindCanonicalPolicy(resource sources.ResourceType, path string) (AttributePolicy, bool)

FindCanonicalPolicy returns the policy whose pattern covers path.

type Authority

type Authority interface {
	// Find returns the authority configuration for a specific field
	Find(resourceType sources.ResourceType, fieldPath string) *Field

	// List returns all authorities for a resource type
	ModelFields() []Field
	ProviderFields() []Field
	AuthorFields() []Field
}

Authority determines which source is authoritative for each field.

func New

func New() Authority

New creates a new DefaultAuthorities with standard configurations.

type EmptyPolicy added in v0.1.0

type EmptyPolicy string

EmptyPolicy defines whether a Go zero/empty value carries source evidence.

const (
	// EmptyReject makes an empty identity or required field invalid.
	EmptyReject EmptyPolicy = "reject"
	// EmptyAbsent treats nil/empty as no claim and permits fallback.
	EmptyAbsent EmptyPolicy = "absent"
	// EmptyAuthoritative preserves explicit zero and false values as evidence.
	EmptyAuthoritative EmptyPolicy = "authoritative"
)

type Field

type Field struct {
	Path     string     `json:"path" yaml:"path"`         // e.g., "pricing.input", "metadata.knowledge_cutoff"
	Source   sources.ID `json:"source" yaml:"source"`     // Which source is authoritative
	Priority int        `json:"priority" yaml:"priority"` // Priority (higher = more authoritative)
}

Field defines source priority for a specific field.

type MergePolicy added in v0.1.0

type MergePolicy string

MergePolicy defines how accepted values compose after authority selection.

const (
	// MergeIdentity requires one stable value and rejects disagreement.
	MergeIdentity MergePolicy = "identity"
	// MergeReplace selects one complete value without mixing subfields.
	MergeReplace MergePolicy = "replace"
	// MergeFillMissing accepts lower-authority values only for absent subfields.
	MergeFillMissing MergePolicy = "fill_missing"
	// MergeSetUnion combines unique members while preserving authority order.
	MergeSetUnion MergePolicy = "set_union"
	// MergeDeep combines named maps/records while resolving each leaf by authority.
	MergeDeep MergePolicy = "deep_merge"
)

Jump to

Keyboard shortcuts

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