ElixirScope.ASTRepository.Repository (elixir_scope v0.0.1)

Central repository for AST storage with runtime correlation capabilities.

Designed for high-performance access patterns:

  • O(1) module lookup by name
  • O(log n) correlation ID to AST node mapping
  • O(1) instrumentation point retrieval
  • O(log n) temporal range queries

Integrates with existing ElixirScope infrastructure:

  • Uses ElixirScope.Storage.DataAccess patterns for ETS storage
  • Follows ElixirScope.Config for configuration management
  • Implements GenServer pattern like PipelineManager

Summary

Functions

Returns a specification to start this module under a supervisor.

Correlates a runtime event with AST nodes using correlation ID. Returns the AST node ID that correlates with the event.

Retrieves function data by function key.

Gets instrumentation points for a specific AST node.

Retrieves a module's data by name.

Gets repository statistics and performance metrics.

Performs a health check on the repository.

Creates a new repository instance (for testing or multiple repositories).

Starts the AST Repository with optional configuration.

Stores function-level data with runtime correlation capabilities.

Stores a module's AST data with instrumentation metadata.

Updates a module's data using an update function.

Types

ast_node_id()

@type ast_node_id() :: binary()

correlation_id()

@type correlation_id() :: binary()

function_key()

@type function_key() :: {module_name(), atom(), non_neg_integer()}

module_name()

@type module_name() :: atom()

repository_id()

@type repository_id() :: binary()

t()

@type t() :: %ElixirScope.ASTRepository.Repository{
  ast_nodes_table: term(),
  configuration: term(),
  correlation_index: term(),
  creation_timestamp: term(),
  data_access: term(),
  functions_table: term(),
  instrumentation_points: term(),
  last_updated: term(),
  modules_table: term(),
  patterns_table: term(),
  performance_metrics: term(),
  repository_id: term(),
  runtime_correlator: term(),
  stats_table: term(),
  temporal_correlation: term(),
  version: term()
}

Functions

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

correlate_event(repository, runtime_event)

@spec correlate_event(GenServer.server(), map()) ::
  {:ok, ast_node_id()} | {:error, term()}

Correlates a runtime event with AST nodes using correlation ID. Returns the AST node ID that correlates with the event.

get_function(repository, function_key)

@spec get_function(GenServer.server(), function_key()) ::
  {:ok, ElixirScope.ASTRepository.FunctionData.t()} | {:error, :not_found}

Retrieves function data by function key.

get_instrumentation_points(repository, ast_node_id)

@spec get_instrumentation_points(GenServer.server(), ast_node_id()) ::
  {:ok, [map()]} | {:error, :not_found}

Gets instrumentation points for a specific AST node.

get_module(repository, module_name)

@spec get_module(GenServer.server(), module_name()) ::
  {:ok, ElixirScope.ASTRepository.ModuleData.t()} | {:error, :not_found}

Retrieves a module's data by name.

get_statistics(repository)

@spec get_statistics(GenServer.server()) :: {:ok, map()}

Gets repository statistics and performance metrics.

health_check(repository)

@spec health_check(GenServer.server()) :: {:ok, map()} | {:error, term()}

Performs a health check on the repository.

new(opts \\ [])

@spec new(keyword()) :: {:ok, t()} | {:error, term()}

Creates a new repository instance (for testing or multiple repositories).

start_link(opts \\ [])

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

Starts the AST Repository with optional configuration.

Options

  • :name - Process name (default: MODULE)
  • :config - Repository configuration (merged with defaults)
  • :data_access - Existing DataAccess instance (optional)

store_function(repository, function_data)

@spec store_function(GenServer.server(), ElixirScope.ASTRepository.FunctionData.t()) ::
  :ok | {:error, term()}

Stores function-level data with runtime correlation capabilities.

store_module(repository, module_data)

@spec store_module(GenServer.server(), ElixirScope.ASTRepository.ModuleData.t()) ::
  :ok | {:error, term()}

Stores a module's AST data with instrumentation metadata.

update_module(repository, module_name, update_fn)

Updates a module's data using an update function.