reconcile

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: May 12, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package reconcile builds skeeper operation plans from project state.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BranchName

func BranchName(namespace, sourceBranch string) string

BranchName returns the deterministic sidecar branch for a namespace/source branch pair.

Types

type AdoptPlanOptions

type AdoptPlanOptions struct {
	Force bool
}

AdoptPlanOptions configures adopt planning.

type BaseFile added in v0.2.1

type BaseFile struct {
	SidecarBlob string `json:"sidecar_blob,omitempty"`
	SHA256      string `json:"sha256,omitempty"`
	Size        int64  `json:"size,omitempty"`
}

BaseFile describes the last hydrated sidecar state for one path.

type ClassCount added in v0.2.1

type ClassCount struct {
	Unchanged            int `json:"unchanged"`
	MissingLocal         int `json:"missing_local"`
	LocalOnly            int `json:"local_only"`
	LocalModified        int `json:"local_modified"`
	SidecarModified      int `json:"sidecar_modified"`
	BothModifiedConflict int `json:"both_modified_conflict"`
	NamespaceRemoved     int `json:"namespace_removed"`
	ConfigUnowned        int `json:"config_unowned"`
}

ClassCount stores per-class counts in a stable JSON shape.

type DefaultPlanner

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

DefaultPlanner is the production planner.

func NewPlanner

func NewPlanner(runner gitexec.Runner) *DefaultPlanner

NewPlanner returns a production planner.

func (*DefaultPlanner) PlanAdopt

func (p *DefaultPlanner) PlanAdopt(
	ctx context.Context,
	root RepoRoot,
	targets []string,
	opts AdoptPlanOptions,
) (Plan, error)

PlanAdopt builds an adoption plan.

func (*DefaultPlanner) PlanFSCK

func (p *DefaultPlanner) PlanFSCK(ctx context.Context, root RepoRoot, opts FSCKPlanOptions) (Plan, error)

PlanFSCK builds an fsck plan.

func (*DefaultPlanner) PlanPattern

func (p *DefaultPlanner) PlanPattern(
	ctx context.Context,
	root RepoRoot,
	glob string,
	opts PatternPlanOptions,
) (Plan, error)

PlanPattern builds a pattern update plan.

func (*DefaultPlanner) PlanSync

func (p *DefaultPlanner) PlanSync(ctx context.Context, root RepoRoot, opts SyncPlanOptions) (Plan, error)

PlanSync builds a sync plan.

func (*DefaultPlanner) PlanUntrack

func (p *DefaultPlanner) PlanUntrack(
	ctx context.Context,
	root RepoRoot,
	targets []string,
	opts UntrackPlanOptions,
) (Plan, error)

PlanUntrack builds an untrack plan.

func (*DefaultPlanner) PlanVerify

func (p *DefaultPlanner) PlanVerify(ctx context.Context, root RepoRoot, opts VerifyPlanOptions) (Plan, error)

PlanVerify builds a verify plan.

type Diagnostic

type Diagnostic struct {
	Code      string `json:"code"`
	Severity  string `json:"severity"`
	Message   string `json:"message"`
	Path      string `json:"path,omitempty"`
	Namespace string `json:"namespace,omitempty"`
	Recovery  string `json:"recovery,omitempty"`
}

Diagnostic describes a stable machine-readable warning or failure.

type DiffSummary added in v0.2.1

type DiffSummary struct {
	OK         bool            `json:"ok"`
	Counts     ClassCount      `json:"counts"`
	Namespaces []NamespaceDiff `json:"namespaces"`
}

DiffSummary aggregates all namespace diffs.

func SummarizeDiff added in v0.2.1

func SummarizeDiff(namespaces []NamespaceDiff) DiffSummary

SummarizeDiff aggregates namespace diffs and marks OK only when every path is unchanged.

type FSCKPlanOptions

type FSCKPlanOptions struct {
	SourceBranch string
}

