KetraTerm
API · DevelopmentAll versions

TerminalCompletionLearningStore

class TerminalCompletionLearningStore @JvmOverloads constructor(replayFilter: Predicate<String>, capacity: Int = DEFAULT_CAPACITY)

Mutable, bounded in-memory store for exact command completion learning.

Hosts record command lifecycle outcomes and explicit popup feedback. Optional persistence may hydrate the store once through mergeSnapshot and persist snapshot values. The store performs no I/O and does not emit candidates. Mutations are serialized around one mutable exact index. Ranking rows retain only opaque identities; plaintext replay is attached only to successful commands that both TerminalCompletionReplayPolicy and replayFilter approve. Published snapshots are immutable and retain identity until their contents change.

The host filter is an additional admission restriction for executions and imported replay rows. Returning false for every command disables plaintext replay while preserving opaque ranking evidence. The filter runs synchronously outside the store lock, only after the built-in policy approves a command. It may run concurrently and must be thread-safe and consistent for this store's lifetime. Failures propagate before the operation records or merges evidence. Admission filtering does not retroactively remove previously retained rows.

Parameters

replayFilter

additional host restriction on plaintext replay retention.

capacity

maximum distinct exact-command rows retained.

Throws

if capacity is not positive.

Constructors

Link copied to clipboard
constructor(replayFilter: Predicate<String>, capacity: Int = DEFAULT_CAPACITY)
constructor(capacity: Int = DEFAULT_CAPACITY)

Creates a store using only the built-in plaintext replay policy.

Functions

Link copied to clipboard
fun clear()

Removes all retained ranking evidence and replay commands.

Link copied to clipboard

Adds distinct aggregate events from snapshot to retained learning.

Link copied to clipboard
fun recordCommandResult(commandLine: String, successful: Boolean, profileId: String?, workingDirectoryUri: String?, usedAtEpochMillis: Long): Boolean

Records a completed command execution.

Link copied to clipboard
fun recordSuggestionFeedback(commandLine: String, feedback: TerminalCompletionFeedbackKind, profileId: String?, workingDirectoryUri: String?, feedbackAtEpochMillis: Long): Boolean

Records explicit user feedback for the exact suggested command.

Link copied to clipboard

Returns the current immutable exact-command statistics snapshot.