reconcile

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: May 7, 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 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 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 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 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 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 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