FSCKPlanOptions configures fsck planning.

type FilePlan

type FilePlan struct {
	Path   string `json:"path"`
	Size   int64  `json:"size"`
	Staged bool   `json:"staged,omitempty"`
}

FilePlan describes one owned main-repo path.

type FileSide added in v0.2.1

type FileSide struct {
	SHA256 string `json:"sha256,omitempty"`
	Size   int64  `json:"size,omitempty"`
	Blob   string `json:"blob,omitempty"`
}

FileSide is the comparable file metadata for one side of a path diff.

type GuardrailReport

type GuardrailReport struct {
	Files         int   `json:"files"`
	Bytes         int64 `json:"bytes"`
	MaxFiles      int   `json:"max_files"`
	MaxBytes      int64 `json:"max_bytes"`
	RequiresForce bool  `json:"requires_force"`
}

GuardrailReport summarizes broad-plan thresholds.

type NamespaceDiff added in v0.2.1

type NamespaceDiff struct {
	Name          string     `json:"name"`
	Branch        string     `json:"branch,omitempty"`
	LockedCommit  string     `json:"locked_commit,omitempty"`
	ExpectedFiles int        `json:"expected_files"`
	ActualFiles   int        `json:"actual_files"`
	ExpectedBytes int64      `json:"expected_bytes"`
	ActualBytes   int64      `json:"actual_bytes"`
	Counts        ClassCount `json:"counts"`
	Paths         []PathDiff `json:"paths,omitempty"`
}

NamespaceDiff summarizes one namespace's per-path lock/worktree diff.

func BuildNamespaceDiff added in v0.2.1

func BuildNamespaceDiff(input NamespaceDiffInput) NamespaceDiff

BuildNamespaceDiff classifies paths for one namespace.

type NamespaceDiffInput added in v0.2.1

type NamespaceDiffInput struct {
	Name         string
	Branch       string
	LockedCommit string
	Locked       map[string]SnapshotFile
	Local        map[string]SnapshotFile
	Base         map[string]BaseFile
}

NamespaceDiffInput contains the comparable data for one namespace.

type NamespaceName

type NamespaceName string

NamespaceName is a configured sidecar namespace name.

type NamespacePlan

type NamespacePlan struct {
	Name          NamespaceName     `json:"name"`
	Branch        string            `json:"branch"`
	Namespace     config.Namespace  `json:"-"`
	Files         []FilePlan        `json:"files"`
	StagedContent map[string]string `json:"-"`
}

NamespacePlan describes one namespace in a plan.

type Operation

type Operation struct {
	Kind      string `json:"kind"`
	Namespace string `json:"namespace,omitempty"`
	Path      string `json:"path,omitempty"`
	Message   string `json:"message,omitempty"`
}

Operation describes one planned side effect.

type PathClass added in v0.2.1

type PathClass string

PathClass identifies how one managed path differs between lock, worktree, and local journal state.

const (
	PathUnchanged            PathClass = "unchanged"
	PathMissingLocal         PathClass = "missing_local"
	PathLocalOnly            PathClass = "local_only"
	PathLocalModified        PathClass = "local_modified"
	PathSidecarModified      PathClass = "sidecar_modified"
	PathBothModifiedConflict PathClass = "both_modified_conflict"
	PathNamespaceRemoved     PathClass = "namespace_removed"
	PathConfigUnowned        PathClass = "config_unowned"
)

type PathDiff added in v0.2.1

type PathDiff struct {
	Path      string    `json:"path"`
	Class     PathClass `json:"class"`
	Locked    *FileSide `json:"locked,omitempty"`
	Local     *FileSide `json:"local,omitempty"`
	Base      *FileSide `json:"base,omitempty"`
	Namespace string    `json:"namespace,omitempty"`
}

PathDiff describes one classified path.

func FilterPathDiffs added in v0.2.1

