LLMDB.Snapshot (LLM DB v2026.4.5)

Copy Markdown View Source

Canonical snapshot artifact helpers.

Snapshots are the immutable unit of metadata publication and runtime loading. They are stored as a single snapshot.json file, addressed by snapshot_id, and optionally mirrored to GitHub Releases.

Summary

Functions

Returns the local build output directory for snapshots.

Returns the default build artifact path for snapshot-meta.json.

Returns the default build artifact path for snapshot.json.

Returns provider/model counts for a snapshot document.

Decodes and verifies a snapshot document from JSON.

Encodes a snapshot or metadata document as pretty JSON.

Builds a canonical snapshot document from an engine snapshot.

Builds snapshot metadata suitable for snapshot-index.json and latest.json.

Returns the packaged snapshot file path.

Reads and verifies a snapshot document from disk.

Returns the canonical snapshot schema version.

Computes the content-addressed snapshot ID for a snapshot document.

Returns the source-tree packaged snapshot path used for release packaging.

Verifies snapshot integrity and provider ID safety.

Writes a snapshot or metadata document to disk.

Functions

build_dir()

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

Returns the local build output directory for snapshots.

build_meta_path()

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

Returns the default build artifact path for snapshot-meta.json.

build_path()

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

Returns the default build artifact path for snapshot.json.

counts(snapshot)

@spec counts(map()) :: %{
  provider_count: non_neg_integer(),
  model_count: non_neg_integer()
}

Returns provider/model counts for a snapshot document.

decode(content)

@spec decode(binary()) :: {:ok, map()} | {:error, term()}

Decodes and verifies a snapshot document from JSON.

encode(document)

@spec encode(map()) :: String.t()

Encodes a snapshot or metadata document as pretty JSON.

from_engine_snapshot(map)

@spec from_engine_snapshot(map()) :: map()

Builds a canonical snapshot document from an engine snapshot.

history_archive_filename()

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

history_meta_filename()

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

latest_filename()

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

metadata(snapshot, attrs \\ %{})

@spec metadata(map(), map()) :: map()

Builds snapshot metadata suitable for snapshot-index.json and latest.json.

packaged_path()

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

Returns the packaged snapshot file path.

read(path)

@spec read(String.t()) :: {:ok, map()} | {:error, term()}

Reads and verifies a snapshot document from disk.

schema_version()

@spec schema_version() :: pos_integer()

Returns the canonical snapshot schema version.

snapshot_filename()

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

snapshot_id(snapshot)

@spec snapshot_id(map()) :: String.t()

Computes the content-addressed snapshot ID for a snapshot document.

snapshot_index_filename()

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

snapshot_meta_filename()

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

source_packaged_path()

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

Returns the source-tree packaged snapshot path used for release packaging.

verify(snapshot)

@spec verify(map()) :: :ok | {:error, term()}

Verifies snapshot integrity and provider ID safety.

write!(path, document)

@spec write!(String.t(), map()) :: :ok

Writes a snapshot or metadata document to disk.