ΦΜΛ
A library that is also an operating system. Documents have margins that run when you read them.
Working. Open source under MIT. The manual and documentation are at oma.ooo.
| Role | Year | Kind | Try it |
|---|---|---|---|
| Concept, world and language design, engineering | 2026 | Operating system, interactive fiction | oma.ooo |
| 3,497 | lines of Rust, in 10 modules |
| 2 | dependencies |
| 28 | commands, every one a word a reader would use |
Play it
The library runs here, in the page. It is the same program as the download, with shelves that last until you leave.
The problem
A command line asks you to learn its words: ls, cd, cat. The files it shows you are inert.
I wanted to find out what a system feels like when it uses the reader's words instead, and when the documents in it are allowed to do things.
What I built
- A shell in a reader's vocabulary.
browseinstead ofls,walkinstead ofcd,inscribeinstead ofcat >. Rooms are directories, shelves are their contents, the journal is the system log written as prose. - Three registers on every document. Φ is where it is, Μ is what it says, Λ is what it does.
readshows the text.inspectshows all three. - A small language for the margins. Λ has eleven instructions. A document can speak, ask the reader something, create other documents, delete them, and rewrite or erode its own text.
- A founding collection. The documents on the shelves at first boot are the manual, and each one is also a program: one loses a line every time it is read, one deletes itself after a single reading, one writes the next lesson when you finish it.
- Two daemons. A librarian tidies and writes to the journal every five minutes. A dreamer reads random fragments once an hour and inscribes new documents, which expire after a day.
- A second language underneath. A two-dimensional grid language in which the three registers must agree before an instruction runs. It exists as a Python reference interpreter and a partial Rust port.
How it is structured
Rust, with two dependencies (chrono for time, libc for the terminal). One binary, 37 commits.
How a document is stored
A document is an ordinary text file. If it has a margin, the file holds the text, then a line reading --- Λ ---, then the margin. Nothing else: no database, no hidden attributes. You can open any document in another editor and see exactly what it will do.
The Λ language
| Instruction | What it does |
|---|---|
say | Prints text, with variables filled in |
set | Sets a variable: to a value, a count of files, the number of times this document has been read, a random line, a random file, or the reader's answer to a question |
if, loop, loop while | Run the indented lines below, once or repeatedly |
write | Adds a line to a file |
inscribe | Creates a document from the indented lines below |
withdraw | Deletes a document |
erode self | Removes lines from this document's own text |
mutate self | Replaces words in this document's own text |
wait | Pauses |
In the code
From Beach-Bum/OMA-Library-OS, which is public.
The most interesting code in the repository is in the Python reference for the grid language. An instruction does not fail; the three registers vote on it, and a disagreement is written into the record with the names of the dissenters. The same cell disagreeing again is treated as more serious each time, and the fourth time halts the program.
class Consensus:
def __init__(self, fa: FindingAid):
self.fa = fa
self.schism_counts: dict = {}
self.fatal = False
self.total = 0
self.polite = 0
def check(self, cycle, pos, op, polite, phi_fn, mu_fn, lam_fn) -> bool:
self.total += 1
if polite: self.polite += 1
p_ok, p_why = phi_fn()
m_ok, m_why = mu_fn()
l_ok, l_why = lam_fn()
if p_ok and m_ok and l_ok:
return True
ds, rs = [], []
if not p_ok: ds.append('PHI'); rs.append(p_why)
if not m_ok: ds.append('MU'); rs.append(m_why)
if not l_ok: ds.append('LAMBDA'); rs.append(l_why)
cnt = self.schism_counts.get(pos, 0) + 1
self.schism_counts[pos] = cnt
sev = ['MINOR','MODERATE','ESCALATED','FATAL'][min(cnt-1,3)]
self.fa.schism(cycle, pos, op, ds, rs, polite, sev)
if sev == 'FATAL':
self.fatal = True
self.fa.log('s3', cycle, f'FATAL SCHISM at {pos}', 'FATAL')
return FalseWhat a reviewer would say: in practice only two of the three vote. No instruction supplies a check for Φ, so the disagreements are always about stack depth or degree. And the polite count is kept and never used.
Reading a stranger's document
A margin runs when you read its document, with the shell's own file permissions. Until this pass, a margin's paths were joined to the library folder unchecked, so a document could write or delete anywhere on the machine, and a loop could not end itself. Both are fixed, in pull request 7, now merged, which also gave the Rust its first 24 tests.
Staying inside the library. A path is checked twice: by its parts, which rejects an absolute path or a .. without touching the disk, and then by where its nearest existing parent really is, which catches a link inside the library that points out of it.
/// Turn a path named by a margin into a real path inside `root`, or refuse.
///
/// Refused: an empty path, an absolute path, any `..` component, and any
/// path whose nearest existing ancestor resolves (through symlinks) to
/// somewhere outside `root`. A dangling symlink is refused too, because
/// writing through it would create its target.
///
/// The symlink check reads the filesystem and the caller acts afterwards,
/// so it is not atomic: it stops a margin from following a link that is
/// already there, not a second process racing to plant one.
pub fn confine(root: &Path, rel: &str) -> Option<PathBuf> {
let rel = rel.trim();
if rel.is_empty() || rel.contains('\0') {
return None;
}
// Only plain names and `.` may appear. This rejects `/x` (RootDir),
// `C:\x` (Prefix) and `a/../../x` (ParentDir) without resolving anything.
let named = Path::new(rel);
if !named
.components()
.all(|c| matches!(c, Component::Normal(_) | Component::CurDir))
{
return None;
}
let full = root.join(named);
let real_root = fs::canonicalize(root).ok()?;
// Walk up to the nearest thing that exists (the root itself at worst)
// and ask where it really is.
let mut probe = full.as_path();
loop {
if fs::symlink_metadata(probe).is_ok() {
let real = fs::canonicalize(probe).ok()?;
if !real.starts_with(&real_root) {
return None;
}
break;
}
probe = probe.parent()?;
}
Some(full)
}The comment states the limit: it stops a margin following a link that is already there, not a second program racing to plant one.
One allowance per reading. Every instruction costs a step, and a reading has 10,000. Loops read the same variables their body writes, so a loop can end itself, and one that never would is stopped.
} else if line.starts_with("loop while ") && line.ends_with(':') {
// loop while condition:
let condition = line.strip_prefix("loop while ").unwrap()
.strip_suffix(':').unwrap().trim().to_string();
let body = take_block(&lines, &mut i);
// The condition is read from the live variables, which the
// body shares, so the body can end the loop. Each further
// pass costs a step of its own: an empty body still ends.
while eval_condition(&condition, &self.vars) {
if self.run(&body) == Flow::Stop || !self.spend() {
return Flow::Stop;
}
}
} else if line == "loop:" {
// Runs until the reading's allowance is spent.
let body = take_block(&lines, &mut i);
loop {
if self.run(&body) == Flow::Stop || !self.spend() {
return Flow::Stop;
}
}Writing the test that runs all eight founding documents showed two of them had never worked. The first lesson created an empty second lesson, and the dreamer wrote a one-line dream and then tried to run the rest of the dream as instructions. Both came from the same bug as the loop: indented blocks were flattened. They now produce what they describe.
The grid language
Under the readable margin language is a stranger one. A program is a grid of cells that wraps at its edges, and execution moves across it in four directions. Each instruction passes through three stages, one per register: declared, populated, activated. If the registers do not agree, the instruction does not run and the disagreement is written down as a schism, not raised as an error. A cell is rewritten after it has been executed.
I wrote it first as a reference interpreter in Python (970 lines) and then began a port to Rust (526 lines). The port is not finished and not connected: it has no consensus step, its instruction set differs from the reference in places, and the shell has no command that runs it. The written specification is in the repository.
How it is built
cargo build --release, then the binary is stripped. The Makefile also cross-compiles for a Raspberry Pi and has a target for a bootable SD card image, so the library can be the only thing a small computer does.
How it is tested
24 tests on the margin engine: refused paths (absolute, .., three kinds of link), loops that end and loops that are stopped, waits that are refused or shortened, and all eight founding documents run from a fresh library. I checked the tests bite by breaking the code three ways; a test failed each time. They have run on macOS only. The Python reference has a self-test of five small programs.
What it does not do
- A margin can still do anything inside the library. Confinement stops at the library's edge. Within it a document can overwrite any other document, the journal included.
- The shell's own commands were not reviewed for the same path problem; only margins were.
- A binary built before the merge has none of this.
as-archivistis a word, not a password. It marks intent. It does not check who you are.- One reader at a time.