ElixirScope.ASTRepository.RuntimeCorrelator (elixir_scope v0.0.1)

Runtime correlation bridge that maps runtime events to AST nodes.

This module provides the core functionality for correlating runtime execution events with static AST analysis data, enabling the hybrid architecture.

Key responsibilities:

  • Map correlation IDs from runtime events to AST node IDs
  • Maintain temporal correlation data
  • Provide fast lookup capabilities (<5ms target)
  • Update AST repository with runtime insights

Summary

Functions

Returns a specification to start this module under a supervisor.

Correlates a runtime event with AST nodes.

Batch correlates multiple runtime events for better performance.

Gets all runtime events correlated with a specific AST node.

Gets all runtime events correlated with a specific AST node, ordered chronologically.

Gets correlation statistics and performance metrics.

Performs a health check on the correlator.

Queries events within a time range for temporal correlation.

Starts the RuntimeCorrelator with the given repository and configuration.

Types

ast_node_id()

@type ast_node_id() :: binary()

correlation_id()

@type correlation_id() :: binary()

correlation_result()

@type correlation_result() :: {:ok, ast_node_id()} | {:error, term()}

runtime_event()

@type runtime_event() :: map()

t()

@type t() :: %ElixirScope.ASTRepository.RuntimeCorrelator{
  cache_size_limit: term(),
  cleanup_interval: term(),
  correlation_cache: term(),
  correlation_timeout: term(),
  data_access: term(),
  failed_correlations: term(),
  performance_tracking: term(),
  repository_pid: term(),
  start_time: term(),
  statistics: term(),
  successful_correlations: term(),
  temporal_index: term(),
  total_correlations: term()
}

Functions

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

correlate_event(correlator \\ __MODULE__, runtime_event)

@spec correlate_event(GenServer.server(), runtime_event()) :: correlation_result()

Correlates a runtime event with AST nodes.

Returns the AST node ID that correlates with the event, or an error if no correlation can be established.

correlate_events(correlator \\ __MODULE__, runtime_events)

@spec correlate_events(GenServer.server(), [runtime_event()]) ::
  {:ok, [{correlation_id(), ast_node_id()}]} | {:error, term()}

Batch correlates multiple runtime events for better performance.

get_correlated_events(correlator \\ __MODULE__, ast_node_id)

@spec get_correlated_events(GenServer.server(), ast_node_id()) ::
  {:ok, [runtime_event()]} | {:error, term()}

Gets all runtime events correlated with a specific AST node.

get_events_for_ast_node(correlator \\ __MODULE__, ast_node_id)

@spec get_events_for_ast_node(GenServer.server(), ast_node_id()) ::
  {:ok, [runtime_event()]} | {:error, term()}

Gets all runtime events correlated with a specific AST node, ordered chronologically.

This is the primary function for AST-centric debugging queries.

get_statistics(correlator \\ __MODULE__)

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

Gets correlation statistics and performance metrics.

health_check(correlator \\ __MODULE__)

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

Performs a health check on the correlator.

query_temporal_events(correlator \\ __MODULE__, start_time, end_time)

@spec query_temporal_events(GenServer.server(), integer(), integer()) ::
  {:ok, [runtime_event()]} | {:error, term()}

Queries events within a time range for temporal correlation.

start_link(opts \\ [])

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

Starts the RuntimeCorrelator with the given repository and configuration.

update_correlation_mapping(correlator \\ __MODULE__, correlation_id, ast_node_id)

@spec update_correlation_mapping(GenServer.server(), correlation_id(), ast_node_id()) ::
  :ok

Updates the correlation mapping for an AST node.