Raxol.Agent.Memory.Store.Ets (Raxol Agent v2.6.0)

Copy Markdown View Source

Default cross-session memory provider: a self-contained ETS+DETS store.

Follows the Raxol.Payments.Mandate.Store pattern: a GenServer owns writes, reads bypass through ETS directly (read_concurrency: true). Table names are derived from the registered name, so multiple instances can coexist via a distinct :name.

Tables (derived from the server name)

  • primary :set {id, record}
  • Tok :bag {token, id} - inverted index
  • Tag :bag {tag, id}
  • Agent :bag {agent_id, id} - per-agent partition
  • DF :set {token, doc_freq} plus {:__N__, doc_count} and {:__DL__, total_doc_len} for IDF / average document length

Only the primary records are persisted to DETS (:dets_path opt or the :memory_store_path Application key); every secondary index, including DF, is rebuilt from the primary records on open, so no stale index can survive a restart.

Ranking (pure Elixir, no SQLite/NIF)

score = relevance + recency + tag_bonus, where relevance is a length- normalized BM25-lite sum of IDF over matching query tokens, recency decays exponentially from last_accessed, and tag_bonus rewards tag overlap. An empty query degrades to recency-only most-recent-N (the prefetch default).

Summary

Functions

Returns a specification to start this module under a supervisor.

Remove all entries. Intended for tests.

Every stored record, in unspecified order.

Derived ETS table names. Public for tests and tooling.

Functions

agent_table(server)

@spec agent_table(atom()) :: atom()

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 all entries. Intended for tests.

df_table(server)

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

handle_manager_info(msg, state)

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

list_all(server \\ __MODULE__)

@spec list_all(atom()) :: [Raxol.Agent.Memory.Record.t()]

Every stored record, in unspecified order.

primary_table(server)

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

Derived ETS table names. Public for tests and tooling.

start_link(init_opts \\ [])

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

tag_table(server)

@spec tag_table(atom()) :: atom()

tok_table(server)

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