Skip to content

Bundles

Joe Curlee (w4ffl35) edited this page Feb 18, 2026 · 9 revisions

Curlee Bundles (Manifest-Carrying Artifacts)

Curlee bundles package a manifest plus a bytecode payload into a single portable artifact.

v1 semantics: when curlee run --bundle <file.bundle> <file.curlee> is used, the bundle bytecode payload is the execution source-of-truth. The CLI does not recompile <file.curlee> to execute it.

Build command (v1)

Curlee supports deterministic bundle creation:

curlee bundle build [--root <dir>] [--stdlib-root <dir>] [--cap <capability>]... <entry.curlee> <out.bundle>

Behavior:

  • Resolves imports using the v1 module rules (importing dir, entry root, stdlib roots).
  • Runs the same check pipeline used by curlee check/curlee run (parse, resolve, type-check, verify).
  • Emits bytecode and writes a bundle artifact consumable by:
    • curlee bundle verify <file.bundle>
    • curlee run --bundle <file.bundle> <file.curlee>
  • Records deterministic manifest metadata:
    • capabilities: values provided via --cap (sorted, deduplicated)
    • imports: import pins using deterministic module IDs + content hash

Flag notes:

  • --root <dir>: sets the entry root used for resolution; relative <entry.curlee> is resolved under this root.
  • --stdlib-root <dir>: appends deterministic stdlib/import roots (repeatable).
  • CURLEE_STDLIB_ROOT: :-separated stdlib roots appended before CLI-provided --stdlib-root values.

Schema (v1)

Bundles are plain UTF-8 text files with a fixed header and key/value lines.

CURLEE_BUNDLE_V1
version=1
bytecode_hash=<fnv1a64-hex>
manifest_hash=<fnv1a64-hex>
capabilities=<capability>,<capability>,...
imports=<path>:<hash>,<path>:<hash>,...
proof=<optional proof or claim id>
bytecode=<base64 bytecode>

Fields

  • version
    • Bundle format version. The reader rejects unsupported versions.
  • bytecode_hash
    • Deterministic hash of the raw bytecode.
    • Current algorithm: FNV-1a 64-bit, hex-encoded (lowercase, 16 chars).
  • manifest_hash
    • Optional integrity hash of the manifest fields (excluding manifest_hash itself).
    • Bundles produced by current tooling include this field; the loader verifies it when present.
  • capabilities
    • Declarative list of required capabilities (e.g., io.stdout, net:none).
    • Execution is capability-scoped; ambient authority is forbidden.
    • v1 guardrail: python.ffi and python.sandbox are rejected.
  • imports
    • Import pins (path:hash) are recorded as metadata for reproducibility.
    • Current v1 IDs are root-relative and deterministic:
      • project imports: entry/<relative-module-path>
      • stdlib imports: stdlib<N>/<relative-module-path>
    • v1 runner note: bundle execution does not perform source-based import resolution; these pins are not consulted by curlee run --bundle.
  • proof
    • Optional proof or claim reference (placeholder in MVP).
    • In MVP, this field is informational and not consumed by the runtime.
  • bytecode
    • Base64-encoded bytecode payload.
    • v1 payload format: an encoded vm::Chunk (see Chunk Encoding below).

Chunk Encoding (v1)

The bundle bytecode payload is a stable, little-endian encoding of a VM chunk:

  • Magic header: CURLEE_CHUNK
  • Chunk format version: 1
  • max_locals
  • code bytes
  • spans (start/end byte offsets)
  • constant pool (Int/Bool/String/Unit)

This encoding is validated and decoded before execution.

Compatibility contract (v1+)

For Curlee v1.x releases, bundle compatibility follows this contract:

  • A v1.x runtime must read bundles with format_version=1 produced by earlier v1.y releases.
  • format_version does not change across v1 minor/patch releases.
  • Any incompatible bundle-format change requires a major-version transition and explicit migration guidance in release notes.

Policy anchors:

  • kBundleFormatVersion in include/curlee/bundle/bundle.h is the implementation source-of-truth.
  • CI checks enforce consistency between the policy artifact and bundle-format constant.

Proven vs. enforced (MVP)

Curlee separates proof obligations from runtime enforcement:

  • Proven (compile/verification time):

    • Contract obligations (requires / ensures) are discharged against the declared logic fragment.
    • A program that cannot be proven within the supported fragment is rejected.
  • Enforced (runtime / loader):

    • Bundle integrity: version, bytecode_hash, and bytecode are validated when the bundle is loaded.
    • Capabilities: in bundle mode, the manifest capability set must be granted at runtime.
    • Import pins: v1 runner does not consult source text during execution, so pins are not currently enforced by curlee run --bundle.
    • Fuel: execution is resource-bounded and deterministic (today the CLI uses a fixed fuel budget; see Running Programs).

Manifest fields → enforcement mapping (v1)

  • version: enforced by the bundle loader (read_bundle rejects unsupported versions).
  • bytecode_hash + bytecode: enforced by the bundle loader (hash mismatch / invalid base64 hard-error).
  • manifest_hash: enforced by the bundle loader when present (hash mismatch hard-error).
  • capabilities: enforced by curlee run --bundle (missing required capability hard-error).
    • v1 guardrail: manifests declaring python.ffi / python.sandbox are rejected.
  • imports: recorded in the manifest for reproducibility; not enforced by curlee run --bundle in v1.
  • proof: not enforced in MVP (reserved for future proof-carrying workflows).

V1 interop opcode guard

curlee bundle verify and curlee run --bundle reject bundle bytecode containing PythonCall. This keeps runtime behavior aligned with v1 source policy where python_ffi.* is de-scoped.


Notes

  • The bundle reader validates version, bytecode_hash, and bytecode before executing.
  • The manifest is treated as authoritative; mismatches are hard errors.
  • Future versions may add richer proofs or signatures; the version gate ensures safe evolution.
  • Release notes must include migration guidance when a major bundle-format change is introduced.

Clone this wiki locally