Documentation
¶
Index ¶
- func ContentHash(data []byte) string
- func FormatSize(bytes int64) string
- func MatchGlob(path, pattern string) bool
- func ResolveMergeStrategy(relPath string, strategies map[string]string) string
- func ResolveMergeStrategyWithPattern(relPath string, strategies map[string]string) (strategy string, pattern string)
- func Rotate(cfg *config.Config, oldIdentity age.Identity, newRecipient age.Recipient, ...) (int, error)
- type DiffResult
- type FileEntry
- type Manifest
- type ObjectStore
- func (s *ObjectStore) Delete(hash string) error
- func (s *ObjectStore) Exists(hash string) bool
- func (s *ObjectStore) Init() error
- func (s *ObjectStore) ListAll() ([]string, error)
- func (s *ObjectStore) ObjectPath(hash string) string
- func (s *ObjectStore) Read(hash string) ([]byte, error)
- func (s *ObjectStore) Write(hash string, encrypted []byte) error
- type ProgressFunc
- type RepairResult
- type ScanResult
- type SealStats
- type UnsealStats
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ContentHash ¶
ContentHash computes the SHA-256 hash of plaintext content.
func FormatSize ¶
FormatSize formats a byte count as a human-readable string.
func MatchGlob ¶
MatchGlob matches a path against a glob pattern with ** support. It splits both path and pattern into segments and matches segment-by-segment.
func ResolveMergeStrategy ¶
ResolveMergeStrategy finds the merge strategy for a file based on glob patterns.
func ResolveMergeStrategyWithPattern ¶
func ResolveMergeStrategyWithPattern(relPath string, strategies map[string]string) (strategy string, pattern string)
ResolveMergeStrategyWithPattern returns both the strategy and the pattern that matched. An empty pattern means a built-in default was used. When multiple glob patterns match, the most specific wins (most segments, fewest wildcards). This ensures deterministic resolution regardless of Go map iteration order.
Types ¶
type DiffResult ¶
type DiffResult struct {
Added []string // files in new but not old
Modified []string // files in both but with different hashes
Deleted []string // files in old but not new
}
DiffResult describes the differences between two manifests.
func Status ¶
func Status(cfg *config.Config) (*DiffResult, error)
Status returns the diff between the current claude directory and the seal manifest.
func UnsealStatus ¶
func UnsealStatus(cfg *config.Config) (*DiffResult, error)
UnsealStatus returns what Unseal would do without actually writing anything. "Added" = files in manifest but missing on disk (would be restored). "Modified" = files on disk with different content than manifest (would be overwritten). "Deleted" = managed files on disk but not in manifest (would be deleted).
type FileEntry ¶
type FileEntry struct {
ContentHash string `json:"content_hash"`
SizePlaintext int64 `json:"size_plaintext"`
SizeEncrypted int64 `json:"size_encrypted"`
Mtime string `json:"mtime"`
MergeStrategy string `json:"merge_strategy"`
// For JSONL files, track line count for efficient dedup merge
JSONLLineCount int `json:"jsonl_line_count,omitempty"`
// Whether a session file is complete (immutable)
SessionComplete bool `json:"session_complete,omitempty"`
}
FileEntry describes a single file in the seal store.
type Manifest ¶
type Manifest struct {
Version int `json:"version"`
DeviceID string `json:"device_id"`
SealedAt string `json:"sealed_at"`
Files map[string]FileEntry `json:"files"`
}
Manifest tracks all files in the seal store with their content hashes and metadata.
func LoadManifest ¶
Load reads a manifest from disk.
func NewManifest ¶
NewManifest creates an empty manifest for the given device.
func (*Manifest) Diff ¶
func (m *Manifest) Diff(other *Manifest) DiffResult
Diff compares this manifest against another and returns the differences.
type ObjectStore ¶
type ObjectStore struct {
// contains filtered or unexported fields
}
ObjectStore manages content-addressed encrypted blobs. Files are stored as objects/<hash[0:2]>/<hash[2:]>.age
func NewObjectStore ¶
func NewObjectStore(sealDir string) *ObjectStore
NewObjectStore creates an ObjectStore rooted at the given directory.
func (*ObjectStore) Delete ¶
func (s *ObjectStore) Delete(hash string) error
Delete removes an object by its content hash.
func (*ObjectStore) Exists ¶
func (s *ObjectStore) Exists(hash string) bool
Exists checks if an object with the given hash exists.
func (*ObjectStore) ListAll ¶
func (s *ObjectStore) ListAll() ([]string, error)
ListAll returns all content hashes of objects on disk.
func (*ObjectStore) ObjectPath ¶
func (s *ObjectStore) ObjectPath(hash string) string
ObjectPath returns the filesystem path for a given content hash.
type ProgressFunc ¶
ProgressFunc is called during long operations to report progress.
type RepairResult ¶
type RepairResult struct {
TotalManifest int
TotalOnDisk int
MissingObjects []string // manifest entries with no .age file
CorruptObjects []string // objects that fail decrypt or hash mismatch
OrphanObjects []string // .age files not in manifest
Fixed int
}
RepairResult describes the outcome of a seal store integrity check.
type ScanResult ¶
type ScanResult struct {
// RelPath is the path relative to the claude directory.
RelPath string
// AbsPath is the absolute filesystem path.
AbsPath string
// Size in bytes.
Size int64
// ModTime as Unix timestamp (milliseconds).
ModTimeMs int64
}
ScanResult represents a file found during scanning.
type SealStats ¶
SealStats tracks what happened during a seal operation.
func Seal ¶
func Seal(cfg *config.Config, recipient age.Recipient, verbose bool, progress ProgressFunc) (SealStats, error)
Seal encrypts changed files from claudeDir into the seal store.
func (SealStats) HasChanges ¶
HasChanges returns true if the seal produced any modifications worth committing.
type UnsealStats ¶
UnsealStats tracks what happened during an unseal operation.
func Unseal ¶
func Unseal(cfg *config.Config, identity age.Identity, verbose bool, progress ProgressFunc) (UnsealStats, error)
Unseal decrypts seal contents back to claudeDir and removes managed files not in the manifest. The manifest is the source of truth.
func (UnsealStats) String ¶
func (s UnsealStats) String() string