Gralkor.Generalise (jido_gralkor v4.0.0)

Copy Markdown View Source

Orchestrate one generalisation run: hypothesise generalisations from a transcript, search existing generalisations to rule candidates in or out, evaluate relationships, and persist the strongest.

Pure orchestration — all dependencies (hypothesise LLM call, evaluate LLM call, search, add_episode, remove_episode) are passed as functions in opts. Production wiring lives in Gralkor.Client.Native.

See ex-generalise in TEST_TREES.md.

Summary

Functions

Schema for the evaluate LLM call. Returns a decision per hypothesis relative to any existing generalisations found via search.

Run the full generalisation pipeline against a flushed transcript.

Schema for the hypothesise LLM call. Returns a list of candidate generalisations with confidence scores.

Types

group_id()

@type group_id() :: String.t()

opts()

@type opts() :: [
  hypothesise_fn: function(),
  search_gen_fn: function(),
  evaluate_fn: function(),
  add_episode_fn: function(),
  remove_episode_fn: function(),
  min_confidence: float(),
  max_gen_results: pos_integer()
]

Functions

evaluate_schema()

Schema for the evaluate LLM call. Returns a decision per hypothesis relative to any existing generalisations found via search.

generalise(group_id, transcript, opts)

@spec generalise(group_id(), String.t(), opts()) :: :ok | {:error, term()}

Run the full generalisation pipeline against a flushed transcript.

Returns :ok (best-effort — failures are logged but do not propagate), or {:error, term()} when no required opts keys are provided.

hypothesise_schema()

Schema for the hypothesise LLM call. Returns a list of candidate generalisations with confidence scores.