worktreeretire

package
v0.182.2 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2026 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Overview

Package worktreeretire owns the immutable private archive and its remote proof.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ArchiveIncludesRunPath

func ArchiveIncludesRunPath(claimID, reportName, path string) bool

func ArchiveManifestPreserve

func ArchiveManifestPreserve(manifest Manifest) string

func ArchiveRef

func ArchiveRef(result Transaction) string

func CaptureFile

func CaptureFile(source, destination string) (string, error)

CaptureFile opens the complete source path without following symlinks.

func CaptureFileInjected

func CaptureFileInjected(source, destination string, inj *filewrite.Injector) (string, error)

func CaptureTree

func CaptureTree(source, destination string, include func(string) bool, hashes map[string]string, prefix string) error

func DeleteOriginal

func DeleteOriginal(ctx context.Context, result *Transaction, afterPhase func(string) error, ports TransactionPorts) error

func DeletionProofRef

func DeletionProofRef(result Transaction) string

func GitBytes

func GitBytes(ctx context.Context, directory string, args ...string) ([]byte, error)

func GitObjectSHA

func GitObjectSHA(ctx context.Context, directory, object string) (string, error)

func PreserveMode

func PreserveMode(result Transaction) string

func PublishArchive

func PublishArchive(ctx context.Context, home, remote string, result *Receipt, ports Ports) error

func PublishSource

func PublishSource(ctx context.Context, result *Transaction, ports TransactionPorts) error

func ReportPath

func ReportPath(home string, result Transaction) string

func SourceRef

func SourceRef(result Transaction) string

func ValidateArchiveManifest

func ValidateArchiveManifest(expected, actual Manifest) ([]string, error)

func ValidateArchiveTree

func ValidateArchiveTree(files map[string]string, paths, listed []string) error

func ValidateRemovedReceipt

func ValidateRemovedReceipt(result Transaction, path, task, repository string) error

func VerifyArchive

func VerifyArchive(ctx context.Context, working, remote, ref, expectedSHA string, expected Manifest, ports Ports) error

func VerifyReceipts

func VerifyReceipts(ctx context.Context, canonical, archiveRemote string, result Transaction, ports TransactionPorts) error

func WriteReport

func WriteReport(result Transaction) error

func WriteReportInjected

func WriteReportInjected(result Transaction, inj *filewrite.Injector) error

Types

type ApplyPorts

type ApplyPorts struct {
	ValidateHeld         func() error
	CommitSource         func(context.Context, string, func(string, string) error) (bool, error)
	ValidateIntentCommit func(context.Context, Transaction, string) error
	CurrentHead          func(context.Context) (string, error)
	Clean                func(context.Context) (bool, error)
	SealWorkLog          func(Transaction) error
	CheckPrivateArchive  func(context.Context, Transaction) error
	PublishArchive       func(context.Context, *Transaction) error
	BeforeDeletion       func(context.Context) error
	RemoveLocal          func(context.Context, *Transaction) error
}

ApplyPorts contains the checkout and authority operations that must remain in the caller. Each port is bound to one held retirement task and checkout.

type Claim

type Claim struct {
	ClaimID, Repository, Branch, PromptArchive, PromptDigest string
}

type Manifest

type Manifest struct {
	Version    int               `json:"version"`
	Repository string            `json:"repository"`
	Branch     string            `json:"branch"`
	Preserve   string            `json:"preserve,omitempty"`
	SourceSHA  string            `json:"source_sha"`
	RetiredRef string            `json:"retired_ref"`
	ClaimID    string            `json:"claim_id"`
	Files      map[string]string `json:"files"`
}

type Operation

type Operation struct {
	Remote        TransactionPorts
	Apply         ApplyPorts
	ArchiveRemote string
	Now           func() time.Time
	AfterPhase    func(string) error
	WriteReport   func(Transaction) error
}

Operation is scoped to one held task. It owns phase persistence and proof order while the facade keeps authority checks and descriptor-bound mutation.

