reconcile
Package reconcile provides complex multi-source data reconciliation with field-level authority and provenance tracking.
reconcile
import "github.com/agentstation/starmap/pkg/reconcile"
Package reconcile provides catalog synchronization and reconciliation capabilities. It handles merging data from multiple sources, detecting changes, and applying updates while respecting data authorities and merge strategies.
The reconciler coordinates fetching data from various sources, computing differences, and merging changes into a target catalog. It supports dry-run operations, changeset generation, and intelligent conflict resolution.
Example usage:
// Create a reconciler
r := NewReconciler(targetCatalog, sources)
// Perform reconciliation
changeset, err := r.Reconcile(ctx, options)
if err != nil {
log.Fatal(err)
}
// Review changes
for _, change := range changeset.Changes {
fmt.Printf("Change: %s %s\n", change.Type, change.ModelID)
}
// Apply changes if not dry-run
if !options.DryRun {
err = r.Apply(changeset)
}
Index
func MatchesPattern(fieldPath, pattern string) bool
MatchesPattern checks if a field path matches a pattern (supports * wildcards)
ApplyStrategy represents how to apply changes
type ApplyStrategy string
const (
// ApplyAll applies all changes including removals
ApplyAll ApplyStrategy = "all"
// ApplyAdditive only applies additions and updates, never removes
ApplyAdditive ApplyStrategy = "additive"
// ApplyUpdatesOnly only applies updates to existing items
ApplyUpdatesOnly ApplyStrategy = "updates-only"
// ApplyAdditionsOnly only applies new additions
ApplyAdditionsOnly ApplyStrategy = "additions-only"
)
AuthorChangeset represents changes to authors
type AuthorChangeset struct {
Added []catalogs.Author // New authors
Updated []AuthorUpdate // Updated authors
Removed []catalogs.Author // Removed authors
}
func (*AuthorChangeset) HasChanges
func (a *AuthorChangeset) HasChanges() bool
HasChanges returns true if the author changeset contains any changes
func (*AuthorChangeset) Print
func (a *AuthorChangeset) Print()
Print outputs author changes in a human-readable format
AuthorUpdate represents an update to an existing author
type AuthorUpdate struct {
ID catalogs.AuthorID // ID of the author being updated
Existing catalogs.Author // Current author
New catalogs.Author // New author
Changes []FieldChange // Detailed list of field changes
}
AuthorityBasedStrategy uses field authorities to resolve conflicts
type AuthorityBasedStrategy struct {
// contains filtered or unexported fields
}
func (*AuthorityBasedStrategy) ResolveConflict
func (s *AuthorityBasedStrategy) ResolveConflict(field string, values map[SourceName]interface{}) (interface{}, SourceName, string)
ResolveConflict uses authorities to resolve conflicts
AuthorityProvider determines which source is authoritative for each field
type AuthorityProvider interface {
// GetAuthority returns the authority configuration for a specific field
GetAuthority(fieldPath string, resourceType ResourceType) *FieldAuthority
// GetAuthorities returns all authorities for a resource type
GetAuthorities(resourceType ResourceType) []FieldAuthority
}
func NewDefaultAuthorities() AuthorityProvider
NewDefaultAuthorities creates a new DefaultAuthorities with standard configurations
func NewDefaultAuthorityProvider() AuthorityProvider
NewDefaultAuthorityProvider is an alias for NewDefaultAuthorities
ChainEnhancer allows chaining multiple enhancers with custom logic
type ChainEnhancer struct {
// contains filtered or unexported fields
}
func NewChainEnhancer(priority int, enhancers ...Enhancer) *ChainEnhancer
NewChainEnhancer creates a new chain enhancer
func (*ChainEnhancer) CanEnhance
func (e *ChainEnhancer) CanEnhance(model catalogs.Model) bool
CanEnhance checks if any enhancer in the chain can enhance
func (*ChainEnhancer) Enhance
func (e *ChainEnhancer) Enhance(ctx context.Context, model catalogs.Model) (catalogs.Model, error)
Enhance applies all enhancers in sequence
func (e *ChainEnhancer) EnhanceBatch(ctx context.Context, models []catalogs.Model) ([]catalogs.Model, error)
EnhanceBatch enhances multiple models
func (*ChainEnhancer) Name
func (e *ChainEnhancer) Name() string
Name returns the enhancer name
func (*ChainEnhancer) Priority
func (e *ChainEnhancer) Priority() int
Priority returns the priority
ChangeType represents the type of change
type ChangeType string
const (
ChangeTypeAdd ChangeType = "add"
ChangeTypeUpdate ChangeType = "update"
ChangeTypeRemove ChangeType = "remove"
)
Changeset represents all changes between two catalogs
type Changeset struct {
Models *ModelChangeset // Model changes
Providers *ProviderChangeset // Provider changes
Authors *AuthorChangeset // Author changes
Summary ChangesetSummary // Summary statistics
}
func (*Changeset) Filter
func (c *Changeset) Filter(strategy ApplyStrategy) *Changeset
Filter filters the changeset based on the apply strategy
func (c *Changeset) HasChanges() bool
HasChanges returns true if the changeset contains any changes
func (*Changeset) IsEmpty
func (c *Changeset) IsEmpty() bool
IsEmpty returns true if the changeset contains no changes
func (*Changeset) Print
func (c *Changeset) Print()
Print outputs a detailed, human-readable view of the changeset
func (*Changeset) String
func (c *Changeset) String() string
String returns a human-readable summary of the changeset
ChangesetSummary provides summary statistics for a changeset
type ChangesetSummary struct {
ModelsAdded int
ModelsUpdated int
ModelsRemoved int
ProvidersAdded int
ProvidersUpdated int
ProvidersRemoved int
AuthorsAdded int
AuthorsUpdated int
AuthorsRemoved int
TotalChanges int
}
Conflict represents a merge conflict
type Conflict struct {
Path string // Field path (e.g., "pricing.input")
Base interface{} // Original value
Ours interface{} // Our change
Theirs interface{} // Their change
Type ConflictType
CanMerge bool // Whether automatic merge is possible
Suggested interface{} // Suggested resolution
}
ConflictInfo describes a conflict that was resolved
type ConflictInfo struct {
Sources []SourceName // Sources that had conflicting values
Values []interface{} // The conflicting values
Resolution string // How the conflict was resolved
SelectedSource SourceName // Which source was selected
}
ConflictResolution defines how to resolve conflicts
type ConflictResolution string
const (
ResolutionOurs ConflictResolution = "ours" // Always take our changes
ResolutionTheirs ConflictResolution = "theirs" // Always take their changes
ResolutionMerge ConflictResolution = "merge" // Try to merge if possible
ResolutionBase ConflictResolution = "base" // Keep original value
ResolutionNewest ConflictResolution = "newest" // Take the newest change
ResolutionAuthority ConflictResolution = "authority" // Use field authorities
)
ConflictResolver is a function that resolves conflicts
type ConflictResolver func(field string, values map[SourceName]interface{}) (interface{}, SourceName, string)
ConflictType describes the type of conflict
type ConflictType string
const (
ConflictTypeModified ConflictType = "modified" // Both sides modified the same field
ConflictTypeDeleted ConflictType = "deleted" // One side deleted, other modified
ConflictTypeAdded ConflictType = "added" // Both sides added different values
)
CustomAuthorities allows for custom field authority configurations
type CustomAuthorities struct {
// contains filtered or unexported fields
}
func NewCustomAuthorities() *CustomAuthorities
NewCustomAuthorities creates a new CustomAuthorities
func (*CustomAuthorities) AddAuthority
func (ca *CustomAuthorities) AddAuthority(resourceType ResourceType, authority FieldAuthority)
AddAuthority adds a field authority for a resource type
func (ca *CustomAuthorities) GetAuthorities(resourceType ResourceType) []FieldAuthority
GetAuthorities returns all authorities for a resource type
func (*CustomAuthorities) GetAuthority
func (ca *CustomAuthorities) GetAuthority(fieldPath string, resourceType ResourceType) *FieldAuthority
GetAuthority returns the authority configuration for a specific field
CustomStrategy allows custom conflict resolution logic
type CustomStrategy struct {
// contains filtered or unexported fields
}
func (s *CustomStrategy) ResolveConflict(field string, values map[SourceName]interface{}) (interface{}, SourceName, string)
ResolveConflict uses custom resolver
DefaultAuthorities provides standard field authorities
type DefaultAuthorities struct {
// contains filtered or unexported fields
}
func (da *DefaultAuthorities) GetAuthorities(resourceType ResourceType) []FieldAuthority
GetAuthorities returns all authorities for a resource type
func (*DefaultAuthorities) GetAuthority
func (da *DefaultAuthorities) GetAuthority(fieldPath string, resourceType ResourceType) *FieldAuthority
GetAuthority returns the authority configuration for a specific field
Differ handles change detection between resources
type Differ interface {
// DiffModels compares two sets of models and returns changes
DiffModels(existing, new []catalogs.Model) *ModelChangeset
// DiffProviders compares two sets of providers and returns changes
DiffProviders(existing, new []catalogs.Provider) *ProviderChangeset
// DiffAuthors compares two sets of authors and returns changes
DiffAuthors(existing, new []catalogs.Author) *AuthorChangeset
// DiffCatalogs compares two complete catalogs
// Both catalogs only need to be readable
DiffCatalogs(existing, new catalogs.Reader) *Changeset
}
func NewDiffer(opts ...DifferOption) Differ
NewDiffer creates a new Differ with default settings
DifferOption is a functional option for configuring Differ
type DifferOption func(*differ)
func WithDeepComparison(enabled bool) DifferOption
WithDeepComparison enables/disables deep structural comparison
func WithIgnoredFields(fields ...string) DifferOption
WithIgnoredFields sets fields to ignore during comparison
func WithProvenanceTracking(enabled bool) DifferOption
WithProvenanceTracking enables provenance tracking in diffs
Enhancer defines the interface for model enrichment
type Enhancer interface {
// Name returns the enhancer name
Name() string
// Enhance enhances a single model with additional data
Enhance(ctx context.Context, model catalogs.Model) (catalogs.Model, error)
// EnhanceBatch enhances multiple models efficiently
EnhanceBatch(ctx context.Context, models []catalogs.Model) ([]catalogs.Model, error)
// CanEnhance checks if this enhancer can enhance a specific model
CanEnhance(model catalogs.Model) bool
// Priority returns the priority of this enhancer (higher = applied first)
Priority() int
}
EnhancerPipeline manages a chain of enhancers
type EnhancerPipeline struct {
// contains filtered or unexported fields
}
func NewEnhancerPipeline(enhancers ...Enhancer) *EnhancerPipeline
NewEnhancerPipeline creates a new enhancer pipeline
func (*EnhancerPipeline) Enhance
func (p *EnhancerPipeline) Enhance(ctx context.Context, model catalogs.Model) (catalogs.Model, error)
Enhance applies all enhancers to a single model
func (*EnhancerPipeline) EnhanceBatch
func (p *EnhancerPipeline) EnhanceBatch(ctx context.Context, models []catalogs.Model) ([]catalogs.Model, error)
EnhanceBatch applies all enhancers to multiple models
func (p *EnhancerPipeline) WithProvenance(tracker ProvenanceTracker) *EnhancerPipeline
WithProvenance enables provenance tracking for enhancements
FieldAuthority defines source priority for a specific field
type FieldAuthority struct {
FieldPath string `json:"field_path" yaml:"field_path"` // e.g., "pricing.input", "metadata.knowledge_cutoff"
Source SourceName `json:"source" yaml:"source"` // Which source is authoritative
Priority int `json:"priority" yaml:"priority"` // Priority (higher = more authoritative)
}
func AuthorityByField(fieldPath string, authorities []FieldAuthority) *FieldAuthority
AuthorityByField returns the highest priority authority for a given field path
func FilterAuthoritiesBySource(authorities []FieldAuthority, sourceName SourceName) []FieldAuthority
FilterAuthoritiesBySource returns only the authorities for a specific source
FieldChange represents a change to a specific field
type FieldChange struct {
Path string // Field path (e.g., "pricing.input")
OldValue string // Previous value (string representation)
NewValue string // New value (string representation)
Type ChangeType // Type of change
Source SourceName // Source that caused the change (for provenance)
}
FieldProvenance contains provenance history for a single field
type FieldProvenance struct {
Current ProvenanceInfo // Current value and its source
History []ProvenanceInfo // Historical values
Conflicts []ConflictInfo // Any conflicts that were resolved
}
Merger performs the actual merging of resources
type Merger interface {
// MergeModels merges models from multiple sources
MergeModels(sources map[SourceName][]catalogs.Model) ([]catalogs.Model, ProvenanceMap, error)
// MergeProviders merges providers from multiple sources
MergeProviders(sources map[SourceName][]catalogs.Provider) ([]catalogs.Provider, ProvenanceMap, error)
// MergeField merges a single field using authorities
MergeField(fieldPath string, values map[SourceName]interface{}) (interface{}, SourceName)
// WithProvenance sets the provenance tracker
WithProvenance(tracker ProvenanceTracker)
}
MetadataEnhancer adds metadata from various sources
type MetadataEnhancer struct {
// contains filtered or unexported fields
}
func NewMetadataEnhancer(priority int) *MetadataEnhancer
NewMetadataEnhancer creates a new metadata enhancer
func (e *MetadataEnhancer) CanEnhance(model catalogs.Model) bool
CanEnhance checks if this enhancer can enhance a model
func (e *MetadataEnhancer) Enhance(ctx context.Context, model catalogs.Model) (catalogs.Model, error)
Enhance enhances a single model
func (e *MetadataEnhancer) EnhanceBatch(ctx context.Context, models []catalogs.Model) ([]catalogs.Model, error)
EnhanceBatch enhances multiple models
func (e *MetadataEnhancer) Name() string
Name returns the enhancer name
func (e *MetadataEnhancer) Priority() int
Priority returns the priority
ModelChangeset represents changes to models
type ModelChangeset struct {
Added []catalogs.Model // New models
Updated []ModelUpdate // Updated models
Removed []catalogs.Model // Removed models
}
func (*ModelChangeset) HasChanges
func (m *ModelChangeset) HasChanges() bool
HasChanges returns true if the model changeset contains any changes
func (*ModelChangeset) Print
func (m *ModelChangeset) Print()
Print outputs model changes in a human-readable format
ModelUpdate represents an update to an existing model
type ModelUpdate struct {
ID string // ID of the model being updated
Existing catalogs.Model // Current model
New catalogs.Model // New model
Changes []FieldChange // Detailed list of field changes
}
ModelsDevEnhancer enhances models with models.dev data
type ModelsDevEnhancer struct {
// contains filtered or unexported fields
}
func NewModelsDevEnhancer(priority int) *ModelsDevEnhancer
NewModelsDevEnhancer creates a new models.dev enhancer
func (*ModelsDevEnhancer) CanEnhance
func (e *ModelsDevEnhancer) CanEnhance(model catalogs.Model) bool
CanEnhance checks if this enhancer can enhance a model
func (*ModelsDevEnhancer) Enhance
func (e *ModelsDevEnhancer) Enhance(ctx context.Context, model catalogs.Model) (catalogs.Model, error)
Enhance enhances a single model
func (*ModelsDevEnhancer) EnhanceBatch
func (e *ModelsDevEnhancer) EnhanceBatch(ctx context.Context, models []catalogs.Model) ([]catalogs.Model, error)
EnhanceBatch enhances multiple models
func (*ModelsDevEnhancer) Name
func (e *ModelsDevEnhancer) Name() string
Name returns the enhancer name
func (*ModelsDevEnhancer) Priority
func (e *ModelsDevEnhancer) Priority() int
Priority returns the priority
Option configures a Reconciler
type Option func(*reconciler) error
func WithAuthorities(authorities AuthorityProvider) Option
WithAuthorities sets the field authorities
func WithEnhancers(enhancers ...Enhancer) Option
WithEnhancers adds model enhancers to the pipeline
func WithProvenance(enabled bool) Option
WithProvenance enables field-level tracking
func WithStrategy(strategy Strategy) Option
WithStrategy sets the merge strategy
ProvenanceAuditResult contains audit findings
type ProvenanceAuditResult 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
}
ProvenanceAuditor validates provenance tracking
type ProvenanceAuditor interface {
// Audit checks provenance for completeness and consistency
Audit(provenance ProvenanceMap) *ProvenanceAuditResult
// ValidateAuthority ensures authority scores are valid
ValidateAuthority(provenance ProvenanceMap) []string
// CheckCoverage verifies all required fields have provenance
CheckCoverage(provenance ProvenanceMap, requiredFields []string) []string
}
ProvenanceInfo tracks the origin and history of a field value
type ProvenanceInfo struct {
Source SourceName // Source that provided the value
Field string // Field path
Value interface{} // The actual value
Timestamp time.Time // When the value was set
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 interface{} // Previous value if updated
}
ProvenanceMap tracks provenance for multiple resources
type ProvenanceMap map[string][]ProvenanceInfo // key is "resourceType:resourceID:fieldPath"
ProvenanceReport generates a human-readable provenance report
type ProvenanceReport struct {
Resources map[string]ResourceProvenance // key is "resourceType:resourceID"
}
func GenerateReport(provenance ProvenanceMap) *ProvenanceReport
GenerateReport creates a provenance report from a ProvenanceMap
func (*ProvenanceReport) String
func (r *ProvenanceReport) String() string
String generates a string representation of the provenance report
ProvenanceTracker manages provenance tracking during reconciliation
type ProvenanceTracker interface {
// Track records provenance for a field
Track(resourceType ResourceType, resourceID string, field string, info ProvenanceInfo)
// GetProvenance retrieves provenance for a specific field
GetProvenance(resourceType ResourceType, resourceID string, field string) []ProvenanceInfo
// GetResourceProvenance retrieves all provenance for a resource
GetResourceProvenance(resourceType ResourceType, resourceID string) map[string][]ProvenanceInfo
// Export returns the complete provenance map
Export() ProvenanceMap
// Clear removes all provenance data
Clear()
}
func NewProvenanceTracker(enabled bool) ProvenanceTracker
NewProvenanceTracker creates a new provenance tracker
ProviderChangeset represents changes to providers
type ProviderChangeset struct {
Added []catalogs.Provider // New providers
Updated []ProviderUpdate // Updated providers
Removed []catalogs.Provider // Removed providers
}
func (*ProviderChangeset) HasChanges
func (p *ProviderChangeset) HasChanges() bool
HasChanges returns true if the provider changeset contains any changes
func (*ProviderChangeset) Print
func (p *ProviderChangeset) Print()
Print outputs provider changes in a human-readable format
ProviderUpdate represents an update to an existing provider
type ProviderUpdate struct {
ID catalogs.ProviderID // ID of the provider being updated
Existing catalogs.Provider // Current provider
New catalogs.Provider // New provider
Changes []FieldChange // Detailed list of field changes
}
Reconciler is the main interface for reconciling data from multiple sources
type Reconciler interface {
// ReconcileCatalogs merges multiple catalogs from different sources
ReconcileCatalogs(ctx context.Context, sources map[SourceName]catalogs.Catalog) (*Result, error)
// ReconcileModels merges models from multiple sources
ReconcileModels(sources map[SourceName][]catalogs.Model) ([]catalogs.Model, ProvenanceMap, error)
// ReconcileProviders merges providers from multiple sources
ReconcileProviders(sources map[SourceName][]catalogs.Provider) ([]catalogs.Provider, ProvenanceMap, error)
}
func New(opts ...Option) (Reconciler, error)
New creates a new Reconciler with options
Resolution represents a conflict resolution decision
type Resolution struct {
Conflict Conflict
Decision ConflictResolution
Value interface{}
Reason string
}
ResourceProvenance contains provenance for a single resource
type ResourceProvenance struct {
Type ResourceType
ID string
Fields map[string]FieldProvenance
}
ResourceType identifies the type of resource being merged
type ResourceType string
const (
ResourceTypeModel ResourceType = "model"
ResourceTypeProvider ResourceType = "provider"
ResourceTypeAuthor ResourceType = "author"
)
Result represents the outcome of a reconciliation operation
type Result struct {
// Success indicates if reconciliation completed successfully
Success bool
// Catalog is the reconciled catalog (if successful)
Catalog catalogs.Catalog
// Changeset contains all changes that were detected
Changeset *Changeset
// AppliedChanges contains changes that were actually applied
AppliedChanges *Changeset
// Errors contains any errors that occurred
Errors []error
// Warnings contains non-critical issues
Warnings []string
// Metadata about the reconciliation
Metadata ResultMetadata
// Provenance information for audit trail
Provenance ProvenanceMap
}
func (r *Result) HasChanges() bool
HasChanges returns true if any changes were detected
func (r *Result) HasErrors() bool
HasErrors returns true if there were errors
func (r *Result) HasWarnings() bool
HasWarnings returns true if there were warnings
func (r *Result) IsSuccess() bool
IsSuccess returns true if the reconciliation was successful
func (*Result) Report
func (r *Result) Report() string
Report generates a detailed report of the reconciliation
func (*Result) Summary
func (r *Result) Summary() string
Summary returns a human-readable summary of the result
func (r *Result) WasApplied() bool
WasApplied returns true if changes were applied
ResultBuilder helps construct Result objects
type ResultBuilder struct {
// contains filtered or unexported fields
}
func NewResultBuilder() *ResultBuilder
NewResultBuilder creates a new ResultBuilder
func (*ResultBuilder) Build
func (b *ResultBuilder) Build() *Result
Build finalizes and returns the Result
func (b *ResultBuilder) WithAppliedChanges(changeset *Changeset) *ResultBuilder
WithAppliedChanges sets the applied changes
func (b *ResultBuilder) WithCatalog(catalog catalogs.Catalog) *ResultBuilder
WithCatalog sets the reconciled catalog
func (b *ResultBuilder) WithChangeset(changeset *Changeset) *ResultBuilder
WithChangeset sets the detected changes
func (*ResultBuilder) WithDryRun
func (b *ResultBuilder) WithDryRun(dryRun bool) *ResultBuilder
WithDryRun marks this as a dry run
func (*ResultBuilder) WithError
func (b *ResultBuilder) WithError(err error) *ResultBuilder
WithError adds an error
func (b *ResultBuilder) WithProvenance(provenance ProvenanceMap) *ResultBuilder
WithProvenance sets the provenance map
func (b *ResultBuilder) WithSources(sources ...SourceName) *ResultBuilder
WithSources sets the sources that were reconciled
func (b *ResultBuilder) WithStatistics(stats ResultStatistics) *ResultBuilder
WithStatistics sets the result statistics
func (b *ResultBuilder) WithStrategy(strategy Strategy) *ResultBuilder
WithStrategy sets the reconciliation strategy
func (b *ResultBuilder) WithWarning(warning string) *ResultBuilder
WithWarning adds a warning
ResultMetadata contains metadata about the reconciliation process
type ResultMetadata struct {
// StartTime when reconciliation started
StartTime time.Time
// EndTime when reconciliation completed
EndTime time.Time
// Duration of the reconciliation
Duration time.Duration
// Sources that were reconciled
Sources []SourceName
// Strategy used for reconciliation
Strategy Strategy
// DryRun indicates if this was a dry-run
DryRun bool
// Statistics about the reconciliation
Stats ResultStatistics
}
ResultStatistics contains statistics about the reconciliation
type ResultStatistics struct {
// Number of resources processed
ModelsProcessed int
ProvidersProcessed int
AuthorsProcessed int
// Number of conflicts resolved
ConflictsResolved int
// Number of resources skipped
ResourcesSkipped int
// Performance metrics
MergeTimeMs int64
DiffTimeMs int64
ApplyTimeMs int64
TotalTimeMs int64
}
SourceName represents the name/type of a data source
type SourceName string
Common source names
const (
ProviderAPI SourceName = "Provider APIs"
ModelsDevGit SourceName = "models.dev (git)"
ModelsDevHTTP SourceName = "models.dev (http)"
LocalCatalog SourceName = "Local Catalog"
)
func (SourceName) String
func (sn SourceName) String() string
String returns the string representation of a source name
SourcePriorityOrderStrategy resolves conflicts using a fixed source precedence order.
Sources earlier in the priority slice have higher precedence than sources later in the slice.
type SourcePriorityOrderStrategy struct {
// contains filtered or unexported fields
}
func (*SourcePriorityOrderStrategy) ResolveConflict
func (s *SourcePriorityOrderStrategy) ResolveConflict(field string, values map[SourceName]interface{}) (interface{}, SourceName, string)
ResolveConflict uses source priority order to resolve conflicts
StrategicMerger implements strategic three-way merge
type StrategicMerger struct {
// contains filtered or unexported fields
}
func NewStrategicMerger(authorities AuthorityProvider, strategy Strategy) *StrategicMerger
NewStrategicMerger creates a new StrategicMerger
func (*StrategicMerger) MergeField
func (sm *StrategicMerger) MergeField(fieldPath string, values map[SourceName]interface{}) (interface{}, SourceName)
MergeField merges a single field using authorities
func (*StrategicMerger) MergeModels
func (sm *StrategicMerger) MergeModels(sources map[SourceName][]catalogs.Model) ([]catalogs.Model, ProvenanceMap, error)
MergeModels merges models from multiple sources
func (sm *StrategicMerger) MergeProviders(sources map[SourceName][]catalogs.Provider) ([]catalogs.Provider, ProvenanceMap, error)
MergeProviders merges providers from multiple sources
func (sm *StrategicMerger) WithProvenance(tracker ProvenanceTracker)
WithProvenance sets the provenance tracker
Strategy defines how reconciliation should be performed
type Strategy interface {
// Name returns the strategy name
Name() string
// Description returns a human-readable description
Description() string
// ShouldMerge determines if resources should be merged
ShouldMerge(resourceType ResourceType) bool
// ResolveConflict determines how to resolve conflicts
ResolveConflict(field string, values map[SourceName]interface{}) (interface{}, SourceName, string)
// ValidateResult validates the reconciliation result
ValidateResult(result *Result) error
// GetApplyStrategy returns how changes should be applied
GetApplyStrategy() ApplyStrategy
}
func NewAuthorityBasedStrategy(authorities AuthorityProvider) Strategy
NewAuthorityBasedStrategy creates a new authority-based strategy
func NewCustomStrategy(name, description string, resolver ConflictResolver) Strategy
NewCustomStrategy creates a new custom strategy
func NewSourcePriorityOrderStrategy(priorityOrder []SourceName) Strategy
NewSourcePriorityOrderStrategy creates a new source priority order strategy.
The priorityOrder slice determines precedence: earlier elements have higher priority.
func NewStrategyChain(strategies ...Strategy) Strategy
NewStrategyChain creates a new strategy chain
func NewUnionStrategy() Strategy
NewUnionStrategy creates a new union strategy
StrategyChain combines multiple strategies with fallback
type StrategyChain struct {
// contains filtered or unexported fields
}
func (s *StrategyChain) Description() string
Description returns a human-readable description
func (s *StrategyChain) GetApplyStrategy() ApplyStrategy
GetApplyStrategy returns the first strategy's apply strategy
func (*StrategyChain) Name
func (s *StrategyChain) Name() string
Name returns the strategy name
func (s *StrategyChain) ResolveConflict(field string, values map[SourceName]interface{}) (interface{}, SourceName, string)
ResolveConflict tries each strategy in order
func (s *StrategyChain) ShouldMerge(resourceType ResourceType) bool
ShouldMerge checks all strategies
func (s *StrategyChain) ValidateResult(result *Result) error
ValidateResult validates using all strategies
ThreeWayMerger performs three-way merges with conflict resolution
type ThreeWayMerger interface {
// MergeModels performs a three-way merge on models
MergeModels(base, ours, theirs catalogs.Model) (catalogs.Model, []Conflict, error)
// MergeProviders performs a three-way merge on providers
MergeProviders(base, ours, theirs catalogs.Provider) (catalogs.Provider, []Conflict, error)
// MergeAuthors performs a three-way merge on authors
MergeAuthors(base, ours, theirs catalogs.Author) (catalogs.Author, []Conflict, error)
// ResolveConflicts applies a conflict resolution strategy
ResolveConflicts(conflicts []Conflict, strategy ConflictResolution) []Resolution
}
func NewThreeWayMerger(authorities AuthorityProvider, strategy Strategy) ThreeWayMerger
NewThreeWayMerger creates a new three-way merger
UnionStrategy combines all values without conflict resolution
type UnionStrategy struct {
// contains filtered or unexported fields
}
func (s *UnionStrategy) ResolveConflict(field string, values map[SourceName]interface{}) (interface{}, SourceName, string)
ResolveConflict in union strategy returns the first non-nil value in a deterministic order
ValidationError represents a validation error
type ValidationError struct {
ResourceType ResourceType
ResourceID string
Field string
Message string
}
ValidationResult represents the result of validating a catalog or changeset
type ValidationResult struct {
Valid bool
Errors []ValidationError
Warnings []ValidationWarning
}
func (*ValidationResult) HasWarnings
func (v *ValidationResult) HasWarnings() bool
HasWarnings returns true if there are warnings
func (*ValidationResult) IsValid
func (v *ValidationResult) IsValid() bool
IsValid returns true if validation passed
func (*ValidationResult) String
func (v *ValidationResult) String() string
String returns a string representation of the validation result
ValidationWarning represents a validation warning
type ValidationWarning struct {
ResourceType ResourceType
ResourceID string
Field string
Message string
}
Generated by gomarkdoc