A Ruby implementation written in Mere, in pure
Mere, targeting ruby 4.0.10. The
reference upgrade notes record the move
from 4.0.9, its inputs, validation and newly exposed gaps. Each number below
says which reference it was measured against.
It runs Ruby two ways -- a tree-walking evaluator, and an ISeq compiler with
a bytecode VM behind MERE_RUBY_VM=1 (see The two executions) --
and loads C extensions compiled against its own C API
(capi/README.md), so native gems install with gem install.
It is measured by CRuby's own test suites
and by ruby/spec: of the 34,634 tests in
CRuby's test/, 33,068 pass here as they pass under ruby 4.0.10; all of
basictest passes; and 2,673 of 2,994 ruby/spec files are byte-identical
to ruby 4.0.9 — see Where it stands for every suite and what the
rest is. set, pathname and digest are compiled in; the real csv gem is
not, and pointed at it with -I this parses CSV byte-identically to ruby
(bench/csv.sh).
The milestones further down (M0-M6) are how it was first built.
Measured by CI on main 0f0413c5 (2026-11-28,
run 46101446305),
against ruby 4.0.10, except the ruby/spec row, whose record was last swept
against ruby 4.0.9 (2026-11-11). MATCH: passes under both. RED: passes under
ruby and not here -- the number to work on. BOTH: fails under ruby as well,
and is not counted.
| suite | measured | MATCH | RED | BOTH |
|---|---|---|---|---|
CRuby test/ (758 files as 761 units, unittest/) |
34,634 tests | 33,068 | 1,427 | 117 |
bootstraptest (bootstraptest/) |
2,046 | 2,020 | 20 | 5 |
basictest (basictest/) |
894 | 894 | 0 | 0 |
tool/test (tooltest/) |
205 | 194 | 0 | 11 |
| ruby/spec (SPEC_STATUS.md, ruby 4.0.9) | 2,994 files | 2,673 | DIFF 16 | SKIP 305 |
the corpus (corpus/, byte-for-byte, hash index ON and OFF) |
1,033 programs | 1,033 | 0 | |
the corpus on the ISeq VM (tools/iseq/vm_corpus.sh) |
1,033 programs | 1,033 | 0 |
test/ also has 22 EXTRA (passes here and not under ruby) and 60 tests
excluded on both sides (unittest/excludes-gc/); bootstraptest has one EXTRA.
On the VM every corpus program ran on the VM itself: none fell back to the
evaluator.
What the 1,427 RED of test/ are, by file, from the same run's files.tsv:
| RED | ||
|---|---|---|
| files stopped at a bound or before their summary | 694 | ruby/test_array.rb reaches the 2 GiB bound (491), ruby/test_time.rb and ruby/test_sprintf.rb the 600-second one (123); json/json_parser_test.rb, json_addition_test.rb, json_generic_object_test.rb and -ext-/string/test_set_len.rb end without a summary (78); -ext-/thread/test_lock_native_thread.rb runs none (2). Every test such a file holds is RED, including the ones that pass when the file is run alone |
| JIT | 451 | test_zjit, test_yjit, test_yjit_exit_locations: a method JIT on top of the VM |
| C API test extensions and mkmf | 78 | the rest of -ext-/ and mkmf/: TracePoint and the debug inspector from C, postponed jobs, profile frames, ISeq loading (capi/README.md) |
| GC, ObjectSpace and allocation | 68 | ruby/test_allocation.rb (58), objspace/ (9), ruby/test_gc.rb (1) |
| RubyGems | 26 | test_gem_uninstaller.rb (20) and three more files |
| AST, Ripper and Prism | 8 | |
| VM and ISeq | 6 | test_iseq.rb, test_vm_dump.rb |
| the rest | 96 | across 41 files; ruby/test_string.rb (18) is the largest |
The three files at a bound completed against ruby 4.0.9 (main 79f287ae,
2026-11-24: test_array 473 of 477 MATCH, test_sprintf and test_time
every test ruby passes) and have stopped at their bounds in every CI run on
main since the reference moved to 4.0.10. The JSON files completed on main
85da98fb (2026-11-26) and end without a summary from 491cc5ca
(2026-11-28) on.
Divergences understood and deliberately left are in KNOWN_GAPS.md; results that move between runs of the same code are listed in unittest/README.md.
Use the pinned Mere compiler source
for native builds: it is the MERE_REF CI builds with (Mere 0.1.733), and
mere.toml asks for Mere 0.1.731 or later, the oldest the source builds on. Anonymous Class/Module metadata collection requires its
candidate string-root scanning and bounded-word string Map hashing.
tools/build.sh requires native cache trimming and verifies the compiler’s
default 64-region cache with zeroed reuse. Native openssl needs OpenSSL 3
(below) before the first build.
./tools/build.sh # -O2: the build that sweeps and the build that ships
./tools/build.sh --fast # -O1: faster to build than -O2, slower to run (-O0 cannot run the prelude).
# For shaping a change, NOT for the record -- the
# spec sweep refuses a --fast binary, because every verdict
# in it is bounded in CPU seconds.
./tools/build.sh --cc-only # skip the emit and compile the mr.c that is there
./tools/build.sh --relink # the same, recompiling mr.c only when it changed
# (for work on the C beside it: capi/, tools/*_glue.c)
# The core of what build.sh does, by hand. build.sh also compiles libprism
# (vendor/prism), tools/*_glue.c and the C API (capi/*.c) into the same link,
# with OpenSSL; this line alone does not make a complete mere-ruby.
mere -c main.mere > mr.c && clang -O2 -Wl,-stack_size,0x20000000 mr.c -o mere-ruby
# That line is macOS's. On Linux all three pieces differ, and none of them was
# written down until CI ran it somewhere else:
# clang -O2 -fbracket-depth=1024 mr.c -lm -o mere-ruby && ulimit -s 524288
# -Wl,-stack_size Mach-O only; the main thread's stack there is `ulimit -s`
# -fbracket-depth mainline clang caps nesting at 256, Apple's allows more.
# The Ruby prelude is one `"..." ++ "..."` chain and each ++
# is a bracket there, so it is split into four `let`s as well.
# MEASURED 2026-09-19: the emitted C needed 270, and the flag
# was LOAD-BEARING -- a build without it did not compile. It
# was 240 on 2026-09-10 and 155 in CI on main 0f0413c5
# (2026-11-28): the number moves both ways, so the flag
# stays. What grows is the
# count of top-level VALUES a function reads, plus each run of
# `let _`s between two of them -- not every top-level `let`
# (functions cost nothing; measured 2026-11-13, see the head
# of tools/bracket_depth_check.sh, which bisects clang's own
# answer and prints both distances on every CI run).
# -lm libm is separate there and part of libSystem here
#
# run_corpus.sh diffs this interpreter against the ruby on the machine, so it
# has to claim the identity of the platform it runs on: RUBY_PLATFORM is
# "arm64-darwin25" on macOS and "x86_64-linux" / "aarch64-linux" on Linux, and
# the socket constants are that platform's (corpus/108_sockets.rb prints
# them). CI runs the whole corpus on both. Comparing like with like means
# running where the identity it claims is true -- and, for the same reason,
# beside the ruby VERSION it claims to be.
# mere-ruby reports `ruby 4.0.10` (tools/ref_ruby.sh names the same version,
# and every gate sources it). The oracle has to be that release: 3.4 changed
# Hash#inspect to put spaces around `=>`, 4.0 prints a Set as `Set[1, 2]`, and
# 3.2.11 stopped warning on a `$=` read where 3.2.2 still warned -- a
# difference inside one minor version. Every axis of the string this reports
# has to match, so CI pins the oracle to exactly 4.0.10 on darwin. None of those
# differences was a defect on either side.
./mere-ruby script.rb
MERE_RUBY_VM=1 ./mere-ruby script.rb # the same program on the ISeq VM
./run_corpus.sh # diff every corpus/*.rb against the real ruby
./clitest/run.sh # diff the driver's argv handling against the real rubyThe driver takes the shapes ruby's does:
mere-ruby script.rb a b # ARGV = ["a", "b"]
mere-ruby -e 'puts 1+1' # repeated -e are lines of ONE program
mere-ruby -I lib script.rb # -Idir or -I dir; flags AFTER the script are its own
echo 'puts 1' | mere-ruby - # `-` is stdin; a BARE mere-ruby prints usage
mere-ruby -v # the same string RUBY_DESCRIPTION returns
mere-ruby -hAn unrecognised option is an error, not a filename. A bare mere-ruby does
not read stdin though ruby does — see KNOWN_GAPS.md.
# Install the build on this machine. The base URL has to point at the tarball
# that was just made -- with the default (a release URL) ruby-build would go
# and download a DIFFERENT one, which is a 404 until that release exists.
./packaging/rbenv/package.sh 0.1.0 "file://$PWD/dist"
rbenv install dist/mere-ruby-0.1.0
# Publishing: the default base URL is the GitHub release for the tag, so
# upload dist/*.tar.gz to it and ship dist/mere-ruby-0.1.0 as the definition.
./packaging/rbenv/package.sh 0.1.0rbenv needs nothing but a bin/ruby under $(rbenv root)/versions/<name>/, and
the definition is plain shell that ruby-build sources — so it carries its own
build_package_* function and no patch to ruby-build is required. The version
name deliberately has no platform in it (a .ruby-version naming one platform is
wrong on every other machine); the definition picks its tarball from uname and
refuses, by name, a platform it has no build for.
What this does not get you is gem install or bundle install out of the
box. The package carries the binary and its documents and no standard library,
and RubyGems and Bundler are standard library. That is a gap in the package, not
in the interpreter: given CRuby's standard library on RUBYLIB, mere-ruby runs
RubyGems and the published Bundler (see the RubyGems and Bundler paragraph
below). It installs C-extension gems with gem install through its own mkmf and
C API — nokogiri among them, compared with ruby by tools/capi_gem_check.py
(capi/README.md) — and takes a real Rails application through
Bundler, its dependencies, migration, boot, tests and Puma, on the evaluator
and on the VM (railstest/README.md). Rails' own
component test suites are compared with ruby test by test in
railstest/framework/.
-stack_size is not optional. Parsing and evaluating recurse over the
statement list, so native stack use grows with program size; on the
default 8 MB main-thread stack a program of roughly 8000 statements
segfaults before the interpreter's own SystemStackError guard can see
it. 512 MB was measured, not guessed: at that size both plain recursion
and a heavy frame (block, hash, string, begin/rescue) reach 100 000
native frames. The interpreter's own guard sits at 15 000 — deep enough
for rubocop-ast's recursive-descent pattern compiler, which needs more
than 10 000, and low enough that a RUNAWAY recursion trips the catchable
SystemStackError before it has committed much of that stack, which is
what a batch of programs in one process depends on. See
PAIN.md §M9.
Divergences that are understood and deliberately unfixed are tracked in KNOWN_GAPS.md, with what each costs and what fixing it would take — separately from what nobody has looked at yet.
By default a program runs on the evaluator, which walks the parsed tree.
RubyVM::InstructionSequence compiles Ruby to ruby's own instructions --
to_a and disasm are compared with ruby's byte for byte (tools/iseq/) --
with a compiler written in Ruby (lib/iseq_compiler_ext.rb) and one written
in Mere (ic/); CI compares the two compilers with ruby and with each other.
MERE_RUBY_VM runs whole files on a VM over those instructions:
| value | what happens |
|---|---|
unset or 0 |
the evaluator |
1 |
each file (the main script and every file it requires) runs on the VM when the compiler and the VM take all of it, and on the evaluator otherwise |
report |
as 1, and says on stderr which files fell back to the evaluator and why |
strict |
as 1, and a file the VM does not take raises instead of falling back |
why |
says whether the main script would run on the VM, and runs nothing |
The VM is held to the same answers as the evaluator: CI runs every corpus
program on it (tools/iseq/vm_corpus.sh; a fallback not listed in
tools/iseq/vm_fallbacks.txt fails, and the list is empty at present),
compares ISeq#eval snippets with ruby on the VM alone
(tools/iseq/vm_check.sh), and runs the C API contracts on it
(tools/capi_check.py --vm). unittest/vm_compare.sh runs CRuby's tests on
both executions and compares them test by test; CI runs it on the weekly
schedule and by hand. Its last run over all of test/ruby (main d5869476,
2026-11-25, loop/2026-11-25-stage10-test-ruby-whole.md) found two tests
that fail on the VM alone.
These are mere-ruby's own. Some harnesses give mere-ruby a cleaned
environment and drop any MERE_RUBY_* the caller has set: CI's CRuby,
bootstrap, basic and tool measurements (unittest/ci.py and the
measure.py scripts built on it), mspec/run_spec.sh (an env -i
allowlist), the C API checks (tools/capi_check.py, capi_gem_check.py,
capi_spec_check.py, capi_mkmf_check.py; --vm asks for the VM), and
railstest/measure.py and railstest/framework/run.py (--mere-env passes
one on explicitly). Others inherit the caller's settings: run_corpus.sh
runs the candidate with whatever the caller exported (--both only clears
MERE_RUBY_NO_HASH_INDEX for its first pass), so an exported
MERE_RUBY_VM, MERE_RUBY_GC_TIGHT or MERE_RUBY_GC_STRESS changes what the
corpus comparison measures. tools/iseq/vm_corpus.sh, unittest/run.sh and
unittest/try.sh inherit them the same way (vm_corpus.sh sets
MERE_RUBY_VM itself, and unittest/vm_compare.sh sets or unsets it per
pass).
| variable | |
|---|---|
MERE_RUBY_VM |
the ISeq VM, above |
MERE_RUBY_NO_GEMS=1 |
do not require RubyGems before the program, as --disable=gems |
MERE_RUBY_NO_HASH_INDEX=1 |
Hash lookups walk instead of using the index (run_corpus.sh --both runs every program both ways) |
MERE_RUBY_STACKTRACE=1 |
the recursion guard prints the innermost call names before it raises SystemStackError |
MERE_RUBY_GC_TIGHT=1 |
the collector's byte trigger fires at baseline + 8 MB instead of 2x + 32 MB, so the peak follows what is live rather than when a collection happened to run. The memory comparisons between builds recorded in loop/ use it, with a fixed test seed (--seed=1) |
MERE_RUBY_GC_STRESS=N |
collect at every Nth safepoint, pressure or not (a missing root shows up as a wrong answer) |
MERE_RUBY_GC_LOG=1 |
log each collection |
MERE_RUBY_STORE_STATS=1 |
print the interpreter's table sizes at the end (=exit: after the at_exit handlers) |
Every change is checked against the reference ruby before it lands:
./run_corpus.sh # every corpus program, byte-for-byte
./run_corpus.sh --both # ...with the hash index ON and OFF,
# running the reference once, not twice
# (and the SOURCE gates below first)
sh tools/iseq/vm_corpus.sh -j 3 # every corpus program on the ISeq VM
sh tools/iseq/vm_check.sh # ISeq#eval snippets on the VM against ruby
./bootstraptest/all.sh <ruby-checkout> # legacy assert_equal pairs (a subset)
./mspec/scoreboard.sh <ruby>/spec/ruby # every group the record has a row for
./mspec/record_hygiene.sh # the records name no machine and no operator
./rgtest/run.sh <rubygems-checkout> # rubygems' own test files
./unittest/try.sh <ruby-src> <test file> [-n ...] # one CRuby test file, one side, as run.sh runs it
./parsetest/run.sh <dir> [dir ...] # can it READ the ruby that exists?
./gemtest/run.sh <gem-home> <rubygems-checkout> [stdlib] # legacy gem-load report
# gemtest/measure.py pins the reference and records all three modes (gemtest/README.md)
./bundlertest/run.sh <stdlib-dir> <gem-home> # how far bundler gets, step by stepEach harness derives what it needs from the arguments; nothing is left in
/tmp between runs. Two of them used to be, and a cleared /tmp quietly
took the measurement with it.
CI also measures every bootstraptest/test_*.rb through the pinned Ruby's
native runner, including exit, pattern, syntax and finish assertions. See
bootstrap measurement for the complete manifest,
bounded execution, explicit skips and saved per-assertion results.
run_corpus.sh also runs SOURCE gates and two interpreter self-checks before
it runs a program, because each of them catches a defect that is invisible at
runtime -- a rule written twice, a table nobody reads, a guard that silently
disables the arm behind it. The gates are in tools/:
| gate | what it refuses |
|---|---|
gc_roots_check.sh |
a Val-valued global the collector does not scan |
dup_defs_check.sh |
one name defined twice in a chain (the second silently wins) |
dead_defs_check.sh |
a top-level function nothing calls |
meth_writes_check.sh |
a method-table write that skips the generation bump |
iv_door_check.sh |
an instance variable read or written by its table key instead of through the shape (the read finds nothing, quietly) |
strbuf_region_check.py |
a StrBuf made outside a region block (its buffer would stay for the rest of the run) |
name_spec_check.sh |
a name_set tag with no arm (an empty table answers false about every name), and an arm nobody asks for |
rx_caps_check.sh |
a regex capture slot written around rx_cap_set (the next match answers with the last one's group) |
ns_names_check.sh |
a namespace arm and its name list disagreeing -- either a name the call refuses though the arm implements it, or one respond_to? claims and the arm does not |
name_len_check.sh |
a length guard that is not its literal's length, which makes the arm UNREACHABLE with no build error |
bracket_depth_check.sh |
the emitted C outgrowing the nesting the build passes (CI-only: it needs the C) |
The self-checks ask the built interpreter: every Errno class has its
strerror text (MERE_RUBY_ERRNO_CHECK=1), and the per-class shape tables
hold a few hundred keys at most after 3,000 classes are made and dropped
(tools/shape_class_tables_check.rb).
mspec/record_hygiene.sh runs there too: it refuses a record that names a
machine or an operator, a tag file whose row count disagrees with its table
row (which is what a killed sweep leaves behind), and a tag file with no table
row at all.
run_corpus.sh takes MR_BIN (the binary to test, default ./mere-ruby),
CORPUS_KEEP_GOING=1 (report every difference instead of stopping at the
first) and CORPUS_STDERR=warnings|all (compare stderr too). Two runs may go
at once, even in one tree: a corpus program that writes a file names it with
its process id, and one that listens asks for port 0.
⚠ The sweep clones the spec tree ONCE, not once per file. Measured
2026-09-22: a spec file cost 2.71s of which 1.89s was SYS and 0.15s user --
the two interpreters take about 0.1s between them and the rest was copying the
4,333 files of core, language, library, shared and fixtures, which never
change. Ten million clones per sweep, about an hour of syscalls, and enough
filesystem churn to hold fseventsd at 100%+ for hours afterwards, which
slowed every other run on the machine by up to 8x. scoreboard.sh builds one
tree and hands it to run_spec.sh through SPEC_TREE; a hand-run of a single
file still gets its own. The full sweep went from ~90 minutes to 30, with every
row of the record byte-identical -- which is the check that the shared tree
changes no answer, and where it would show if a spec ever dirtied it.
LOOP.md has the full breakdown of what a cycle costs, what each
attempt to shorten it was worth, and what is left to try.
⚠ The sweep's bounds are its own, and the one that matters is CPU time. A
spec run is limited three ways and mspec/bounds.sh owns all
three: SPEC_CPU (25s) is how much CPU one side may BURN and answers "does
this finish"; SPEC_WALL (24× that) is how long one side may EXIST and catches
a process that is blocked rather than slow; the outer bound scoreboard.sh
puts on run_spec.sh is DERIVED from SPEC_WALL so it can never fire first.
Bytes are the third, and the sweep starts mspec/rss_guard.sh itself and takes
it down on the way out instead of asking the operator to remember.
A row says WHICH bound the measurements put a file over, never which signal
arrived — two files sit above both the CPU budget and the memory cap, so
"which bound fired" has no stable answer. The numbers behind it go to
mspec/bound_events.log, per run, not checked in.
SPEC_JOBS defaults to 6. The full record is byte-identical at one worker
and at six, which is the check — the speed is the consequence. ⚠ On the ratio:
the eight-group A/B was run back to back and is the load-independent figure
(627.5s against 271.2s, 2.31×); the full-sweep pair (1829.7s against
646–662s across three samples) was taken hours apart and is the softer claim. Getting there took three fixes, and the last one is the one worth
knowing: a shell sets SIGINT to SIG_IGN for a BACKGROUND job and SIG_IGN
survives fork and exec, so every spec under a worker was ignoring SIGINT
while the sequential path was not. LOOP.md has the measurements.
Still run the sweep ALONE. Starting a second harness next to it is what took this machine down once: bootstraptest extracts a 121k-line generated program, and the two peaks land together.
MERE_RUBY_STACKTRACE=1 makes the recursion guard dump the innermost call
names before it raises. A SystemStackError's backtrace stops at the guard, so
this is the view into a runaway recursion — it is what named rubocop's as an eight-frame
cycle through a fallback visitor, and from there the cause (a method_added
hook that never fired) was one test away.
zlib is a C extension in CRuby. Here it is mgz
— gzip in pure Mere — vendored under .mere_modules/ and imported, so a
checkout needs its submodule:
git clone --recurse-submodules <this repo>
# or, in an existing checkout:
git submodule update --initThat gives you Zlib.crc32 (including the seeded form a PNG chunk
needs), Zlib.adler32, Zlib::Inflate.inflate and
Zlib::Deflate.deflate — real dynamic-Huffman compression, not stored
blocks. Verified both directions against CRuby: mere-ruby reads what the
system zlib writes, and the system zlib reads what mere-ruby writes.
The submodule is pinned to mgz 661a01d (including its hash-chain match
finder, bounded token blocks and length-limited Huffman trees). The length
limiter corrects the actual code-space excess, and all three Huffman trees
are validated before any block bits are emitted, preventing oversubscribed
trees from producing corrupt streams. The old
74fa3a3 pin scanned the entire 32 KiB window at each position. Compressed
bytes and ratios may change; the uncompressed bytes and gzip CRC/size checks
remain the contract. The bridge uses mgz's inflate_buf byte-buffer API for
one-shot decoding; the Ruby streaming inflater keeps its existing bounded
reader and dictionary handling.
prism is CRuby's parser, and require "prism" works here because
libprism -- Prism 1.8.2, the copy Ruby 4.0.9 and 4.0.10
ship, as C -- is compiled into the binary by tools/build.sh and reached
through eight extern fn (prism_* in m_state.mere, written in
tools/prism_glue.c). The parse returns the parser's SERIALIZED
answer, and Prism's own Ruby library (shipped, as json's is; generated by
tools/gen_prism_lib.rb) deserializes it into the node tree -- the shape of
Prism's FFI backend on other Ruby implementations, with Mere's bytes in
place of FFI::MemoryPointer. The C extension (prism/extension.c) is not
used; lib/prism_ext.rb answers require "prism/prism" in its place. This
is the first of two steps: the parser itself is to be written in Mere behind
the same externs. Of test/prism and test/ripper together (75 files,
14,005 tests at main 0f0413c5 against 4.0.10), 8 tests are RED: one in
magic_comment_test and seven in test/ripper.
ripper is parse.y with event callbacks, a C extension. Here ::Ripper is
Prism::Translation::Ripper -- Ripper's API over Prism's tree, as on
TruffleRuby -- with the Ruby half the reference layers on its C core
(Ripper::Lexer and Ripper.tokenize / lex / slice over
Prism.lex_compat, Ripper::Filter, dedent_string, the C core's default
event handlers that answer their first argument) in lib/ripper_ext.rb,
which answers require "ripper" and every name ripper's own files are
required by. Prism documents the known differences: some scanner events are
not dispatched during #parse, and a syntax error's message is Prism's, not
parse.y's. Every file of test/ripper runs to its summary here, as under ruby
(two are ZERO on both sides); the seven RED above are what remains.
python3 unittest/zlib_compression_check.py checks both formats in both
directions against Python's native zlib/gzip, including binary data, input
beyond the token-block boundary, a 1 MiB repeated input and a corrupt gzip
CRC. Each child has a 30-second limit to catch the old window-scan behavior.
Random.urandom, also used by SecureRandom.random_bytes, reads
/dev/urandom in bounded chunks on native Unix hosts. It returns a binary
string without consuming the generator controlled by srand. A host without
that entropy source, or a failed read, raises RuntimeError; there is no
pseudorandom fallback for this API. Random.bytes remains the seeded generator.
mere-ruby ships a set of pure-Ruby libraries compiled in (monitor,
stringio, strscan, set, pathname, time, delegate, English,
digest, securerandom, base64, shellwords, observer,
fcntl, io/console, the escape half of cgi, …) and those always win over
a file of the same name. ⚠ Each is there because something asked for it and
failed by NAME -- require "fcntl" on line four of a spec file took a whole
group down with it -- and each is only as much of the library as can be
answered exactly: cgi's escapers are here and CGI.new is not, because a
CGI object in a process that is not a CGI script would have to invent its
environment. Everything else is
searched for on $LOAD_PATH, which starts empty — mere-ruby has no
stdlib directory of its own to seed it with. -I and RUBYLIB fill it,
in that order, exactly as in ruby:
./mere-ruby -I/path/to/ruby/lib/ruby/4.0.0 script.rb
RUBYLIB=/path/to/ruby/lib/ruby/4.0.0 ./mere-ruby script.rbPointed at a CRuby installation's stdlib, mere-ruby runs a good deal of
it directly. fileutils and uri also ship embedded; URI.parse,
URI.join and URI.encode_www_form follow the pinned Ruby source.
⚠ MEASURED 2026-09-20, and two of the three names this sentence used to carry
were wrong in opposite directions. uri did NOT load: a constant defined in a
class << self body could not be read from that same body (uri/common.rb
line 99 is exactly that shape), which is now fixed and is corpus/205. racc
did not load either, and that one is not this interpreter's doing -- in ruby
4.0 racc is a BUNDLED GEM and is no longer under rubylibdir at all, so the
example was describing a layout rather than measuring anything. (shellwords
used to be here too; it is compiled in now, so the shipped one wins and it
demonstrates nothing about the load path.)
Psych's ScalarScanner, ClassLoader and Handler use their real pure Ruby
files from the supplied library path. The class resolver preserves restricted
class/symbol loading, and String subclasses can call super into match?.
sh tools/psych_scalar_check.sh compares these protocols with native Psych,
including autoload and direct require. The existing YAML parser/emitter is
still a subset; full Parser, Nodes, aliases, tags and serialization remain work.
nkf uses the pinned NKF 2.1.5 core for conversion, MIME processing and encoding
guessing in native and browser builds. kconv ships its original Ruby API and
String extensions. See NKF.md for source provenance and verification.
A C extension is not automatically out of reach, but it has to be
answered rather than found. digest, date and etc ship as Ruby
source, zlib's compression comes from a vendored Mere package (above)
with its stream classes shipped as Ruby source over it, and rbconfig,
thread and fiber are satisfied without a file (fiber.so is loaded
before any Ruby runs in CRuby 3.x, so require "fiber" returns false
there too). socket is answered by the interpreter itself: TCPSocket,
TCPServer and the rest are Ruby source over Mere's own socket FFI, so a
program here really does connect, listen, accept and exchange bytes —
zero bytes included. Native UDP datagrams, UNIX sockets and Socket.pair
are also supported. Native openssl uses OpenSSL 3
(libssl and libcrypto) for keys, certificates, TLS, digests, MACs, KDFs and
ciphers, including authenticated modes. Install openssl@3 on macOS or
libssl-dev on Linux before sh tools/build.sh; OPENSSL_PREFIX selects an
explicit installation. ASN.1 and BN value conversion also work in Wasm, where
portable Digest/HMAC/AES remain available and native key/certificate/TLS
operations raise NotImplementedError.
The OpenSSL selection covers all 32 nonempty upstream files and 593 tests
from Ruby 4.0.10: 591 match and two FIPS tests skip on both sides (CI, main
0f0413c5, macOS). This includes PKCS12, PKCS7/S/MIME, OCSP, Timestamp and Netscape SPKI.
Engine discovers zero reference tests and is excluded from the pass count.
Independent wire, cryptographic-vector, cross-format, TLS-peer and
resource-lifetime gates live in unittest/openssl_*_check.py; the complete
inventory and verification are recorded in openssl-plan.json and
openssl-completion-plan.json. Native container operations raise explicit
capability errors in Wasm; portable cryptographic operations remain available.
RubyGems and Bundler are the ones that matter, because everything else is
loaded through them: pointed at a CRuby stdlib, require "rubygems" works,
require "bundler" works, a real Gemfile evaluates, and Bundler.setup
answers what ruby answers — resolving the dependencies and setting up the load
paths. bundlertest/run.sh compares that step by step against the reference and
has no recorded divergence left; the walls it worked through, in order, were
thor's caller[1], comparison through a user <=>, module_function's scope,
an exception that kept neither class nor message, rescue *[] swallowing
everything, an ensure body consuming the exception it ran under, and
File.open refusing the Pathname bundler writes the lockfile through.
Against the unchanged sample of 29 gems, an isolated snapshot of 278 packages
is fixed by archive and source-tree hashes. The pinned Ruby 4.0.9 reference
loads 22; on 2026-11-10 mere-ruby loads all 22 with bundled libraries
and with an external CRuby stdlib on -I. Six cases need Rails setup or native
dependencies unavailable to the reference; private sidekiq-pro 7.2.0 sources
are unavailable and remain a separate exclusion. No run timed out. This is a
require-only measurement, with installed gem libraries available in both modes.
See gemtest/latest.json and gemtest/README.md for locked restoration,
source-drift detection and bounded measurements.
Real local HTTPS succeeds with explicit trust using native SSLSocket and
bundled Net::HTTP, including rejection of an untrusted certificate and a wrong
hostname. URI, Timeout, Net::Protocol, Net::HTTP, OpenURI and Resolv are bundled
from pinned, licensed sources; net/ftp and resolv-replace ship with them.
No external stdlib path is needed. Excon also passes all three TLS outcomes
under the reference and both native modes; implicit native exception dispatch
and the controlled localhost/IPv4 measurement are covered by regressions.
See network-stdlib-plan.json and gemtest/https_latest.json for exact scope.
The Wasm playground supports URI and DNS/IP codecs. Its host reserves 512 MiB
for the expanded libraries. Zero/nil Timeout blocks work; nonzero asynchronous
deadlines explicitly raise NotImplementedError on this target. Native socket,
DNS transport and OpenSSL operations remain native capabilities.
json is answered by the interpreter (json 2.18's own Ruby files, and its
C parser and generator in Mere), which is what moved three of them.
⚠ This number fell from 21 to 4 with no gate noticing, and the cause was one line: the source was cut at its first NUL byte anywhere, and rubygems writes gemspec stubs with NUL-separated extension lists, so every such gemspec evaluated to nil. gemtest is not in CI (it needs an installed gem home); run it after any change to loading, parsing or rubygems' paths.
mere-ruby also compiles straight to WebAssembly, so it runs Ruby entirely
client-side — no server, no filesystem. The playground under docs/
is a single page that fetches mere-ruby.wasm, hands the editor's source to
run_cli (via a read_file sentinel), and shows the output:
# Requires WABT (wat2wasm), Binaryen (wasm-opt) and Node.
# Generates a no-coroutine copy, optimizes it, then checks the actual HTML host.
MERE=/path/to/mere sh docs/build.sh
cd docs && python3 -m http.server # then open http://localhost:8000/This needs Mere v0.1.127+, whose Wasm backend widened int to 64 bits —
without it 1234567890123 + 1 (and any Ruby integer past 2³¹) could not run
in the browser.
- Literals: integers, floats, double- and single-quoted strings
(with Ruby's escape rules for each),
true/false/nil, array literals, hash literals ({"a" => 1}). - Operators, with Ruby's precedence and semantics where they differ
from C:
**right-associative and tighter than unary minus on its left (2**3**2 == 512,-2**2 == -4)- floor division and sign-of-divisor modulo (
-7 / 2 == -4,-7 % 3 == 2,7 % -3 == -2) - value-returning
&&/||(1 && 2is2,nil || 5is5) with short-circuit evaluation - Ruby truthiness: only
nilandfalseare falsy —0and""are truthy (!0isfalse) - mixed int/float arithmetic and comparison (
1 == 1.0istrue), string+/*/ comparisons, array+/==
putswith Ruby's exact behavior: arrays flatten recursively onto separate lines,nilprints an empty line, bareputsprints an empty line, multiple comma-separated arguments.- Comments, blank lines, expression statements.
- Local variables: assignment and reassignment (
x = x + 1), read anywhere an expression is allowed. The environment is a MereMap— whose insertion-ordered semantics happen to match Ruby's hashes, a design coincidence this project leans on. - Control flow in the multi-line
... endform:if / elsif / else / end,unless(desugared to a negatedif)whileanduntil(desugared to a negatedwhile), with optionaldocase / when / else / end, including multi-valuewhen a, b(Ruby's===is plain equality for the value classes in this subset)- optional
thenafter conditions, nested blocks
- Enough for real small programs: the corpus closes with FizzBuzz and a
float-accumulation loop, both byte-identical to
ruby.
- Method definitions:
def name(a, b) ... endanddef name ... end, called asname(args)or (for a no-arg method) barename. Methods live in a namespace separate from local variables. return, explicit (with or without a value) and implicit (a method's value is its last statement). Early return propagates out of nestedif/while/caseto the method boundary.- Recursion: factorial, Fibonacci, and a recursive sum are in the corpus.
- Flat method scope: a method body sees only its parameters, not the caller's locals — Ruby methods are not closures over their caller. Each call runs in a fresh environment, which is both correct and simpler than a lexical closure.
- Statement modifiers:
return x if cond,... unless ...,... while ...,... until ....
M2 forced a fix in the host language itself: the evaluator became one
mutual-recursion group of eleven functions threading two maps, and the
Mere C backend emitted several of them twice (a duplicate-definition
build failure). It is fixed upstream in Mere v0.1.66 — see PAIN.md.
- Classes:
class Name ... end,class Name < Super ... end, instance methods viadefinside the class body. - Instances:
Name.new(args)allocates an object and runsinitialize;@ivarreads and writes instance variables;selfis the receiver. - Method dispatch walks the ancestor chain (
obj.method(args), and no-argobj.method), so subclasses override and inherit. A method can call a sibling method with an implicitself. attr_accessor/attr_reader/attr_writersynthesize getters and setters;obj.attr = valuecalls the setter.- Symbols (
:name) and a few primitive methods (to_s,to_i,to_f,size/length,abs) — a small preview of M5, since a class'sto_simmediately needs@x.to_s.
Objects are represented as integer handles into the interpreter's world
(a bundle of maps: class table, superclass links, object classes,
instance variables). See PAIN.md for why that shape, and why the
world is a tuple of maps rather than a record.
- Blocks (
{ |x| ... }anddo |x| ... end) as true closures: a block captures its defining scope and reads and mutates the enclosing locals — the counterpoint to M2's flat method scope. Its params and the locals it first assigns are block-local, living in a per-invocation frame chained to that scope, so each iteration gets its own binding and alambdacreated inside the block keeps them after the block returns. - Built-in iterators taking a block:
each,map,select,each_with_indexon arrays;timesanduptoon integers. - Ranges:
1..5(inclusive) and1...5(exclusive), with.each,.map,.to_a. yield, which calls the block passed to the current method — including nested cases (a method that yields from inside@xs.each { |n| yield(n) }) and implicit-selfblock calls (each { ... }inside a method callingself.each).
All non-mutating, matching Ruby's results:
- Indexing:
arr[i],str[i],hash[k], with negative indices. - String:
upcase,downcase,capitalize,reverse,strip,chars,split,include?,start_with?,end_with?,empty?. - Array:
first,last,sort,uniq,min,max,sum,index,count,join,reverse,include?, plus block formsreduce/inject,reject,count. - Hash:
keys,values,size,[],key?/has_key?,include?,each { |k, v| },select { |k, v| },empty?. - Integer:
even?,odd?,zero?,succ,pred,abs. - Universal:
class,nil?,inspect,to_s,to_i,to_f,to_a,size/length.
Method names ending in ? or ! lex correctly, and method chains
continue after a block (arr.map { |x| x * 2 }.sum). In-place mutation
(<<, push, arr[i] = v) is deferred to a later milestone; the corpus
builds collections functionally.
raisewith a message, a class, or a class and message.begin/rescue/else/ensure/end,rescue Class => e, multiplerescueclauses, a barerescue(catchesStandardError), method-level rescue (def f ... rescue ... end), andbeginused as a value (x = begin ... end).- Exception class hierarchy: built-in
RuntimeError/ArgumentError/ZeroDivisionError/ …< StandardError < Exception; user exceptions extend it (class MyError < StandardError).rescuematches up the chain. Integer division by zero raises a realZeroDivisionError. e.message/e.class. (retryis deferred.)
This is the last piece of the G1 subset: 40 corpus programs — FizzBuzz,
class hierarchies, iterator chains, hashes, and exception flows — all match
the reference ruby byte-for-byte, on both the interpreter and the
C backend.
run_corpus.sh runs every program in corpus/ under the real ruby
and under ./mere-ruby and diffs the output byte-for-byte: 1,033 programs,
1,033 identical in CI on main 0f0413c5 (2026-11-28) — and again with
MERE_RUBY_NO_HASH_INDEX=1, so the hash index cannot hide behind the walk it
replaced, and once more on the ISeq VM. CI runs the corpus on macOS and on
Linux. The corpus covers the semantic corners above. A deliberate negative control (lossy float
printing, see PAIN.md) confirms the harness actually detects divergence.
Ruby has no normative written spec — CRuby (MRI) is the definition, and ruby/spec is the community's executable conformance suite that the other alternative implementations (JRuby, TruffleRuby, Opal, Artichoke) target. mere-ruby measures against it too.
mspec/scoreboard.sh sweeps ruby/spec directories, runs each spec file under
both mere-ruby and ruby through a minimal mspec shim, and compares
byte-for-byte. It writes SPEC_STATUS.md (a per-group MATCH / DIFF / CRASH /
SKIP table) and mspec/tags/*.txt (the per-file list of what does not
match, each row carrying WHY it does not).
./mspec/causes.sh then groups those rows by cause and writes
CAUSES.md. That is the number worth acting on: the table says how
many files disagree, and this says how many NAMES they come down to. It reads
the tags files only, so the bucket key can be retuned without re-sweeping. Those tag files are the honest, checked-in record of the gap — the
same idea as the tags/filter files every other implementation keeps. The
long-term goal is to pass every test in the pinned Ruby suites, including
stdlib, VM and C-API tests as the required runtime support is implemented.
The existing scoreboard below measures its recorded groups and source tree;
it is not a complete inventory. CI's measurement-plan/suites.json separately
lists the broader target suites and inputs still awaiting measurement.
The record covers 2994 spec files: 2673 MATCH, 16 DIFF, 0 CRASH,
305 SKIP, 0 SLOW, against ruby 4.0.9 (last swept 2026-11-11; it has not yet
been swept against 4.0.10). Run with no
directories, the sweep refreshes exactly the groups the table already has, so
the numbers above are reproducible rather than a snapshot -- and every row of
one table is measured by ONE build (MR_BIN, default ./mere-ruby; the
sweep refuses a tools/build.sh --fast binary unless SPEC_BUILD_OK=1).
⚠ The record is measured against ONE ruby/spec tree, and it is not ruby's
master. SPEC_STATUS.md names it on its last line (ruby@3e93b23afcec, the
ruby/ruby commit tagged v4.0.9, whose spec/ruby it is; until 2026-11-09 the
record was master's 84a27934cf53). A checkout of anything else has a
different number of files in some groups (core/string has 124 on 2026-10-03's
master and 114 in the record), and scoreboard.sh refuses to sweep it rather
than let the new files read as regressions. Make the tree once, beside your
ruby checkout, and sweep that:
git -C <ruby-checkout> worktree add --detach ../ruby-spec-3e93b23 3e93b23afcec
./mspec/scoreboard.sh ../ruby-spec-3e93b23/spec/ruby # core, language, ...
SPEC_WITH_STDLIB=1 ./mspec/scoreboard.sh ../ruby-spec-3e93b23/spec/ruby # library/Moving the record to a newer tree is a deliberate upgrade of the suite
(SPEC_TOTALS_OK=1, the whole table re-measured together), not a pull.
core and language are measured nearly in full: of that tree's 2,095
core files every directory but core/enumerator/generator and
core/enumerator/yielder (6 files) has a row, and all 79 language files do.
library is measured for the libraries this ships: 793 of 1517, across 68
groups. One row, core/ruby/source_range (1 file, SKIP), is left over from
master's tree and has no file in v4.0.9's.
⚠ 2994 is not all of ruby/spec -- the v4.0.9 tree has 3783 files, and the number worth writing down is the one that says what is NOT being asked. Here are the other 790, counted so that they add up:
| files | not measured | why |
|---|---|---|
| 724 | library/ outside the groups with rows |
the libraries this does not ship. A group gets a row when the library is answered, not before -- and which those are is MEASURED rather than remembered: on 2026-09-22 every require the then-unrecorded groups made was asked of this interpreter, and the groups whose libraries all loaded were swept |
| 46 | optional/capi |
measured by tools/capi_spec_check.py, not by this sweep: each spec file needs its C extension built for both rubies. Its record is capi/check/spec_expect.tsv -- 2,420 of the reference's 2,602 examples pass (2026-11-24, Ruby 4.0.10) |
| 14 | security |
CVE regressions |
| 6 | core/enumerator/generator, core/enumerator/yielder |
no row yet |
command_line (32 files) is in the record, and clitest/ also measures the
executable's flag handling directly. A percentage over a surface you chose is
worth less than the list of what you left out, so the list is here and it adds
to 3783 (2993 real files in the record, plus these 790).
⚠ The 448 files added on 2026-09-22 cost no interpreter change at all, and
picking them was the whole of the work. library/ has 118 directories with no
row; the question "which of these does this interpreter ship?" was answered by
asking IT, not by reading a list: every non-relative require those 118 groups
make -- 49 distinct names -- was run under this binary, and the 49 groups whose
requires ALL loaded were swept. That moved 1764 MATCH to 1934 before a line
of the interpreter changed, and four groups came back whole on the first run
(cgi/queryextension 38/38, cgi/htmlextension 26/26, cgi/cookie 9/9,
date/infinity 10/10).
⚠ It also found that the default sweep had been dropping twelve of its own
rows in silence. scoreboard.sh with no arguments re-sweeps "every group the
table has a row for", and it read those names with sed -n 's/^| \([a-z][a-z_/-]*\) |.*/\1/p'.
A group name with a digit or a capital does not shorten under that class -- the
whole line fails to match and the ROW DISAPPEARS. library/base64 had been in
the table for weeks and had never been re-measured by a default run; so had
every digest/*, win32ole/* and openssl/x509/* group, and library/English.
The same expression lived a second time in record_hygiene.sh with a slightly
different class, which is why that gate reported library/English as a tag file
with no row. Both now use one expression, and the comment in each names the other.
⚠ The last 416 of those were not hard to measure -- they were never ASKED.
run_spec.sh clones core, language, shared and fixtures into the tree it runs
in, and once it also cloned library, sixteen library groups had rows. The same
kind of omission hid the rest: the scoreboard takes a nested group name like
core/file/stat and turns it into a tag file, and it had simply never been
given one. Adding 32 group names moved 416 files from "unknown" to measured,
157 of them straight to MATCH (core/process was 26 of 40 the first time it
was ever run), and it is why the headline MATCH went UP while the percentage
went DOWN. Both are the honest direction.
⚠ CRASH went 0 -> 10 -> 0. Measuring core and language in full put ten aborts in the record, because the surface nobody had measured is where they were. All ten are closed, and every one was a CYCLE or a REFUSAL that killed the process instead of raising:
| was | root |
|---|---|
| 4 | Enumerator::Lazy materialised its source for every operator the pipeline did not know, so an infinite one ran to 6-17 GB. Sixteen operators are lazy now, buffering ones included |
| 3 | a self-referential structure walked forever. Arrays and hashes were guarded in the PRINTER only: an object holding itself, Marshal.dump of a cycle, and ==/eql? between two cycles were each a SIGSEGV. Marshal now writes ruby's object table (@<index>), which is also why [s, s] writes the string once |
| 2 | \g<1>, \k<-1> and \k<01>: the by-NAME spellings parsed, the numbered ones reached the "undefined group reference" arm and failed. ⚠ The load-time check validates LENIENTLY, so an unsupported literal passed it and then died in the real parse. A literal this engine cannot compile raises RegexpError now, exactly as Regexp.new always did, and one construct no longer costs a whole file |
| 1 | Enumerator::Product did not exist |
⚠ These do NOT come from run_spec.sh <one file>, which prints DIFF for every
one of them. That verdict answers "do the two outputs differ"; the scoreboard
asks "did it run at all", and mere-ruby printed no tally where ruby ran eleven
examples. When two instruments disagree, find out which question each is
answering before believing the friendlier one.
Nothing aborts on its own — CRASH is 0, and so is SLOW now. When the
record had eight SLOW files they were stopped by one of this harness's bounds
(six by the CPU budget, one by the memory cap), not by the interpreter giving
up. ⚠ That distinction is now the
definition rather than a convention: a SIGKILL from mspec/rss_guard.sh used
to be filed as CRASH, which is a claim about the interpreter, and its row names
the bound instead. So the gap is not "cannot", and a group score reads low for
a reason worth naming rather than for breakage -- real programs (the corpus) match exactly while a value class scores
low on an error message or a frozen-object check. ⚠ Three earlier CRASH rows
have appeared and gone: every one was a NAMED MISSING LIBRARY (fcntl, cgi,
io/console) that the file required on its fourth line, which the scoreboard
reports as a crash because the process dies before it can report.
A whole group can carry a crash for a handful of integers.
Naming the rest is what CAUSES.md is for. Grouped by cause, the DIFFs come
down to a bounded number of kinds. When it was last generated
(2026-10-01, from 185 DIFF files; the record now has 16) the kinds were led
by missing surface (NameError, NoMethodError: a name that is not there),
VALUE mismatches (expected "S", got "S", expected N, got N) and REFUSALS
ruby makes and this does not (expected ArgumentError to be raised).
./mspec/causes.sh rewrites it from mspec/tags/ without a sweep. Because
ruby/spec is laid out
as core/<class>/<method>_spec.rb, those files name the absent methods
themselves -- CAUSES.md ends with that list, per class, and
MISSING_NAMES.md asks the same question from the other
side (ruby's own method lists, probed under this interpreter: 58 absent of
1410 on 2026-09-30, against ruby 4.0.6).
⚠ A record refreshed only when someone remembers is a claim about the past. One re-sweep found the table had drifted 3 files from the committed interpreter, so the invitation to re-run at the bottom of the table is the load-bearing part of it.
mere-ruby is a dogfood program for Mere — the start of a long-running probe:
how far can a young ML-family language carry a real dynamic-language
implementation? The interpreter structure (lexer → precedence-climbing
parser → tree-walking evaluator over a value variant) is the classic
functional-language shape, and Mere's variants, pattern matching, and
mutual recursion carry it naturally. What doesn't carry — float
formatting fidelity, for one — gets found, recorded in PAIN.md, and
fixed upstream.
Native builds go through Mere's C backend and the browser build through its Wasm backend (In the browser); the interpreter core is backend-agnostic. The ISeq VM came later, beside the tree-walking evaluator (The two executions).