Case study 15 / 37
Halyard
A deterministic, gas-metered, capability-gated register VM for running code you don't trust and replaying exactly what it did.
- Status
- Research
- Period
- 2026
- Domain
- Security · Experiments
- Language
- Rust
- Last push
- 26 OCT 2026
- License
- MIT
- Source of claims
- README.md, docs/ISA.md, ARCHITECTURE.md
A small register machine (16 × i64, fixed 8-byte instructions) for executing agent tools, workflow actions and plugins where the host must bound how long code runs, control what it can touch, and prove what happened. Pure Rust, zero dependencies, with an assembler, disassembler and interactive debugger.
01/The problem
WebAssembly is the right answer for portable, fast sandboxing, but it is a large specification with no built-in gas metering and no serialisable machine state. Lua-style embeds aren't deterministic and can't be paused and resumed byte for byte. Orchestrators running untrusted steps need something bounded, deterministic, inspectable and resumable.
02/The system
A small register machine (16 × i64, fixed 8-byte instructions) for executing agent tools, workflow actions and plugins where the host must bound how long code runs, control what it can touch, and prove what happened. Pure Rust, zero dependencies, with an assembler, disassembler and interactive debugger.
03/Implementation
- 01Deterministic: no wall clock, no OS randomness, no threads; a seeded xorshift and a state hash that fingerprints the whole machine.
- 02Metered: every instruction has a fixed gas cost; running out of gas stops cleanly and can be resumed, which gives preemption without threads.
- 03Capability-gated: the only exits are numbered syscalls, each behind an explicit capability, down to individual host-function ids.
- 04Resumable: snapshot/restore serialise registers, memory, stacks, heap, handler, gas and RNG, so a run can pause on one machine and finish on another.
- 05Recoverable traps for division by zero, out-of-bounds memory, stack overflow, bad jumps, illegal instructions and denied capabilities.
- 06Harvard layout: code lives outside data memory, so no self-modifying code and no jumping into data.
04/Engineering
Gas is part of the ISA
Costs are documented per instruction and exposed to the program itself, rather than bolted on as an external timer.
Snapshots are the unit of scheduling
A VM that ran out of gas is a complete, serialisable value, and tests show that a resumed run ends in the same state hash as an uninterrupted one.
Fixed-width instructions
Trivially decodable 8-byte instructions make the disassembler exact and the execution trace cheap.
05/Interface
No product screenshots are published for this project. The visual above is a code-driven representation of how it behaves, built from the repository source — not a screenshot.
06/Tech stack
- Rust
- Zero dependencies
- Custom ISA
- Assembler
- Debugger
07/Result
Verified outcomes
- 28 tests covering every trap, gas accounting to the unit, capabilities from both sides, snapshot determinism and corrupt-input rejection.
- Reported in the README (one run): ~660M instructions/s in a tight loop; snapshot + restore of 64 KiB in 67 µs.
Known limitations
- A switch-dispatch interpreter with bounds checks on every access. Gas, not CPU, is the intended limit.
08/Links
Related work
Temporal SQL database
TesseraDB →
An embedded SQL database where the past is a first-class query: every row version retained, AS OF reads, and event streams in the same transactions.
Open source · Research
Optimizing compiler
Bellows →
An optimizing compiler you can read end to end, from source text to x86-64 machine code, with an IR interpreter that must agree with the native binary on every program.
Open source · Research
Language for agent workflows
Tarn →
A small language for agent workflows: deterministic tasks, typed capability-gated tools, and record/replay of every side effect.
Open source · Research
Next case study
Bellows →