LemonMemory.TaskFingerprint (lemon_memory v0.1.0)

View Source

Coarse task fingerprint derived from a finalized run.

A fingerprint groups runs by the dimensions that matter for routing decisions: what the user was trying to do (:task_family), which tools were involved, which workspace the run belonged to, and which model/provider served it.

Fingerprints are intentionally coarse — granular enough to accumulate signal across similar runs, but not so specific that each run gets its own bucket.

Fields

  • :task_family — broad semantic category of the task (see "Task families" below)
  • :toolset — sorted unique list of tool names used during the run
  • :workspace_key — workspace identifier, or nil for session-scoped runs
  • :model — LLM model name, or nil if unknown
  • :provider — LLM provider name, or nil if unknown

Task families

FamilySignals
:codeImplement, fix, debug, refactor, build, write, test, deploy
:queryExplain, describe, analyze, compare, review, summarize
:file_opsRead, write, create, delete, move, rename, find
:chatShort conversational turns (yes/no/thanks/status)
:unknownDefault when no signal is detected

Fingerprint key

key/1 serialises a fingerprint to a stable string suitable for use as a SQLite key or map key. The key is constructed from sorted, lowercased dimensions joined by | so it remains human-readable in debug output.

Summary

Functions

Classify a prompt text into a task family atom.

Returns the 3-segment context key for cross-model comparison.

Build a TaskFingerprint from a Document.

Serialise a fingerprint to a stable, deterministic string key.

Returns the valid task family atoms.

Types

t()

@type t() :: %LemonMemory.TaskFingerprint{
  model: String.t() | nil,
  provider: String.t() | nil,
  task_family: task_family(),
  toolset: [String.t()],
  workspace_key: String.t() | nil
}

task_family()

@type task_family() :: :code | :query | :file_ops | :chat | :unknown

Functions

classify_prompt(prompt)

@spec classify_prompt(String.t() | nil) :: task_family()

Classify a prompt text into a task family atom.

Returns one of :code, :query, :file_ops, :chat, or :unknown.

context_key(fp)

@spec context_key(t()) :: String.t()

Returns the 3-segment context key for cross-model comparison.

Strips the provider and model dimensions so the key can be used to look up historical performance across different models serving the same task context.

Format: family|toolset|workspace

from_document(doc)

@spec from_document(LemonMemory.Document.t()) :: t()

Build a TaskFingerprint from a Document.

key(fp)

@spec key(t()) :: String.t()

Serialise a fingerprint to a stable, deterministic string key.

The format is family|toolset|workspace|provider|model where each segment is lowercased and missing values are replaced with "-".

task_families()

@spec task_families() :: [task_family()]

Returns the valid task family atoms.