application

package
v0.32.0 Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package application defines the orchestration layer between presentation adapters and the domain model.

This layer contains write-side use cases, read-side query-service contracts, and shared DTOs used to move structured data across those boundaries without leaking infrastructure concerns into the domain.

Index

Constants

This section is empty.

Variables

View Source
var ErrHookConfigInvalidHooksField = xerrors.New("hooks field must be an object of hook arrays")

ErrHookConfigInvalidHooksField indicates that a hook configuration file contained a top-level "hooks" field that was not an object of hook arrays.

View Source
var ErrHookConfigNotJSONObject = xerrors.New("config file must be a JSON object")

ErrHookConfigNotJSONObject indicates that a hook configuration file was successfully read but its top-level payload was not a JSON object.

Functions

This section is empty.

Types

type AntigravityUsageRepository added in v0.32.0

type AntigravityUsageRepository interface {
	model.UsageObservationRepository
	FindSnapshotHead(context.Context, string) (types.Optional[*model.UsageObservation], error)
}

AntigravityUsageRepository persists observations and exposes the current immutable snapshot head without leaking SQL details into the use case.

type AntigravityUsageSnapshot added in v0.32.0

type AntigravityUsageSnapshot struct {
	ConversationID types.SessionID
	Model          string
	SourceVersion  string
	ObservedAt     time.Time
	InputTokens    int64
	OutputTokens   int64
}

AntigravityUsageSnapshot contains the allowlisted cumulative fields from one idle status-line payload.

type AntigravityUsageSource added in v0.32.0

type AntigravityUsageSource interface {
	Decode(context.Context, io.Reader) (*AntigravityUsageSnapshot, error)
}

AntigravityUsageSource decodes only body-free, allowlisted status-line metadata. A nil snapshot is the supported result for non-idle states.

type ArchiveTableData added in v0.28.0

type ArchiveTableData struct {
	Name       string
	PrimaryKey []string
	Rows       []map[string]any
}

ArchiveTableData is a named table payload for store archive packages.

type ClaudeHeadlessUsageStream added in v0.32.0

type ClaudeHeadlessUsageStream interface {
	io.Writer
	Complete() (ClaudeUsageLoadResult, error)
}

ClaudeHeadlessUsageStream forwards a Traceary-owned Claude JSON stream while retaining only terminal body-free usage metadata.

type ClaudeHeadlessUsageStreamFactory added in v0.32.0

type ClaudeHeadlessUsageStreamFactory interface {
	New(io.Writer) ClaudeHeadlessUsageStream
}

ClaudeHeadlessUsageStreamFactory creates one bounded stream adapter per run.

type ClaudePluginDetection added in v0.8.2

type ClaudePluginDetection struct {
	// Active is true when the user's ~/.claude/settings.json lists a
	// Traceary plugin under enabledPlugins with value true.
	Active bool
	// SettingsPath is the absolute path that was consulted.
	SettingsPath string
	// PluginKey is the enabledPlugins key that matched, e.g.
	// "traceary@traceary-plugins". Empty when Active is false.
	PluginKey string
}

ClaudePluginDetection reports whether the Traceary Claude Code plugin is enabled in the user's global Claude settings.

type ClaudePluginDetector added in v0.8.2

type ClaudePluginDetector interface {
	DetectClaudeTracearyPluginIn(home string) ClaudePluginDetection
}

ClaudePluginDetector resolves whether the Traceary Claude Code plugin is enabled for the given host home directory. Presentation callers depend on this interface so the presentation layer stays free of direct infrastructure imports.

type ClaudeUsageCaptureMode added in v0.32.0

type ClaudeUsageCaptureMode string

ClaudeUsageCaptureMode fixes the authoritative representation for a Claude run.

const (
	// ClaudeUsageModeTranscriptCalls records unique interactive assistant requests.
	ClaudeUsageModeTranscriptCalls ClaudeUsageCaptureMode = "transcript_calls"
	// ClaudeUsageModeOneShotStream records only the terminal one-shot result.
	ClaudeUsageModeOneShotStream ClaudeUsageCaptureMode = "one_shot_stream"
)

