Indexer behaviour (fnord v0.9.22)

View Source

This behaviour wraps the AI-powered operations used by Cmd.Index to allow overrides for testing. See impl/0.

Summary

Functions

Returns the current indexer module. This can be overridden by config for unit testing. See test/test_helper.exs.

Indexes a single entry: reads the source, generates summary and outline in parallel, computes embeddings, and persists everything. Returns the entry struct on success so callers can immediately read its data.

Types

completion()

@type completion() :: {:ok, String.t()}

embeddings()

@type embeddings() :: {:ok, [float()]}

error()

@type error() :: {:error, term()}

file_content()

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

file_path()

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

indexer()

@type indexer() :: module()

Callbacks

get_embeddings(file_content)

@callback get_embeddings(file_content()) :: embeddings() | error()

get_outline(file_path, file_content)

@callback get_outline(file_path(), file_content()) :: completion() | error()

get_summary(file_path, file_content)

@callback get_summary(file_path(), file_content()) :: completion() | error()

Functions

impl()

Returns the current indexer module. This can be overridden by config for unit testing. See test/test_helper.exs.

index_entry(entry)

@spec index_entry(Store.Project.Entry.t()) ::
  {:ok, Store.Project.Entry.t()} | {:error, term()}

Indexes a single entry: reads the source, generates summary and outline in parallel, computes embeddings, and persists everything. Returns the entry struct on success so callers can immediately read its data.

This is the canonical single-file indexing pipeline, used by Cmd.Index for bulk indexing.