Minga.Extension.ArtifactInventory (Minga v0.1.0)

Copy Markdown View Source

Validates the complete BEAM output of an isolated extension compilation.

Validation is deliberately performed before ownership or code-server mutation. The validator bounds artifact count, artifact bytes, and BEAM atom tables before :beam_lib is allowed to materialize any atoms in the host VM. Cache inventories include deterministic digests so missing, additional, or replaced files are rejected exactly like fresh compiler output.

Summary

Functions

Removes an inventory's private validation snapshot after admission finishes.

Returns the cache manifest filename reserved by the inventory contract.

Rebases validated artifact paths after an atomic staging-directory rename.

Validates a cache directory and its deterministic completeness manifest.

Validates fresh compiler output and verifies the compiler's complete module report.

Writes the deterministic completeness manifest after fresh validation.

Types

t()

@type t() :: %Minga.Extension.ArtifactInventory{
  artifacts: [Minga.Extension.Artifact.t()],
  fingerprint: binary(),
  snapshot_dir: String.t() | nil
}

validation_error()

@type validation_error() ::
  :empty_inventory
  | {:artifact_limit_exceeded, non_neg_integer(), pos_integer()}
  | {:unexpected_artifact_entry, String.t()}
  | {:non_regular_artifact_entry, String.t(), atom()}
  | {:non_regular_cache_directory, String.t(), atom()}
  | {:artifact_read_failed, String.t(), File.posix()}
  | {:artifact_too_large, String.t(), non_neg_integer(), pos_integer()}
  | {:total_artifact_bytes_exceeded, non_neg_integer(), pos_integer()}
  | {:invalid_beam, String.t(), term()}
  | {:atom_limit_exceeded, String.t(), non_neg_integer(), pos_integer()}
  | {:total_atom_limit_exceeded, non_neg_integer(), pos_integer()}
  | {:host_atom_capacity_exceeded, non_neg_integer(), non_neg_integer(),
     pos_integer(), pos_integer()}
  | {:invalid_atom_name, String.t(), term()}
  | {:invalid_module_name, String.t()}
  | {:filename_module_mismatch, String.t(), String.t()}
  | {:duplicate_module_identity, String.t()}
  | {:incomplete_compiler_output, [String.t()], [String.t()]}
  | {:cache_manifest_missing, String.t()}
  | {:cache_manifest_invalid, term()}
  | {:cache_manifest_mismatch, term()}

Functions

cleanup(artifact_inventory)

@spec cleanup(t()) :: :ok

Removes an inventory's private validation snapshot after admission finishes.

manifest_filename()

@spec manifest_filename() :: String.t()

Returns the cache manifest filename reserved by the inventory contract.

rebase(inventory, dir)

@spec rebase(t(), String.t()) :: t()

Rebases validated artifact paths after an atomic staging-directory rename.

validate_cache(dir, opts \\ [])

@spec validate_cache(
  String.t(),
  keyword()
) :: :miss | {:ok, t()} | {:error, validation_error()}

Validates a cache directory and its deterministic completeness manifest.

validate_staging(dir, expected_modules, opts \\ [])

@spec validate_staging(String.t(), [String.t()], keyword()) ::
  {:ok, t()} | {:error, validation_error()}

Validates fresh compiler output and verifies the compiler's complete module report.

write_manifest(dir, inventory, opts \\ [])

@spec write_manifest(String.t(), t(), keyword()) :: :ok | {:error, term()}

Writes the deterministic completeness manifest after fresh validation.