Skip to content

Compiled deck format

This reference is for applications that read .fcd files. To export a deck, see exporting.

deck.write() and fabcheck compile create deterministic, uncompressed .fcd files containing the validated graph and reference layouts. The primary layout is supplied separately. Python source, local paths, and source maps are excluded.

Container

Section Encoding What it does and why
Header Six bytes: FCD\0\x01\n Identifies the file as a supported compiled-deck format. Readers check it before interpreting the remaining bytes.
Manifest length Eight-byte unsigned big-endian integer Tells the reader exactly how many bytes belong to the JSON manifest. This separates metadata from the reference-file data that follows.
Manifest Canonical UTF-8 JSON, at most 64 MiB Holds deck rules, operations, versions, and reference-file identities. Readers use it to validate what the artifact contains before executing it.
Reference assets Raw bytes in manifest order, sorted by logical name Stores the actual reference layout bytes in the declared order. Embedding them keeps an exported deck tied to the same reference data after source files change.

The file limit is 4 GiB. The manifest contains format/compiler versions, the graph, validation evidence (graph SHA-256 and zero diagnostics), and each reference's name, byte count, and SHA-256. Decimals use { "$decimal": "exact decimal text" }. Transport compression does not change the canonical file.

Read and verify

open_deck_file(path) checks the header, manifest, graph, graph digest, reference bindings, and file size. It returns CompiledDeckFile without extracting assets. extract_references(new_directory) verifies asset digests while writing them; failed extraction removes the new directory.

Use manifest.graph.name and ordered manifest.graph.rules for metadata. Messages may need runtime evaluation. Rule selection belongs to the consuming application; it does not rewrite the artifact.

Consumers must check the graph, assets, and capabilities before execution. They can implement the format without importing FabCheck. See the integration contract.

Legacy snapshot API

New consumers should use .fcd. The older fabcheck.transport API remains available:

Call Behavior What it does and why
stage_deck(compiled, inputs=bindings, directory=new_directory) Return DeckPayload and stage immutable copies of all inputs, including the primary layout Copies the explicitly bound input files into a new directory and records their identities. Use it when an older application stages the primary layout and references separately from the payload.
payload.to_bytes() Encode graph and asset identities; asset bytes stay separate Serializes the graph and asset identities, not the asset bytes. Use it to send the small description while transferring the staged files separately.
DeckPayload.from_bytes(data) Validate the envelope Reads and checks the serialized legacy envelope. Use it before accepting payload data from a file or transport.
payload.bind(directory) Verify staged files Checks files in a staging directory against the recorded identities and returns input bindings. Use it to avoid executing against missing or changed files.
payload.compile(capabilities=...) Revalidate graph and requirements Rechecks the graph and its required operations, optionally against capabilities. Use it to obtain a checked snapshot from an older payload.

Bindings must match inputs exactly. The staging directory must be new; files use digest names. The caller manages upload, access, cleanup, and quotas.

Legacy bytes start with FABCHK and byte 1, followed by one gzip member of UTF-8 JSON with format_version, graph, and assets. Decimal encoding matches .fcd. Limits: 16 MiB compressed, 64 MiB expanded, 64 nested containers. Unknown fields, duplicate keys, invalid versions/references, trailing data, and truncated streams are rejected. All nodes, including unused ones, are validated. There is no automatic migration; recompile with compatible components.