RUNELEARNING TOOLCHAIN
Prologue
RUVNET / RUST TOOLCHAIN

RUNEThe learning toolchain for Rust

Source becomes software. Evidence earns promotion.

The premise

AI may propose a faster path. It does not get to move the finish line.
01 / 08

Two paths. One trust boundary.

Rune wraps Cargo with a deterministic build path and a separate, budgeted discovery path.

An approved plan replays without a model. Exploration may suggest a candidate, but it cannot edit the acceptance contract or silently enter the build.

  • Build from a frozen plan
  • Explore only when explicitly asked
  • Promote only after independent evaluation
02 / 08

Freeze the world that matters.

A plan is bound to the exact source tree, lockfile, compiler identity, policy, and target.

Its ID is the SHA-256 of canonical JSON. Edit a source file and ordinary rune build refuses with a stale-plan reason until you approve a new plan with --freeze.

Why it matters: reproducibility starts by making drift visible.
03 / 08

Build without asking an agent.

The normal path replays the approved plan using Cargo’s locked, offline mode.

rune build runs the equivalent of cargo build --release --locked --offline, records an artifact digest, and writes a receipt stating that model calls equal zero.

  • Credentials are not read
  • The cost ledger is not touched
  • rune verify rebuilds in a clean target directory
04 / 08

Learning is a gated loop.

Recall. Propose. Apply. Evaluate. Retain. Record.

Recipes are ranked by workload, hardware, compiler, ABI, target, and policy fingerprints. Ranking is only a suggestion. A paid proposal reserves its dollar and token budget first; output remains data until tested.

  • Candidate edits are hash-checked
  • Failure preserves the baseline
  • Rejected recipes remain searchable with their failure scope
05 / 08

The optimizer cannot grade itself.

The contract, thresholds, and hidden holdout live outside the candidate tree.

Static gates reject new unsafe, dependencies, build scripts, proc-macros, network access, process creation, environment reads, and filesystem writes before candidate code is built.

  • At least 30 paired, interleaved samples after warmup
  • The 95% CI lower bound must clear the minimum improvement
  • Guard benchmarks must stay within tolerance
06 / 08

Approve the thing you tested.

Promotion binds approval to the exact artifact, target, compiler, policy, contract, and evaluator version.

An Ed25519 evaluator receipt authenticates the report bytes. A trusted key must be supplied independently of the candidate workspace.

Important: a signature proves provenance and integrity—not correctness, and not a hardened sandbox.
07 / 08

Measured, scoped, and falsifiable.

A squared-distance fixture reached a 3.51× geometric-mean speedup with a 95% CI of [3.511, 3.513].

The experiment used 40 interleaved pairs after five warmups, pinned to one core. A candidate that dropped the final partial chunk passed visible tests, then failed the hidden length-7 holdout.

Scope: one small kernel, one session, one x86_64 Linux machine. It is not a benchmark of your code.
08 / 08

Suggestions are cheap. Evidence is durable.

Rune turns optimization from an act of faith into a chain of inspectable decisions.

Explain shows the recipe, measurements, and cost behind a decision. Rollback restores the previous approved plan. Cleanup is dry-run by default and quarantines only owned generated objects.

  • Similarity suggests
  • Measurements decide
  • Evidence travels with the artifact
Self-learning optimizer / exact mechanics

It learns around the compiler.

Rune is not a new Rust compiler and does not replace rustc. It is a learning orchestration layer around Cargo and rustc: it remembers which source-level optimization recipes worked, where they worked, what they cost, and why other candidates failed.

Compiler compatibility is the boundary.

Rustc still parses, optimizes, and emits machine code. Rune owns the surrounding loop: context, candidate search, controlled edits, independent evaluation, evidence memory, promotion, rollback, and artifact lineage.

Orchestrator ≠ compiler fork
01

Fingerprint the current problem

Rune describes the optimization context using source semantics, workload distribution, target architecture, CPU features, compiler version, ABI, and policy fingerprint.

A match on source text alone is not enough; hardware or policy drift changes the context.
02

Recall evidence, not instructions

Memory stores recipe descriptors linked to baseline and candidate hashes, raw measurements, confidence intervals, failures, evaluator version, resource cost, and retention class.

A recipe says “this worked under these conditions,” not “apply this everywhere.”
03

Rank or propose a candidate

Contextually similar recipes are ranked first. If local memory cannot supply a useful candidate, rune improve may request one bounded model proposal after reserving its dollar and token budget.

The model returns candidate data. It does not alter the approved build.
04

Apply inside a candidate workspace

An exact replacement or pinned Agent Booster sidecar applies the edit only after source-hash, path, symlink, and size checks. A placement confidence score is never treated as correctness.

The baseline remains untouched and available for comparison or rollback.
05

Evaluate against today’s contract

A separate evaluator compiles, runs visible tests, challenges a hidden holdout, applies capability gates, and performs paired interleaved benchmarks. The optimizer cannot edit these rules.

Even a previously successful recipe must pass again when compiler, target, policy, or contract changes.
06

Learn from success and failure

Validated evidence enters memory. Rejected candidates remain searchable with their failure scope, preventing the system from repeatedly paying for known-bad ideas while avoiding overgeneralization.

