sync

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: May 28, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package sync coordinates section-scoped synchronization between local specs and docs providers.

Index

Constants

View Source
const (
	DirectionIn   = "in"
	DirectionOut  = "out"
	DirectionBoth = "both"
)

Sync directions.

View Source
const (
	ConflictWarn  = "warn"
	ConflictAbort = "abort"
	ConflictForce = "force"
	ConflictSkip  = "skip"
)

Conflict strategies.

Variables

View Source
var ErrSyncConflict = errors.New("sync conflicts detected")

ErrSyncConflict is returned when conflicts are found and the strategy is abort.

Functions

func Hash

func Hash(content string) string

Hash returns the deterministic sync hash for section content.

Types

type Engine

type Engine struct {
	// contains filtered or unexported fields
}

Engine coordinates sync through adapter interfaces and store APIs.

func NewEngine

func NewEngine(docs adapter.DocsAdapter, db *store.DB) *Engine

NewEngine creates a sync engine.

func (*Engine) Finalize

func (e *Engine) Finalize(ctx context.Context, prepared *PreparedRun) error

Finalize applies external docs writes, sync-state persistence, and activity logging.

func (*Engine) Prepare

func (e *Engine) Prepare(ctx context.Context, opts Options) (*PreparedRun, error)

Prepare computes the sync plan and applies only local file changes.

func (*Engine) Run

func (e *Engine) Run(ctx context.Context, opts Options) (*Report, error)

Run executes a sync run.

type Options

type Options struct {
	SpecID           string
	SpecPath         string
	Direction        string
	ConflictStrategy string
	OwnerRole        string
	UserName         string
	DryRun           bool
}

Options configures one sync run.

type PreparedRun

type PreparedRun struct {
	Report *Report
	// contains filtered or unexported fields
}

PreparedRun contains local changes and deferred external/state side effects.

type Report

type Report struct {
	SpecID           string
	Direction        string
	DryRun           bool
	OutboundPushed   bool
	InboundApplied   []string
	OutboundSections []string
	Conflicts        []SectionConflict
	Skipped          []SectionSkip
	Unchanged        []string
	PageMissing      bool
}

Report summarizes the outcome of a sync run.

func (Report) HasBlockingConflicts

func (r Report) HasBlockingConflicts() bool

HasBlockingConflicts returns whether conflicts should block the command.

type SectionConflict

type SectionConflict struct {
	Section    string
	Owner      string
	LocalHash  string
	RemoteHash string
	Reason     string
}

SectionConflict describes a local/remote section conflict.

type SectionSkip

type SectionSkip struct {
	Section string
	Reason  string
}

SectionSkip describes a section that was intentionally not updated.

Jump to

Keyboard shortcuts

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