Beamscope.Callgraph.Store (Beamscope v0.1.2)

Copy Markdown View Source

Caches built call graphs per repo path so repeated queries (e.g. from MCP tool calls) don't re-walk and re-parse the whole repo on every call.

Building a graph for a large repo takes real wall-clock time (seconds), so the first call for a given path pays that cost and every subsequent call for the same path is an in-memory lookup, until reindex/2 is called explicitly.

Also persists the built graph to <repo_path>/.beamscope/callgraph.json (Beamscope.Callgraph.Graph.to_node_link_json/1) so a server restart reloads it from disk instead of re-parsing the whole repo from source. Writes go to a .tmp.<unique> file first, renamed into place only once fully written — a crash mid-write leaves the last-known-good real file untouched rather than corrupting it.

Summary

Functions

Returns a specification to start this module under a supervisor.

Returns the cached graph for repo_path, building and caching it first if this is the first request for that path.

Returns whether repo_path has a cached graph, without building one.

Forces a rebuild of the graph for repo_path, replacing any cached version.

Types

repo_path()

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

Functions

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

get_or_build(repo_path, opts \\ [])

@spec get_or_build(
  repo_path(),
  keyword()
) :: Graph.t()

Returns the cached graph for repo_path, building and caching it first if this is the first request for that path.

indexed?(repo_path)

@spec indexed?(repo_path()) :: boolean()

Returns whether repo_path has a cached graph, without building one.

reindex(repo_path, opts \\ [])

@spec reindex(
  repo_path(),
  keyword()
) :: Graph.t()

Forces a rebuild of the graph for repo_path, replacing any cached version.

start_link(opts \\ [])

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