Approval is bound to the exact tested artifact; memory only improves the next search order.
53.5%validated selection on fresh cases

Evidence that memory can improve selection—within a narrow domain.

Frozen memory selected a validated improvement in 154 of 288 fresh cases across twelve synthetic sorting contexts, versus 35.5% expected for uniform random selection and 36.8% for the training-selected fixed algorithm. All 24 seed blocks favored memory and the preregistered confirmation gates passed.

Scope: one shared host, synthetic sorting contexts, and harness-supplied feature metadata. This does not prove general compiler improvement, autonomous algorithm invention, or production-wide transfer.

Why Rune is different

Optimization with a memory—and a constitution.

Most optimization systems own one part of the loop. Rune connects search, measurement, safety policy, economics, memory, artifact identity, and rollback while keeping proposal power separate from approval power.

ApproachWhat it optimizesWhat it remembersWho decidesRune’s distinction
rustc / LLVMCompiler IR and machine code through built-in passes and heuristics.Normally no cross-project evidence memory between ordinary builds.The compiler’s tested implementation and flags.Rune reuses rustc, then governs source-level alternatives and evidence across runs.
AI coding agentOpen-ended source edits guided by prompts and repository context.Conversation or agent memory, often without artifact-bound performance evidence.Frequently the same agent proposes and informally judges the edit.Rune treats model output as untrusted candidate data and grades it independently.
PGOCompiler decisions guided by profiles from representative executions.Profile data tied to instrumented workloads and compiler tooling.The compiler applies profile-guided transformations.Rune can search algorithmic or source-level alternatives; it complements rather than replaces PGO.
AutotunerA predefined parameter or implementation search space.Measurements for configurations in that search domain.A scoring objective selects the winner.Rune adds semantic contracts, capability gates, cost accounting, negative memory, and signed promotion evidence.
RuneContextual source-level recipes executed by the existing Rust toolchain.Scoped successes and failures with hashes, costs, statistics, policy, and evaluator identity.An independent evaluator under a frozen contract.A deterministic build path remains agent-free; learning changes search priority, never the acceptance rules.

Where this architecture is better

01 / REPRODUCIBILITY

Learning cannot contaminate normal builds.

Approved builds replay pinned inputs offline with zero model calls. Exploration is explicit, separate, and reversible.

02 / NEGATIVE MEMORY

Failure becomes useful evidence.

Rejected candidates keep their failure scope, so later searches can avoid repeating expensive mistakes without banning an idea everywhere.

03 / CONTEXT

“Faster” is tied to where.

Target, CPU features, compiler, ABI, workload, and policy travel with the result. An x86 win does not silently become an ARM approval.

04 / TRUST

The optimizer cannot move the goalposts.

Hidden tests, thresholds, capability policy, signing keys, and promotion permissions stay outside the candidate workspace.

05 / ECONOMICS

Search has a visible price.

Paid calls reserve budget before execution, reconcile provider-reported cost, and attach resource cost to the evidence record.

06 / OPERATIONS

Every decision is explainable and reversible.

Plans, artifact digests, measurements, evaluator receipts, cleanup ownership, and rollback targets form one auditable chain.

Where Rune is not “better”

Rune is not a replacement for rustc’s optimizer, LLVM, PGO, formal verification, or a hardened sandbox. It adds the most value when optimization must be reproducible, governed, budgeted, hardware-aware, and auditable. Its published learning result is promising but deliberately narrow; broad production generalization remains unproven.

Repository-measured results

Claims with edges.

3.51×Fixture kernel geometric-mean speedup95% CI [3.511, 3.513]
0.77 msp95 recipe selection over 10,000 synthetic recipesTarget: under 10 ms
$0.0119One live rune improve call1,325 tokens; ledger reconciled
0Model calls in approved build and verify pathsAsserted by repository tests
Read the boundary

These results come from the repository’s fixtures and tests. The confidence interval measures within-session variance, not drift across days; recipe selection uses synthetic records; the live-call ledger check is not an independent billing audit. Rune’s broader cross-family generalization remains unproven.

Four commands

Make drift explicit.

Install the rune-toolchain package, freeze a plan from committed inputs, verify its artifact, then inspect the evidence trail.

Open full quick start ↗
RUNE / QUICK START
$ cargo install rune-toolchain

$ cd your-cargo-workspace
$ rune build --freeze
✓ plan approved · build offline · digest recorded

$ rune verify
✓ clean rebuild matches recorded artifact

$ rune explain
# plan lineage · budget · measurements · evidence
Workspace architecture

Small crates. Explicit roles.

CLIrune-toolchain

User-facing orchestration and commands.

CONTRACTSrune-toolchain-core

Plans, tree digests, plan store, and cost ledger.

BUILDrune-toolchain-cargo

Toolchain identity and locked offline Cargo builds.

EDITrune-toolchain-edit

Hash-checked exact-replace and Agent Booster edits.

EVALUATErune-toolchain-eval

Isolation, hidden holdouts, paired statistics, and receipts.

REMEMBERrune-toolchain-memory

Recipe ranking, approval keys, snapshots, and studies.

TARGETrune-toolchain-target

Cross-build descriptors, executors, and artifact envelopes.

LIFECYCLErune-toolchain-gc

Ownership manifests, leases, quarantine, and purge.