Expand description
Instruction set, .bf (BFV0) wire format, assembler and verifier.
Pure data plane — no threads, no mailboxes. The scheduler and VM consume
Chunk values produced here.
| Piece | Purpose |
|---|---|
Opcode / Instruction | ISA (opcodes are append-only) |
Value / Message | Runtime / constant-pool tags (ABI versioned) |
Program / Fn | Host-side assembler with named registers |
encode / decode | .bf module bytes (MAGIC + ABI_VERSION) |
verify | Structural checks before a crate::Runtime starts |
Headers: ABI_VERSION (scalars, v5), ABI_VERSION_LISTS (v6),
ABI_VERSION_MAPS (v7), and ABI_VERSION_RECORDS (v8). encode
writes the oldest of these that can hold the constant pool. decode
accepts all four.
Structs§
- Cap
- Authorization record stored in the runtime Cap table, never in bytecode.
- CapId
- Unpredictable capability token. Never a flow id.
- CapRights
- Fixed-width rights bitset. Keep this an explicit allow-list: every new bit here must be audited against the threat-model doc before production.
- Chunk
- A compiled unit of Byteflow bytecode: code, constants and the function
table. One
Chunkcan back many concurrently-running flows — it is immutable after construction, so it is shared behind anArcrather than copied per flow (seecrate::Vm). - Fn
- Emit instructions for one bytecode function.
- Function
Def - A callable entry point inside a
Chunk: either bytecode-defined or a slot reserved for a native (Rust) function registered with the runtime via the FFI table. - Instruction
- A single packed instruction word.
- Label
- An unresolved jump target, patched to a relative offset once its address
is known (see
ChunkBuilder::bind_label). - Message
- Envelope carried in mailboxes and registers (Atomic Hop).
- Native
Mask - Bitset over
NativeTableindices, sized once at boot toNativeTable::len(). Shared viaArcbecause attenuation clones the Cap far more often than it clones the mask. - Program
- Assemble one bytecode module.
- Reg
- A virtual register in the current function.
- RegWindow
- Contiguous register window (e.g. four slots for
make_msgnatives). - Revocation
Cell - One revocation counter per capability issuer (a flow, the native table, the scheduler). Revoke is O(1); every derived Cap dies with it.
- Verify
Config - Knob for
verify_with. Default trust is untrusted.
Enums§
- Assemble
Error - Why a text listing could not become a verified
Chunk. - CapId
Error - Why
CapId::randomcould not produce a token. - CapTarget
- What a capability addresses. Bytecode never sees this enum — only the
opaque
CapIdtoken. - Constant
Kind - Constant-pool tags that untrusted modules must not embed.
- Format
Error - Why a
.bfbuffer failed to decode. - IntCmp
- Integer comparison used by
Opcode::ReceiveMatchCmp. - MapKey
- Key of a
Value::Map. Floats are not keys: equality would not be a useful match, and a NaN key could never be read back. - Opcode
- A single Byteflow opcode.
- Restart
Policy - Restart policy consulted when a supervised flow terminates.
- Trust
Level - Whether the chunk may contain authority-bearing constants.
- Value
- A dynamically-tagged runtime value.
- Verify
Error - Why a
Chunkfailed verification.
Constants§
- ABI_
VERSION - Scalar module header (v5). A list, map, or record raises the header to
ABI_VERSION_LISTS,ABI_VERSION_MAPS, orABI_VERSION_RECORDS. Bump on any breaking change to instruction encoding, constant representation, or function-table layout. - ABI_
VERSION_ LISTS - ABI that introduces
Value::List.encodeemits this when the pool contains a list and no map or record.decodeaccepts v5 through v8. A v5 header rejects tag9. - ABI_
VERSION_ MAPS - ABI that introduces
Value::Map. Emitted when a constant contains a map and no record. A map nested in a record is written asABI_VERSION_RECORDS. Decode accepts v5 through v8. A header below v7 rejects tag10. - ABI_
VERSION_ RECORDS - ABI that introduces
Value::Record. Emitted when a constant contains a record, including one nested in a list, map, or message. Decode accepts v5 through v8. A header below v8 rejects tag11. - MAGIC
- On-disk magic for the
.bfmodule format (see design notes §32). Chosen so a corrupted/truncated file is rejected in the first 4 bytes rather than partway through decoding. - MAX_
LIST_ LEN - Most elements a
Value::Listmay hold. Wider sequences are rejected by the decoder,ListPack, andValue::try_list. - MAX_
MAP_ LEN - Most pairs a
Value::Mapmay hold. Keys areMapKey(IntorStr). - MAX_
RECORD_ LEN - Most fields a
Value::Recordmay hold. Positional, not a map. - TAG_
SYS_ AWAIT - Reserved Atomic Hop tag for a host
HostAwaitcompletion.request_idis the ticket written into the await register. - TAG_
SYS_ DOWN - Reserved Atomic Hop tag for monitor
DOWNevents (not an application tag). - TAG_
SYS_ EXIT - Reserved Atomic Hop tag for linked-exit notices (
Asktarget death ortrap_exitlink signal).
Functions§
- assemble
- Parse a listing produced by
super::disassembleand verify it. - decode
- Decode a BFV0 module. Untrusted by default: Cap / Pid / Message constants
are rejected (see
decode_with). - decode_
with - Decode with an explicit trust level. Trusted decode is for host-packed modules that may embed authority tags in the constant pool.
- disassemble
- Assemblable listing of a
Chunk.super::assemblereads it back. - encode
- Encode
chunkas a BFV0 module (little-endian). Pure data — no I/O. - payload_
matches truewhenhopis aValue::Messagewithtagand a payload equal toexpected.- verify
- Verify structural invariants of
chunk. SeeVerifyErrorfor what is checked. This does not perform full dataflow/register-liveness verification (unlike, say, the JVM verifier) — v0 trades that off against implementation complexity. - verify_
with - Like
verify, with an explicitVerifyConfig.
Type Aliases§
- FuncId
- Function index returned by
Program::function. - Native
Idx - Index into a
crate::NativeTable.