# `Minga.Extension.ArtifactInventory`
[🔗](https://github.com/jsmestad/minga/blob/main/lib/minga/extension/artifact_inventory.ex#L1)

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.

# `t`

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

# `validation_error`

```elixir
@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()}
```

# `cleanup`

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

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

# `manifest_filename`

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

Returns the cache manifest filename reserved by the inventory contract.

# `rebase`

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

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

# `validate_cache`

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

Validates a cache directory and its deterministic completeness manifest.

# `validate_staging`

```elixir
@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`

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

Writes the deterministic completeness manifest after fresh validation.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
