source

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2026 License: GPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrResumeTargetIDEmpty = errors.New("resume target id is empty")
	ErrResumeDirEmpty      = errors.New("resume directory is empty")
	ErrResumeDirNotDir     = errors.New("resume directory is not a directory")
)
View Source
var ErrMalformedRawData = errors.New("malformed raw data")

Functions

func Dedupe

func Dedupe[T comparable](values []T) []T

Dedupe returns a stable deduplicated copy of values.

func DedupeAndSort

func DedupeAndSort(values []string) []string

DedupeAndSort returns a sorted, deduplicated copy of values, skipping empty strings.

func FileNeedsSync

func FileNeedsSync(srcInfo os.FileInfo, dstPath string) bool

FileNeedsSync returns true if the destination is missing, different, or older.

func FileNeedsSyncInfo

func FileNeedsSyncInfo(srcInfo, dstInfo os.FileInfo) bool

FileNeedsSyncInfo compares pre-obtained source and destination file info. Use this when both infos are already available to avoid redundant stat calls.

func FindInsertPosition

func FindInsertPosition[T any](items []T, anchor time.Time, timestamp func(T) time.Time) int

FindInsertPosition returns the index after the latest timestamp not after anchor.

func FirstNonZeroTime

func FirstNonZeroTime[T any](items []T, timestamp func(T) time.Time) time.Time

FirstNonZeroTime returns the first non-zero time from items, or zero if none found.

func InsertAt

func InsertAt[T any](items []T, index int, item T) []T

InsertAt inserts a single item at the given index.

func InsertSliceAt

func InsertSliceAt[T any](items []T, index int, inserted []T) []T

InsertSliceAt inserts multiple items at the given index.

func MarkMalformedRawData added in v0.4.0

func MarkMalformedRawData(err error) error

func ProviderRawDir

func ProviderRawDir(archiveDir string, provider conv.Provider) string

ProviderRawDir returns the provider-specific raw archive path.

func SortedKeys

func SortedKeys(values map[string]struct{}) []string

SortedKeys returns the keys of a set as a sorted slice.

func StatDir

func StatDir(path string) (bool, error)

StatDir returns whether path exists and is a directory.

func ValidateResumeTarget

func ValidateResumeTarget(target conv.ResumeTarget) error

ValidateResumeTarget applies the shared strict resume policy.

Types

type Analysis

type Analysis struct {
	UnitsTotal       int
	FilesInspected   int
	Conversations    int
	NewConversations int
	ToUpdate         int
	UpToDate         int
	SyncCandidates   []string
}

Analysis describes provider-local import state before syncing raw files.

type Backend

type Backend interface {
	Provider() conv.Provider
	Scan(ctx context.Context, rawDir string) (ScanResult, error)
	Load(ctx context.Context, conversation conv.Conversation) (conv.Session, error)
	LoadSession(ctx context.Context, conversation conv.Conversation, meta conv.SessionMeta) (conv.Session, error)
	Analyze(ctx context.Context, sourceDir, rawDir string, onProgress func(Progress)) (Analysis, error)
	SyncCandidates(ctx context.Context, sourceDir, rawDir string) ([]SyncCandidate, error)
	ResumeCommand(target conv.ResumeTarget) (*exec.Cmd, error)
}

Backend is the generic provider contract used by archive, canonical, and app.

type DriftFinding added in v0.2.0

type DriftFinding struct {
	Category string
	Value    string
}

DriftFinding identifies one unknown field or type observed during a scan.

type DriftReport added in v0.2.0

type DriftReport struct {
	// contains filtered or unexported fields
}

DriftReport accumulates unique findings for one provider scan pass.

func NewDriftReport added in v0.2.0

func NewDriftReport() DriftReport

func (DriftReport) Count added in v0.2.0

func (r DriftReport) Count() int

func (DriftReport) Empty added in v0.2.0

func (r DriftReport) Empty() bool

func (DriftReport) Findings added in v0.2.0

func (r DriftReport) Findings() []DriftFinding

func (DriftReport) GroupedByCategory added in v0.2.0

func (r DriftReport) GroupedByCategory() map[string][]string

func (DriftReport) Log added in v0.2.0

func (r DriftReport) Log(ctx context.Context, provider conv.Provider)

func (*DriftReport) Merge added in v0.2.0

func (r *DriftReport) Merge(other DriftReport)

func (*DriftReport) Record added in v0.2.0

func (r *DriftReport) Record(category, value string)

type IncrementalLookup

