Skip to content
openIE-devPublic

About

RCE: a small language defined by a written specification. Spec, grammar, Lean proofs and the reference checker rce.

Resources

Code of conduct

Contributing

Stars

0 stars

Watchers

0 watching

Forks

RCE: the Reality Code Engine

RCE stands for Reality Code Engine. It is a programming language and toolchain in which every program has the one shape of the Form, so that programs can be written, checked, changed and run by machines without a language model in the loop. The shape is rigid at each commit of the specification, and it grows inside the same text when a program needs a form it lacks.

Why RCE exists

RCE is made for the AI coding era. Models now write most of the code that gets written, and they write it in languages designed for people: text whose meaning depends on the compiler, the platform, the library versions and the flags, and whose correctness is checked after the fact by tests, reviews and more model calls. Every one of those steps spends energy and tokens on resolving ambiguity that the language itself introduced, and none of them can promise that the result is right.

RCE removes the ambiguity at the source. A program is a Form: a state machine P = (S, E, δ, D, λ) of declared states, declared events, a pure step function from a state and an event to the next state and its outputs, and the hash-chained log D of every event applied. Everything the program can do is in the Form, including the example lines it carries, so an accepted program is a Form whose examples hold. Where a text does not yet have the Form's shape (a parse error, a type error, an example that does not hold), the checker names the place and the part of the shape it lacks.

This is what makes autonomous coding deterministic. A proposal, whether a person, a search over existing Forms or a model produced it, is read by the checker alone, with the same result on every machine. Once accepted, the Form replays identically wherever the reference runs, is designed to project to any target language without changing meaning, and is reused as a whole. RCE is designed so that every language is both an output and an input of the Form (spec/proposals/rce-form.md): a print table emits a language from the Form, and a lift table, the reverse map, brings a program written in that language into the Form, each accepted at a level by exact comparison with the language's own implementation. That layer is not built yet. Today rce emit translates a checked program, not the Form, to Rust, Python, JavaScript and Scala through four hand-written emitters, all four of which agree with the reference on the conformance suite (1,459 tests pass, 0 fail, for each). The lifts are the probe spec/lift/go/lift_go.py, for one Go pattern, and spec/lift/python/lift_py.py, for a subset of Python 3.13, which carries 6 of the 92 cases of the pinned Python corpus (lang/README.md). The registry (spec/proposals/emit-targets.md) lists the languages that follow, including the new entrants of 2024 to 2026. No model is needed to decide what a program means, whether a change is safe, or whether two programs are the same, so the costly and non-deterministic part of AI coding is taken out of the loop. The aim is the lowest cost and lowest energy per correct program.

What the language guarantees:

  1. A program gives the same answer on every computer. Arithmetic, text and floating point each have one defined result, so nothing depends on the machine or the compiler.
  2. Every program finishes. Loops have limits and recursion works on smaller and smaller parts of its input, so a program cannot hang.
  3. A program's meaning is settled before it runs. Ownership, every case of a match and the program's example lines are part of its Form, so an accepted program never uses memory after giving it away, never leaves a case unhandled and has no example that fails. Where a text does not yet have that shape, the checker names the place and the rule.
  4. There is one language, batteries included. The specification at one commit is the language, every module of a program is in it, and the whole standard library is built into the checker: a program writes use enc and has it, with nothing to install, no directive and no flag (rce lib lists the modules). Nothing in this repository depends on a released or pinned version of anything else in it; the library is pinned by hash. A program never breaks because a library or a tool moved.

What is here

This repository holds everything that defines, implements, teaches, exercises or must agree with the language: the specification, the reference checker and interpreter, the Lean proofs, the grammar package, the book, the standard library, the example programs, the conformance suite, the IDE and the playground. All of it is built and checked from the same commit.

RCE overview: source, checker, Form, log, emit targets, host, fabrics

The checker reads a program into its Form, naming the place where a text does not yet have the Form's shape; every step is appended to the log D; rce emit translates the program to a target language (Rust, Python, JavaScript and Scala today; every registry language by table is the design); a host runs it on a compute fabric.

Try it

The playground runs the checker, compiled to WebAssembly, in the browser. The RCE Book teaches the language from first principles.

Build

rce is built from source with Rust; rustup reads spec/checker/rust-toolchain.toml and installs the toolchain on first build. The default build needs a C compiler only for ring, the crypto provider of the TLS adapter.

git clone https://github.com/openIE-dev/rce
cd rce/spec/checker
cargo build --release
install -m 755 target/release/rce ~/.local/bin/

Prebuilt rce binaries with the desktop IDE are on the releases page.

Quickstart

Save this as counter.rce:

intent "a counter that never goes below zero"
    example Inc, Inc, Dec -> 1
    example Dec -> kept: Underflow

state Counter
    n: u64 = 0

event Inc
event Dec

error Underflow

step Counter on Inc -> n + 1
step Counter on Dec -> try n.checked_sub(1) else Underflow
$ rce test counter.rce
ok counter.rce (2 examples, 0 checks)
1 passed, 0 failed

