Documentation
¶
Overview ¶
Package snapshot handles snapshot creation, listing, and querying.
Index ¶
- Constants
- Variables
- func Find(repoRoot string, opts FilterOptions) ([]*model.Descriptor, error)
- func FindByTag(repoRoot string, tag string) (*model.Descriptor, error)
- func FindOne(repoRoot string, query string) (*model.Descriptor, error)
- func FormatMatchList(matches []*MatchScore) string
- func InspectPublishState(repoRoot string, snapshotID model.SnapshotID, opts PublishStateOptions) (*PublishState, *PublishStateIssue)
- func IsDescriptorNotFound(err error) bool
- func ListAll(repoRoot string) ([]*model.Descriptor, error)
- func LoadDescriptor(repoRoot string, snapshotID model.SnapshotID) (*model.Descriptor, error)
- func PublishReadyMarkerExists(snapshotDir string) (bool, error)
- func PublishStateIssueError(issue *PublishStateIssue) error
- func PublishedSnapshotExists(repoRoot string, snapshotID model.SnapshotID) (bool, error)
- func SetAfterSnapshotPayloadStagedHookForTest(hook SnapshotPayloadStagedHook) func()
- func VerifySnapshot(repoRoot string, snapshotID model.SnapshotID, verifyPayloadHash bool) error
- type CatalogEntry
- type Creator
- func (c *Creator) Create(worktreeName, note string, tags []string) (*model.Descriptor, error)
- func (c *Creator) CreatePartial(worktreeName, note string, tags []string, paths []string) (*model.Descriptor, error)
- func (c *Creator) CreateSavePoint(worktreeName, note string, tags []string) (*model.Descriptor, error)
- func (c *Creator) CreateSavePointLocked(worktreeName, note string, tags []string) (*model.Descriptor, error)
- func (c *Creator) CreateWithParent(worktreeName, note string, tags []string, parentID model.SnapshotID) (*model.Descriptor, error)
- func (c *Creator) LastTransferRecord() (transfer.Record, bool)
- func (c *Creator) SetCompression(level compression.CompressionLevel)
- type FilterOptions
- type MatchScore
- type PublishState
- type PublishStateIssue
- type PublishStateOptions
- type SnapshotPayloadStagedHook
Constants ¶
const ( PublishStateCodeSnapshotIDInvalid = publishstate.CodeSnapshotIDInvalid PublishStateCodeDescriptorMissing = publishstate.CodeDescriptorMissing PublishStateCodeDescriptorCorrupt = publishstate.CodeDescriptorCorrupt PublishStateCodeDescriptorChecksumMismatch = publishstate.CodeDescriptorChecksumMismatch PublishStateCodeReadyMissing = publishstate.CodeReadyMissing PublishStateCodeReadyInvalid = publishstate.CodeReadyInvalid PublishStateCodeReadyDescriptorMissing = publishstate.CodeReadyDescriptorMissing PublishStateCodePayloadMissing = publishstate.CodePayloadMissing PublishStateCodePayloadInvalid = publishstate.CodePayloadInvalid PublishStateCodePayloadHashMismatch = publishstate.CodePayloadHashMismatch )
Variables ¶
var ErrDescriptorNotFound = errors.New("descriptor not found")
Functions ¶
func Find ¶
func Find(repoRoot string, opts FilterOptions) ([]*model.Descriptor, error)
Find returns snapshots matching filter criteria.
func FindByTag ¶
func FindByTag(repoRoot string, tag string) (*model.Descriptor, error)
FindByTag returns the latest snapshot with the given tag.
func FindOne ¶
func FindOne(repoRoot string, query string) (*model.Descriptor, error)
FindOne finds a single snapshot by fuzzy match (note/tag prefix). Returns error if multiple matches or no matches.
func FormatMatchList ¶
func FormatMatchList(matches []*MatchScore) string
FormatMatchList formats a list of matches for interactive display.
func InspectPublishState ¶
func InspectPublishState(repoRoot string, snapshotID model.SnapshotID, opts PublishStateOptions) (*PublishState, *PublishStateIssue)
InspectPublishState validates READY/descriptor/payload consistency for one checkpoint. Expected damage is returned as a classified issue instead of an unstructured error so callers can fail closed with stable codes.
func IsDescriptorNotFound ¶
func ListAll ¶
func ListAll(repoRoot string) ([]*model.Descriptor, error)
ListAll returns all snapshot descriptors sorted by creation time (newest first).
func LoadDescriptor ¶
func LoadDescriptor(repoRoot string, snapshotID model.SnapshotID) (*model.Descriptor, error)
LoadDescriptor loads a descriptor from disk.
func PublishReadyMarkerExists ¶
PublishReadyMarkerExists reports whether a snapshot dir has a regular publish marker leaf and rejects invalid marker leaves without following symlinks.
func PublishStateIssueError ¶
func PublishStateIssueError(issue *PublishStateIssue) error
PublishStateIssueError converts a classified publish-state issue into the stable public error type used by CLI JSON and package callers.
func PublishedSnapshotExists ¶
func PublishedSnapshotExists(repoRoot string, snapshotID model.SnapshotID) (bool, error)
PublishedSnapshotExists reports whether snapshotID has a ready published payload, independent of descriptor readability.
func SetAfterSnapshotPayloadStagedHookForTest ¶
func SetAfterSnapshotPayloadStagedHookForTest(hook SnapshotPayloadStagedHook) func()
SetAfterSnapshotPayloadStagedHookForTest installs a hook used by tests to deterministically simulate a workspace write after payload staging.
func VerifySnapshot ¶
func VerifySnapshot(repoRoot string, snapshotID model.SnapshotID, verifyPayloadHash bool) error
VerifySnapshot verifies a snapshot's integrity.
Types ¶
type CatalogEntry ¶
type CatalogEntry struct {
SnapshotID model.SnapshotID
Descriptor *model.Descriptor
DescriptorErr error
}
CatalogEntry is one published checkpoint payload plus its descriptor load result. Callers that resolve refs can distinguish a missing ref from a published checkpoint whose descriptor is missing or corrupt.
func ListCatalogEntries ¶
func ListCatalogEntries(repoRoot string) ([]CatalogEntry, error)
ListCatalogEntries returns ready checkpoint payloads with descriptor load state, preserving corrupt descriptor candidates for ref resolution.
type Creator ¶
type Creator struct {
// contains filtered or unexported fields
}
Creator handles snapshot creation using the 12-step protocol.
func NewCreator ¶
func NewCreator(repoRoot string, engineType model.EngineType) *Creator
NewCreator creates a new snapshot creator.
func NewCreatorWithCompression ¶
func NewCreatorWithCompression(repoRoot string, engineType model.EngineType, comp *compression.Compressor) *Creator
NewCreatorWithCompression creates a new snapshot creator with compression.
func (*Creator) Create ¶
Create performs a full snapshot of the worktree using the 12-step protocol.
func (*Creator) CreatePartial ¶
func (c *Creator) CreatePartial(worktreeName, note string, tags []string, paths []string) (*model.Descriptor, error)
CreatePartial performs a snapshot of specific paths within the worktree. If paths is nil or empty, performs a full snapshot.
func (*Creator) CreateSavePoint ¶
func (c *Creator) CreateSavePoint(worktreeName, note string, tags []string) (*model.Descriptor, error)
CreateSavePoint performs a full snapshot for the public save path. The descriptor parent is selected from the worktree's latest snapshot while the mutation lock is held, so concurrent saves cannot publish a stale lineage.
func (*Creator) CreateSavePointLocked ¶
func (c *Creator) CreateSavePointLocked(worktreeName, note string, tags []string) (*model.Descriptor, error)
CreateSavePointLocked creates a public save point while the caller already holds the repository mutation lock.
func (*Creator) CreateWithParent ¶
func (c *Creator) CreateWithParent(worktreeName, note string, tags []string, parentID model.SnapshotID) (*model.Descriptor, error)
CreateWithParent performs a full snapshot while using parentID as the descriptor lineage parent, independent of the worktree's current head.
func (*Creator) LastTransferRecord ¶ added in v0.4.7
LastTransferRecord returns the final primary transfer from the most recent successful public save-point creation handled by this creator.
func (*Creator) SetCompression ¶
func (c *Creator) SetCompression(level compression.CompressionLevel)
SetCompression sets the compression level for this creator.
type FilterOptions ¶
type FilterOptions struct {
WorktreeName string
NoteContains string
HasTag string
Since time.Time
Until time.Time
}
FilterOptions for searching snapshots.
type MatchScore ¶
type MatchScore struct {
Desc *model.Descriptor
Score int
MatchType string // "id", "tag", "note"
}
MatchScore represents how well a snapshot matches a query.
func FindMultiple ¶
func FindMultiple(repoRoot string, query string, maxResults int) ([]*MatchScore, error)
FindMultiple finds snapshots matching a query with fuzzy scoring. Returns up to maxResults matches, sorted by relevance.
type PublishState ¶
type PublishState = publishstate.State
type PublishStateIssue ¶
type PublishStateIssue = publishstate.Issue
type PublishStateOptions ¶
type PublishStateOptions = publishstate.Options
type SnapshotPayloadStagedHook ¶
type SnapshotPayloadStagedHook func(model.SnapshotID, string) error