reconcile

package
v0.1.0-dev.20260129030150 Latest Latest
Warning

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

Go to latest
Published: Jan 29, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package reconcile provides full-stack drift detection and repair for writ deployments.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Entry

type Entry struct {
	// RelTarget is the relative path from target root (e.g., .bashrc)
	RelTarget string

	// Source is the absolute path to the source file
	Source string

	// Target is the absolute path to the target file
	Target string

	// State is the current status
	State State

	// Project is the project this belongs to
	Project string

	// Operations that were/should be performed
	Operations []string

	// Message provides additional context (e.g., "points to wrong file")
	Message string

	// SourceChecksum is the expected source checksum (from receipt)
	SourceChecksum string

	// TargetChecksum is the expected target checksum (from receipt)
	TargetChecksum string
}

Entry represents the status of a single file.

type Report

type Report struct {
	// TargetRoot is the deployment target (e.g., $HOME)
	TargetRoot string

	// SourceRoot is the environment layer path
	SourceRoot string

	// Projects checked
	Projects []string

	// Entries are the individual file statuses
	Entries []Entry

	// FromReceipt indicates status was computed from a receipt
	FromReceipt bool

	// ReceiptPath is the path to the receipt used (if any)
	ReceiptPath string
}

Report contains the full status report.

func FromBuildResult

func FromBuildResult(br *tree.BuildResult) *Report

FromBuildResult generates status by checking entries in a build result.

func FromReceipt

func FromReceipt(rcpt *receipt.Receipt, receiptPath string) *Report

FromReceipt generates status by checking entries in a receipt. For copied files without drift detection, use this function.

func FromReceiptWithDrift

func FromReceiptWithDrift(rcpt *receipt.Receipt, receiptPath string, checkDrift bool) *Report

FromReceiptWithDrift generates status from a receipt with optional drift detection. When checkDrift is true, checksums are compared to detect source/target changes.

func ScanTarget

func ScanTarget(targetRoot, sourceRoot string) *Report

ScanTarget scans the target directory for writ-managed symlinks. This works without a receipt by looking for symlinks that point into sourceRoot.

func (*Report) HasIssues

func (r *Report) HasIssues() bool

HasIssues returns true if there are any non-linked/copied states.

func (*Report) Summary

func (r *Report) Summary() map[State]int

Summary returns counts of each state.

type State

type State int

State represents the status of a deployed file.

const (
	// StateLinked means the symlink exists and points to the correct source.
	StateLinked State = iota
	// StateConflict means a file exists at the target but isn't our symlink.
	StateConflict
	// StateMissing means the source file exists but target symlink is missing.
	StateMissing
	// StateOrphan means the symlink points to a nonexistent file.
	StateOrphan
	// StateCopied means the file was copied (template/secret) and matches expected.
	StateCopied
	// StateStale means the source template/secret has changed since deployment.
	StateStale
	// StateModified means the target file was edited after deployment.
	StateModified
	// StateDriftConflict means both source and target changed since deployment.
	StateDriftConflict
)

func (State) Label

func (s State) Label() string

Label returns a human-readable label for the state.

func (State) String

func (s State) String() string

String returns the status indicator for display.

Jump to

Keyboard shortcuts

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