CBDF Specification: Overview

Version 1.1 (Phase II)

Document: 00-Overview • Date: 2026-07-13

1. What is CBDF?

CBDF (Compact Binary Document Format) is a binary open-standard document format designed to radically reduce the size of marked-up documents relative to HTML/CSS. A CBDF-formatted message can be on the order of 1% of an equivalent modern HTML email for styled mail; tiny messages are a few percent. The format optimizes for bandwidth, storage, and parse cost while remaining degradable to plain text.

CBDF achieves this by:

  • Using a 2-byte Layout ID (65,536 predefined page layouts in a client-side catalogue vs. hundreds of bytes of CSS/HTML)
  • Limiting colors to 65,536 (2 bytes vs. 7 bytes for CSS #RRGGBB)
  • Using a fixed font table of 4,096+ fonts (2 bytes vs. font-family strings)
  • Encoding all formatting as compact binary style records referenced by 1-byte indices
  • Using ASCII control characters (0x000x1F) as inline commands instead of verbose HTML tags
  • Placing binary resources (images, fonts) in a separate skippable section after Text
  • Optional compression of Styles+Text (zlib mandatory to implement in Phase II)

2. Design Principles

  1. One canonical encoding. Strict parsers; no HTML-style quirks repair.
  2. Degrade to readable text. Stripping bytes 0x00–0x1F (keeping TAB and LF) from Text yields clean UTF-8.
  3. Tables over self-description. Layouts, fonts, and styles live in the codec/catalogue; the wire carries indices.
  4. Fixed sizes and explicit lengths. No delimiter sniffing for style records or section boundaries.
  5. Static documents are safe. Phase II has no executable Logic. AI prompts are receiver-evaluated requests.
  6. User owns the final render. Themes and accessibility outrank document chrome.
  7. Claims vs attestations. Meta is sender claim; QMail Tell/RAIDA data is network attestation (see Meta receiver annotations).

Registries (meta keys, feature bits, layout catalogue, fonts, named style sets) are open-standard, append-only, jointly governed by the CloudCoin Consortium, the Perfect Money Foundation, and the RAIDA Group.

3. Use Cases

  • QMail: Quantum-safe email (.qmail files)
  • QWeb: Web pages (.qweb files)
  • Presentation / form documents: reserved Meta File Type values 4 and 5
  • RAIDA: Client-server data exchange
  • Text messaging: Ultra-compact meta-only messages (on the order of 14–50 bytes for short SMS-class content)

4. Document Structure

[Meta] FS [Styles] FS [Text] FS [Resources] FS [Logic]
[ optional: FS [SectionID:1][Len:4 LE][payload] ... ]
SectionCompressed?Description
MetaNeverEnvelope: identity, routing, preview, feature flags, version. Always readable. In QMail, may ship as file_type=0 separate from the body.
StylesWith Text if enabledLayoutID + visual formatting lookup tables.
TextWith Styles if enabledUTF-8 body + control codes. Before Resources for abortable download.
ResourcesNever (already-compressed codecs)Binary blobs (images, fonts). Slot always present in Phase II; payload may be empty.
LogicExecutable code. Phase II: always zero length. Phase III: BEAM/Elixir (or successor).

All multi-byte integers in CBDF are little-endian. Core sections are identified by position, not by a per-section file-ID byte.

5. Versioning

VersionDetectionBody shape
0 (Phase I)Meta key 30 absentFS FS STX [plain text…EOF] — implemented in qmail_cbdf.c
1 (Phase II)Meta key 30 = 1Length-prefixed Styles, Text, Resources, Logic; full style/control language
2+Key 30 ≥ 2Future (e.g. Logic). Bump only when old parsers cannot safely skip new constructs.

No leading magic byte before the Meta pair count — that would break deployed Phase I files.

6. Specification Documents

DocumentDescription
00-OverviewThis document
01-Document-StructureSection layout, compression, empty tails, QMail packaging, parallel parse notes
02-Meta-SectionKLV format, key table, feature flags, Tell annotations, mailbox format
03-Styles-SectionLayoutID, style sub-tables, record formats, layers
04-Text-SectionControl codes in text, tables, plain-text extraction
05-Resources-SectionBinary resource format, abortable downloads
06-Logic-SectionPhase III placeholder
07-Control-Characters32 ASCII control assignments
08-Color-SystemR5G6B5 encoding, transparency codes
09-Font-SystemFont IDs, effects, custom fonts
10-Layout-CatalogueLayoutID registry, pane indices, mobile pairs, nav bar rules, JSON data file

7. Phases

PhaseDescriptionStatus
Phase IPlain text only (qmail_cbdf.c)Implemented
Phase IIStyled text, LayoutID catalogue, images, nav, tables, layers, Tell annotations, feature flagsCurrent phase
Phase IIILogic section, forms, interactive features, optional separate large resources, semantic encodingPlanned

Semantic encoding (compression type 5) is experimental and not required for Phase II implementers until a model registry exists.

8. Parallel Parsing (summary)

CBDF supports coarse-grained parallelism: section split via FS + lengths, packed style tables (indexable after one pass), resource decode on a thread pool, pane paint after a serial Text walk. The Text control stream remains sequential (style stack). Full details: Document Structure § parallel parse.