NativeArtifact.Manifest (native_artifact v0.1.0)

Copy Markdown View Source

Bounded, fail-closed validation of pinned Manifest v1 metadata.

decode/2 rejects duplicate JSON object keys before validating the schema and cross-references. validate/2 accepts already-decoded string-keyed JSON data. Both return %Manifest{data: original_data} without creating atoms from input. Validation performs no I/O and does not prove that an archive exists, its bytes match, or its native code is compatible with a running system.

Options are positive integer limits: :max_manifest_bytes (4 MiB), :max_depth (64 container levels), :max_nodes (100,000 values/object keys), :max_artifacts (128), :max_files (4,096 across the manifest), :max_archive_bytes (256 MiB per archive), and :max_unpacked_bytes (1 GiB across the manifest). For validate/2, the byte limit applies to the compact JSON representation; decode/2 also bounds the original input bytes.

Summary

Functions

Decodes bounded UTF-8 JSON, rejecting duplicate object keys and invalid v1 metadata.

Validates string-keyed JSON data without normalizing it or performing I/O.

Types

t()

@type t() :: %NativeArtifact.Manifest{data: %{required(String.t()) => term()}}

Functions

decode(json, opts \\ [])

@spec decode(binary(), keyword()) :: {:ok, t()} | {:error, NativeArtifact.Error.t()}

Decodes bounded UTF-8 JSON, rejecting duplicate object keys and invalid v1 metadata.

validate(data, opts \\ [])

@spec validate(term(), keyword()) :: {:ok, t()} | {:error, NativeArtifact.Error.t()}

Validates string-keyed JSON data without normalizing it or performing I/O.