Repository navigation
Bundles
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.
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-rootvalues.
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>
-
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_hashitself). - Bundles produced by current tooling include this field; the loader verifies it when present.
- Optional integrity hash of the manifest fields (excluding
-
capabilities- Declarative list of required capabilities (e.g.,
io.stdout,net:none). - Execution is capability-scoped; ambient authority is forbidden.
- v1 guardrail:
python.ffiandpython.sandboxare rejected.
- Declarative list of required capabilities (e.g.,
-
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>
- project imports:
- v1 runner note: bundle execution does not perform source-based import resolution; these pins are not consulted by
curlee run --bundle.
- Import pins (
-
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).
The bundle bytecode payload is a stable, little-endian encoding of a VM chunk:
- Magic header:
CURLEE_CHUNK - Chunk format version:
1 max_locals-
codebytes -
spans(start/end byte offsets) - constant pool (Int/Bool/String/Unit)
This encoding is validated and decoded before execution.
For Curlee v1.x releases, bundle compatibility follows this contract:
- A
v1.xruntime must read bundles withformat_version=1produced by earlierv1.yreleases. -
format_versiondoes not change acrossv1minor/patch releases. - Any incompatible bundle-format change requires a major-version transition and explicit migration guidance in release notes.
Policy anchors:
-
kBundleFormatVersionininclude/curlee/bundle/bundle.his the implementation source-of-truth. - CI checks enforce consistency between the policy artifact and bundle-format constant.
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.
- Contract obligations (
-
Enforced (runtime / loader):
-
Bundle integrity:
version,bytecode_hash, andbytecodeare 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).
-
Bundle integrity:
-
version: enforced by the bundle loader (read_bundlerejects 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 bycurlee run --bundle(missing required capability hard-error).- v1 guardrail: manifests declaring
python.ffi/python.sandboxare rejected.
- v1 guardrail: manifests declaring
-
imports: recorded in the manifest for reproducibility; not enforced bycurlee run --bundlein v1. -
proof: not enforced in MVP (reserved for future proof-carrying workflows).
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.
- The bundle reader validates
version,bytecode_hash, andbytecodebefore executing. - The manifest is treated as authoritative; mismatches are hard errors.
- Future versions may add richer proofs or signatures; the
versiongate ensures safe evolution. - Release notes must include migration guidance when a major bundle-format change is introduced.