type ClaudeUsageCounters added in v0.32.0

type ClaudeUsageCounters struct {
	InputTokens           *int64
	CachedInputTokens     *int64
	CacheWriteInputTokens *int64
	OutputTokens          *int64
	ReasoningOutputTokens *int64
	TotalTokens           *int64
}

ClaudeUsageCounters preserves provider field presence. Nil is unavailable; a pointer to zero is a provider-reported known zero.

type ClaudeUsageLoadCriteria added in v0.32.0

type ClaudeUsageLoadCriteria struct {
	SessionID types.SessionID
}

ClaudeUsageLoadCriteria selects one host-owned Claude transcript.

type ClaudeUsageLoadResult added in v0.32.0

type ClaudeUsageLoadResult struct {
	Mode             ClaudeUsageCaptureMode
	Samples          []ClaudeUsageSample
	BoundaryObserved bool
}

ClaudeUsageLoadResult contains the selected representation and any retained legacy evidence. Empty is a supported explicit outcome.

type ClaudeUsageRepository added in v0.32.0

type ClaudeUsageRepository interface {
	model.UsageObservationRepository
}

ClaudeUsageRepository persists provider-neutral observations idempotently.

type ClaudeUsageSample added in v0.32.0

type ClaudeUsageSample struct {
	RecordID      string
	SourceName    string
	SourceVersion string
	Model         string
	Scope         types.UsageScope
	ObservedAt    time.Time
	TerminalCode  types.UsageTerminalCode
	Available     bool
	Counters      ClaudeUsageCounters
}

ClaudeUsageSample is one body-free authoritative call or run record.

type ClaudeUsageSource added in v0.32.0

type ClaudeUsageSource interface {
	Load(context.Context, ClaudeUsageLoadCriteria) (ClaudeUsageLoadResult, error)
}

ClaudeUsageSource reads only body-free usage metadata from local Claude files.

type CodexHeadlessUsageStream added in v0.32.0

type CodexHeadlessUsageStream interface {
	io.Writer
	Complete() (CodexUsageLoadResult, error)
}

CodexHeadlessUsageStream forwards a Traceary-owned Codex exec JSON stream while retaining only body-free terminal usage metadata in memory.

type CodexHeadlessUsageStreamFactory added in v0.32.0

type CodexHeadlessUsageStreamFactory interface {
	New(destination io.Writer) CodexHeadlessUsageStream
}

CodexHeadlessUsageStreamFactory creates one bounded stream adapter per supervised Codex exec invocation.

type CodexMemorySource added in v0.7.0

type CodexMemorySource interface {
	// Load walks the configured root (criteria.Root) and returns candidate
	// rows. Implementations are expected to perform path containment
	// checks — the returned slice must only contain rows whose source path
	// stays inside the resolved root — and to emit non-fatal issues via
	// the warnings return value so the usecase can forward them to the
	// CLI.
	Load(ctx context.Context, criteria apptypes.CodexImportCriteria) ([]apptypes.ImportedMemoryCandidate, []string, error)
}

