Documentation
¶
Overview ¶
Package sync provides options and utilities for synchronizing the catalog with provider APIs.
Index ¶
- Constants
- type DependencyDecision
- type DependencyDecisionHandler
- type Option
- func WithAutoInstallDeps(autoInstall bool) Option
- func WithCatalogPath(path string) Option
- func WithCleanModelsDevRepo(cleanup bool) Option
- func WithDependencyDecisionHandler(handler DependencyDecisionHandler) Option
- func WithDryRun(dryRun bool) Option
- func WithFresh(fresh bool) Option
- func WithModelsDevGitCommit(commit string) Option
- func WithProvider(providerID catalogs.ProviderID) Option
- func WithReformat(reformat bool) Option
- func WithRequireAllSources(require bool) Option
- func WithSkipDepPrompts(skip bool) Option
- func WithSources(types ...sources.ID) Option
- func WithSourcesDir(dir string) Option
- func WithTimeout(timeout time.Duration) Option
- type Options
- type ProjectionResult
- type ProjectionStatus
- type ProviderResult
- type Result
Constants ¶
const ( // ProjectionStatusApplied reports that the workspace projection was written. ProjectionStatusApplied = catalogmeta.ProjectionStatusApplied // ProjectionStatusPendingRepair reports that publication succeeded but the // workspace projection needs repair. ProjectionStatusPendingRepair = catalogmeta.ProjectionStatusPendingRepair // ProjectionIssueWorkspaceFailed identifies a workspace projection failure. ProjectionIssueWorkspaceFailed = catalogmeta.ProjectionIssueWorkspaceFailed )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DependencyDecision ¶ added in v0.1.0
type DependencyDecision uint8
DependencyDecision describes how an interactive adapter wants to handle one missing source dependency.
const ( // DependencyDecisionInstall requests automatic installation. DependencyDecisionInstall DependencyDecision = iota + 1 // DependencyDecisionSkip requests skipping the source. DependencyDecisionSkip // DependencyDecisionCancel cancels synchronization. DependencyDecisionCancel )
type DependencyDecisionHandler ¶ added in v0.1.0
type DependencyDecisionHandler func(context.Context, sources.ID, sources.Dependency, bool) (DependencyDecision, error)
DependencyDecisionHandler lets an interactive adapter decide how to handle a missing dependency. Core synchronization never installs a terminal reader or prompts on its own.
type Option ¶
type Option func(*Options)
Option is a function that configures sync Options.
func WithAutoInstallDeps ¶ added in v0.0.17
WithAutoInstallDeps configures whether to automatically install missing dependencies.
func WithCatalogPath ¶ added in v0.2.0
WithCatalogPath configures the single human workspace used for local observation and post-commit materialization.
func WithCleanModelsDevRepo ¶
WithCleanModelsDevRepo configures whether to remove temporary models.dev repository after update.
func WithDependencyDecisionHandler ¶ added in v0.1.0
func WithDependencyDecisionHandler(handler DependencyDecisionHandler) Option
WithDependencyDecisionHandler configures the interactive dependency decision adapter. Noninteractive callers should leave it unset.
func WithModelsDevGitCommit ¶ added in v0.1.0
WithModelsDevGitCommit pins explicit models.dev Git verification to one commit.
func WithProvider ¶
func WithProvider(providerID catalogs.ProviderID) Option
WithProvider configures syncing for a specific provider only.
func WithReformat ¶
WithReformat configures whether to reformat providers.yaml file even without changes.
func WithRequireAllSources ¶ added in v0.0.17
WithRequireAllSources requires every configured source to be available and return a complete, successful observation containing at least one model.
func WithSkipDepPrompts ¶ added in v0.0.17
WithSkipDepPrompts skips optional sources with missing dependencies without consulting a configured DependencyDecisionHandler.
func WithSources ¶
WithSources configures which sources to use.
func WithSourcesDir ¶
WithSourcesDir configures the directory for external source data (models.dev cache/git).
func WithTimeout ¶
WithTimeout configures the sync timeout.
type Options ¶
type Options struct {
// Orchestration control
DryRun bool // Show changes without applying them
Timeout time.Duration // Timeout for the entire sync operation
// Source selection
Sources []sources.ID // Which external/human sources to use; verified embedded always participates.
ProviderID *catalogs.ProviderID // Filter for specific provider
// Human workspace used for both local observation and materialization.
CatalogPath string
// Source behavior control
Fresh bool // Delete existing models and fetch fresh from APIs (destructive)
CleanModelsDevRepo bool // Remove temporary models.dev repository after update
Reformat bool // Reformat providers.yaml file even without changes
SourcesDir string // Directory for external source data (models.dev cache/git)
ModelsDevGitCommit string // Exact models.dev commit required by Git verification
// Dependency control
AutoInstallDeps bool // Automatically install missing dependencies without prompting
SkipDepPrompts bool // Skip dependency prompts and continue without optional dependencies
RequireAllSources bool // Require every configured source to return a complete, successful, nonempty observation
// DependencyDecisionHandler is supplied by an interactive adapter. It is nil
// for library, server, scheduler, and other noninteractive callers.
DependencyDecisionHandler DependencyDecisionHandler
}
Options controls one explicit acquisition.Syncer.Sync operation.
func (*Options) SourceOptions ¶
SourceOptions converts sync options to properly typed source options.
func (*Options) Validate ¶
func (s *Options) Validate(providers catalogs.ProvidersReader) error
Validate checks if the sync options are valid.
func (*Options) ValidateFilesystemLayout ¶ added in v0.2.0
ValidateFilesystemLayout rejects machine-owned source/cache roots that overlap the configured human provider-YAML workspace. It is safe to call before reading the workspace or creating any source state.
type ProjectionResult ¶ added in v0.2.0
type ProjectionResult = catalogmeta.ProjectionResult
ProjectionResult is the optional post-commit workspace projection result.
type ProjectionStatus ¶ added in v0.2.0
type ProjectionStatus = catalogmeta.ProjectionStatus
ProjectionStatus is retained as the acquisition-result spelling of the shared catalog lifecycle type.
type ProviderResult ¶
type ProviderResult struct {
ProviderID catalogs.ProviderID // The provider that was synced
Added []catalogs.Model // New models not in catalog
Updated []differ.ModelUpdate // Existing models with changes
Removed []catalogs.Model // Models in catalog but not in API (informational only)
// Summary counts
AddedCount int // Number of models added
UpdatedCount int // Number of models updated
RemovedCount int // Number of models removed from API (not deleted from catalog)
// Metadata
APIModelsCount int // Total models fetched from API
ExistingModelsCount int // Total models that existed in catalog
EnhancedCount int // Number of models enhanced with models.dev data
}
ProviderResult represents sync results for a single provider.
func (*ProviderResult) HasChanges ¶
func (spr *ProviderResult) HasChanges() bool
HasChanges returns true if the provider result contains any changes.
func (*ProviderResult) Summary ¶
func (spr *ProviderResult) Summary() string
Summary returns a human-readable summary of the provider result.
type Result ¶
type Result struct {
// Overall statistics
TotalChanges int // Total number of changes across all providers
ProvidersChanged int // Number of providers with changes
ProviderResults map[catalogs.ProviderID]*ProviderResult // Results per provider
// Operation metadata
DryRun bool // Whether this was a dry run
Fresh bool // Whether this was a fresh sync
CatalogPath string // Human workspace used by the synchronization
Sources []sources.ID
// SourceObservations contains caller-owned freshness/audit projections from
// every source used by this attempt, including no-change synchronizations.
SourceObservations []catalogs.SourceObservationLink
GenerationID string // Durable generation activated by a non-dry sync
SyncRunID string // Correlation ID for the synchronization attempt
Projection *ProjectionResult
// ReviewCandidates contains deterministic non-fatal records excluded
// from the published canonical catalog after source authority resolution.
ReviewCandidates []catalogmeta.ReviewCandidate
}
Result represents the complete result of a sync operation.
func ChangesetToResult ¶
func ChangesetToResult(changeset *differ.Changeset, dryRun bool, catalogPath string, providerAPICounts map[catalogs.ProviderID]int, modelProviderMap map[string]catalogs.ProviderID, activeSources ...sources.ID) *Result
ChangesetToResult converts a reconcile.Changeset to a SyncResult.
func ChangesetToResultWithProvenance ¶ added in v0.1.0
func ChangesetToResultWithProvenance(changeset *differ.Changeset, dryRun bool, catalogPath string, providerAPICounts map[catalogs.ProviderID]int, modelProviderMap map[string]catalogs.ProviderID, fieldProvenance provenance.Map, activeSources ...sources.ID) *Result
ChangesetToResultWithProvenance converts a reconcile.Changeset to a SyncResult and uses field-level provenance to report models.dev enrichment counts.
func (*Result) HasChanges ¶
HasChanges returns true if the sync result contains any changes.