func FilterPathDiffs(paths []PathDiff, classes ...PathClass) []PathDiff

FilterPathDiffs returns paths matching any provided class. Empty classes return every path.

type PatternPlanOptions

type PatternPlanOptions struct {
	Namespace     string
	Exclude       []string
	AdoptExisting bool
	Force         bool
}

PatternPlanOptions configures pattern planning.

type Plan

type Plan struct {
	Kind         PlanKind         `json:"kind"`
	Root         RepoRoot         `json:"root"`
	SourceBranch string           `json:"source_branch"`
	SidecarURL   string           `json:"sidecar_url"`
	Config       config.Config    `json:"-"`
	Namespaces   []NamespacePlan  `json:"namespaces"`
	Operations   []Operation      `json:"operations"`
	Warnings     []Diagnostic     `json:"warnings,omitempty"`
	Failures     []Diagnostic     `json:"failures,omitempty"`
	Guardrails   GuardrailReport  `json:"guardrails"`
	Targets      []TargetDecision `json:"targets,omitempty"`
}

Plan describes the reconciled operation.

type PlanKind

type PlanKind string

PlanKind identifies the operation a plan supports.

const (
	// PlanKindSync mirrors owned files into the sidecar.
	PlanKindSync PlanKind = "sync"
	// PlanKindAdopt moves main-repo tracked files under sidecar coverage.
	PlanKindAdopt PlanKind = "adopt"
	// PlanKindUntrack removes main-repo index tracking while preserving sidecar coverage.
	PlanKindUntrack PlanKind = "untrack"
	// PlanKindPattern updates namespace ownership patterns.
	PlanKindPattern PlanKind = "pattern"
	// PlanKindVerify validates skeeper.lock against the sidecar remote.
	PlanKindVerify PlanKind = "verify"
	// PlanKindFSCK compares the working tree against skeeper.lock.
	PlanKindFSCK PlanKind = "fsck"
)

type Planner

type Planner interface {
	PlanSync(ctx context.Context, root RepoRoot, opts SyncPlanOptions) (Plan, error)
	PlanAdopt(ctx context.Context, root RepoRoot, targets []string, opts AdoptPlanOptions) (Plan, error)
	PlanUntrack(ctx context.Context, root RepoRoot, targets []string, opts UntrackPlanOptions) (Plan, error)
	PlanPattern(ctx context.Context, root RepoRoot, glob string, opts PatternPlanOptions) (Plan, error)
	PlanVerify(ctx context.Context, root RepoRoot, opts VerifyPlanOptions) (Plan, error)
	PlanFSCK(ctx context.Context, root RepoRoot, opts FSCKPlanOptions) (Plan, error)
}

Planner constructs operation plans.

type RepoRoot

type RepoRoot string

RepoRoot is a normalized repository root path.

type SidecarRef

type SidecarRef string

SidecarRef is a sidecar Git ref or commit.

type SnapshotFile added in v0.2.1

type SnapshotFile struct {
	Path    string `json:"path"`
	Size    int64  `json:"size"`
	SHA256  string `json:"sha256"`
	Blob    string `json:"blob,omitempty"`
	Content string `json:"-"`
}

SnapshotFile describes one file in a comparable namespace snapshot.

type SyncPlanOptions

type SyncPlanOptions struct {
	Staged bool
	Force  bool
}

SyncPlanOptions configures sync planning.

type TargetDecision

type TargetDecision struct {
	Path      string `json:"path"`
	Namespace string `json:"namespace"`
	Tracked   bool   `json:"tracked"`
}

TargetDecision describes an adopted or untracked target.

type UntrackPlanOptions

type UntrackPlanOptions struct {
	Force bool
}

UntrackPlanOptions configures untrack planning.

type VerifyPlanOptions

type VerifyPlanOptions struct {
	SourceBranch string
}

VerifyPlanOptions configures verify planning.

Jump to

Keyboard shortcuts

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