RCE language specification, draft 0.9
10. Tooling: the `rce` command and the language server
This section defines the tools that read RCE programs: the rce command
and the language server it contains. It adds no rules to the language; it
says what each tool prints and returns for a given input. Example:
rce run counter.rce "Inc, Dec, Dec" prints the state after each event
and shows that the step of the third event keeps the state, with exit status 1.
10.1 Principles
- Determinism. Every subcommand of 10.2 to 10.10 is a function of its
arguments and the bytes of the files it reads. Two runs on the same input
give the same output bytes and the same exit status. None of them reads
the clock, the network, environment variables or random numbers. The same
binary also carries the host commands (
rce host ...) andrce db, defined by Appendix E; the host loop reads the clock (the frame period ofTick) and the network by design, and logs what it reads as inputs (HC-2, HC-14), so this item does not describe them. The handler-spec staleness rule W-HS-CUR-2 takes a time as an input and is part of the engine profile (D.9, D.10), not of these subcommands. - No model in the loop. No subcommand and no language server request
calls a language model, a remote service or any learned component. A
diagnostic, a run, a test verdict, an emitted file and a formatted file
come only from the rules of sections 2 to 7. A program written outside
RCE, by a model or by a person, enters only as an input file, the
proposals file of
rce repair(10.13, RF-1), and is judged by the same gate as every other candidate. - One checker.
rce check,rce test,rce run,rce emitand the language server all use the same parser, type checker and admission gate (6.9) as the reference checkerrce-check. A file accepted by one is accepted by all. - Exit status. 0 means success. 1 means a program requires change, an
example or check failed, a run reached a kept step,
fmt checkfound a file to change, or an admission receipt does not hold (10.15). Forrce checkandrce fmtthis is the rule AC-1 of 7.1: the status is 1 exactly when a finding requires change. 2 means a usage error: unknown subcommand, wrong number of arguments, unreadable file, or an unknown emit target or construct an emitter does not translate (10.5). 3 means a question the command could not decide within its bound:rce equivandrce changewhen exploration reachedfuelbefore either equivalence or a distinguishing event sequence was established, andrce lawwhen the bound LAW_FUEL left a law undecided (10.11). Status 4 is not used: every run offn mainruns on a host without task threads too (10.3).
rce is one binary, built from the reference checker crate in
spec/checker (crate rce-spec-check, cargo build --release --bin rce).
The language commands of this section are implemented in
spec/checker/src/cli.rs (entry point cli::main), with their tests in
spec/checker/tests/. This rce carries the language commands only; the
Form command line (rce form ...), which reads the Form spec format rather
than RCE programs, is not part of this build, and rce form exits with
status 2.
The tables of 5.15 (which methods each receiver has) and C.6.4 (the work
class of each method) are not typed into the checker a second time: it
reads them from spec/data/spec-data.json, which rce-spec-data
generates from this book. The two tables are cut from it into
spec/data/spec-tables.json, the file compiled into rce, the checker
and its wasm build; rce-spec-data check fails when either file
differs from what the book gives.
10.2 `rce check [write RECEIPT] FILE|DIR...`
All FILEs form one program: use resolves among them and then in the built-in standard library (4.1). A DIR is a
package: it stands for its .rce files, recursively, in sorted order,
and reads nothing outside it (the multi-module example is the package
spec/examples/26_use_module/, so rce check spec/examples/26_use_module
checks it alone). Each file is
parsed, type checked (section 5) and admitted (6.9: every const,
comptime block, check and example is evaluated; 6.11: every law is
decided; 6.12: once these hold, the obligations are judged on the mutants
of the program, W-MUT-1). For each file, in
the order given, one line is printed:
ok FILE
recommended FILE: line N: RULE message
requires change FILE: line N: RULE message [METHOD][; line M: RULE message [METHOD] ...]
observed FILE: line N: RULE message [observed: rce fmt records the rewrite and writes nothing]
Every requires change report names its rule from section 7 and ends with
the rule's method from the table of 7.1: [altered by rce fmt] when
rce fmt writes the change (10.6), else [requires change]. A
recommended line follows the ok line of an admitted file, one per
recommended change. A report of an altered rule whose mode is observe
(RM-2 of 7.1) does not block admission and is printed as an observed
line after the file's verdict; one whose mode is off is not printed.
Last, on standard error, the attention line of AC-1 (7.1), for example
attention: 1 requires change, 0 recommended, 0 altered, 0 observed.
Exit status 1 if any file requires change, else 0.
With write RECEIPT, when every file is admitted, rce check writes the
admission receipt of the program (10.15) to RECEIPT and prints
receipt RECEIPT: SHA256, the SHA-256 of the receipt's bytes; when a file
requires change it writes nothing and prints no receipt RECEIPT: the program requires change. The receipt is written from the admission just
computed, so it records exactly the run whose verdicts were printed.
10.3 `rce run FILE [EVENTS]`
The file must pass rce check alone; otherwise one requires change line is
printed and the status is 1.
With EVENTS. EVENTS is written exactly as the event list of an
example line (3.2, EventRef { "," EventRef }), for example
"Inc, Inc, Dec" or "Deposit(amount: 50), Withdraw(amount: 20)".
Let s₀ be the initial state (6.1) and e₁ … eₙ the events. For k = 1 … n the command computes
(sₖ, oₖ) = δ(sₖ₋₁, eₖ)
where δ is the step function of 6.4 and oₖ is the sequence of values the
step emitted (λ). It prints line 0 as 0 (initial) STATE, then for each k
the line k EVENT STATE followed by one line emit VALUE per element of
oₖ, in order. STATE lists every region as Region { field = value, ... },
regions separated by ; , in declaration order. If the step for eₖ keeps the state, the line
is k EVENT kept: ERROR, sₖ = sₖ₋₁ (T8), and the next event is applied to
that state, as on the host (HC-21). The status is 1 when the step of some
event keeps the state, and 0 otherwise. An event name that is not declared is a usage
of a wrong event list: one requires change line, status 1.
For the counter spec/examples/01_counter.rce:
$ rce run 01_counter.rce "Inc, Inc, Dec, Dec, Dec, Inc"
0 (initial) Counter { n = 0 }
1 Inc Counter { n = 1 }
2 Inc Counter { n = 2 }
3 Dec Counter { n = 1 }
4 Dec Counter { n = 0 }
5 Dec kept: Underflow
6 Inc Counter { n = 1 }
Without EVENTS. The module must declare fn main() with no
parameters. The command evaluates its body by the rules of section 6 and
prints emit VALUE for each value emitted, in order. If the body traps or
fails, the last line is kept: REASON and the status is 1. Calls to
foreign functions (5.11) are not executed by the reference evaluator and
trap. If there is no fn main(), the command says so and the status is 1.
The evaluator is the reference interpreter of the checker, with the fuel bound
of 6.7 and the VALUE_LIMIT of 6.3. It is a definition of meaning, not a fast
runtime. The body runs on the tick runtime of 6.8 and Appendix C, whose log
of the run is the trace of fn main in rce trace (10.9).
The reference tick runtime runs each task, fn main included, on its own
thread of the host, or as a state machine of its one scheduler
(conc::Tasks). A task held as a state machine is the list of answers
the scheduler has given it: at each move the scheduler runs the task's
body from its start on a fresh evaluator, replays those answers in order,
and takes the first step not yet answered as the task's next request. A
body is a function of its arguments and its answers, so every earlier
step repeats exactly, and the log of the run (10.9) is the same, entry
for entry, as with threads (spec/checker/tests/emit_run.rs,
main_traces_without_threads_equal_the_reference, on 66 runs). A par
whose branches wait on lvars runs, in such a task, its branches in
source order, each until it ends or reaches a wait not yet satisfied,
and runs a stopped branch again from the fork after a pass in which a
put changed an lvar; a pass with no change fails the waits, as the
threaded par does when every waiting branch is idle (T29). Where the
host cannot start a thread, such as WASI preview 1 (rce built for
wasm32-wasip1), every task is a state machine and every par runs this
way, so the run needs no thread and prints what it prints on any host.
An lvar (C.11.8) can pass from one task to another, as a spawn
argument, in a message to a channel or an actor, as a task's result, or
inside a closure that captures it, and is then shared: from that point on
a task's lvar operations can see another task's. The reference keeps
such a run a function of the program on every host by three rules.
- Logged lvar operations. A state machine logs what each of its lvar
operations gave (
lvar_new,put,wait,freeze) with the fuel and cost units it took and whether it changed the cell (conc::LvTape). A replay gives each logged result back and charges its cost without reading or changing any cell, so a replayedlvar_newis the cell other tasks hold, not a new one, and a replayed read is not made at a later state. - Moves in task order. Once an lvar has passed between tasks, every task moves alone, in task order (6.8), on a thread as well as when it is a state machine, so the lvar operations of a tick happen in one order on every host.
- Waits the scheduler answers. In a task, outside the branches of a
par, awaiton a shared lvar that is at no threshold is a communication step: the scheduler answers it at the first delivery at which a put has brought the lvar to a threshold, and when no task can move any more such waits trap withlvar wait cannot be satisfied, as the waits of apardo (T29).
A body is a function of its arguments, its answers and the results of its
lvar operations, and a replay is given all three, so it takes the path of
the run it repeats up to the first step not yet answered; that step and
the steps after it run at the point of the run where a thread of the task
runs them, in its move, and the moves happen in the same order on every
host. The log is therefore the same entry for entry with or without
threads (emit_run.rs, lvar_passing_traces_without_threads_equal_the_reference,
on eight programs that pass an lvar by each route, two of them filling it
after the waiting task has started, each also on twenty threaded runs).
No run of fn main needs task threads. The tick runtime written in the
core, which rce run-core would run, is still the next slice of the
proposal one-emitter.md (section 13, 10.12).
10.4 `rce test FILE|DIR...`
The test cases of a module are its example lines and its check items,
including those inside intent blocks. rce test admits the files as
rce check does, which evaluates every case (6.9, W-INT-1). It prints, per
file,
ok FILE (E examples, C checks)
FAIL FILE: line N: RULE message[; ...]
with E and C the numbers of cases in that file, then a total line
P passed, F failed. Exit status 1 if F > 0. A test verdict therefore
equals the admission verdict: a module whose examples do not hold is not a
program (section 7).
10.5 `rce emit TARGET FILE`
TARGET names an output. The file must pass rce check on its own; for
core it may instead be a core module, a JSON object whose format is
rce-core/1, which is read only if it is well formed (rules W1 to W6 of
the proposal spec/proposals/one-emitter.md, ONE-3).
| TARGET | Output |
|---|---|
form |
the Form P = (S, E, δ, D, λ) as one line of JSON (6.1), then a line end |
core |
the core module of FILE, format rce-core/1 (the module lowered once, or the core module read), as one line of canonical JSON (6.1.1), then a line end (informative: the core is the proposal one-emitter.md, ONE-1) |
rust |
one Rust 2024 source file with a main |
python |
one Python 3 source file |
js |
one JavaScript module (ES2020 or later, BigInt) for Node |
scala |
one Scala 3 source file with a @main for the JVM (Java 19 or later) |
verilog |
the step function δ as one synthesizable Verilog-2005 module (IEEE 1364-2005), for the subset of the proposal spec/proposals/emit-verilog.md (informative) |
wasm |
each graph term of FILE (6.13) as one WebAssembly text module that runs the term node by node through the kernel library (10.18) |
The Form JSON lists objects in canonical order (6.1), so it is a deterministic function of the program text.
The four program targets and verilog are the ones this checker emits. The language
places no bound on targets, and it is designed so that every language is
both an output of the Form (a target, printed through a per-language
table) and an input (a lift, the reverse map, from the language's grammar
and a semantics table), each passing the same gate, the reference trace of
every example program byte for byte (T9). That design
(spec/proposals/rce-form.md, informative) is not built; of the four
program targets, rust, python and js pass the gate today. The registry of targets
and the one-emitter mechanism are the proposal spec/proposals/emit-targets.md
(informative); a target that the table cannot pin to 6.3 is observation-only,
never a projection.
The program emitters. rust, python, js and scala translate the checked
module, not the Form. Each output is self-contained. Its first line is a
comment naming the program hash (10.8: the SHA-256 over the definition
hashes of F.4.3, name-free and layout-free) and the checker version and
commit that printed it, so an emitted file is tied to its source. It starts with a
runtime that defines the values of 6.3 and their operations, following the
reference evaluator (spec/checker/src/interp.rs) value by value. That
includes the integer range checks, the trap messages, canonical map key order
and the display of floats and text. After the runtime comes one target
function per RCE function, method, step and constant. An expression becomes
calls to runtime helpers with its operands in evaluation order; if,
while, loop, for and match become the target's own control flow,
with one counter per loop against its bound. Values are never changed in
place: an assignment to a.f[i] rebuilds the value, as the reference
evaluator's assign does.
The Rust output follows the shape of the verified emitter of T9
(spec/lean/RCE/Emit.lean): one value type, Result with ? for traps
and kept steps, and i128 arithmetic checked against each integer type's
range. The theorem of T9 is about the Lean model of that emitter. The
emitter in rce is tested against the reference evaluator; it is not
proved.
The Scala output is the functional-language target. Its values are the
same dynamic values as the JavaScript output's (integers as BigInt with
their type, floats as JVM Double, whose arithmetic is IEEE 754 binary64
with round to nearest even and no contraction since Java 17, and whose
toString is the shortest round trip since Java 19). Loops are while
loops, and break and continue are control exceptions caught at the
loop, so no RCE loop grows the stack; the observations run on one thread
with a 2 GiB stack.
What an emitted program does. Run it, and it prints the module's
observations: one line per constant, per check, per function without
parameters (other than main), per event of each example (the state after
it, its outputs, or the kept record), and finally the outputs and result of
fn main. These are the lines emit::observe computes with the reference
evaluator, so that a target and the reference can be compared line for
line.
Embedding an emitted program. An emitted file is also the step
function of the module, for a host to call (Appendix E: the host contract
is met around δ). Imported rather than run, it prints nothing: the Python
file prints its observations only under __name__ == "__main__", and the
JavaScript module only when node runs that file itself; the JavaScript
module exports initialState, delta, showState, show, construct,
fuelReset, chk, Kept, the value classes Int, F, Rec, Lst,
Mp and Opt, EVENT_FIELDS, formValue and fvJson, and loads where
there is no process (a browser), where steps run and tasks and par do
not. The Rust file, used as a module (#[path = "FILE"] mod m;), makes
initial_state, delta, show_state and event_fields public. A host
calls the initial state once and delta(state, event) once per input,
after resetting the fuel (HC-7a); delta returns the next state and the
outputs, or reports the step as kept with the reason's display text.
examples/interop/ holds such hosts (an asyncio and a FastAPI service in
Python, a tokio service in Rust, a node:http service and a React
component in JavaScript) and examples/interop/check.py, which requires
each host's transcript to equal rce run FILE EVENTS byte for byte.
How the emitters are tested. spec/checker/tests/emit.rs emits all 62
programs of spec/examples/ (the 60 files and the 2 of 26_use_module) in
all three targets. To exercise function
bodies, it first adds probes: for each function and method, up to three
calls on small sample arguments built from the parameter types, plus one
example that sends every event. It then runs each output (rustc,
python3, node) and requires its output to equal the reference
evaluator's, line for line. On 2026-10-16, with rustc 1.98.1, Python 3.13.5
and Node 20.19.2, all 58 agree on all three targets, with 474 observation
lines per target. (The dated runs below were made when the corpus was 51
programs, and 55 for Scala, with 299 and 361 observation lines.) Four programs (14, 15, 34, 47) contain only
concurrency and give no observation. A separate program
(tests/emit_edge.rce) covers range traps, loop bounds, &mut write-back,
closures and float display. The Scala target has its own test in the same
file: on 2026-10-14, on the Apple M5 Max below, with Scala 3.10.0 run by
scala-cli 1.18.0 on OpenJDK 27, all 55 programs of the current corpus
(with the package files of example 26) agree with the reference, 0
not printed, 361 observation lines, and the edge program agrees on all four
targets. Its oracle is RCE_SCALA (default scala-cli). That agreement is for this examples corpus only. On the larger conformance suite (conformance/), a run on 2026-10-28 with Scala 3.10.0 on OpenJDK 21, which compared each trace by its head only, passes 1,459 tests with 0 failures, and 520 are not applicable to an emitter; the Scala emitter has not yet been run with the whole-trace comparison of the emit baseline (conformance/README.md).
The targets a test run covers are named as data,
one word per line, in spec/checker/tests/emit_targets.txt (rust,
python, js, scala), never by an environment variable or a flag. Every
test that runs emitted programs runs them on each covered target it uses
and fails when a covered target's toolchain does not start; a target the
file does not name is reported as not covered by the run, never counted as
a pass, and a test of that target alone is reported as ignored. The file
names rust, python and js, the toolchains of the continuous
integration runs; Scala is covered by adding its word. The
oracles used were Python 3.13.5 and Node 20.19.2.
The test reads the oracle paths from RCE_RUSTC, RCE_PYTHON and
RCE_NODE (default rustc, python3, node on the path) and prints each
oracle's version. On 2026-10-12 the same tests were also run on an Apple
M5 Max (macOS 27.0.1, arm64) with rustc 1.98.1, Python 3.14.5 and Node
26.11.1: 51 of 51 agree on each of the three targets, 0 not printed, 0
skipped, 299 observation lines per target, and the edge program agrees on
all three.
Fuel. Each emitted program counts fuel (6.7) at the reference
evaluator's charge points: one tick per evaluated expression, per
executed statement, per call of a user function or method, and per
element of a list comprehension and of map, filter and fold. A
temporary introduced by the emitter's own lowering is not charged. The
limit is 50,000,000; it is reset before each observation, as the reference
starts a new evaluator for each, and running out traps with the message
"comptime fuel exhausted". The words fuel N set the limit to N and
fuel-trace prints fuel K after each observation, K being the ticks
used. These two words exist for the test below; the default program
takes no argument.
The log D. With the word trace, an emitted program also prints
the log D (6.1) of each example. Before the line of each event that δ
applied or kept comes its entry, d applied HASH BODY or d kept HASH BODY, where BODY is the canonical JSON of {event, prev_hash, seq, state_hash} over the positional forms and HASH is its SHA-256; after the
example's last event comes trace HEAD, the hash of the last entry (64
zeros when there is none). emit::observe_trace computes the same lines
with the reference evaluator, the fuel lines of fuel-trace included.
The head commits to the events and the state hashes only. The state shown
after each event, the outputs, the reason an event was kept and the fuel
are not hashed, so a trace is compared whole: every line of an example's
block, the entries of D included. The emit adapters of conformance/
answer a trace with that block, and the harness compares it line for line
with the block rce-conform prints for the same program and events.
spec/checker/tests/fuel.rs compares the ticks used, line for line, on
the 50 programs of the emitter tests (with probes) against
emit::observe_fuel of the reference evaluator, in all three targets. It
then runs ten programs at every limit from 0 up to 300 and at 400 evenly
spaced limits above, up to one more than the program uses, and requires
each target to trap at the same observation with the same output as the
reference run at the same limit. Within one observation, the emitted
order of ticks can differ from the reference where the emitter evaluates
arguments before entering a call; the trap observation and the total are
what the test fixes. The Scala target is in the same test (the emitted
file is packaged once into a jar and run with java -jar); on 2026-10-14
it agreed on all 54 programs of that corpus and at all 1,366 swept limits
(a run that covered Scala alone).
Running fn main. Run with the word run, an emitted program
instead evaluates fn main with tasks, channels, select, actors and
par on a runtime of its own: every task is a thread (a worker in
JavaScript), and one scheduler admits their moves tick by tick in the
order of conc::run_main, the reference of rce run without EVENTS. It
prints emit VALUE per output and the line outcome Done,
outcome Deadlock or outcome Stopped: REASON. A module without
fn main() prints the reference's message ("nothing to run") on standard
error and exits with status 1, as rce run does. Fuel follows the reference's
pools: each task has its own, starting full (its first ticks are the call
of its function and one per argument); actor handlers share the
scheduler's pool; a par branch or for ... par chunk starts from its
parent's remaining fuel, and the branches are charged back in source
order, so the trap falls where the reference's sequential run puts it.
With trace as well, the program prints the trace of fn main (10.9)
before the outcome line: per entry of the run's log, in order, the line
d applied HASH BODY (d kept HASH BODY for a Kept entry), BODY the
canonical JSON of {event, prev_hash, seq, state_hash} of that step and
HASH its SHA-256, then trace HEAD.
spec/checker/tests/emit_run.rs compares the three runtimes with
conc::run_main on a corpus of task programs. Among them are the four
concurrency examples 14, 15, 34 and 47, each run with a fn main from
spec/checker/tests/drivers/ appended to its unchanged text. Its test
main_traces_agree_on_every_target compares the traces of fn main of
the three runtimes with the reference's, line for line, on 66 runs: that
corpus, the supervised actors of the same file, example 37, two session
programs of spec/conc06b/accept/, the partition cases and program
events, which together write an entry of every kind of 10.9.
spec/checker/tests/fuel_run.rs runs seven of these programs at every
fuel limit where the reference's result changes and at the limit before
it (258 runs over the three targets), and requires the same outputs and
outcome.
The Verilog target. verilog prints δ, not the observations: one
module that holds the state in registers, loaded with the initial state
s0 at reset, and takes one step per clock on the event at its inputs (a
tag, a payload and a valid strobe). Its outputs are the outcome of the
step (applied, or kept with the declared error or the trap and the value
the trap names), the values the step emitted, and the state registers.
Loops are unrolled to their constant bounds and calls are inlined; every
integer operation is computed at a width that holds its exact result and
then checked against its type (6.3 N2), so an overflow or another trap
keeps the state where the reference evaluator keeps it, with the same
reason. The subset is the proposal's EV-1: integer, bool, field-less
kind and fixed-array state and event fields, steps whose loops have
constant bounds, non-recursive functions, and no text, list, map, task or
fn main. A program outside it is answered requires change for target verilog: REASON, line N, status 1, and nothing is printed. The module's
comment line // rce-hdl/1 JSON gives its layout and the program's
example events. spec/checker/hdl/rce_tb.v is a test bench that reads
those events as a byte stream and dumps the registers after each step,
and spec/checker/hdl/bench.py computes the state hashes from the dumps,
outside the hardware, and prints each example's whole trace (the lines
of emit::trace_example except fuel N, which counts the evaluator's
steps and has no counterpart in a circuit).
spec/checker/tests/emit_verilog.rs checks, with no simulator, that two
emits give the same bytes, that six modules equal their golden texts,
that the admitted examples are 01, 17, 30, 59, 60 and 61, that ten
programs outside the subset are refused with their reasons, and that the
harness prints the reference's trace from a dump of the reference's
states; .github/workflows/verilog.yml installs Icarus Verilog,
Verilator and Yosys and requires every program's simulated trace to equal
the reference's line for line on both simulators, then synthesizes each
module with Yosys and prints its cell counts. A passing run is a
simulation and synthesis result; no module has run on a board.
Limits of the emitters.
- In the observations, channels,
spawn,select, actors andexternfunctions trap with the same message as in the reference evaluator ("not available at comptime"); they run only underrun.externfunctions trap there too. - A
parwhose branches wait on an lvar runs its branches at the same time in the reference (ParMode::Threads). Derivation. The governing law is schedule independence: aparmust be observationally equal to one fixed sequential order, source order (C.4). Fuel is additive over sequential composition, so the sequential run traps at the first branch i where the uses of branches 1..i sum past the fuel left at the fork. The reference therefore gives each branch a copy of that fuel, sums the branches' uses in source order after they finish, and traps with "comptime fuel exhausted" at the first branch whose running sum passes it, before that branch's own result is taken. The trap point is the sequential one. A split of the fuel before the fork would make the set of programs that trap depend on the split rule and would agree with no sequential order, with no gain in soundness, so it is not used. The cost of running branches ahead is bounded: at most k times the fuel left at the fork is evaluated for aparof k branches, of which the excess over the sequential run is discarded. A wait charges no fuel while blocked, so a branch's use does not depend on the schedule. The emitters run such aparby restart and restore the fuel and the budgets of an abandoned attempt (par_snap,par_restore), so each branch is charged once, for its completing attempt.spec/checker/tests/fuel_run.rschecks this at every change point on two programs (lvarpar, andlvartrap, where a late division by zero must lose to the fuel trap when fuel runs out first). - Deep recursion ends with the target's own stack error.
- A call that writes back its receiver or a
&mutargument (xs.push(x),f(&mut a)) is translated only as a whole statement or as the right side oflet,var, an assignment,return,emitorfail. Elsewhere,rce emitdoes not yet print the program: it exits with status 2 and names the construct. Every example program is printed. - When a function whose result is a union fails, its
&mutarguments are not written back. The reference evaluator writes them back. - The Python output has been checked with Python 3.13.5 and 3.14.5, and the JavaScript output with Node 20.19.2 and 26.11.1. Other versions have not been run.
- The Scala output has been checked with Scala 3.10.0 only, on OpenJDK 27
(the examples corpus) and OpenJDK 21 (the conformance suite). With
runit runsfn mainthrough its task runtime, the same tick scheduler as the other targets, and prints that there is nothing to run when nofn main()is declared. Aparruns its branches in source order on one thread (by restart when they wait on lvars), as the JavaScript output does when a local cannot go to a worker.
For an unknown target, or a program that one of these emitters does not
translate, rce emit prints nothing on standard output, prints the reason
on standard error, and exits with status 2; a program outside the subset
of verilog requires change (status 1). It never prints a partial file.
10.6 `rce fmt [check] FILE...`
rce fmt rewrites each file into canonical layout. Let tok(t) be the token
sequence of text t produced by the lexer and layout pass of 2.6, with line
numbers dropped. The formatter is a function fmt on texts with:
- Meaning preserved. tok(fmt(t)) = tok(t). The formatter checks this
equality on every file before writing it; if it would fail, the file is
left unchanged, a
requires changeline is printed and the status is 1. - Canonical layout. In fmt(t): a block that is k levels deep starts its lines with exactly 4k spaces; no line has trailing spaces; there are no blank lines before the first line, no two blank lines in a row, and the file ends with exactly one line end. A comment-only line takes the indentation of the next code line. A line that continues inside an open bracket keeps its position relative to the line that opened it.
- Idempotence. fmt(fmt(t)) = fmt(t). This is tested on every program
in
spec/examples/and on the formatter's tests; it is not proved.
A text that requires change under the lexer (2.6, W-LEX-1, W-LEX-2) requires change
under fmt with the same reason. A file that requires change under rce check
can still be formatted.
Altered rules. Before the layout, fmt writes the rewrite of every
report whose rule's method is altered (7.1): W-UNUSED-1 and W-DROP-1. The
rewrites are those of the table of 7.1. A new name is the first of n,
n1, n2, … that is not already a name in the text. Each rewrite is
written only when the static reports of the new text are those of the old
text less the one it answers; otherwise the report is printed as
requires change FILE: line N: RULE message [not altered: …] and the
status is 1. No line is added or removed, except that a match arm written
on one line, P -> e, whose e is a W-DROP-1 report becomes the block arm
P with the one statement let _ = e, since let is not an expression. A
second run writes nothing (tests/three_methods.rs). Item 1 holds for the layout step; the altered
step changes exactly the places its rewrites name.
With check, no file is written; each rewrite is printed as
would alter FILE: line N: RULE what, each file whose layout would change
as would reformat FILE, and the status is 1: under check, each such
line is a finding that requires change. Without it, each rewrite is
printed as altered FILE: line N: RULE what, and each changed file is
written and printed as formatted FILE.
Modes. The rewrites above are those of the altered rules whose mode
(RM-2 of 7.1) is auto; a rule whose mode is off is not rewritten.
The rewrites of the rules whose mode is observe are worked out on the
text as the auto rewrites leave it, in the same rounds, and recorded,
never written, with or without check: each is printed as
observed FILE: line N: RULE what, followed by its canonical diff
(the - and + lines of 10.13, each indented by four spaces) from the
text as the earlier recorded rewrites leave it. Applying the diffs in
order to the text gives the text rce fmt would write before the layout
step if those rules were auto and applied after the others
(tests/rule_modes.rs). A recorded rewrite does not change the status.
The run ends with the attention line of AC-1 (7.1) on standard error.
rce fmt nameless FILE prints the name-free projection of one file
to standard output and writes nothing. Every identifier the module declares
is replaced by a positional name in order of first declaration, by kind:
regions r0, r1, …, events e0, …, errors x0, …, functions f0, …,
types t0, …, kind variants k0, …, fields, parameters and locals
v0, …. Keywords, built-in types, standard library names, string contents
and intent text are unchanged; the wildcard _ and a _ prefix are
kept, as are main, the built-in traits and their methods, the host
events and the named constants of 6.7. A use is renamed by its position
as well as its name. After ., a call is renamed only when it names a
method of the module's own impl blocks, since a call after . reaches a
function of the module in no other way (5.15): a standard library method,
or a function of another module, keeps its name even when the module
declares a function, field or local of that name. After ., a name that is
not called is renamed only as a field of the module's own types. A label
NAME: in parentheses, on the line of the parenthesis or on a line of its
own, is renamed only when the callee is the module's own function, type,
variant, event or error; NAME: inside braces is a map key (R7) and is
renamed as the local it names. A field name that a type of a standard
library module the program uses (directly or through that module's own
use lines) also declares keeps its text wherever it names a field of a
struct, event, error or variant (after ., as a label, and in a struct
block), since a receiver's type is not known to the projection. It is
still renamed where it names a local, a parameter, or a field of a state
or actor, which steps and handlers name by its bare name; such a name
takes its positional name at its first declaration that is renamed, so a
struct field and a state field of one name are projected apart and
consistently. Function calls by name are renamed at their call sites. The projection is deterministic and
idempotent, and it has the same outcomes, outputs, ids and log hashes as
the source: rce trace of the two is equal step for step except
in the readable event field, since 6.1 hashes the positional forms
(T7). A name the
projection does not recognise as declared is left as written, so the
output is accepted whenever the input is for every example
(tests/nameless.rs), and for every one of the 1,876 files of the
repository that rce check admits on their own. The expressions inside a
template's {…} (F.6.1) are projected like code, and the authority structs
DirRead and DirWrite keep their names and their field root, which the
checker reads by name (F.5.1). It is the text of the concept record's
complement (6.6).
10.7 The language server: `rce lsp`
rce lsp speaks the Language Server Protocol 3.17 over standard input and
output (JSON-RPC 2.0 messages framed by Content-Length headers). It keeps
the full text of each open document; it does not read other files.
| Message | Behaviour |
|---|---|
initialize |
replies with capabilities: full-text sync (textDocumentSync = 1), formatting, hover, definition, document symbols, and completion triggered by . |
textDocument/didOpen, didChange |
stores the text and publishes diagnostics for that document |
textDocument/didClose |
forgets the text and publishes an empty diagnostic list |
textDocument/formatting |
returns one edit replacing the whole text with fmt(t), the canonical layout of 10.6 without the altered rewrites, or no edit if t is canonical or requires change |
textDocument/hover |
the type or declaration of the name at the position, or null |
textDocument/definition |
the location of that name's binding or item, or null |
textDocument/completion |
the names that can be written at the position |
textDocument/documentSymbol |
the document's items, each with its fields, variants or methods |
shutdown |
replies null |
exit |
ends the server: status 0 after shutdown, 1 without it |
| any other request | error -32601, method not found |
Diagnostics. For a document with text t, the published diagnostics are
exactly the reports rce check gives for t that the text requires change, one per
report, with severity Error and source rce. They come from the one
admission code that rce check, rce test and rce index use
(spec/checker/src/admission.rs), under the same rule set and modes, so a
report of a rule in observe mode is not a diagnostic. A report line N: ... covers line N − 1 in the
protocol's 0-based numbering, from column 0 to the start of the next line.
use resolves among the module paths of all open documents.
Names. Hover, definition, completion and symbols all read one index of
the document. The index is built from the parsed module and from the
bindings the type checker declares while it checks the module: each local
binding, with its line and its inferred type. A document that does not
parse has an empty index, so these requests answer null or an empty list.
- Hover on a local binding shows
name: T, with the type T the checker inferred. On an item it shows the item's declaration: the line of a function, constant, event or alias, or the whole block of a kind, struct, state or trait. On a variant, field or method it shows that line. - Definition gives the line of the binding or item, and the column where the name appears on it.
- Completion after
.offers user methods, fields and the builtin methods of the reference evaluator. Elsewhere it offers the local bindings of the enclosing item, the module's items, variants and fields, and the keywords. Each list is filtered by the part of the name already typed. - Document symbols list the items in order, with fields of structs and states, variants of kinds and methods of impls as children.
Limits: the AST has no columns, so a name is found by scanning its line,
and columns are counted in Unicode scalar values rather than the UTF-16
units of the protocol; the two counts differ only on a line with a character outside
the Basic Multilingual Plane. A local is visible from its line to the end
of its enclosing item: block scope is not tracked, so a binding of a closed
block is still offered. Names are resolved within one document, not across
use.
Because diagnostics come from the same checker, an editor shows a program
as clean exactly when rce check accepts it (10.1, principle 3).
10.8 What is not yet implemented
- The program emitters do not run concurrency or actors in their
observations, only under
run, and never runexternfunctions (10.5). - The language server resolves names within one document, without block scope, and counts columns in Unicode scalar values (10.7). It has no rename, references or semantic tokens.
rce runuses the reference interpreter; there is no compiled runtime.- Idempotence of
fmtis tested, not proved. - Version 0.9 (Appendix F) is implemented in part (F.12).
rce hash,rce api-diff OLD NEW(F.4.3) andrce v09-statusexist:rce hash FILE|DIR...prints the definition hash, kind and name of every named item (pubmarks an export) and, last, the program hash (program: the SHA-256 of the canonical JSON list, sorted, of the definition hashes of the name-free projection (10.6) of the program, with every unnamed item (steps, impls, examples, checks) hashed by its masked text, under the domainrce-program/1; name-free, layout-free and order-free, so a program and its renaming have one hash and a changed step body changes it),rce api-diff OLD NEWprints one row per change of the exports (compatibleorbreaking, then kind and name, then the change; status 1 when any row is breaking) andrce v09-statusprints the implemented and the unimplemented rules.rce manifest DIRwrites the manifest of a directory (F.5.3: every.rcefile as a module pinned by the hash of its canonical text, canonical JSON; a directory whose modules import the built-in library gets the one dependencystdlib, pinned by the hash of the library's manifest) andrce manifest-checkverifies one. The standard library is pinned this way (stdlib/lib/MANIFEST.json), and the checker carries that manifest with the library.rce libprints the library's hash after the modules, then each module whose text differs from its pin (status 1); while such a difference exists,rce manifestwrites nostdlibpin andrce manifest-checkaccepts none. The broker contract (F.7), the provenance record and the build cache of F.5.3, and the emitter messages of F.5.4 for a construct not yet printed do not exist yet. Results are reproducible from the inputs alone (10.1).
10.9 `rce trace FILE [EVENTS]`: reference traces (informative)
The trace format lets an independent projector (another compiler or runtime of the same Form) show that it agrees with the reference evaluator step by step. It adds no meaning: every field is a field of the log D of 6.1, so a trace is the log, and conformance to 6.1 implies conformance to the trace.
rce trace FILE prints one trace per example of the module, in
source order (the same logs rce emit form puts in logs), then, when
the module declares fn main(), the trace of its run (below);
rce trace streams FILE PATH prints one trace per event list of PATH (one list per
line, in the syntax of an example line; a line starting with # is
skipped), named stream@k, in one run of the checker, with streams
carrying their number; with EVENTS
(the syntax of an example line, as in 10.3) it prints one trace of that
event list. A module that requires change, or a trace of EVENTS that yields no
step, is status 1. The output is one JSON object (format rce-trace/2;
rce-trace/1 differed in hashing the named forms, before the T7
resolution of C.15), compact, with sorted keys:
| Field | Meaning |
|---|---|
format |
"rce-trace/2" |
file |
the file name, without directories |
events |
the EVENTS argument, or null |
genesis |
the first prev_hash: 64 zeros (6.1) |
traces |
list of {source, steps}; source is "example@L" (the example's line), "events" or "main"; a "main" trace also has outcome (below) |
steps[i].seq |
required: 0-based index in the trace |
steps[i].event |
required: {type, payload}, payload values as in 6.1 |
steps[i].state_hash |
required: SHA-256 (lower-case hex) of the canonical JSON of the positional form of the state after the step (6.1) |
steps[i].prev_hash, steps[i].hash |
the 6.1 chain: hash is the SHA-256 of the canonical JSON of {event, prev_hash, seq, state_hash} with the positional form of the event |
steps[i].outcome |
"applied" or {kept: error name}; derived, not hashed |
steps[i].hashed |
{event, state}: the positional forms the two hashes are over (6.1), so a reader recomputes both without the module; derived |
A kept step is a step of its trace, with outcome {kept: error name}
and the unchanged state's hash (T8), and the next event is applied to
that unchanged state, as on the host (HC-21); a trace ends only with its
event list. A projector conforms on a module when, for every trace, its
steps have the same seq, event and state_hash as the reference, in
order and with none missing or extra; when it also emits prev_hash,
hash or outcome they must be equal too. Since state_hash covers
the whole state, equal hashes mean equal states without exchanging them.
The trace of fn main. Its run is the one rce run FILE performs
without EVENTS (10.3): fn main() on the tick runtime of 6.8 and
Appendix C, with no link, event or restart input and the default seed of
select nondet. The scheduler writes a log of the run (C.11.4), one entry
per action, and a step of the trace is one entry, in the order written.
Within a tick the order is the scheduler's: link inputs, then program
events, then the actors (transactions, then one message per actor in id
order), then each task's pending operation in task order (higher priority
first, then id). Every choice in that order is a function of ids,
payloads and per-select counters (6.8), so the trace is a function of
the program, as the run is (T1), however the tasks are placed on threads
or held as state machines (10.3).
The text of an entry is K or K(A), A showing values as emit lines
do (10.3):
| Entry | Written when |
|---|---|
Spawn(task ID, priority P) |
a spawn is admitted, before the new task first moves |
Done(task ID) |
a task's function returns, traps, fails or is cancelled |
Emit(V) |
a task emits V, or a committed handler emitted V |
Send(V) |
a send of V is admitted: to a channel, to an actor, by a select arm, inside atomic, or by a committed handler |
Backpressure |
the channel of a send is full: the sender is held (6.8) |
Recv(V), Recv(none) |
a receive or a select arm takes V, or finds the channel closed and empty |
Close |
a channel is closed |
Atomic |
the sends of an atomic block are admitted together (C.11.10) |
Choice(task ID, select line L, execution K, arm A) |
a select nondet takes arm A (C.5) |
Cancelled(task ID) |
a deadline of the task has passed at its communication step (C.6.2) |
Deliver(V) |
an actor's handler takes the message V |
Kept(R) |
an actor's handler kept its state for reason R, or another handler of the same transaction was not committed (T30) |
Restart(CHILD, ID, R, tick T, K), Stopped(supervisor S) |
a supervisor restarts a child or stops (C.11.11) |
Input(V), Unhandled(V) |
a program event arrives, and no actor handles it (HC-6) |
Partition(A, B), Heal(A, B), Held(A -> B) |
a link input, and a message held at a partitioned link (C.11.4) |
The last two rows need inputs of the run, so they occur only in a trace
of a run given those inputs (spec/checker/tests/emit_run.rs gives them).
A step's event is {type: K, payload: A}, with payload null for an
entry K; its state is [tick, actors]: the tick at which the entry was
written (the first tick is 1) and, for every live actor in id order,
[ID, [v₁, …]], its field values in declaration order in the positional
form of 6.1. hashed holds the two, state_hash is the SHA-256 of the
canonical JSON of the state, and prev_hash and hash chain from the
genesis as an example's entries do. outcome is {kept: R} for a step
Kept(R) and "applied" for every other step; as in an example's trace,
a kept step does not end it: the trace ends where the run ends. The
trace's outcome is "done", "deadlock" or {stopped: REASON}, as
rce run ends. An entry's event is display text, which names declared
types (Ping(n: 7, reply: <chan>)), so renaming a declaration changes the
hashes of a main trace, where an example's (T7) stay the same. With
trace, an emitted program run with run prints the trace of
fn main as lines of D (10.5). The core evaluator (10.12) does not run
fn main on the tick runtime, so it prints no trace of fn main.
On a host that cannot start a task thread (10.3, WASI preview 1) the
tasks are state machines of the scheduler and the trace of fn main is
the same as on any host; the cross-architecture parity job
(.github/workflows/xarch-parity.yml) compares the five examples with
fn main() on wasm32-wasip1 as on the other targets. That holds
also for a run in which an lvar passes from one task to another (10.3).
spec/traces/ holds the reference traces of the example corpus: one
file per top-level example (the package 26_use_module/ has no state
machine), plus two event-list traces, 01_counter.events.json (the
counter on a longer list) and 16_multi_region.events.json (two regions
stepped by one event, on the event list of its first example). Five examples
declare fn main(): 02, 13 and 37 run to done, and 40 and 48 stop at
their first foreign call, which the reference evaluator does not execute
(10.3). Examples without a state machine or fn main() have an empty
traces list. spec/traces/rce-trace-diff.py REFERENCE OTHER (Python 3,
standard library only) compares two trace files or two directories of
them and prints exact match or the first divergence (trace, seq,
field, both values); exit 0 on full match. spec/checker/tests/traces.rs
checks that the fixtures are current, that every step is on the 6.1
chain, and that the runner finds a planted divergence.
10.10 `rce index [vectors N] FILE|DIR...` and `rce search CATALOG QUERY`: the brick catalog (informative)
rce index checks the files as one program (10.2) and prints one JSON
object (format rce-catalog/1, compact, sorted keys) with one entry per
top-level function of each module (the pub ones when the module marks
any pub, else all; methods are not bricks), sorted by module and name.
A use item names a module given with the files or one of the built-in
library (4.1), and a file is listed as requiring change in the catalog exactly when
rce check reports that it requires change.
An entry holds module, name, file, line, generics, params
(name and type), ret, key (the type with generic parameters renamed
t0, t1, ... in order of first occurrence), hash (SHA-256 of the
module path and the canonical text of the function alone, so layout and
position do not change it), checked (the verdict of its file) and
lowering ({"term": T}, the D.7 lowering, or {"kept": reason}).
The catalog's hash is the SHA-256 of the canonical JSON of its entries;
pending_files maps each file that requires change to its diagnostics. With
vectors N, vectors maps a lowered brick's hash to up to N
{"args", "out"} or {"args", "trap"} records of the reference
evaluator on inputs generated from the parameter types by a fixed rule
(an input that needs more than 200000 interpreter steps gives none, as the
store-passing terms do more work than the interpreter); they are outside the catalog
hash. rce-brick-verify CATALOG (src/form/brick.rs) evaluates each
lowered term on its vectors and reports, per brick, agreement or the
first disagreement: a result must be equal, a trap must be an error.
rce search reads a catalog and a query A -> R or (A, B) -> R, where
one-letter lowercase names are type variables, and prints RANK module.name : key per match, best first. A brick matches when its
arguments and result unify with the query's, in some order of the
arguments. RANK is 0 for a type equal up to renaming of variables, 1 for
an instance, plus 2 when the arguments match only in another order. Ties
break by module and name. Both commands are deterministic: equal inputs
give equal output bytes.
10.11 `rce dim [fuel N] [control] [json] FILE`: behaviours and redundancy (informative)
rce dim checks the file (10.2) and measures the quantities of 6.10 on its
Form, with its use imports linked. It explores reach(P) breadth-first
from s₀: at each state it applies every instance of the explored
alphabet, defined here. Each payload field has a column of candidate
values: first the boundary set of 6.3 for the field's base type (the
type's minimum, −1, 0, 1 and maximum for a signed integer; 0, 1 and the
maximum for an unsigned one; −1.0, 0.0 and 1.0 for a float; (); false and
true; the texts "" and "a"; for T?, none and some of each
value of T; for List[T], the empty list and the list of the second value
of T's set), then the field's harvested values. A field of another type
has no boundary set, and its event is not explored (the report lists it).
Literal harvesting finds the literals a program compares a field with.
A field's value is followed from the step pattern (or actor handler) that
binds it, through let and var bindings whose value is the name itself,
copy(x), &x, x as T, or if c then x else y with x or y followed,
into the arms of a match on it (or on a tuple position that holds it),
and into a parameter of a function of the module it is passed to, each
(function, parameter, field) once. A literal (an integer, float or text
literal, a negated one, or a constant whose value is one) is harvested
when it meets a followed value in ==, !=, <, <=, > or >=, as a
literal or range-end pattern of a step pattern or a match arm, or in the
predicate of the field's refined type (5.1) with self the field. A value
computed by a method call or an operator (t.split("/"), x + 1) is not
followed. The harvested values of an integer field are each harvested
integer and its two neighbours within the type's range; of a float field,
each harvested float and it ± 1.0; of a text field, each harvested text,
and, when both "" and "a" are harvested, the first of "aa",
"aaa", … that is not, so some value of the column equals none of the
literals. Values already in the column are not repeated; at most 64 are
added per field, the smallest in value order, plus that one text. A field
of another type harvests nothing. The instances of an event are the
Cartesian product of its columns in field order, the first field varying
slowest, cut at 4,096 instances per event; an instance that a refined type
refuses at construction (T35) is not explored and is listed.
Exploration stops at fuel states (default 100,000) and reports whether
the bound was reached. On the explored graph it runs partition refinement (Hopcroft)
with the per-step output of λ as the initial partition, giving the number
of distinct behaviours among explored states, which is dim(P) exactly when
the bound was not reached and a lower bound otherwise. It prints, per
program and per region:
states explored 12480 bound reached: no
behaviours 1206 dim(P) (exact)
redundancy 3.37 bits: log2(states) - log2(behaviours)
region Counter 0.00
region Audit 3.37
control states 17 dim_c(P) [control]
shape_ctl sha256:… [control]
A region's redundancy is computed from the projection of the explored
graph onto that region's fields. control computes the control quotient
of 6.10 on the same explored graph: each step is labelled by its control
outcome only (the kept step's error, by declaration index; else the
constructors of what was emitted, by declaration index or type class) and
never by a value, a name or a state change, so the quotient is a coarser
output function on the same deterministic machine and dim_c ≤ dim holds by
construction. Predicate equivalence is decided by concrete
evaluation on reach(P): exact on the explored set, a lower bound when the
bound is reached. The canonical control string numbers the quotient's
states by first visit in breadth-first order from s₀ with events in
canonical order, one line per (state, event) with the successor's number
and the label; shape_ctl is the SHA-256 of its canonical JSON text. It
is invariant under renaming (T61, tested by tests/dim.rs against
rce fmt nameless).
The report also says whether some explored step has a λ output (6.1): an
emitted value, or the record of a kept step (has_output in the JSON, with
emits and keeps reported separately, since a kept step and an emitted
value are two kinds of the program's answer: a kept step leaves the state as
it was and records why, an emitted value is an output), and how many
distinct output sequences the explored steps carry (distinct_outputs; a
silent step is excluded). A program with no such step has one behaviour by
definition, so its redundancy is its whole state: the state is in D and
readable, and an example may check it, but no future output depends on
it. A program whose every output is the same has one behaviour as well.
The dimension benchmark reports these strata separately.
json prints the same as one JSON object (format rce-dim/1, compact,
sorted keys; has_output, emits, keeps and distinct_outputs since 2026-10-24, replacing observable and distinct_labels). The command is deterministic: equal inputs give equal output
bytes, and the exploration order is the canonical order of 6.1 on events
and payloads. It is informative: no admission depends on it.
rce equiv [fuel N] [json] A B asks whether two programs have the same
behaviour (6.10): it links both and explores both from their initial
states over the same event instances (the explored alphabet above, with
the harvested literals of A and B joined per event, by declaration index,
and per field, by position, so x < 5 and x <= 4 are compared on the
same values), compares every step by its name-free output (emitted
values in their positional form, a kept step by its error's declaration
index, T7), refines the two graphs together by those outputs and reads
whether the two initial states fall in one class (T58: equivalence is
bisimilarity). Status 0 and equivalent when they do; status 1 and
different with the shortest distinguishing event sequence and the two
outputs at its end, or the event instances one program explores and the
other does not. When an exploration reached its bound and the refinement
separates the initial states but no distinguishing sequence exists within
the explored graph, the separation may come from the unexplored frontier,
so the verdict is undecided with status 3, never different.
The verdict is over the explored alphabet and, when a bound is reached, to
that bound; T59 bounds what agreement to a depth proves. Two programs that
differ only on a payload value outside that alphabet (a target that only
t.split("/") distinguishes, for example) are called equivalent. A program and its
name-free projection (10.6) are equivalent by T7. JSON format
rce-equiv/1.
rce change [fuel N] OLD NEW classifies a change to a program by the
classes of C.15 and proposal CC-2, comparing the two programs under one
text: it prints both program hashes (equal hashes mean a renaming
or a reformatting, the same program), the rce api-diff rows (F.4.3) and
the behaviour check of rce equiv, and decides: erratum when every
export is compatible and every behaviour is kept (status 0; "to the
explored bound" when a bound was reached); meaning change when a
behaviour changed (status 1: the program's meaning changed); interface change
when behaviour is kept but an export is broken (status 1: callers must
change); undecided when rce equiv is undecided (status 3: raise
fuel); compatible or breaking from the rows alone when neither
program is a Form. The decision is the tool's, not a version number's.
Laws (6.11) are part of a program's meaning. rce change prints one law
row per law of OLD, decided on NEW with NEW's definitions (= the law is
unchanged in NEW, ~ edited, - removed), and one + row per law NEW
adds. Meaning change (status 1) is then also the verdict when NEW breaks
a law of OLD (CC-L1 of spec/proposals/laws.md; the row is followed by the
counterexample line) and when a law of OLD is edited or removed (CC-L2),
whatever the behaviour check says. A law added to a program whose
behaviour is unchanged is an erratum. On the flag game of 6.11, the change
that removes the far-edge walls has the same behaviour (no step emits a
value or keeps the state), so without its law it was an erratum; with the
law it is a meaning change, with the 9-event sequence.
rce law FILE checks FILE as rce check does up to the admission gate,
then decides every law of FILE by method D1 (6.11) and prints one line per
law: its name, its verdict (holds, fails, undecided or attested),
the method and the counts (states, steps, alphabet size and whether it is
complete, whether the exploration closed), and for a failing law the
counterexample line. An undecided law's line names what left it undecided
and the cover an attestation must carry. Exit status 0 when every law holds
or is attested, 3 when the only obstacle is the bound LAW_FUEL, 1 otherwise.
scripts/t7-equiv.sh runs rce equiv between every corpus program and
its name-free projection (T7) and is a continuous-integration step.
10.12 `rce run-core FILE`: the core evaluator (informative)
rce run-core FILE lowers FILE to its core module, as rce emit core
does (FILE is an RCE module or an rce-core/1 core module, read only if
it is well formed), runs that module with the core evaluator of the
proposal one-emitter.md (ONE-1), and prints what the run writes. The
core evaluator is an implementation under test, compared with the
reference evaluator like any target: the expected bytes of every
comparison are the reference trace (10.9), never this output. Exit status
0 when the run ends; 1 when the checker reports that FILE requires change, when a core module
is not well formed, or when the run halts; 2 when FILE uses a construct
the lowering does not cover, or on an internal error.
The core evaluator observes fn main as one call of its body, as the
main block of the proposal's trace (ONE-5) does, not as a run on the
tick runtime: the lowering covers no channel, spawn, select, actor or
supervisor (status 2), and the core has no scheduler, so rce run-core
prints no trace of fn main (10.9). The reference's tick runtime now
holds tasks as state machines where the host has no threads (10.3), so
the run of fn main happens on WASI preview 1 as on other hosts, also
when an lvar passes from one task to another; that
scheduler is written in Rust inside the reference (conc.rs), not in the
core. The next slice of the proposal is the same scheduler in the core:
the lowering of channels, send, spawn, select, actors, protocols,
nodes and supervisors, and the tick, its phases and the log written as
core functions, so that rce run-core prints the trace of fn main.
10.13 `rce repair [json] [bound N] [known GOOD] [proposals PROPOSALS] FILE [MODULE...]`: the exact-proposer ladder and rung f (informative)
rce repair takes a program FILE that requires change (an example or
check does not hold, or a static rule reports it) and proposes a changed
program. FILE is checked together with the MODULEs, which are the
program's other modules (10.2); GOOD, when given, is a known-good version
of FILE, such as the one in the previous commit. The command is a ladder of exact
proposers: each rung builds candidate programs by a fixed rule from the
program, the MODULEs, GOOD and the built-in library alone, and the checker, the
same gate as rce check (6.9), judges each candidate. The ladder stops at
the first candidate the checker admits; since the gate runs every
example and check, an admitted candidate is one whose examples and checks
all hold. No rung calls a model (10.1, item 2). A candidate is the
canonical text of an edited module (the source printer of unparse.rs),
never a text written by hand, and a candidate equal to one already judged
is judged once. After the exact rungs, rung f judges candidate programs
written outside RCE and given to the command as a file (RF-1 to RF-7
below); the command calls no model for them either.
Terms. A definition is a function, a method of an impl, a step, an
actor, a constant or a state declaration. A site is one expression
of a definition. Intent, example, check and law items, and check, requires
and ensures statements, are never edited: they are what a candidate is
judged by. The name-free signature of a function is its number of
generic parameters, its parameter types and its result type, without the
names of the function and its parameters.
Order of definitions. First the definitions that contain a line the report of FILE names (a static rule); then, breadth first, the definitions reachable from the checks that do not hold (the functions they call, and what those call) and, when an example does not hold, the steps, actors and state declarations and what they call; then every other definition, in source order. Sites within a definition are visited in preorder.
The rungs, in order:
- a. Reuse. The body of one function becomes the body of another
function with the same name-free signature, from FILE, the MODULEs or
the built-in library (
rce lib), with its parameters renamed to the receiving function's. A donor with the same name as the receiving function comes first, then donors by module and name; donors with equal name-free projections (10.6) are tried once, and a donor equal to the receiving function is not tried. - b. Lookup by type. The brick catalog (10.10) of FILE, the MODULEs
and the library modules FILE uses is searched (
rce searchorder) for (1) a function of the same type as a definition, whose body then becomesreturn h(p1, ..., pn)on its own parameters, and (2) a function of the same type as the callee of a call, which then replaces that callee. Only functions FILE can name are proposed: its own, and those of a module it uses, through the module's alias. - c. Altered rules. The text
rce fmtwrites (10.6) for the rules whose method is altered in 7.1 (W-UNUSED-1 and W-DROP-1,alter.rs): every rewrite of FILE, in the orderrce fmtwrites them, and only when the canonical layout accepts the result, as inrce fmt. The candidate is the canonical text of that program, one per run; there is none whenrce fmtwould alter nothing. A rewrite only names a binding or drops a value that was already dropped, so the candidate has the behaviour of FILE; it is admitted when the reports it answers were the only reason FILE requires change. The edit lists each rewrite asrce fmtreports it (line L: RULE what). - d. Bounded enumeration. One small edit at one site: a binary
operator replaced by each other operator of its class (
+ - * / %,< <= > >=,== !=,and or,& | ^,<< >>), the operands of an ordering comparison swapped, an integer literal n replaced by n + 1, n - 1, 0 and 1 (each value at least 0 and different from n), a boolean literal negated, two arguments of a call with two to four arguments swapped (each pair once), and a condition (ofif,elif,while, a guard or anifexpression) negated, or itsnotremoved. These edits never add or rename a name, so they act alike on a program and on its name-free projection. At most N candidates (bound N, default 2000) are judged in this rung; the bound counts checker calls, not edits skipped as duplicates. - e. Renames. One name changed to another. A rename carries no
information about behaviour: the name-free projection (10.6) removes
names, so a consistent renaming leaves it unchanged, and the checker
sees a renamed use only where it now reaches another binding (often as
an unknown or unused name, or a type that does not match). The
candidates, for each definition in the order above: (1) one use of a
value name, or of a name the report of FILE names between backquotes,
becomes another value name in scope at that use (the parameters, the
let,varandforbindings and pattern bindings whose block has not closed, the fields of a step's state or of an actor, and the module's constants); uses on a line the report names come first, then the others in preorder, and the names that replace a use are ordered by whether the report names them, then by edit distance to the name they replace, then innermost binding first; (2) one parameter, orlet,varorforbinding of one name, becomes a name the report names that the definition does not bind. The edit names the line of FILE and, when the line has more than one use of the name, which use. At most N candidates (bound N) are judged in this rung. - The renaming onto GOOD. When GOOD is given and the canonical texts of FILE and GOOD differ in identifiers only (none of them a keyword), the renaming is read from the two texts, with no search. Each name of GOOD becomes the name FILE writes most often in its place (on a tie, the first); every identifier of FILE that this renaming does not give is changed to the one it gives. That text keeps FILE's names, and it is the first candidate when the renaming is one-to-one and the text has GOOD's name-free projection. The second candidate is the canonical text of GOOD, every name renamed back; it is the only one when FILE has GOOD's projection. Both count as candidates of rung e, and they are judged before rung a. A candidate of the search in (1) or (2) that had GOOD's projection would differ from GOOD in names only, so the search needs no preference of its own for GOOD. The edit lists each identifier changed, by line of the canonical text.
- f. Outside proposals. When every candidate of rungs a to e, with the
renaming onto GOOD, is judged and none is admitted, each program of the
file PROPOSALS is judged by the same gate, in the mode of rung f (RF-1
to RF-4 below). Rung f is not exact: what it judges is not computed from
FILE by a fixed rule, so equal inputs to the ladder do not give it. It is
the ladder's stochastic rung in the sense of the deterministic-first
principle, under which at least 98% of the closes come from exact rungs,
at most 2% from stochastic ones, and every stochastic output is gated
(hypothesis H6 of
compile/HYPOTHESES.md).
The order of rungs c, d and e, the three that edit FILE at one site, is the order of how many alternatives one edit chooses among, which is both its cost and the information it carries. Rung c judges at most one candidate and changes no behaviour. Rung d chooses among a fixed handful at each site: the other operators of a class of two to five, four literals, one negation. Rung e chooses among the names in scope at a use, a number that grows with the definition, so it judges the most candidates per site and runs last. On the 83 rename and 27 guard tasks of the second registered ladder run, rerun with this checker, both orders restore 102 of the 110 programs, and this order judges 6,556 candidates where e before d judges 10,579. The renaming onto GOOD comes before every rung because it judges at most two candidates, needs no search, and uses the most information: a known-good version of the program.
Rungs a, b and c are not bounded by bound: a and b judge at most one
candidate per donor or catalog hit, and c at most one candidate; rung f
judges at most N proposals. No rung edits an intent, example, check or
law line, and rung f refuses a proposal that does (RF-2).
Output: the rung that closed the program (a reuse, b lookup by type,
c altered rules, d bounded enumeration, e renames, f outside proposal (stochastic), or none when FILE already
complies with the Form), the edit (it names the line of FILE), the diff of the canonical
texts (- the old lines and + the new, with line numbers of the
canonical text), the number of candidates each rung judged with
0 model calls, the skipped rungs (every rung, when FILE does not
parse; a GOOD that does not parse is a usage error), and the checker's verdict on the
result: ok FILE: admitted; E examples and C checks hold, or, when no
candidate is admitted, the report on FILE and not closed FILE. With
json the same is one JSON object (format rce-repair/1) that also holds
the repaired text, model_calls (always 0), canonical_same_report
(whether the canonical text of FILE gets the report FILE gets, line
numbers aside) and attempts, one record per candidate judged: rung,
definition, edit and the checker's verdict, and the members of RF-4. Last,
on standard error, the attention line of AC-1 (RF-4). Exit status 0 when the
program is closed or already complies, 1 when it is not closed, 2 on a
usage error. The command is deterministic: equal inputs give equal
output bytes and the same exit status.
An admitted candidate passes the examples and checks; that does not make
it the program that was meant. rce equiv (10.11) and the program hash of
rce hash (10.8) say whether a repair has the behaviour or the
definitions of a known original; scripts/ladder-run.py reports that
split for the task sets that scripts/ladder-tasks.py writes.
Rung f (RF-1 to RF-7). A proposal is a candidate program for FILE
written outside RCE: by a model, hosted or local, or by a person. Its
origin is a label it carries, such as person or local model. RCE
reads proposals and never asks for them: the checker calls no model (10.1,
item 2), and a proposal enters only as a file. Example:
rce repair json known good.rce proposals p.json counter.rce runs rungs a
to e on counter.rce and, when they close nothing, judges each proposal
of p.json; in observe mode it reports each one the checker admits and
leaves the program as it is.
- RF-1 (proposals are data). PROPOSALS is the canonical JSON (6.1.1)
of the object
{"format": "rce-proposals/1", "proposals": [...]}, followed by one line end. Each proposal is an object with exactlyorigin, a text of one line that is not empty, andtext, the program text. A proposal is recorded by its digest, the SHA-256 ofrce-proposal/1, a line end and its text, as the rule-set hash is formed (10.15, AR-1). A file not in this form is a usage error: the command printsPROPOSALS: RF-1 ...on standard error and exits 2. - RF-2 (the same gate, after the exact rungs). Rung f runs only when
FILE parses and rungs a to e, with the renaming onto GOOD, have admitted
no candidate. It takes the proposals in the order of the file. A
proposal whose text does not parse requires change with the parser's
report. A proposal that names another module than FILE, or that does
not keep what FILE is judged by, requires change under RF-2: its intent,
example, check and law items, and the
check,requiresandensuresstatements of each definition, have the canonical texts of FILE's, in any order. A proposal may thus change a definition but never what judges it, as no exact rung does. Every other proposal is judged as its canonical text by the gate of every rung,check_program: the admission ofrce check(6.9, 6.11), which on a text whose obligations hold runs the mutation gate (6.12). A proposal is therefore admitted only when every example, check and law holds and no obligation is vacuous (W-MUT-1), so a close by rung f never rests on an obligation that no edit can make fail. A proposal whose canonical text was judged before (FILE itself, a candidate of an earlier rung or an earlier proposal) is not judged again. At most N proposals are judged (bound N). - RF-3 (modes). Rung f has one mode, given by the table below:
off,observeorauto, the modes of the altered rules (7.1, RM-1 to RM-3). The mode is data: the checker reads it fromspec/data/spec-data.json(repair_modes), no program text, comment or command word sets it, and a rung the table does not list isobserve.off: rung f does not run, and the report says so (skipped f).observe: every proposal is judged, and each one the checker admits is reported asobserved, with its diff, digest and origin; rung f closes nothing and writes nothing, and the status is that of a program not closed.auto: the first admitted proposal closes the program as rungf, and the report labels the close stochastic. Rung f entered asobserve. Promotion toautois a change of its row, allowed only under RF-5 and RF-7.
| Rung | Mode | Reason |
|---|---|---|
| f | observe | Entered as observe: a proposal written outside RCE is reported, never applied, until the criterion registered for its promotion holds on a recorded evaluation (RF-5, RF-7). No evaluation is recorded. |
-
RF-4 (the record). The text report adds
f Ntotried, aproposalsline (given, judged, admitted and observed, the mode, and the SHA-256 of PROPOSALS) and oneobservedblock per observed proposal: its place in the file, origin, digest, what W-MUT-1 measured, the diff of the canonical texts and, with GOOD, how it compares with GOOD. The JSON report adds these members:bound;inputs, the SHA-256 of the bytes of FILE, GOOD, PROPOSALS and each MODULE (nullfor a file not given);stochastic, true exactly when rung f closed the program;proposals(nullwithout PROPOSALS): the mode, the file's SHA-256,ran(whether rung f ran), the countsgiven,judged,admittedandobserved, and one record per proposal, in the order of the file, with itsindex,origin, digestsha256,verdict,admittedandobserved. An admitted proposal's record also holds itsdiff,mutation(its obligations, how many W-MUT-1 measured, andvacuous, which is 0) and, with GOOD,known.knownisrestoredwhen the program hash of 10.8 is GOOD's; otherwise, byrce equiv(10.11) with the state bound of 10.14 (20,000),behaviour-equal,contradicts(with the event sequence after which GOOD and the proposal give different outputs, when there is one) orundecided; andnot comparedwhen a program has no step.
The JSON report is canonical JSON (6.1.1).
model_callsstays 0: RCE made no model call, and the proposals' origins are recorded instead. Every run ends with the attention line of AC-1 on standard error: one finding that requires change when the program is not closed, none recommended or altered, and one observed per observed proposal. Equal inputs give equal bytes. -
RF-5 (a registered promotion criterion). Rung f is promoted from
observetoautoonly when the criterion registered inspec/proposals/repair-observe/criterion.jsonholds. The registration is dated data, in the form of the ladder's registrations: it was committed on 2026-11-03, before any observation; its SHA-256 is pinned beside it (criterion.json.sha256); and it is not edited afterwards. It fixes the corpus by path and SHA-256 (the 151 tasks of the second and third registered ladder runs), the observation (one run ofrce repair json known ORIGINAL proposals PROPOSALS MUTANTper task, inobservemode, bound 2000), and three conditions derived from the deterministic-first principle, each of which holds:- Share. Every task has exactly one record, made as registered, and every task that rungs a to e do not close and whose mutant parses had at least one proposal judged. Of the closes, the tasks closed by rungs a to e (E) and the tasks they leave open on which rung f observes an admitted proposal (F), at most 2% come from rung f: 100 × F ≤ 2 × (E + F), with E + F > 0.
- W-MUT-1. Every observed proposal also passes W-MUT-1: its record shows that the mutation gate ran and found no vacuous obligation.
- GOOD. No observed proposal contradicts the task's original, given
as GOOD: for none does
rce equivfind an event sequence after which the two give different outputs, or show that they explore other event instances.
-
RF-6 (the evaluator).
rce repair criterion [json] REGISTRATION CORPUS RECORDSreads the registration, the corpus, whose SHA-256 is the registered one, and RECORDS, onerce repair jsonreport per line. It matches each record to a task by the SHA-256 of FILE (inputs.file, the task'smutant_sha256). It prints, one line each, the registration, the corpus, the records, the closes by rungs a to e and by rung f with the share, the tasks admitted as given or not closed (and of these, where rung f did not run), the observed proposals (how many pass W-MUT-1 and how each compares with GOOD), the proposals judged per origin, any task the records do not cover as registered, and lastcriterion holdsorcriterion does not hold: REASONS. Withjsonthe same is the canonical JSON of formatrce-repair-criterion/1, the form in which an evaluation is recorded (spec/proposals/repair-observe/evaluation.json). Exit status 0 when the criterion holds, 1 when it does not, 2 when a file cannot be read or the corpus is not the registered one. The command is deterministic. -
RF-7 (the mode row follows the evaluation).
rce-spec-checkfails when the registration's SHA-256 is not the pinned one, or when the mode row of rung f isautoand no recorded evaluation of this registration shows the criterion met. The check derives the verdict again from the evaluation's counts and the registration, as AR-5 derives a receipt again, and does not take itsholdson trust. Rung f isobserve, and no evaluation is recorded.
Conformance. Each rule of rung f is checked by these tests of
spec/checker/tests/:
| Rule | Test |
|---|---|
| RF-1 | repair_observe.rs: a_proposals_file_is_canonical_json_and_each_proposal_has_its_digest |
| RF-2 | repair_observe.rs: rung_f_never_runs_when_an_exact_rung_closes, a_proposal_the_checker_or_w_mut_1_refuses_is_not_admitted, a_proposal_that_edits_what_judges_it_requires_change |
| RF-3 | repair_observe.rs: observe_records_and_never_closes, auto_closes_with_the_stochastic_label, off_judges_nothing, the_modes_table_gives_rung_f_observe |
| RF-4 | repair_observe.rs: the_report_is_byte_stable, an_observed_proposal_is_compared_with_good |
| RF-5 | repair_observe.rs: the_registration_is_dated_and_pinned |
| RF-6 | repair_observe.rs: the_criterion_holds_when_every_condition_holds, the_criterion_fails_on_each_condition |
| RF-7 | repair_observe.rs: the_mode_row_of_rung_f_is_auto_only_with_a_met_criterion |
The design and its sources are in spec/proposals/repair-observe.md: the
accept modes of DeepSeek's dsh-superagent-prototype (MIT), already taken
for 7.1, and its rule that a model assesses and deterministic policy
decides.
10.14 `rce mutants [json] [bound N] FILE [MODULE...]`: mutation adequacy (informative)
rce mutants judges the mutant set of FILE (6.12), checked with the
MODULEs as in 10.2, on its obligations: the first N mutants (bound N,
default MUTANT_BOUND, 2,000), each on every obligation whose reach holds
its definition. FILE must be admitted by every rule but W-MUT-1; otherwise
the command prints rce check's report and exits 1.
Output, one line each: mutants (judged, single edits, the bound, the
definitions), the counts of mutants not in Form, equivalent and undecided,
score (killed of non-equivalent, with the share rounded down to a tenth
of a percent), one obligation line per example, check and law in text
order (its line, the mutants it kills of the in-Form mutants of its reach,
its text, and why it is not measured when it is not), one vacuous line
per W-MUT-1 report, then one survivor block per survivor: the edit as
rce repair prints it, the diff of the canonical texts (- and + lines
with line numbers of the canonical text, as in 10.13), and either after EVENTS: the program OUTPUT, the mutant OUTPUT from rce equiv (10.11,
with a state bound of 20,000) or not compared: REASON (a definition no
step reaches, one fn main reaches, or a program with no step: rce equiv
compares the behaviour of the steps); last, verdict. For the fixture
spec/checker/tests/mutants/vacuous.rce:
score 19 killed of 23 non-equivalent (82.6%)
obligation line 7 kills 0 of 23 example Reset -> n >= (0)
survivor W-MUT-2 in `step Counter on Inc`, line 26: `6` becomes `7`
- 25 step Counter on Inc -> (n + (1)) % (6)
+ 25 step Counter on Inc -> (n + (1)) % (7)
after Inc(), Inc(), Inc(), Inc(), Inc(), Inc(), Show(): the program emits Shown(value: 0), the mutant emits Shown(value: 12)
With json the same is one JSON object (format rce-mutants/1) that also
lists every mutant judged with its definition, edit, line and fate (not in Form with the report, killed with the lines of the obligations that
kill it, equivalent, undecided, or survives with the witness or the
reason it was not compared, and its diff), and per obligation its cost
(fuel, or a law's steps) and whether W-MUT-1 measures it. Exit status 1
when an obligation is vacuous (W-MUT-1) or FILE requires change, else 0;
survivors do not change it. The command is deterministic: equal inputs give
equal output bytes.
rce check decides W-MUT-1 without judging the whole set: for each
measured obligation not yet killed it judges first the mutants at
expressions its run on the program evaluated, stops at the first kill,
and on a kill runs that mutant on the other obligations whose runs
evaluated the edited expression. An obligation is reported only after it
has been run on every in-Form mutant of its reach, so rce check and
rce mutants report the same W-MUT-1 lines.
10.15 `rce check write RECEIPT` and `rce check receipt RECEIPT FILE|DIR...`: admission receipts
An admission receipt is the record of why a program was admitted: what
it was, which rules were in force, which checker judged it, and what each
obligation measured. It is evidence of a past admission, never an
authority: no tool reads a receipt to decide whether a program is
admitted, and revalidation recomputes admission from the program text
every time. A receipt whose program, rule set and checker are unchanged
holds because the recomputed receipt has the same bytes, not because the
receipt says so. Example: rce check write counter.receipt counter.rce
writes the receipt; after an edit of a step, rce check receipt counter.receipt counter.rce prints that the program changed and whether
it is still admitted.
-
AR-1 (contents). A receipt is the JSON object of format
rce-admission-receipt/1with exactly these members:program, the program hash of 10.8 (name-free, layout-free and order-free);checker, the commit, specification draft and release label ofrce version;rules, the rule set in force astable, every rule of 7.1 as[RULE, METHOD]or, for an altered rule,[RULE, "altered", MODE], sorted by rule, andsha256, the SHA-256 ofrce-rules/1, a line end and the canonical JSON oftable;obligations, every example, check and law of the program's own modules, each with itskind, its obligation hashsha256(the SHA-256 underrce-obligation/1of its text in the name-free projection of 10.6 with every named definition replaced by its definition hash, as 10.8 hashes an unnamed item), itsresult(holds, orattestedfor a law), itsfuel(an example or a check, 6.7) or itsstatesandsteps(a law that holds, 6.11) or itsattestation(WHO;YYYY-MM-DD;COVER, 6.11), for an example whose run derived frames,frames, the number that W-UI-1 judged (Appendix E, E.4f), and, when the mutation gate judged it,mutation: whether W-MUT-1 measures it, the mutants of its reach and whether one was killed (6.12);mutation, the mutants judged and the whole mutant set;attestations, every attestation that admitted a law, sorted;observed, per rule in observe mode the number of its reports (RM-2); andbinding,PROGRAM;RULES;CHECKER, the program hash, the rule-set hash and the checker commit, in the form of an attestation (6.11), so that one line names what the receipt is bound to. -
AR-2 (canonical bytes). The receipt is the canonical JSON of 6.1.1 followed by one line end. Obligations are sorted by their canonical JSON and an obligation written twice is listed once, as the program hash hashes it once, so the same program text, rule set and checker give the same bytes (
tests/admission_receipts.rs). The receipt reads no clock and names no person but the authors of attestations. -
AR-3 (evidence, not authority). Admission is always recomputed. A receipt never admits a program, never skips an obligation and never changes a verdict; the break-even receipt of D.11 is a measurement record in the same sense.
-
AR-4 (revalidation).
rce check receipt RECEIPT FILE|DIR...admits the program again under the rules in force, prints each file's verdict as 10.2 does, and then one of these, in this order of precedence:receipt holds RECEIPT: program P admitted under rules R by checker Cwhen the program hash, the rule set and the checker are the receipt's and the recomputed receipt has its bytes;receipt does not hold RECEIPT: the program changed (program OLD -> NEW); under the rules in force the program is admitted(orrequires change) when the program hash differs;receipt does not hold RECEIPT: the rule set changed (rules OLD -> NEW); under the new set the program is admitted(orrequires change), then one line per ruleadded RULE METHOD,removed RULE METHODorchanged RULE OLD -> NEW(a change of method or of mode, such aschanged W-UNUSED-1 altered observe -> altered auto);receipt does not hold RECEIPT: the checker changed (checker OLD -> NEW); the program is admitted, and the record it gives is(oris not)the receipt'swhen only the checker differs;receipt does not hold RECEIPT: its record is not the one admission gives for the same program, rules and checkerotherwise.
The precedence follows what the receipt is bound to: a receipt of another program says nothing about this one, and the rule set is compiled into the checker, so a change of rules is named before the change of checker that carries it. The run ends with the attention line of AC-1, which counts a receipt that does not hold as one finding that requires change; the status is 0 when the receipt holds and the program is admitted, else 1.
-
AR-5 (an invalid receipt). A receipt is read back and checked against itself, as D.11 re-derives a break-even receipt: its format, its members, its bytes (the canonical form of its own JSON), a rule table whose rows are well formed and whose hash is
rules.sha256, and abindingmade of its own program, rule-set hash and checker commit. A receipt that fails any of these is invalid:rce check receiptprintsRECEIPT: AR-5 ...on standard error and exits 2, as for an unreadable file (10.1).
Promoting an altered rule from observe to auto (RM-3) changes the rule
set, so every receipt written before the promotion reports changed RULE altered observe -> altered auto and whether the program is still
admitted: a program that had an observed report of that rule now requires
change until rce fmt writes the rewrite.
Conformance. Each rule of this section and of the modes and attention
rules of 7.1 is checked by these tests of spec/checker/tests/:
| Rule | Test |
|---|---|
| AR-1 | admission_receipts.rs: a_receipt_records_program_rules_checker_obligations_and_attestations |
| AR-2 | admission_receipts.rs: a_receipt_is_byte_stable |
| AR-3 | admission_receipts.rs: revalidation_recomputes_admission |
| AR-4 | admission_receipts.rs: revalidation_reports_each_case |
| AR-5 | admission_receipts.rs: an_invalid_receipt_is_reported |
| RM-1 | rule_modes.rs: the_modes_table_names_exactly_the_altered_rules |
| RM-2 | rule_modes.rs: observe_records_exactly_what_auto_writes, the_observe_report_is_a_canonical_diff_with_its_rule, observed_reports_do_not_block_admission |
| RM-3 | admission_receipts.rs: a_promotion_changes_the_rule_set_hash |
| AC-1 | rule_modes.rs: every_check_and_fmt_run_ends_with_the_attention_line |
The design and its source, the mandate and accept modes of DeepSeek's
dsh-superagent-prototype (MIT), are in
spec/proposals/admission-receipts.md.
10.16 `rce graph ops`, `rce graph terms FILE DIR`, `rce graph inspect FILE`, `rce graph run FILE INPUTS`: graph terms
The commands on the graph terms of 6.13 and their .fg files.
rce graph ops prints the operations of std.tensor with their levels
(GT-4). rce graph terms FILE DIR writes each graph term of the admitted
module FILE as DIR/KEY.fg, KEY its content hash (GT-2), and prints one
line per term: key, line, operation, typing and levels. rce graph inspect FILE reads a .fg file, verifies its content hash, checks its term by W7,
and prints its header, sections and nodes with their levels. rce graph run FILE INPUTS evaluates the term of a .fg file by the reference evaluation
(GT-6) on INPUTS, a JSON array with one tensor per parameter, and prints the
result in canonical JSON (GT-8), or trap: non-finite float. A file whose
hash does not hold, or whose term W7 does not admit, requires change
(status 1). Example: rce graph run KEY.fg '[[[0.5,-0.5,0.5],[-1.0,1.0,-1.0]],[1.0,2.0,3.0],[0.5,-0.25]]'
on the term of compute/examples/dense.rce prints [1.5,0.0].
10.17 `rce lift gguf FILE STORE`: a program from a GGUF file
rce lift gguf FILE STORE reads the GGUF file FILE and prints an RCE
program whose step is the model's forward pass as graph terms over
std.tensor (6.13), and puts each of its weights into the store directory
STORE as a blob (GT-9). Saved beside STORE as blobs, the program is
checked, run, tested, traced and hosted like any other; nothing of FILE is
read again. Example: rce lift gguf toy.gguf m/blobs > m/toy.rce, then
rce test m/toy.rce.
-
LIFT-1 (architectures). The architecture
gpt2is lifted: token and position embeddings summed; per block a layer norm, causal multi-head attention whose fused projectionattn_qkvis split into its three row ranges (each its own blob, so no term slices a tensor), the output projection and a residual sum, a layer norm, agelu_tanhfeed-forward layer and a residual sum, every projection with its bias; a final layer norm and the output projection (output.weight, or the token embedding when the file has none). The program has one event,Tokens(ids: [i32; C])with C the file's context length, and keeps the logits of the last sequence in its state. The architecturellamais lifted as LIFT-5 states. Another architecture is refused with its name (status 2). -
LIFT-2 (weights). F32 and F16 tensors become
f32blobs (every binary16 value is a binary32 value). Q8_0 and Q4_0 matrices become their quantized values, ani8blob, and their block scales, anf32blob, exactly as the file holds them (Q4_0 nibbles minus 8, low nibbles first), formatmul_q8_0andmatmul_q4_0. Q4_K, Q5_K and Q6_K matrices become blobs as LIFT-6 states. Another type is refused. -
LIFT-3 (layout). GGUF lists a tensor's lengths fastest first: a matrix of lengths (k, n) is n rows of k, the shape
[n, k], and a projection of x by it is x Wᵀ (matmul_q8_0(x, q, d), ormatmul(x, transpose(W))for f32). -
LIFT-4 (levels). Every operation of a lifted program is at its strongest level (GT-4): the quantization of its weights happened when the file was written and is not an operation of the program. The kernels of RCE's host adapters are judged against it node by node (
spec/checker/tests/lift_gguf.rs, a two-block model of width 32 with Q8_0 and Q4_0 products):rce-ingest-gguf's rows,rce-op-nn-prims's layer norm andrce-op-qmm's Q8_0 and Q4_0 products reproduce every bit;rce-op-attention, which takesexpfrom the platform, reproduced every bit of its 1,024 elements there, andrce-op-nn-prims'sgelu, which takestanhfrom the platform, differed by up to 7 units in the last place on 2,048 elements (glibc, x86-64). So thatgelukernel is not a realisation of the lifted program; a program that accepts it declarestensor.within(N, …)around the operation, and a run whose distance exceeds N is judged as not realising it. -
LIFT-5 (llama). The architecture
llamais lifted from the keysllama.embedding_length,block_count,attention.head_count,attention.head_count_kv(the query heads when absent),context_length,attention.layer_norm_rms_epsilonandrope.freq_base(10000 when absent): the embedding of the input ids (token_embd); per block an RMS norm (rmsnorm), the projections q, k and v reshaped to[C, heads, hd], the rotary position embedding of adjacent pairs (rope, positions 0 to C − 1) on q and k, causal attention heads first with the query heads a multiple of the key and value heads (grouped-query attention, GQA: query head h reads key and value head h / (hq / hk)), the output projection and a residual sum; an RMS norm and the feed-forward layer SwiGLU,(silu(f Wgᵀ) * f Wuᵀ) Wdᵀ, and a residual sum; a final RMS norm and the output projection (output.weight, or the embedding table when the file has none). The rotary frequencies base^(−2i / hd), i from 0 to hd / 2 − 1, are computed once by the lift in binary64 and rounded once tof32, and enter the program as a blob, so the program's arithmetic is all GT-4's. A head of odd length, or query heads that are not a multiple of the key heads, is refused. -
LIFT-6 (the K formats). Q4_K, Q5_K and Q6_K matrices become their values, an
i8blob in position order, and their sub-block scales d · sc (and offsets dmin · m),f32blobs, formatmul_q4_k,matmul_q5_kandmatmul_q6_k(GT-10); each scale and offset is a binary32 value exactly, so the values the program holds are thoserce-ingest-ggufreads from the file, bit for bit. Rows of a length not a multiple of 256 are refused. On a two-block llama model of width 256 with 4 query heads over 2 key and value heads, written in the test from a fixed seed with products in Q4_K, Q5_K, Q6_K, Q8_0 and F16 (spec/checker/tests/lift_llama.rs), the lifted program's logits equal a forward pass written in Rust bit for bit, andrce-op-qmm's K-format products reproduce every bit of the reference on 41,472 elements, serial and dispatched (Apple M5 Max, aarch64).
rce lift fx is not a command yet: the PyTorch FX graphs that
rce-ingest-fx reads carry no shapes for their inputs and intermediate
values and no weight bytes, which a term needs, and several of their
operations (conv2d, batch_norm, elu, leaky_relu, log_softmax)
have no operation in std.tensor.
10.18 `rce emit wasm FILE` and `rce graph run wasm FILE INPUTS`: graph terms in WebAssembly
Terms used here. A realisation of a graph term is a computation of the
term other than the reference evaluation (GT-6); it is judged against the
reference node by node, each node at its level (GT-4). The kernel library
is the WebAssembly module compute/crates/rce-emit-wasm/kernels/rce-kernels.wasm:
the CPU backend's one-node step of the reference evaluation
(rce_vm_backend_cpu::reference_node), compiled to WebAssembly by
scripts/build-wasm-kernels.sh from compute/crates/rce-wasm-kernels. A
program module is the WebAssembly text that rce emit wasm prints: it
holds no arithmetic of its own and calls the kernel library once per node.
A slot is a numbered tensor held by the kernel library.
rce emit wasm FILE prints one program module for the graph terms of the
admitted module FILE, with one exported function term_KEY per term, KEY
its content hash (GT-2). A program with no graph term requires change
(status 1). rce graph run wasm FILE INPUTS runs the term of a .fg file
through its program module and the kernel library under the wasmi
interpreter and prints what rce graph run FILE INPUTS (10.16) prints.
Example: on the term of compute/examples/dense.rce, both print
[1.5,0.0].
- EW-1 (one call per node). The program module calls the kernel
library once per node, in the order of the reference evaluation
(
reference_order: Kahn's algorithm, the ready nodes in ascending index, on the term with each blob node standing alone, as the reference evaluates it). Each call passes the node's descriptor (its operation, output type, operand slots and output slot) from a data segment of the program module. A comment above each call names the node, its operation and its level, and the custom sectionrce.levelslists every node's level. - EW-2 (the pinned library). The kernel library is committed with its
BLAKE3 digest (
rce-kernels.wasm.blake3); the program module imports it under the module namerce-kernels/DIGEST, so a program module links only to the library it was printed for.rcerefuses a library whose bytes are not its digest.scripts/build-wasm-kernels.sh checkrebuilds it and fails when the rebuild differs from the pin. - EW-3 (the reference step). Each node is computed by the reference
evaluation's own step, so an
exactnode is the reference's value bit for bit, the transcendentals included (6.3 F9: the correctly roundedexp,tanhanderfofmath.rce). The earlier emitter's approximate exponential is retired: no program module reaches an approximation. - EW-4 (judged at each level). The value of every node is read back
from its slot and judged against the reference's value of that node: an
exactnode bit for bit, awithin Nnode within N units in the last place, alossynode by its type. The judgement is of the realisation; the reference stays the meaning (GT-6). - EW-5 (weights by digest). The bytes of a blob (GT-9) are put into a slot, and the kernel library computes their BLAKE3 digest before the node reads them; bytes whose digest is not the one the term names stop the term (status 4 of the library), whatever store supplied them.
- EW-6 (the same answers). A non-finite value stops the term at that
node with
trap: non-finite float, as the reference does; floating point runs only on an engine that passes the HC-13 probe. The result ofrce graph run wasmis the result ofrce graph run, trap included.
Conformance. Each rule is checked by these tests of
spec/checker/tests/emit_wasm.rs:
| Rule | Test |
|---|---|
| EW-1 | the_kernel_library_is_pinned_and_the_program_links_to_it_only, every_node_of_the_examples_is_the_reference_at_its_level |
| EW-2 | the_kernel_library_is_pinned_and_the_program_links_to_it_only |
| EW-3 | the_kernel_library_is_pinned_and_the_program_links_to_it_only, every_node_of_the_lifted_toy_gpt2_is_the_reference_at_its_level |
| EW-4 | every_node_of_the_examples_is_the_reference_at_its_level, every_node_of_the_lifted_toy_gpt2_is_the_reference_at_its_level |
| EW-5 | a_blob_whose_bytes_are_not_its_digest_is_refused |
| EW-6 | the_commands |
The design is in spec/proposals/emit-wasm.md.
10.19 Every command, in one place
A command is a path of words that rce help prints, such as
rce host replay; the list is COMMANDS in spec/checker/src/cli.rs.
- CMD-1 Every command is written down three times. Each command of
rce helpis named in this section 10, in Appendix A of the book (book/src/appendix-a-commands.md) and in the command table ofREADME.md. A command that is missing from one of the three requires change. The testcommandsinspec/checker/tests/commands.rsreadsCOMMANDSand the three files and names each command it does not find.
The commands that no earlier subsection defines are these.
rce form-check FORM [VECTORS]runs the gate FG1 to FG15 of the Form proposal (spec/proposals/rce-form.md, section 11) on anrce-form/1module FORM. It printsapplied KEYand exits 0, or printsrequires change RULE GROUP FN PATH: REASONfor the first rule that fails and exits 1. VECTORS are the inputs its vectors are run on.rce fingerprint [json] [depth N] [fuel N] FILE...prints the behaviour fingerprint of rule BF-1 (spec/proposals/behaviour-fingerprint.md): a hash of the name-free outputs of every event sequence of length 1 to N (8 when N is not given) over the alphabet thatrce equivexplores. Programs thatrce equivjudges equal share it; a shared fingerprint is confirmed byrce equiv, never taken as proof.rce unform FORM.jsonprints the canonical source of the terms of a Form. It is the inverse ofrce emit form.rce host run,rce host serve,rce host replayandrce host compactrun a program under the host contract (Appendix E): admission into the durable log D (HC-1), the host loop as a service (HC-24 for HTTP), replay with every adapter disconnected (HC-8) and compaction at entry N by a checkpoint proven equal to the full replay (HC-37). Appendix E is normative for all four; this subsection only names them.rce host tls-id FILE Dprints the Ed25519 key of the TLS identity of the host whose log is D (kept inD.tlskey); a peer pins it withpeer HOST:PORT KEYaftertls.rce helpprints every command with its words;rce helpand theCOMMANDSlist are the same list.
Built from spec commit 1762fb4b. Code cells run the reference checker rce-check, written in Rust and compiled to WebAssembly, inside your browser; nothing is sent to a server. Read-aloud uses the Kokoro-82M model (Apache-2.0), served from this site and run in your browser.