PeaBox Lab › PeaLang › Learn › Chapter 20 › Lesson 1

Part IV — Expert Production Engineering · Chapter 20 · Lesson 1 of 7 · 5 min read

Lesson 1: Integrity-Checked Model Bundles and Registries

Lesson level: Expert

Purpose: Package a trained pipeline as a self-describing, tamper-evident bundle and record it in a registry so that every model in use can be identified, verified, and traced to its origins.

Learning objectives

By the end of this lesson you will be able to:

1.1 From a file to a bundle

A single serialized pipeline file answers only "what are the weights?". A bundle is a directory or archive that answers the governance questions as well:

Bundle partContentsPurpose
Pipeline artifactSerialized fitted pipeline (Chapter 19, Lesson 6)Makes predictions
Input schemaField names, types, ranges, unknown-value policyValidates requests
MetadataName, version, creation time, seeds, hyperparameters, decision policyIdentifies and configures
LineageData snapshot hash, extraction query, code commit, environment lockEnables rebuild and audit
Evaluation evidenceMetrics, intervals, segment results, calibration summaryJustifies approval
Model cardIntended use, limits, owners (Lesson 5)Communicates responsibly
ManifestList of every file with its hash and sizeDetects tampering and loss

1.2 Content hashes

A cryptographic hash such as SHA-256 maps a file to a short fingerprint. Changing a single byte changes the fingerprint completely, so comparing a stored hash with a freshly computed one detects accidental corruption and deliberate modification.

A hash detects change but does not prove who created the content: an attacker who can replace a file can also replace its hash. Hashes therefore provide integrity; Lesson 6 adds signatures for authenticity. Store hashes in the manifest, and protect the manifest itself with a signature.

1.3 The manifest

A bundle manifest identifies the stored model and its integrity metadata. The shipped bundle loader and the separate Ed25519 signature verifier perform different checks; invoking one does not imply the other ran. For production, verify the trusted signature and referenced hashes before loading, and add an explicit file-inventory check if your policy rejects unlisted files. Do not assume that the illustrative manifest layout or automatic rejection of every extra file is a shipped guarantee.

Illustrative listing.

{
  "bundle_format": 1,
  "model": {"name": "churn", "version": "1.0.0"},
  "created_at": "2026-11-01T10:15:00Z",
  "files": [
    {"path": "pipeline.bin",   "size": 48211, "sha256": "9f2c…"},
    {"path": "schema.json",    "size": 1840,  "sha256": "41ab…"},
    {"path": "metadata.json",  "size": 2205,  "sha256": "c07e…"},
    {"path": "evaluation.json","size": 5120,  "sha256": "7d19…"},
    {"path": "model_card.md",  "size": 6730,  "sha256": "e5a0…"}
  ],
  "lineage": {"data_sha256": "b81d…", "code_commit": "4e2f9a1",
              "pealang_version": "0.63.0rc2"}
}

Hash values in this listing are truncated placeholders. Real manifests store the full digest.

1.4 What a registry is for

A model registry is the system of record for models. It answers "which models exist, which version is where, and why?" At minimum each entry records the model name and version, the bundle location and manifest hash, the lineage summary, the evaluation summary, the owner, the current lifecycle state (Lesson 2), and an append-only history of every state change with who made it and when.

Two rules make a registry trustworthy. First, versions are immutable: once version 1.0.0 is registered, its bundle and hash never change. A fix is version 1.0.1. Second, the registry stores references and evidence, not opinions: approval is a recorded event linked to evidence, not a flag someone toggles without trace.

Illustrative listing.

from pealang.ml.registry import Registry

reg = Registry("registry/")            # local file-backed registry
entry = reg.register(
    bundle="bundles/churn-1.0.0",
    owner="retention-analytics",
    description="Weekly churn propensity, calibrated, cost threshold 0.09")
print(entry.name, entry.version, entry.state, entry.manifest_sha256)

verified = reg.verify("churn", "1.0.0")   # recomputes every hash
assert verified.ok, verified.problems

1.5 Tracing a prediction to its origins

Every prediction the service returns should carry, or be logged with, the model name, version, and manifest hash (Lesson 3). From that triple, an investigator can follow a chain: registry entry → bundle → metadata and lineage → data snapshot hash and code commit → evaluation evidence and approval history. If any link is missing, the chain breaks and the prediction cannot be explained. Test the chain end-to-end before the first release, not during the first incident.

1.6 Storage and retention

Common mistakes

Guided practice

Hands-on lab: A verifiable bundle and registry

Review questions

Applied challenge

An auditor asks which model produced a credit decision eight months ago and what data it was trained on. Design the bundle, registry, and logging conventions that would let you answer within one hour, and list the retention periods each artifact needs.

Lesson summary

A bundle packages the pipeline with its schema, metadata, lineage, evidence, and model card, and a manifest of hashes makes tampering and loss detectable. A registry is the immutable, evidence-based system of record for every version. Together they let any prediction be traced back to its data, code, and approval.

Lesson status: Ready for review.

← Previous Next →