CodexMemorySource reads raw candidate rows out of a Codex memory layout (for example ~/.codex/memories/*.md). It is declared in the application package so the usecase can depend on the interface and the filesystem adapter can supply the concrete reader without dragging in parser-specific types.

type CodexUsageCounters added in v0.32.0

type CodexUsageCounters struct {
	InputTokens           *int64
	CachedInputTokens     *int64
	CacheWriteInputTokens *int64
	OutputTokens          *int64
	ReasoningOutputTokens *int64
	TotalTokens           *int64
}

CodexUsageCounters preserves field presence from the verified Codex source. A nil field is unavailable; a pointer to zero is known zero.

type CodexUsageLoadCriteria added in v0.32.0

type CodexUsageLoadCriteria struct {
	SessionID types.SessionID
}

CodexUsageLoadCriteria selects one host-owned Codex session transcript.

type CodexUsageLoadResult added in v0.32.0

type CodexUsageLoadResult struct {
	Samples          []CodexUsageSample
	BoundaryObserved bool
}

CodexUsageLoadResult contains terminal turns currently visible in the selected source. Empty is a supported explicit outcome.

type CodexUsageRepository added in v0.32.0

type CodexUsageRepository interface {
	model.UsageObservationRepository
	RecordExclusive(
		ctx context.Context,
		key types.UsageExclusivityKey,
		additive, excluded *model.UsageObservation,
	) (model.UsageObservationTransition, error)
}

CodexUsageRepository atomically records normal observations and chooses one additive winner among equivalent headless/rollout source alternatives.

type CodexUsageSample added in v0.32.0

type CodexUsageSample struct {
	RecordID      string
	SuppressionID string
	SourceName    string
	SourceVersion string
	Model         string
	ObservedAt    time.Time
	TerminalCode  types.UsageTerminalCode
	Available     bool
	Counters      CodexUsageCounters
}

CodexUsageSample is one body-free, authoritative terminal-turn record.

type CodexUsageSource added in v0.32.0

type CodexUsageSource interface {
	Load(ctx context.Context, criteria CodexUsageLoadCriteria) (CodexUsageLoadResult, error)
}

CodexUsageSource reads only body-free usage metadata from local Codex files.

type FileRetentionExecutor added in v0.31.0

type FileRetentionExecutor interface {
	ApplyFileRetention(ctx context.Context, plan apptypes.FileRetentionPlan, confirmedPlanID string, now time.Time) (apptypes.FileRetentionApplyResult, error)
}

FileRetentionExecutor applies an exact decoded plan through a crash-retryable adapter.

type FileRetentionInventory added in v0.31.0

type FileRetentionInventory interface {
	InspectFileRetention(ctx context.Context, request apptypes.FileRetentionInventoryRequest) (apptypes.FileRetentionInventorySnapshot, error)
}

FileRetentionInventory provides complete read-only root evidence.

type GeminiHeadlessUsageStream added in v0.32.0

type GeminiHeadlessUsageStream interface {
	io.Writer
	Complete() (GeminiUsageLoadResult, error)
}

GeminiHeadlessUsageStream forwards a Traceary-owned Gemini JSON stream while retaining only terminal body-free usage metadata.

type GeminiHeadlessUsageStreamFactory added in v0.32.0

type GeminiHeadlessUsageStreamFactory interface {
	New(io.Writer) GeminiHeadlessUsageStream
}

GeminiHeadlessUsageStreamFactory creates one bounded adapter per run.

type GeminiUsageCounters added in v0.32.0

type GeminiUsageCounters struct {
	InputTokens       *int64
	CachedInputTokens *int64
	OutputTokens      *int64
	TotalTokens       *int64
}

GeminiUsageCounters preserves field presence from the verified terminal stream contract. Nil is unavailable and a pointer to zero is known zero.

type GeminiUsageLoadResult added in v0.32.0

type GeminiUsageLoadResult struct {
	Samples          []GeminiUsageSample
	BoundaryObserved bool
}

GeminiUsageLoadResult contains one authoritative terminal result.

type GeminiUsageRepository added in v0.32.0

type GeminiUsageRepository interface {
	model.UsageObservationRepository
}

GeminiUsageRepository persists provider-neutral observations idempotently.

type GeminiUsageSample added in v0.32.0

type GeminiUsageSample struct {
	RecordID      string
	SourceName    string
	SourceVersion string
	Model         string
	ObservedAt    time.Time
	TerminalCode  types.UsageTerminalCode
	Available     bool
	Counters      GeminiUsageCounters
}

GeminiUsageSample is one body-free terminal run total. When the result reports model totals, each model is emitted separately and the aggregate total is not emitted again.

type GrokHeadlessUsageStream added in v0.32.0

type GrokHeadlessUsageStream interface {
	io.Writer
	Complete() (GrokUsageLoadResult, error)
}

GrokHeadlessUsageStream forwards a Traceary-owned Grok streaming-json response while retaining only terminal body-free usage metadata.

type GrokHeadlessUsageStreamFactory added in v0.32.0

type GrokHeadlessUsageStreamFactory interface {
	New(io.Writer) GrokHeadlessUsageStream
}

GrokHeadlessUsageStreamFactory creates one bounded adapter per run.

type GrokUsageCounters added in v0.32.0

type GrokUsageCounters struct {
	InputTokens       *int64
	CachedInputTokens *int64
	OutputTokens      *int64
	ReasoningTokens   *int64
	TotalTokens       *int64
}

GrokUsageCounters preserves presence from the verified terminal end.usage contract. Nil is unavailable; a pointer to zero is known zero.

type GrokUsageLoadResult added in v0.32.0

type GrokUsageLoadResult struct {
	Samples          []GrokUsageSample
	BoundaryObserved bool
	TerminalRecordID string
	TerminalCode     types.UsageTerminalCode
}

GrokUsageLoadResult contains one authoritative terminal result. A terminal may be observed without a usage object; its provider identity remains available so unavailable evidence is portable across Traceary sessions.

type GrokUsageRepository added in v0.32.0

type GrokUsageRepository interface {
	model.UsageObservationRepository
}

GrokUsageRepository persists provider-neutral observations idempotently.

type GrokUsageSample added in v0.32.0

type GrokUsageSample struct {
	RecordID      string
	SourceName    string
	SourceVersion string
	Model         string
	ObservedAt    time.Time
	TerminalCode  types.UsageTerminalCode
	Available     bool
	Counters      GrokUsageCounters
}

GrokUsageSample is one body-free terminal request total.

type HookDuplicate added in v0.20.1

type HookDuplicate struct {
	Event      string
	Matcher    string
	ManagedKey string
	Count      int
}

HookDuplicate describes duplicate Traceary-managed hook registrations for the same host event, matcher, and managed command key.

type HookManagedCoverage added in v0.21.0

type HookManagedCoverage struct {
	HasPrompt     bool
	HasTranscript bool
	HasAudit      bool
	HasCompact    bool
}

HookManagedCoverage summarizes which Traceary-managed enrichment surfaces are wired into a host's hook configuration. Boundary coverage (session start/end) is intentionally omitted — the existing `<client>-config` check already covers the "no Traceary hooks at all" state, while this value answers the narrower question doctor's coverage diagnostics need: do installed hooks actually capture prompt, transcript, and shell audit?

func (HookManagedCoverage) MissingEnrichment added in v0.21.0

func (c HookManagedCoverage) MissingEnrichment() []string

MissingEnrichment returns the enrichment surfaces (prompt, transcript, audit) that are not wired by the installed hook config. The list is deterministic so the doctor remediation message is stable across runs.

type HookManagedEntry added in v0.23.0

type HookManagedEntry struct {
	Event      string
	Matcher    string
	Name       string
	ManagedKey string
}

HookManagedEntry identifies one Traceary-owned command in a host hook configuration. Doctor uses this operator-facing identity when it needs to explain which manual entries are safe to remove.

type HookUpgradeDiff added in v0.8.0

type HookUpgradeDiff struct {
	AddedEvents     []string
	RefreshedEvents []string
	PreservedEvents []string
	RemovedEvents   []string
}

HookUpgradeDiff reports which events changed during a non-destructive hook install (merge-only mode). The four slices are disjoint.

AddedEvents : events that had no Traceary-managed commands before

but now do (new hook coverage).

RefreshedEvents : events whose Traceary-managed commands were replaced

with the current release's set (upgrade, binary
rename, or command drift).

PreservedEvents : events whose normalized command set matched; the

merged output is byte-identical for these events,
which is what makes --upgrade idempotent.

RemovedEvents : events present only in the existing config that held

Traceary-managed commands for an event the current
release no longer emits (e.g. a hook retired between
releases). Those stale commands are stripped during
the merge so the upgrade leaves the Traceary footprint
consistent with the running binary.

type HooksClientHandler

type HooksClientHandler interface {
	// Name returns the canonical client identifier (e.g. "claude").
	Name() string

	// Build returns the Hooks aggregate Traceary installs for this client.
	// tracearyBin is the command or path used to launch the traceary binary.
	Build(tracearyBin string) model.Hooks

	// DefaultInstallPath returns the standard configuration file path
	// for this client relative to the given project directory.
	DefaultInstallPath(projectDir string) (string, error)
}

HooksClientHandler encapsulates client-specific knowledge required to install Traceary hooks for a single client (for example Claude Code, Codex CLI, or Gemini CLI).

type HooksInspector

type HooksInspector interface {
	// Inspect parses the given hook configuration content and reports
	// whether it contains a top-level "hooks" field and whether any
	// Traceary-managed hook was detected.
	//
	// Returned errors are the sentinel errors defined in hooks_errors.go:
	// ErrHookConfigNotJSONObject when the payload is not a JSON object and
	// ErrHookConfigInvalidHooksField when the "hooks" field has the wrong
	// shape.
	Inspect(content []byte) (hasHooksField bool, hasTracearyManagedHook bool, err error)
	// DuplicateManagedHooks reports Traceary-managed hook registrations that
	// appear more than once for the same event, matcher, and managed key.
	// Missing hooks fields return an empty slice. Returned errors are the
	// same sentinels as Inspect.
	DuplicateManagedHooks(content []byte) ([]HookDuplicate, error)
	// ExtractManagedKeyFromEntry returns the canonical Traceary-managed
	// key extracted from a hook entry's name / command pair, or an
	// empty string if the entry is not Traceary-managed. Presentation
	// code uses this to recognise installed hook entries without
	// re-implementing the command parsing.
	ExtractManagedKeyFromEntry(name, command string) string
	// ManagedCoverage reports which Traceary-managed enrichment surfaces
	// (prompt, transcript, shell audit, compact) are wired for the given
	// client in the hook configuration content. Missing hooks fields or a
	// payload with no matching Traceary-managed entries return a zero
	// HookManagedCoverage. Returned errors are the same sentinels as
	// Inspect.
	ManagedCoverage(content []byte, client string) (HookManagedCoverage, error)
}

HooksInspector inspects a hook configuration JSON payload and reports high-level state relevant to diagnostics. Implementations live in the infrastructure layer so presentation code can depend only on this interface.

type HooksOrchestrator

type HooksOrchestrator interface {
	// Generate returns the rendered hook configuration bytes for the given
	// client. tracearyBin is the command or path used to launch the traceary
	// binary.
	Generate(ctx context.Context, client string, tracearyBin string) ([]byte, error)

	// GenerateWithMatcher is the matcher-aware variant of Generate. The
	// matcher preset only affects clients that honor a preset (Claude
	// Code today); other clients ignore the value. Empty string means
	// "use the client's default matcher set" and is equivalent to
	// calling Generate directly.
	GenerateWithMatcher(ctx context.Context, client string, tracearyBin string, matcherPreset string) ([]byte, error)

	// Install writes the hook configuration file for the given client.
	// outputPath overrides the default install path when present. force
	// overwrites the existing file instead of merging with it.
	// The returned string is the resolved absolute path that was written.
	Install(
		ctx context.Context,
		client string,
		tracearyBin string,
		projectDir string,
		outputPath types.Optional[string],
		force bool,
	) (string, error)

	// InstallWithMatcher is the matcher-aware variant of Install. The
	// matcher preset only affects clients that honor a preset (Claude
	// Code today); other clients ignore the value. Callers should pass
	// the empty string to request the client's default matcher set,
	// which is equivalent to calling Install directly.
	InstallWithMatcher(
		ctx context.Context,
		client string,
		tracearyBin string,
		projectDir string,
		outputPath types.Optional[string],
		force bool,
		matcherPreset string,
	) (string, error)

	// UpgradeWithMatcher applies the current hook configuration for the
	// given client in merge-only mode (never overwrites) and returns a
	// HookUpgradeDiff describing which events were added, refreshed, or
	// preserved. It is the primary entrypoint for non-destructive
	// migrations from older Traceary releases: the file is left byte
	// identical when already up to date (idempotent).
	UpgradeWithMatcher(
		ctx context.Context,
		client string,
		tracearyBin string,
		projectDir string,
		outputPath types.Optional[string],
		matcherPreset string,
	) (string, HookUpgradeDiff, error)

	// RemoveManaged removes only Traceary-owned commands from an existing hook
	// configuration. When dryRun is true it returns the entries that would be
	// removed without writing. Unrelated hooks and top-level fields are kept.
	RemoveManaged(
		ctx context.Context,
		outputPath string,
		dryRun bool,
	) ([]HookManagedEntry, error)

	// SupportedClients returns the canonical list of supported client
	// identifiers (e.g. "claude", "codex", "gemini").
	SupportedClients() []string

	// NormalizeClient resolves a client alias (e.g. "claude-code") to its
	// canonical identifier (e.g. "claude").
	NormalizeClient(client string) (string, error)

	// ResolveInstallPath returns the configuration file path that Install
	// would write to for the given client and project directory. When
	// outputPath is present it overrides the default install path.
	ResolveInstallPath(
		client string,
		projectDir string,
		outputPath types.Optional[string],
	) (string, error)
}

HooksOrchestrator is the application-level entrypoint for hook generation and installation. It resolves the correct HooksClientHandler for a client alias, builds the Hooks aggregate, and renders or writes it to disk.

type KimiUsageCounters added in v0.32.0

type KimiUsageCounters struct {
	InputOther         *int64
	InputCacheRead     *int64
	InputCacheCreation *int64
	Output             *int64
}

KimiUsageCounters preserves field presence from Kimi's verified usage.record contract. Nil is unavailable; a pointer to zero is known zero.

type KimiUsageLoadResult added in v0.32.0

type KimiUsageLoadResult struct {
	Samples           []KimiUsageSample
	LatestTurnOrdinal int64
}

KimiUsageLoadResult contains the verified source rows and the latest stable turn ordinal observed without decoding prompt or content bodies.

type KimiUsageRepository added in v0.32.0

type KimiUsageRepository interface {
	model.UsageObservationRepository
}

KimiUsageRepository persists provider-neutral observations idempotently.

type KimiUsageSample added in v0.32.0

type KimiUsageSample struct {
	RecordID      string
	SourceName    string
	SourceVersion string
	Model         string
	ObservedAt    time.Time
	Counters      KimiUsageCounters
}

KimiUsageSample is one body-free, partial source record from a session wire.

type KimiUsageSource added in v0.32.0

type KimiUsageSource interface {
	Load(context.Context, string) (KimiUsageLoadResult, error)
}

KimiUsageSource loads body-free usage metadata for one provider session.

type OneShotRepairSafetyStore added in v0.31.0

type OneShotRepairSafetyStore interface {
	CreateBackup(ctx context.Context, outputPath string, overwrite bool) error
	Initialize(ctx context.Context) error
}

OneShotRepairSafetyStore provides the mandatory rollback snapshot and store preparation.

type OneShotRepairStore added in v0.31.0

type OneShotRepairStore interface {
	PreviewOneShotSessions(ctx context.Context, params apptypes.OneShotRepairParams) (apptypes.OneShotRepairResult, error)
	ApplyOneShotSessions(ctx context.Context, params apptypes.OneShotRepairParams) (apptypes.OneShotRepairResult, error)
}

OneShotRepairStore exposes distinct no-write preview and atomic persistence paths.

type PluginCacheInspector added in v0.8.2

type PluginCacheInspector interface {
	// DetectClaudePluginCacheStatus resolves the cached plugin version
	// and the marketplace plugin.json version for the given pluginKey
	// (of the form "<plugin>@<marketplace>"). Missing caches and
	// missing marketplace clones are reported via empty fields rather
	// than as errors; only structural IO errors surface through the
	// returned struct.
	DetectClaudePluginCacheStatus(home, pluginKey string) PluginCacheStatus
}

PluginCacheInspector reports the state of the host's Traceary plugin cache (currently only Claude Code has this concept). Implementations live in the infrastructure layer so presentation code depends only on this interface.

type PluginCacheStatus added in v0.8.2

type PluginCacheStatus struct {
	// CachePath is the directory scanned for cached plugin versions.
	// Empty when detection could not resolve it.
	CachePath string
	// CachedVersion is the highest version found under CachePath.
	// Empty when no versioned directory exists (plugin never cached).
	CachedVersion string
	// CachedVersions lists every non-orphaned versioned cache
	// directory found under CachePath, sorted from highest to lowest
	// by semver. Diagnostics use the full list to detect the
	// session-snapshot ambiguity reported in #670.
	CachedVersions []string
	// MarketplaceVersion is the plugin.json "version" Claude Code
	// sees via `~/.claude/plugins/marketplaces/<marketplace>/...`.
	// Empty when the marketplace clone is missing.
	MarketplaceVersion string
	// MarketplacePath is the plugin.json path that was read (empty if
	// the read failed).
	MarketplacePath string
}

PluginCacheStatus describes the cached Traceary plugin version alongside the version the marketplace currently advertises. When the two drift (e.g. operator ran `brew upgrade traceary` without `claude plugins update`), the host continues to run an older hook set than the CLI supports.

func (PluginCacheStatus) HasMultipleCachedVersions added in v0.8.2

func (s PluginCacheStatus) HasMultipleCachedVersions() bool

HasMultipleCachedVersions reports whether the plugin's cache directory holds more than one non-orphaned version subdirectory. When true, a resumed Claude Code session could have snapshotted its hook registry against any of them, so operators should restart without `--continue` to guarantee the newest hooks are live.

func (PluginCacheStatus) Stale added in v0.8.2

func (s PluginCacheStatus) Stale() bool

Stale reports whether the cached plugin is at an older semver than the marketplace currently offers. Returns false when either version is unresolved — a missing cache or missing marketplace is surfaced to the caller through the struct fields rather than as "stale".

type RawBodyRetentionExecutor added in v0.31.0

type RawBodyRetentionExecutor interface {
	ApplyRawBodyPlan(ctx context.Context, databaseIdentity string, sqliteUserVersion int, migrationDigest, planID string, candidates []apptypes.RawBodyCandidate, appliedAt time.Time) (apptypes.RawBodyApplyResult, error)
	RestoreRawBodyPlan(ctx context.Context, databaseIdentity string, sqliteUserVersion int, migrationDigest, planID string, bodies []apptypes.RawBodyRecoveryBody, restoredAt time.Time) (apptypes.RawBodyRestoreResult, error)
}

RawBodyRetentionExecutor applies and restores exact reviewed body identities.

type RawBodyRetentionPlanner added in v0.31.0

type RawBodyRetentionPlanner interface {
	ListRawBodyCandidates(ctx context.Context, before time.Time) (apptypes.RawBodyRetentionSnapshot, error)
}

RawBodyRetentionPlanner provides a body-free snapshot for immutable plan creation.

type StoreArchiver added in v0.28.0

type StoreArchiver interface {
	// ListArchiveEligible returns full row maps for GC-eligible records.
	ListArchiveEligible(ctx context.Context, before time.Time, target apptypes.GarbageCollectionTarget) ([]ArchiveTableData, error)
	// DeleteArchiveRows deletes exact primary-key sets in FK-safe order.
	// idsByTable maps table name → composite id strings (NUL-separated for multi-column PKs).
	DeleteArchiveRows(ctx context.Context, idsByTable map[string][]string) (int, error)
	// RestoreArchiveRows inserts rows idempotently. Conflicts (same PK, different content) are counted.
	RestoreArchiveRows(ctx context.Context, tables []ArchiveTableData, dryRun bool) (inserted, skipped, conflicts int, err error)
}

StoreArchiver selects, deletes, and restores cold rows for archive-before-GC. Implemented by the SQLite store manager; optional for lightweight test stubs.

type StoreManager

type StoreManager interface {
	// Initialize creates the store and applies migrations.
	Initialize(ctx context.Context) error
	// CreateBackup creates a backup of the store.
	CreateBackup(ctx context.Context, outputPath string, overwrite bool) error
	// RestoreBackup restores a backup.
	RestoreBackup(ctx context.Context, inputPath string, overwrite bool) error
	// CollectGarbage removes events older than the given time. Returns the count of deleted events.
	CollectGarbage(ctx context.Context, before time.Time, target apptypes.GarbageCollectionTarget, dryRun bool) (int, error)
	// CloseStaleSessions closes sessions that started before the threshold and
	// have no activity inside it, excluding the protected active sessions.
	CloseStaleSessions(ctx context.Context, staleAfter time.Duration, dryRun bool, protectedSessionIDs []types.SessionID) (int, error)
	// DedupeContentEvents reports (and, when params.Apply is set, quarantines)
	// historical hook-originated prompt/transcript duplicate rows. It never hard-
	// deletes: duplicates are moved into the reversible quarantine archive.
	DedupeContentEvents(ctx context.Context, params apptypes.ContentEventDedupeParams) (apptypes.ContentEventDedupeResult, error)
	// RestoreContentEventDedupeRun moves the rows quarantined by the given dedupe
	// run back into events. It fails rather than overwrite if an original event
	// id already exists in events.
	RestoreContentEventDedupeRun(ctx context.Context, runID string) (apptypes.ContentEventDedupeRestoreResult, error)
}

StoreManager provides store lifecycle and maintenance operations.

Directories

Path Synopsis
Package hostcoverage is the machine-readable source of truth for the per-host lifecycle capture matrix used by doctor diagnostics and the bilingual host-coverage docs table.
Package hostcoverage is the machine-readable source of truth for the per-host lifecycle capture matrix used by doctor diagnostics and the bilingual host-coverage docs table.
Package marketplace provides helpers for reading local plugin marketplace manifests shared by host-specific integration flows.
Package marketplace provides helpers for reading local plugin marketplace manifests shared by host-specific integration flows.
Package queryservice defines read-only application services.
Package queryservice defines read-only application services.
Package redaction provides shared audit-payload redaction helpers that can be consumed both by application/usecase implementations and by presentation-layer callers (e.g.
Package redaction provides shared audit-payload redaction helpers that can be consumed both by application/usecase implementations and by presentation-layer callers (e.g.
Package sensitivepath classifies command audits for sensitive path/intent access.
Package sensitivepath classifies command audits for sensitive path/intent access.
Package types defines application-layer DTOs, criteria objects, and read models shared by usecase and queryservice boundaries.
Package types defines application-layer DTOs, criteria objects, and read models shared by usecase and queryservice boundaries.
Package usecase — bundle usecase implements the v0.9 portability primitive introduced for #572: a local-first, encrypted, content-verifiable archive that operators can move between their machines through any file-transport they already have (AirDrop, scp, Syncthing, etc.).
Package usecase — bundle usecase implements the v0.9 portability primitive introduced for #572: a local-first, encrypted, content-verifiable archive that operators can move between their machines through any file-transport they already have (AirDrop, scp, Syncthing, etc.).

Jump to

Keyboard shortcuts

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