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 |
Current ABI: see ABI_VERSION (FlowCap + Str / Bytes).
Modules§
- asm_
macros - Namespaced re-exports for callers who prefer an explicit path.
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 processes — it is immutable after construction, so it is shared behind anArcrather than copied per Flow (seebyteflow-vm::Vm::chunk). - 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 (design notes §30-31). - 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§
- 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. - Opcode
- A single Byteflow opcode.
- 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 - Current ABI version. Bump on any breaking change to instruction encoding, constant representation, or function-table layout.
- 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. - 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.
Functions§
- 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
- Human-readable listing of a
Chunk, used bybyteflow-cli disasm. - encode
- Encode
chunkas a BFV0 module (little-endian). Pure data — no I/O. - 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, and instead the VM bounds-checks register indices at runtime (cheap: it’s an array index against a fixed small register file, not worth statically proving away yet). - verify_
with - Like
verify, with an explicitVerifyConfig.
Type Aliases§
- FuncId
- Function index returned by
Program::function. - Native
Idx - Index into a
crate::NativeTable.