Verace Marshal
A Rust microkernel and system design for an object-oriented, code-executing agent runtime with self-compiling prompts.
- Rust microkernel core: Holds gateway, failover, sandboxes and storage
- Execution sandboxes: Runs untrusted code in Wasmtime or a subprocess
- Provider resilience layer: Classifies failures and hedges across providers
- Persistent storage layer: SQLite sessions and LanceDB vector memories
Overview
Verace Marshal, research name VA-1, is the lab's research line on an agent runtime built on a fork of another organisation's open-source agent. The Python agent code, command-line and desktop apps, messaging adapters and bridges, installers, container scripts and test tooling are that organisation's work, some of it modified. The forked agent's chat-platform, model and tool capabilities are also that organisation's. The lab's own contributions are a set of Rust crates and a design suite. The design asks whether an agent runs faster, safer and with less prompt maintenance when it acts by writing code instead of exchanging JSON tool calls.
The design suite has 35 documents. It describes a Rust Tokio microkernel under a Python layer built on NOOA, NVIDIA's object-oriented agent library as the design suite names it, and DSPy, an external prompt-compilation framework. In this design the agent is a live object: methods are actions, attributes are state, docstrings are prompts, and methods whose body is an ellipsis are resolved by CodeAct, where the model writes Python that calls tools by reference. Prompts are typed DSPy signatures compiled against metrics. The Rust core handles sandboxing, storage, gateways, provider failover and prefix caching. A second body of design notes adds rules for compiling, verifying and releasing agent prompts safely.
The Rust crates implement the core services: per-session turn leases, a token-bucket rate limiter with flood bans, a throttled streaming consumer, a credential circuit breaker, failure classification and hedged dispatch across model providers, Wasmtime and subprocess sandboxes, a regex secret redactor, a radix-tree prefix cache, a SQLite schema at version 27 with trigram full-text search, a LanceDB vector store with 1536-dimension embeddings, a stdio MCP server, and a PyO3 bridge to Python. The design suite derives a speculative speedup bound of 2.56x at token level and an estimated 1.57x for CodeAct blocks. These are calculations, not measurements.
The Rust services listed above are implemented. Several parts are partial: the batch benchmark runner executes a stub that returns fixed successes, the cron scheduler only prints trigger messages, the A2A gateway adapter is a stub, and the command-line binary prints a version banner. The NOOA object layer, DSPy continuous compilation, the speculative action engine, the six-layer cognitive memory and the voice pipeline exist only in the design documents. No benchmark run, latency measurement or evaluation is recorded. The lab's audit ledger records multiple rounds of defect fixes against the design and code.
Status
Prototype. Rust crates implement the core runtime services, but the benchmark runner is a stub, the agent and compilation layers exist only in the design suite, and no evaluation is recorded.
Simulator
An agent runs sixty tasks whose steps sometimes fail. Choose whether each step is checked, how often a step fails and how long the tasks are.
- pale: worked first time · colour: caught and repeated · white: failed unnoticed · crossed: given up
- Tasks finished correctly
- 58 of 60
- Finished with a hidden error
- 0
- Given up after three tries
- 2
- Extra work spent on retries
- 15%
Turn the check off: the same failures now finish unnoticed. Lengthen the tasks and see how fast unchecked errors add up.
This simulator is an illustration of the principle, with made-up numbers. It does not run the lab's code or show the lab's data, and nothing in it is a measurement.
Architecture
Rust microkernel core
The
verace-corecrate holds the runtime services: gateway, failover, sandboxes, security, storage, radix cache, MCP, cron, Kanban and batch modules. It defines a sharedCoreErrortype covering timeout, contract, database, storage, security and concurrency failures.PyO3 native bridge
The
verace-bridgecrate exposes a Python module_nativewithPyVectorStoreandPySecretRedactor. It maps core errors to Python exceptions and returns search results through the Arrow C Data Interface.Gateway delivery layer
A
PlatformAdaptertrait gives chat platforms one async interface, with per-user rate limiting, per-session turn leases and throttled streaming edits in front of it. An IRC adapter is implemented and an A2A adapter is a stub.Provider resilience layer
Provider HTTP failures are classified into typed reasons, failing credentials are tripped by a circuit breaker, and requests can be hedged across a primary and a secondary provider.
Execution sandboxes
Untrusted code runs either in a Wasmtime sandbox bounded by fuel and epoch deadlines, or in an isolated Python subprocess that is killed on timeout.
Radix prefix KV cache manager
A compressed prefix tree over token ids tracks which prompt prefixes are cached, so that requests sharing a prefix can reuse it. It evicts unused leaves when a token budget is exceeded.
Persistent storage layer
A WAL-mode SQLite schema at version 27 stores sessions, messages, subagent trajectories, skills, cron jobs, preferences, usage and turn leases. A LanceDB table stores vector memories for nearest-neighbour search.
MCP server multiplexer
An implementation of the Model Context Protocol server side over standard input and output, serving registered async tool handlers to MCP clients.
Kanban and scheduling services
A heartbeat watcher returns abandoned multi-agent Kanban tasks to the queue. An in-memory scheduler handles cron strings, intervals and one-shot times, but only prints trigger messages.
Batch benchmark runner
A Tokio
JoinSetrunner executes benchmark tasks in parallel and writes one trajectory file per task. Task execution is currently a stub that returns fixed success values.NOOA and DSPy agent layer
In the design specification, agents are Python objects whose ellipsis methods trigger CodeAct execution and whose prompts are DSPy signatures compiled in the background and hot-swapped. This layer is designed, not built by the lab.
Speculative action engine
In the design specification, a small local draft model pre-executes CodeAct in copy-on-write sandbox forks while the target model verifies. The work is committed if the two programs agree on their syntax trees and discarded otherwise. Only the design exists.
Implementation
Mechanisms as they are implemented in the source code, with the constants the code uses.
- Turn lease with monotonic generation
TurnLeaseRegistrykeeps an owned Tokio mutex per session, acquired with a timeout, so only one agent turn runs per session at a time. The returned token holds the lock until it is dropped (RAII). A generation counter advanced withfetch_addunder AcqRel ordering fences stale holders. The design calls the registry lockless, but the code holds a per-session mutex.- Token bucket with flood-strike bans
GatewayRateLimitergives each user aTokenBucketof capacity 10 that refills at 1 token per second. Each rejected request adds a strike. 3 strikes setbanned_untilto now plus 60s, and 600s without a strike resets the count to 0.- Throttled streaming message edits
- The stream consumer buffers model token chunks and updates one platform message in place through
stream_edit. It uses a minimum interval of 800ms and a buffer threshold of 20, with a cursor glyph shown during streaming. A final flush writes the text without the cursor. - Credential circuit breaker
CredentialBreakerkeeps an atomic open flag and a timed cooldown per provider key. A 429 response opens it for 3600s and a 401 for 300s. It closes automatically when the cooldown has elapsed, with no half-open probe stage.- Provider failure classification
FailoverReasonvalues drive retry and failover. A 429 isRateLimitwithreset_after_secsof 3600, a 503 or 529 is Overloaded and carries the status code, a 401 or 403 is an authentication failure (revoked credentials are terminal), and a 400 whose message mentions context length isContextWindowExceeded.- Hedged request dispatch
- The hedged router calls the primary provider at once and fires the secondary only if the primary has not answered after
hedge_delay. The first successful reply within 30s wins, and cancellation stops the other request. This cuts tail latency without always paying for two calls. - Fuel and epoch Wasm sandboxing
WasmSubagentSandboxbounds compute with Wasmtime fuel and wall-clock time with epoch interruption. A background ticker advances the epoch every 100ms, and the deadline is ticks for a timeout of milliseconds.- Isolated subprocess sandbox
IsolatedProcessSandboxruns untrusted Python withpython3 -I -c, passes input as JSON on stdin, and kills the process after 5000ms. It returns stdout, stderr and a success flag. The design records a 512 MiB memory ceiling, which the code description does not show.- Radix-tree prefix KV cache
RadixKVCacheManagerstores token sequences on compressed edges keyed by their first token. A partial edge match splits the edge at the common prefix, and a lookup returns the deepest handle covering the matched prefix. The root is pinned withref_countset to 1.- LRU unpinned-leaf eviction
- When
total_cached_tokensexceedsmax_cached_tokens, the tree evicts leaves withref_countequal to 0, oldestlast_accessedfirst, until the overflow is freed. Pinned prefixes still in use are never evicted. - Pattern-based secret redaction
SecretRedactorapplies an ordered list of provider-specific token patterns (API keys, GitHub, AWS and Slack tokens, bearer tokens, PEM private keys) and generic key-value assignment patterns, replacing matches with[REDACTED_SECRET]. The Python wrapper releases the GIL whileredact()runs. The design describes 56 patterns compiled into one alternation, while the code holds an ordered list.- SQLite v27 schema with trigram search
- The WAL-mode schema tracks session token and cost accounting, CodeAct messages, subagent delegations with state and iteration budget, cron jobs and
session_turn_leases. An external-content FTS5 table over message content,codeact_scriptandcodeact_outputuses trigram tokenisation and is kept in sync by insert, delete and update triggers. - Cognitive memory vector schema
VectorMemoryStorewrites to a LanceDB tablecognitive_memorywith an Arrow schema of id, a fixed-size list of 1536 float32 values, content, a layer tag naming the memory layer, and a float64 timestamp. Search returns nearest neighbours.- Zero-copy Arrow export to Python
PyVectorStoreruns hybrid search on a global Tokio runtime and exports results witharrow::ffi::to_ffi. The array and schema are boxed into raw pointers so Python imports them without copying.- MCP stdio JSON-RPC server
MCPServerMultiplexerruns a newline-delimited JSON-RPC 2.0 loop for initialize, tools/list and tools/call. It uses a non-blocking reader, spawns each tool execution, and writes through a single channel of capacity 256. Tool errors return code -32000 and unknown methods -32601.- Heartbeat-based stale worker eviction
WorkerWatcherchecks every 10s and returns tasks with no heartbeat for 120s from IN_PROGRESS to TODO withassigned_workerset to NULL. Blocking SQLite work runs on Tokio's blocking pool.- Panic-inclusive batch accounting
- In the batch runner,
JoinSetjoin errors become trajectories marked Panicked that are still saved. Crashed workers therefore count in the success-rate denominator. A code comment ties this to audit fix P1 #5.
Results
From the lab's own experiments and records. They have not been independently replicated.
Speedup figures are derived, not measured
The design suite's 2.56x token-level and 1.57x CodeAct-block speedups, and its 78% token compute saving, come from the speculative speedup formula and estimates. No run in the lab's records measures them.
No benchmark evaluation recorded
The batch runner that would run benchmark tasks executes a stub returning fixed success values, so no task success rate or latency has been recorded for the system.
Crashed workers kept in the denominator
The lab's audit led the batch runner to record panicked workers as saved trajectories, so a crash lowers the success rate instead of disappearing from it (audit item P1 #5).
Multi-round audit corrected the design
The lab's audit ledger records P0 to P2 fixes across rounds. In the lab's Rust crates and design documents these include epoch interruption to enforce the Wasm sandbox timeout (P1 #2), panic-inclusive batch accounting (P1 #5) and an atomic reserve-and-refund of subagent iteration budgets that prevents race conditions (P1 #1).
Wasm sandbox timeout fixed with epoch interruption
Audit item P1 #2 added epoch interruption on a 100ms ticker to the fuel-metered Wasm sandbox so that a 5,000ms wall-clock timeout is enforced, which the Rust code implements.
Code and design differ on several services
The design describes a lockless turn lease, a single alternation of 56 secret patterns and a working cron scheduler. The code uses a per-session mutex, an ordered pattern list, and a scheduler that only prints triggers.
Cited DSPy gains are external results
The design cites the DSPy paper (arXiv:2310.03714) for gains of +25% on HotPotQA and +46% on GSM8K from compiled prompts. These are that paper's results, not the lab's measurements.
Concepts
- Fork of an external agent
- Verace Marshal starts from an open-source agent built by another organisation. The lab's work is the Rust crates and the design documents. Some crates port designs from the upstream Python modules into Rust.
- CodeAct
- Code as action: instead of emitting one JSON tool call per model turn, the model writes a short Python program that calls tools directly. A multi-step task can then run in one turn instead of several.
- Agent as live object
- The NOOA paradigm, from NVIDIA's object-oriented agent library as the design suite names it, treats an agent as a class instance: methods are capabilities, attributes are state, docstrings are prompts and type annotations are return contracts. Methods whose body is an ellipsis are resolved by model-driven CodeAct.
- Declarative DSPy signatures
- DSPy, an external framework, expresses a prompt as a typed input-to-output signature that an optimiser compiles against a metric. The design uses this in place of hand-written skill prompt strings.
- Continuous compilation lifecycle
- The design describes a cold start, background compilation with DSPy's MIPROv2 optimiser, a canary shadow evaluation on 10% of traffic, and then an atomic hot-swap with rollback. Compilation is triggered when 100 or more new traces arrive together with a 3% metric drop, or when the model version changes.
- Compile break-even rule
- The design notes escalate from a cheap few-shot pilot to costlier optimisers such as MIPROv2 or GEPA only when the expected volume pays for it: . Here is the number of calls, the expected success gain and the cost of a retry.
- Verifier independence rule
- The design notes require the verification step to be structurally independent of the acting step and never trained on the actor's traces, so the actor cannot learn to satisfy its own checker.
- Side-effect-safe compilation
- In the design notes, steps with irreversible effects are compiled through a single-step behaviour-cloning sub-signature, and reversible steps through sandboxed clones, so prompt optimisation never repeats a real-world side effect.
- PromptSync
- A design for a versioned, canary-gated bridge that carries newly compiled DSPy instructions into new agent instances.
- Domain-conditional verdict
- The design notes judge the approach buildable now in domains with an oracle, meaning an automatic check of correctness, and buildable at extra cost in domains without one.
- Dual-tier sandbox
- In the design, code first passes a syntax-tree safety gate. Trusted code then runs in Tier A, an in-process sandbox with restricted builtins, and untrusted code in Tier B, a hard sandbox, which the Rust crates implement as Wasmtime and an isolated subprocess.
- Four-layer defence in depth
- The design stacks an injection filter, a syntax-tree analyser, dual-tier containment and an outbound secret redactor. The Rust crates implement the containment and redaction layers.
- Speculative action
- Speculative execution applied to agent code: a small draft model proposes and pre-runs code while the larger target model checks it, as in speculative sampling (Leviathan et al. 2023, Chen et al. 2023).
- Speculative speedup bound
- The design suite uses , where is the acceptance rate and the draft-to-target latency ratio. From it the suite derives 2.56x at token level and an estimated 1.57x for CodeAct blocks.
- Prompt-cache prefix stability
- Model providers cache prompts by byte prefix, so the design keeps the system prompt byte-identical. When the context reaches 80% full, the oldest 70% is summarised while the prefix stays unchanged.
- Radix prefix caching
- A radix tree is a prefix tree whose edges hold whole token runs instead of single tokens. Requests sharing a prompt prefix map to the same path, so cached work can be reused and evicted per leaf.
- Hedged requests
- A tail-latency technique: send a backup request to a second provider only if the first is slow, keep whichever succeeds first, and cancel the other.
- Six-layer cognitive memory
- The design specifies sensory, working, episodic, semantic triple, long-term fact and procedural skill layers, with a truth maintenance system that keeps derived beliefs consistent. The Rust vector schema carries a layer tag for this, but the layers themselves are not implemented.
- Formal invariant matrix
- The testing design names six invariants: prompt stability, return type safety, memory non-destructiveness, zero-leak sandboxing, lockless turn isolation and convergence of trace-to-skill learning.
- Voice latency budget
- The design targets a voice round trip under 800ms, split as 200ms voice activity detection, 150ms speech recognition, 50ms speculative draft and 250ms streaming speech synthesis.
About this page
Written from the lab's own documents and source code. Figures and results are the lab's measurements as it recorded them at the time, and have not been independently replicated.
Published under the PolyForm Noncommercial License 1.0.0: free for noncommercial use.