Raxol.Agent.Memory.SessionSearch (Raxol Agent v2.6.0)

Copy Markdown View Source

Full-text recall over raw conversation history.

Distinct from semantic memory (Raxol.Agent.Memory.Store.Ets, which recalls curated Records), this is an inverted index over Raxol.Agent.Conversation item text. It answers "what did we say about X earlier" by returning the RAW matching items, not summaries.

Items are tokenized with Raxol.Agent.Memory.Record.tokenize/1 (the same tokenizer the semantic store uses) and ranked with the same length-normalized BM25-lite scoring. The index is fed either explicitly with index/2, or by attach/3, which subscribes to a Raxol.Agent.Conversation.Log and indexes its snapshot plus every appended item.

Tables (derived from the registered name)

  • primary :set { {conversation_id, seq}, %{item, len} }
  • Tok :bag {token, {conversation_id, seq}} -- inverted index
  • DF :set {token, doc_freq} plus {:__N__, doc_count} and {:__DL__, total_doc_len} for idf and average document length

Summary

Functions

Subscribe to a Conversation.Log and index its snapshot plus every appended item for conversation_id.

Returns a specification to start this module under a supervisor.

Remove every indexed item.

Index a list of conversation items (each needs conversation_id, seq, type, data).

Derived ETS table names. Public for tests and tooling.

Full-text search over indexed items, returning the raw matching items ranked by relevance. Options: :limit (default 10), :conversation_id to scope to one conversation.

Functions

attach(server \\ __MODULE__, log, conversation_id)

@spec attach(GenServer.server(), GenServer.server(), binary()) :: :ok

Subscribe to a Conversation.Log and index its snapshot plus every appended item for conversation_id.

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

clear(server \\ __MODULE__)

@spec clear(GenServer.server()) :: :ok

Remove every indexed item.

df_table(name)

@spec df_table(atom()) :: atom()

handle_manager_cast(msg, state)

Callback implementation for Raxol.Core.Behaviours.BaseManager.handle_manager_cast/2.

index(server \\ __MODULE__, items)

@spec index(GenServer.server(), [map()]) :: :ok

Index a list of conversation items (each needs conversation_id, seq, type, data).

primary_table(name)

@spec primary_table(atom()) :: atom()

Derived ETS table names. Public for tests and tooling.

search(server \\ __MODULE__, query, opts \\ [])

@spec search(GenServer.server(), String.t(), keyword()) :: [map()]

Full-text search over indexed items, returning the raw matching items ranked by relevance. Options: :limit (default 10), :conversation_id to scope to one conversation.

start_link(init_opts \\ [])

@spec start_link(keyword()) :: GenServer.on_start()

tok_table(name)

@spec tok_table(atom()) :: atom()