Frontier.Store (Frontier v0.2.1)

Copy Markdown

ETS-backed runtime store for Frontier config: root, contexts, ignored modules, reclassifications, and tracer references.

Summary

Functions

Returns all ignored modules as a MapSet.

Returns all reclassified modules as a map of module => target context.

Returns the config for a context module, or nil.

Returns all registered contexts as a map of module => config.

Creates the ETS tables in the calling process. Only Store.Owner should call this — everything else goes through init/0 so the tables are owned by the stable process rather than the caller.

Loads Frontier config from compiled BEAM files if ETS is empty.

Returns true if the module is ignored.

Ensures the ETS tables exist, owned by a stable process.

Marks a module as initialized, clearing its previous references. Idempotent per compilation.

Scans compiled BEAM files for persisted frontier_opts attributes and registers them.

Returns the target context for a reclassified module, or nil.

Records a cross-module reference from the tracer.

Returns all recorded references with :from key injected.

Registers a context module and its config.

Registers a module as ignored.

Registers a module as reclassified to a different context.

Registers the root module config.

Wipes all ETS tables.

Resets the initialized tracking table.

Returns the root module and its config, or nil.

Functions

all_ignored()

@spec all_ignored() :: MapSet.t(module())

Returns all ignored modules as a MapSet.

all_reclassified()

@spec all_reclassified() :: %{required(module()) => module()}

Returns all reclassified modules as a map of module => target context.

context(module)

@spec context(module()) :: map() | nil

Returns the config for a context module, or nil.

contexts()

@spec contexts() :: %{required(module()) => map()}

Returns all registered contexts as a map of module => config.

create_tables()

@spec create_tables() :: :ok

Creates the ETS tables in the calling process. Only Store.Owner should call this — everything else goes through init/0 so the tables are owned by the stable process rather than the caller.

ensure_loaded()

@spec ensure_loaded() :: :ok

Loads Frontier config from compiled BEAM files if ETS is empty.

ignored?(module)

@spec ignored?(module()) :: boolean()

Returns true if the module is ignored.

init()

@spec init() :: :ok

Ensures the ETS tables exist, owned by a stable process.

Idempotent and safe to call concurrently from parallel compiler workers: delegates to Frontier.Store.Owner, which spawns an unlinked, detached process to own the tables so ownership never rides on the transient worker that triggered it. Blocks until the tables exist, so a caller can insert immediately on return.

initialize_module(module)

@spec initialize_module(module()) :: :ok

Marks a module as initialized, clearing its previous references. Idempotent per compilation.

load_from_modules()

@spec load_from_modules() :: :ok

Scans compiled BEAM files for persisted frontier_opts attributes and registers them.

reclassified_to(module)

@spec reclassified_to(module()) :: module() | nil

Returns the target context for a reclassified module, or nil.

record_reference(from, reference)

@spec record_reference(module(), map()) :: true

Records a cross-module reference from the tracer.

references()

@spec references() :: [map()]

Returns all recorded references with :from key injected.

register_context(module, config)

@spec register_context(module(), map()) :: true

Registers a context module and its config.

register_ignored(module)

@spec register_ignored(module()) :: true

Registers a module as ignored.

register_reclassified(module, target_context)

@spec register_reclassified(module(), module()) :: true

Registers a module as reclassified to a different context.

register_root(module, config)

@spec register_root(module(), map()) :: true

Registers the root module config.

reset()

@spec reset() :: :ok

Wipes all ETS tables.

reset_initialized()

@spec reset_initialized() :: :ok | true

Resets the initialized tracking table.

root()

@spec root() :: {module(), map()} | nil

Returns the root module and its config, or nil.