Ancora.Derive (ancora v1.0.0-rc.1)

Copy Markdown View Source

Data construction for source-derived call resolution.

VM introspection is confined to this module. Ancora.Derive.Resolver receives the resulting maps, sets, and functions and remains pure.

Summary

Functions

Returns the complete derived call set, including generated bindings.

Builds the ambient function and macro table once in the tool VM.

Builds a pure resolver context from per-side membership and DefIndexes.

Resolves all tagged test files for one diff side and groups them by subject.

Types

binding()

@type binding() :: {module(), atom(), arity()}

resolver_context()

@type resolver_context() :: %{
  membership: (module() -> boolean()),
  ambient: MapSet.t({atom(), arity()}),
  external_exports: MapSet.t(binding()),
  def_index: (module() -> {:ok, Ancora.Derive.DefIndex.t()} | :unknown),
  findings: [Ancora.Finding.t()],
  side: side()
}

side()

@type side() :: :base | :head

subject_set()

@type subject_set() :: %{
  subject_id: String.t(),
  side: side(),
  bindings: MapSet.t(binding()),
  generated: MapSet.t(binding()),
  dep_generated: MapSet.t(binding()),
  unresolved: [Ancora.Derive.Resolver.unresolved()],
  test_files: [Path.t()],
  findings: [Ancora.Finding.t()]
}

Functions

all_bindings(subject_set)

@spec all_bindings(subject_set()) :: MapSet.t(binding())

Returns the complete derived call set, including generated bindings.

ambient_exports()

@spec ambient_exports() :: MapSet.t({atom(), arity()})

Builds the ambient function and macro table once in the tool VM.

context(membership_result, side, def_indexes, opts \\ [])

@spec context(
  {:ok, Ancora.Derive.Membership.t()} | {:error, term()},
  side(),
  map() | function(),
  keyword()
) :: {:ok, resolver_context()}

Builds a pure resolver context from per-side membership and DefIndexes.

external_modules: precomputes exports for non-member imports. When module location degraded on a parse error, the context carries a finding and an empty membership predicate so the detector run can continue.

run(subject_files, opts)

@spec run(
  %{required(String.t()) => [Path.t()]},
  keyword()
) :: {:ok, %{required(String.t()) => subject_set()}} | {:error, term()}

Resolves all tagged test files for one diff side and groups them by subject.

subject_files maps subject ids to test paths. Required options are :side and a resolver :context. :sources may be a path-to-source map or a function of one path; it defaults to File.read/1.