type IncrementalLookup interface {
	ConversationByFilePath(ctx context.Context, provider conv.Provider, filePath string) (conv.Conversation, bool, error)
	ConversationBySessionID(ctx context.Context, provider conv.Provider, sessionID string) (conv.Conversation, bool, error)
	ConversationByCacheKey(ctx context.Context, cacheKey string) (conv.Conversation, bool, error)
}

IncrementalLookup provides canonical-store conversation lookups for provider-local targeted rebuild resolution.

type IncrementalResolution

type IncrementalResolution struct {
	Conversations                  []conv.Conversation
	ReplaceCacheKeysByConversation map[string][]string
	DeleteCacheKeys                []string
	Drift                          DriftReport
	MalformedData                  MalformedDataReport
}

IncrementalResolution describes the exact conversations that should be replaced during a targeted canonical rebuild.

type IncrementalResolver

type IncrementalResolver interface {
	ResolveIncremental(
		ctx context.Context,
		rawDir string,
		changedRawPaths []string,
		lookup IncrementalLookup,
	) (IncrementalResolution, error)
}

IncrementalResolver is an optional provider hook for targeted canonical rebuilds driven by changed raw paths.

type MalformedDataReport added in v0.4.0

type MalformedDataReport struct {
	// contains filtered or unexported fields
}

func NewMalformedDataReport added in v0.4.0

func NewMalformedDataReport() MalformedDataReport

func (MalformedDataReport) Count added in v0.4.0

func (r MalformedDataReport) Count() int

func (MalformedDataReport) Empty added in v0.4.0

func (r MalformedDataReport) Empty() bool

func (*MalformedDataReport) Merge added in v0.4.0

func (r *MalformedDataReport) Merge(other MalformedDataReport)

func (*MalformedDataReport) Record added in v0.4.0

func (r *MalformedDataReport) Record(value string)

func (MalformedDataReport) Values added in v0.4.0

func (r MalformedDataReport) Values() []string

type Progress

type Progress struct {
	Provider         conv.Provider
	UnitsCompleted   int
	UnitsTotal       int
	FilesInspected   int
	Conversations    int
	NewConversations int
	ToUpdate         int
	CurrentUnit      string
	Err              error
}

Progress reports provider-local analysis progress using provider-neutral terms.

type ProviderDriftReports added in v0.2.0

type ProviderDriftReports = ProviderReports[DriftReport, *DriftReport]

ProviderDriftReports keeps per-provider drift findings for one import or rebuild.

func NewProviderDriftReports added in v0.2.0

func NewProviderDriftReports() ProviderDriftReports

type ProviderMalformedDataReports added in v0.4.0

type ProviderMalformedDataReports = ProviderReports[MalformedDataReport, *MalformedDataReport]

func NewProviderMalformedDataReports added in v0.4.0

func NewProviderMalformedDataReports() ProviderMalformedDataReports

type ProviderReports added in v0.4.0

type ProviderReports[R any, PR providerReport[R]] struct {
	// contains filtered or unexported fields
}

ProviderReports keeps one report per provider for one import or rebuild pass.

func NewProviderReports added in v0.4.0

func NewProviderReports[R any, PR providerReport[R]]() ProviderReports[R, PR]

func (ProviderReports[R, PR]) Count added in v0.4.0

func (r ProviderReports[R, PR]) Count() int

func (ProviderReports[R, PR]) Empty added in v0.4.0

func (r ProviderReports[R, PR]) Empty() bool

func (*ProviderReports[R, PR]) Merge added in v0.4.0

func (r *ProviderReports[R, PR]) Merge(other ProviderReports[R, PR])

func (*ProviderReports[R, PR]) MergeProvider added in v0.4.0

func (r *ProviderReports[R, PR]) MergeProvider(provider conv.Provider, report R)

func (ProviderReports[R, PR]) Providers added in v0.4.0

func (r ProviderReports[R, PR]) Providers() []conv.Provider

func (ProviderReports[R, PR]) Report added in v0.4.0

func (r ProviderReports[R, PR]) Report(provider conv.Provider) R

type ScanResult added in v0.2.0

type ScanResult struct {
	Conversations []conv.Conversation
	Drift         DriftReport
	MalformedData MalformedDataReport
}

ScanResult contains provider scan output and observed format drift.

type SyncCandidate

type SyncCandidate struct {
	SourcePath string
	DestPath   string
	DestExists bool
}

SyncCandidate is a backend-owned raw-file sync plan item.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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