$ rce run counter.rce "Inc, Inc, Dec, Dec, Dec"
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

The example lines are part of the program: if one did not hold, the file would require change under W-INT-1.

Commands

Command What it does
rce check FILE... parse, type check and admit; one verdict per file
rce test FILE... the same, and count each file's examples and checks
rce run FILE [EVENTS] apply events, or run fn main()
rce trace --json FILE [EVENTS] reference trace of each example, or of EVENTS, for checking another implementation step by step
rce emit TARGET FILE form (the Form as JSON), or a target language: rust, python, js and scala today; the emit registry proposal lists the rest
rce fmt [--check] FILE... rewrite files in the canonical layout
rce dim [--fuel N] [--control] [--json] FILE count the behaviours a program can be in and the redundancy of its state (spec 6.10, 10.11)
rce host ... run a program under the host contract (Appendix E): admitter, log, adapters, sandbox
rce lsp language server on standard input and output

Section 10 of the specification defines each command.

Repository

Path Contents
spec/book/ the specification, one chapter per file; start at 00-overview.md. 03-syntax.md is the normative EBNF grammar, read by the tools; 16-host-contract.md is the host contract (Appendix E)
spec/RCE-SPEC.md the specification as one file, generated from spec/book/ by rce-book build
spec/checker/ the reference parser, type checker, interpreter, emitters, formatter, language server and host runtime (Rust); also rce-spec-check, rce-book, rce-spec-data and rce-fuzz
spec/checker-wasm/ the checker compiled to WebAssembly; spec/wasm-test/ tests the package against the examples
spec/lean/ the Lean 4 model of the core language and its proofs (section 8); scripts/lean-audit.sh checks the axioms
spec/examples/ programs the checker must accept, and in change/syntax/, change/types/ and change/admission/, programs that must require change
spec/traces/ reference traces of the example corpus
spec/data/ the specification as data (grammar tables, rules, method and cost tables)
spec/proposals/ design proposals and the decision ledger (LEDGER.md)
spec/fuzz/ results of the grammar-level program fuzzer
tree-sitter/ the tree-sitter grammar package for editors (grammar, generated parser, queries, bindings); the checker's independent second parser
book/ The RCE Book (mdBook); every listing is checked by book/scripts/check-listings.sh
playground/ the browser playground
stdlib/ the standard library (stdlib/lib/), its vectors and checks
lib/ libraries written in RCE: crypto.rce (SHA-2, X25519, Ed25519, X3DH, double ratchet), hpke.rce (RFC 9180), mls.rce (RFC 9420), pq.rce (ML-KEM) and their companions
rcedb/ RCEdb: the log as the database, indexes written in RCE
apps/ applications run by rce host: end-to-end encrypted chat, an SFU and a terminal
programs/ example programs by area (body, data, money, network, science, systems, text, world, hardware, media, multi) and the ecosystem programs
examples/ Form, surface and ingest examples
conformance/ the implementation-independent conformance suite, its harness, adapters and reports
lang/ pinned oracles (rce-oracle/1) and corpora (rce-corpus/1) for Go, Python and JavaScript, the recorder corpus.py and the generator generate.py; the Python lift spec/lift/python carries 6 of the 92 Python cases (lang/README.md)
ide/ the editor, language server, MCP server and sandbox, built on spec/checker
docs/figures/ figures with captions, scripts and data
scripts/ repository scripts: proofs and Lean audit, cross-architecture hashes and determinism streams, the Form corpus generator, claim counts, demos
.github/workflows/ one workflow per directory; each builds the checker from the current commit and runs that directory's checks against it

Checking the specification

cd spec/checker
cargo run --release --bin rce-spec-check
cargo test --release

rce-spec-check reads the grammar from spec/book/03-syntax.md, builds LALR(1) tables and fails on any conflict, parses every example with two parsers that must agree, runs the checker over all accepted examples and all that require change, and checks that RCE-SPEC.md matches the chapters. With --features tree-sitter (needs a C compiler and the tree-sitter CLI) it also regenerates the tree-sitter parser and uses it as a third parser. The emitter tests need rustc, python3 and node; a missing one is reported as skipped.

Status

The specification is a draft under review. The reference interpreter defines what programs mean and is not built for speed; there is no production compiler. Section 10.8 lists what the tools do not do yet. Counts quoted about the specification and the checker are taken from the source by scripts/claim-counts.py --check; a count is not a test result.

The research site and the experiments (research-openie-web, openie-research-experiments) read this repository; this repository never reads them.

Contributing

See CONTRIBUTING.md. Everyone taking part follows the code of conduct.

License

Copyright (c) 2026 Open Interface Engineering, Inc.

Licensed under either of

at your option. Unless you explicitly state otherwise, any contribution you intentionally submit for inclusion in this work shall be dual licensed as above, without any additional terms or conditions.

About

RCE: a small language defined by a written specification. Spec, grammar, Lean proofs and the reference checker rce.

Resources

Code of conduct

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages