Versioning Models, Prompts, Data, and Tools › A manifest format for compound systems
Language AI HandbookAll chapters The manifest holds component references and a parent release identifier. Its compatibility policy is also versioned. This example pins the policy by name and runs its registered implementation before a release enters the store. The dataclasses describe the record shape. The explicit compatibility check validates the combination at registration.
The provenance fields in the example include the parent identity, timestamp, revision, and a synthetic orchestration commit. Those fields count as part of the record's identity. The manifest uses typed fields; this fixture is built directly in Python and skips external parsing.
PythonIn [3]Expand
import hashlib
import json
from dataclasses import asdict, dataclass, replace
from datetime import datetime, timezone
from fractions import Fraction
from typing import Literal
@dataclass(frozen=True)
class ComponentRef:
key: str
version: str
identity: str
source: Literal["content-hash", "provider-tag", "git-sha"]
@dataclass(frozen=True)
class Manifest:
name: str
revision: int
created_at: str
components: dict[str, ComponentRef]
commit: str
parent: str | None = None
compatibility_policy: str = "embedding-index-v1"The source field explains how to interpret an identity. Rehash content-derived references when you load their original bytes. Keep the provider tag alongside any provider-reported revision for components whose bytes you cannot obtain.
The hash covers every serialized field. Sorting object keys and choosing one whitespace convention makes equal input records produce equal bytes under this encoder. This is a deliberately narrow local encoding. An interoperable hash contract needs shared rules for all supported values, including Unicode and numbers. RFC 8785
PythonIn [4]Expand
def canonical_bytes(manifest: Manifest) -> bytes:
payload = asdict(manifest)
return json.dumps(payload, sort_keys=True, separators=(",", ":")).encode(
"utf-8"
)
def manifest_id(manifest: Manifest) -> str:
return "sha256:" + hashlib.sha256(canonical_bytes(manifest)).hexdigest()The fictional support assistant has one hosted model, a prompt, a lookup tool, an index, and an embedder. The locally defined prompt and tool schema have real SHA-256 digests over synthetic bytes. Model and index identifiers are invented fixture values.
PythonIn [5]Expand
def content_identity(text: str) -> str:
return "sha256:" + hashlib.sha256(text.encode()).hexdigest()
# Synthetic component contents (as bytes we control)
PROMPT_V3 = "You are a support agent. Cite [doc_id] for every claim.\n"
TOOL_SCHEMA_V2 = json.dumps(
{
"name": "lookup_order",
"parameters": {
"type": "object",
"properties": {"order_id": {"type": "string"}},
"required": ["order_id"],
},
},
sort_keys=True,
)
base_manifest = Manifest(
name="support-agent",
revision=1,
created_at=datetime(2025, 6, 1, tzinfo=timezone.utc).isoformat(),
commit="a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6e7f8a9b0",
components={
"model": ComponentRef(
key="model",
version="gpt-x-2025-06",
identity="gpt-x-2025-06-01",
source="provider-tag",
),
"prompt.main": ComponentRef(
key="prompt.main",
version="v3",
identity=content_identity(PROMPT_V3),
source="content-hash",
),
"tools.lookup_order": ComponentRef(
key="tools.lookup_order",
version="v2",
identity=content_identity(TOOL_SCHEMA_V2),
source="content-hash",
),
"index.kb": ComponentRef(
key="index.kb",
version="kb-2025-06",
identity="pinecone://kb-v7",
source="provider-tag",
),
"embed.kb": ComponentRef(
key="embed.kb",
version="e5-base-v2",
identity="hf:e5-base-v2@sha:ab12",
source="provider-tag",
),
},
)ConsoleOut [6]Expand
Manifest revision: 1 Manifest identity: sha256:36f5a9a25a9a355007606bdd62b2ee9ce23584262e4f3af9aeb4b8bbe1201508 Prompt identity: sha256:0540bce600e9f6bbfd52ab5121a7c6d4a65039ce8f7d016b82ff53c9a3178166 Tool identity: sha256:796532bc34cd28b6b8fd72804d31791cb0606b4e75443896deda562168a401ec
Here is how a team could construct a content-derived reference for the source snapshot and record the tool implementation separately from its argument schema. The identifiers below are for demonstration. They are not used by a model or a tool in this notebook.
PythonIn [7]Expand
document_snapshot = {
"help-refunds": "Refund requests require the original receipt.",
"help-delivery": "Delivery estimates appear on the dispatch record.",
}
snapshot_bytes = json.dumps(
document_snapshot, sort_keys=True, separators=(",", ":")
)
snapshot_ref = ComponentRef(
key="corpus.kb",
version="kb-2025-06",
identity=content_identity(snapshot_bytes),
source="content-hash",
)
tool_implementation_ref = ComponentRef(
key="tools.lookup_order.implementation",
version="service-v4",
identity=base_manifest.commit,
source="git-sha",
)
print(snapshot_ref.key, snapshot_ref.identity)
print(tool_implementation_ref.key, tool_implementation_ref.version)ConsoleOut [7]Expand
corpus.kb sha256:9fc2446724a09e6975942fec9bfddb36f5d2d887f6107b362b4d01c24685572c tools.lookup_order.implementation service-v4
The source snapshot and index identity are different records. A corpus can support several index builds, and the same corpus can produce a different retrieval index when chunking or the embedder changes. The implementation reference and schema digest are also different records. A compatible schema can stay the same while the underlying code changes.
A manifest assembly service can use a store of immutable named artifacts and add these references only after it validates that the component key and resolver are understood. A mutable catalog is still useful for candidate discovery. When the release is composed, resolve each mutable reference to the stable identity you intend to preserve. The release record should keep that result as a value, so reading it later does not resolve a moving reference by accident.
The digest gives the request log a compact reference to the entire manifest record. Fetching that record recovers the refs it contains. Recovering component content still requires retention of those artifacts and continued access to external dependencies.
Reverse the component map's insertion order and serialize both records under three conventions. Both sorted encodings agree across insertion orders. They still produce different bytes from one another because one uses spaces. The release needs one agreed convention so the encoding is reproducible on both the writing and the reading sides.
PythonIn [8]Expand
manifest_a = base_manifest
manifest_b = replace(
base_manifest,
components=dict(reversed(list(base_manifest.components.items()))),
)
def identity_variant(manifest, *, sort_keys, compact):
separators = (",", ":") if compact else None
payload = json.dumps(
asdict(manifest), sort_keys=sort_keys, separators=separators
)
return content_identity(payload)
variants = [
("insertion order", False, False),
("sorted keys, spaced", True, False),
("sorted keys, compact", True, True),
]
variant_ids = {
label: [
identity_variant(m, sort_keys=sort, compact=compact)
for m in (manifest_a, manifest_b)
]
for label, sort, compact in variants
}
distinct_counts = {label: len(set(ids)) for label, ids in variant_ids.items()}
assert variant_ids["sorted keys, compact"][0] == manifest_id(base_manifest)
assert (
variant_ids["sorted keys, compact"][0]
!= variant_ids["sorted keys, spaced"][0]
)VisualizationOut [9]Expand

Comments
Add to the conversation
A question, a correction, or an example from your own work.
No comments yet. Be the first to share your thoughts!