cap: Documentation
Browse Sign In

Bifaci Protocol

Project runtime frame contract over CBOR encoding

Frame Contract

Bifaci is a Latin term meaning "two-face" or "two-sided", pronounced BYE-FAH-CHEE.

Protocol version is 2. Frames are CBOR maps keyed by integers. Common keys include version, type, id, seq, payload, cap, stream metadata, and checksum fields.

Wire framing: 4-byte big-endian length prefix, then CBOR payload bytes.

Frame Types

Supported frame types include Hello, Req, Chunk, End, Log, Err, Heartbeat, StreamStart, StreamEnd, RelayNotify, RelayState.

Legacy single-response Res frame type is removed.

Lifecycle

  1. HELLO negotiates limits.
  2. REQ starts a request flow.
  3. STREAM_START + CHUNK + STREAM_END carry stream payloads.
  4. END closes the request flow.
  5. ERR reports protocol/runtime failures.

Identity and Integrity

Identity is mandatory at manifest level via CAP_IDENTITY. Relay switch performs nonce-based identity verification across the relay chain.

Chunk payload checksums are supported via per-chunk checksum fields.

References