reconcile

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package reconcile compares and copies project and central trees.

Index

Constants

View Source
const (
	StagePathPrefix  = ".lore-stage-"
	BackupPathPrefix = ".lore-backup-"
)

Variables

This section is empty.

Functions

func CopyTree

func CopyTree(source, destination string) error

CopyTree copies source to a new destination and publishes it atomically.

func InspectTree

func InspectTree(root string) (Snapshot, []Issue, error)

InspectTree snapshots a real directory without following symlinks.

func SortIssues

func SortIssues(issues []Issue)

SortIssues orders issues by path then kind so output stays stable.

func StageSnapshot

func StageSnapshot(destinationRoot string, snapshot Snapshot) (string, error)

StageSnapshot creates a sibling tree containing a merged snapshot.

func TreesEqual

func TreesEqual(left, right string) (bool, error)

TreesEqual reports whether two trees contain the same Git-reproducible data.

Types

type Change

type Change string

Change describes how one side differs from the base.

const (
	ChangeNone     Change = "none"
	ChangeAdded    Change = "added"
	ChangeModified Change = "modified"
	ChangeDeleted  Change = "deleted"
)

type ConflictKind

type ConflictKind string

ConflictKind identifies the unresolved representation written by pull.

const (
	ConflictText          ConflictKind = "text"
	ConflictKeepBoth      ConflictKind = "keep-both"
	ConflictSiblingSuffix              = ".sync-conflict"
)

type Entry

type Entry struct {
	Kind       EntryKind
	Data       []byte
	Executable bool
}

Entry contains the Git-reproducible value of one path.

type EntryKind

type EntryKind string

EntryKind identifies Git-reproducible filesystem object types.

const (
	KindFile    EntryKind = "file"
	KindSymlink EntryKind = "symlink"
)

type FileResult

type FileResult struct {
	Path          string
	State         SyncState
	ProjectChange Change
	CentralChange Change
	Project       *Entry
	Central       *Entry
	Base          *Entry
}

FileResult is the three-way verdict for one path.

type Issue

type Issue struct {
	Kind    IssueKind
	Path    string
	Message string
}

Issue is one typed health problem found during inspection.

type IssueKind

type IssueKind string

IssueKind identifies a condition outside the four sync states.

const (
	IssueCopyMissing       IssueKind = "copy-missing"
	IssueCopyInvalid       IssueKind = "copy-invalid"
	IssueUnsupportedObject IssueKind = "unsupported-object"
	IssueConflictMarkers   IssueKind = "conflict-markers"
	IssueConflictSibling   IssueKind = "conflict-sibling"
	IssueCentralDirty      IssueKind = "central-dirty"
	IssueBaseUnreachable   IssueKind = "base-unreachable"
	IssueCentralMissing    IssueKind = "central-missing"
	IssueInspectionFailed  IssueKind = "inspection-failed"
)

type MergeConflict

type MergeConflict struct {
	Path        string
	Kind        ConflictKind
	SiblingPath string
}

MergeConflict describes one unresolved path and its optional sibling.

type MergeResult

type MergeResult struct {
	Snapshot  Snapshot
	Conflicts []MergeConflict
}

MergeResult contains the project-side tree produced by reconciliation.

func MergeFiles

func MergeFiles(files []FileResult) (MergeResult, error)

MergeFiles reconciles an existing three-way file classification.

func MergeSnapshots

func MergeSnapshots(project, central, base Snapshot) (MergeResult, error)

MergeSnapshots reconciles project and central snapshots against base.

type Result

type Result struct {
	State     SyncState
	BaseStale bool
	Files     []FileResult
	Issues    []Issue
}

Result is the read-only classification of one agent directory.

func Classify

func Classify(project, central, base Snapshot, issues []Issue) Result

Classify compares project and central snapshots against their base. Paths flagged with IssueUnsupportedObject are excluded from the file records because Git cannot reproduce them on either side.

type Snapshot

type Snapshot map[string]Entry

Snapshot is a relative-path map of files and symlinks.

type SyncState

type SyncState string

SyncState is the public four-state classification.

const (
	StateInSync       SyncState = "in-sync"
	StateProjectAhead SyncState = "project-ahead"
	StateCentralAhead SyncState = "central-ahead"
	StateDiverged     SyncState = "diverged"
)

func Rollup

func Rollup(states []SyncState) SyncState

Rollup combines child sync states into the state of their container. It is the single definition of the precedence rule the spec documents, shared by the file-to-directory and directory-to-checkout folds.

type TreeReplacement

type TreeReplacement struct {
	Source      string
	Destination string
}

TreeReplacement names one central-to-project tree publication.

Jump to

Keyboard shortcuts

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