func (Operation) ApplyTransaction

func (operation Operation) ApplyTransaction(ctx context.Context, result Transaction, prior bool, current string, message string) (Transaction, error)

ApplyTransaction resumes from the recorded intent or creates one before any commit, then advances only after each exact remote receipt is verified.

func (Operation) CompleteRemoved

func (operation Operation) CompleteRemoved(result *Transaction) error

func (Operation) PrepareDeletionIntent

func (operation Operation) PrepareDeletionIntent(ctx context.Context, result *Transaction) error

func (Operation) VerifyRemovedRemote

func (operation Operation) VerifyRemovedRemote(ctx context.Context, result Transaction) error

VerifyRemovedRemote applies the same receipt rules to a checkout that has already disappeared, then checks the original-ref deletion proof exactly.

type Ports

type Ports struct {
	ReadClaim      func(home, worktree string) (Claim, error)
	ReadTerminal   func(home, worktree string) (*Terminal, error)
	ReportFileName func(task, repository string) (string, error)
	RemoteSHA      func(context.Context, string, string, string) (string, error)
	Git            func(context.Context, string, ...string) (string, error)
	GitBytes       func(context.Context, string, ...string) ([]byte, error)
	GitObjectSHA   func(context.Context, string, string) (string, error)
	WriteManifest  func(string, []byte, os.FileMode) error
}

Ports are read-only authority projections plus Git operations. A caller's Git runner remains injectable and the leaf does not depend on facade types.

type Receipt

type Receipt struct {
	Task, Repository, Branch, Preserve, SourceSHA, RetiredRef                    string
	Worktree, Canonical, ArchiveRef, ArchiveSHA, ClaimID, EffortID, RunID, Phase string
}

Receipt contains only the identities required to publish and verify one retirement archive. The caller retains the durable retirement transaction.

type Terminal

type Terminal struct {
	ClaimID, FinalCommit, ReportPath string
}

type Transaction

type Transaction struct {
	Version           int       `json:"version"`
	Task              string    `json:"task"`
	Repository        string    `json:"repository"`
	ArchiveRepository string    `json:"archive_repository"`
	Worktree          string    `json:"worktree"`
	Canonical         string    `json:"canonical"`
	WorktreesRoot     string    `json:"worktrees_root"`
	Local             bool      `json:"local"`
	Branch            string    `json:"branch"`
	Preserve          string    `json:"preserve,omitempty"`
	OriginalRemoteSHA string    `json:"original_remote_sha,omitempty"`
	DeleteIntentSHA   string    `json:"delete_intent_sha,omitempty"`
	SourceSHA         string    `json:"source_sha"`
	IntentParentSHA   string    `json:"intent_parent_sha,omitempty"`
	IntentTreeSHA     string    `json:"intent_tree_sha,omitempty"`
	IntentMessage     string    `json:"intent_message,omitempty"`
	IntentAt          time.Time `json:"intent_at,omitempty"`
	RetiredRef        string    `json:"retired_ref"`
	ArchiveRef        string    `json:"archive_ref"`
	ArchiveSHA        string    `json:"archive_sha,omitempty"`
	ClaimID           string    `json:"claim_id"`
	EffortID          string    `json:"effort_id"`
	RunID             string    `json:"run_id"`
	Phase             string    `json:"phase"`
	ReportPath        string    `json:"report_path,omitempty"`
}

Transaction is the durable retirement receipt. It contains identities and hashes; private prompt and journal bytes belong only in the archive.

func ReadReport

func ReadReport(path string) (Transaction, error)

type TransactionPorts

type TransactionPorts struct {
	RemoteSHA        func(context.Context, string, string, string) (string, error)
	PublishSourceRef func(context.Context, Transaction, string) error
	DeleteAndTag     func(context.Context, Transaction, string, string) error
}

TransactionPorts confines remote mutation to the facade's held canonical repository and secure Git helper. The leaf decides the lease and proof rules.

Jump to

Keyboard shortcuts

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