interplane.Get Omega
Read in your language

omega-mcp

aien-dev/omega-mcp

Brought by drakestapleton

branch main Branches Tags History

omega-mcp / README.md

274 lines · 18970 bytes Raw Blame History Source

omega-mcp

Omega MCP on mcprush

An MCP server, written in Omega, that lets an agent compile and run Omega (.om) programs with the pinned seeded compiler and look up the language. It speaks MCP (protocol version 2025-06-18) as newline-delimited JSON-RPC 2.0 over stdio.

The pin is the file PIN: an omega-mv revision and the sha256 of its seed/out/omc. It is written nowhere else. build.sh takes the compiler from that revision, refuses any other, and generates everything else that names the pin; the server checks the sha256 of its compiler again at start-up and reports the pin in initialize and in every compile result. Repinning is an edit of PIN and nothing else: build.sh rewrites data/ from the new revision, and that generated diff is committed with it.

Tools

ToolArgumentsResult
compilesourceok, binary size and sha256, or the compile error {line, code, meaning, fix}
runsource, stdin, timeout_ms (1..30000, default 5000)compile result, capped stdout/stderr, and the exit: normal, trap (with its meaning), or the limit that stopped it (cpu_time, file_size, wall_clock, killed)
explain_errorquery: an error code 1..30, an omc: line N: error K line, trap T, or an exit status 101..114meaning, cause, fix, a minimal example and citations into omega-mv at the pin
lookupquery: a keyword or topic, or a substringthe entry (form, arity, types, result, example, citations), or up to 20 search hits

A compile diagnostic is a successful tool result (isError: false); isError is true when nothing could be run (sandbox failure, a refused compile stage) or when explain/lookup found no entry. Bad arguments are JSON-RPC errors (-32602).

Request limits (src/state.om): source and stdin at most 524288 bytes each after JSON decoding (maxsrc; over it is -32602), one request line at most 983040 bytes (maxline; over it is -32700), 16380 JSON tokens (the 65536-cell token tape, 4 cells a token after a 16-cell header) and 64 nesting levels a request. They exist only because the server's buffers have fixed sizes (the input line ib, 1572864 bytes; the decoded source and the reply share ob, 787472 bytes), declared in fn main as sized local arrays rather than run-time pools. They are listed as defects to lift, not protections; smoke.py prints how close its largest case comes to each.

Isolation

Each compile and run stage gets a fresh /tmp/omega-mcp-<16 hex> directory (mode 0700, removed after the reply) and runs under bwrap --unshare-all --clearenv. The sandbox sees only the compiler or the program (read-only), its in-sandbox reaper, the stage's own stdin file (/i, read-only) and stdout/stderr files (/o, /e), and a 16 MiB tmpfs working directory: no network, no other host files, an empty environment. The server sets the resource limits on the sandbox's pid 1 with the Omega prlimit host word (omega-mv keyword 235) before the sandbox starts, and it kills the whole sandbox at the wall clock. Since omega-mv #970, execprog closes every descriptor at or above 3, so bwrap gets its block, info and status pipes on fds 0..2 and the reaper opens the bound stage files onto fds 0..2 of the program; the program holds no other descriptor.

StageCPUAddress spaceFile sizeProcessesWall clock
run10 s256 MiB1 MiB5timeout_ms (default 5 s, max 30 s)
compile20 s512 MiB16 MiB420 s

Both stages also get 64 open files and no core dumps. --test-only-no-isolation turns all of this off and exists only so the trust gate can prove it detects an escape; never give it to an agent.

Build and use

OMEGA_SRC=/path/to/omega-mv ./build.sh      # any git clone of omega-mv that contains the PIN revision
build/omega-mcp                              # reads JSON-RPC on stdin; logs one line per request on stderr

The server loads data/reference.json and data/examples/ from beside its executable. Start-up exit codes: 2 bad arguments, 3 compiler not the pin, 4 data missing, 5 bwrap missing. build.sh exits 2 when the compiler or PIN disagree with the pin or the pin revision lacks a unit, and 1 when omc refuses a unit or when build/pincheck finds a tracked file that restates the pin or names a hash that is not derived from it (gates/pincheck.om lists what it reads). mcp.json is an example client configuration; point its command at your build/omega-mcp.

Install beside running servers

A running server re-executes its own executable file as the in-sandbox reaper of every compile and run, and finds its compiler and data beside that file. Putting a different file at the path a running server started from breaks that server's compile and run (observed 2026-11-11: "the sandbox ended without a status record"). Install only by adding a release:

OMEGA_SRC=/path/to/omega-mv ./build.sh
tools/install.sh PREFIX NAME     # adds PREFIX/releases/NAME/{omega-mcp,omc,data}, switches PREFIX/current
PREFIX/current/omega-mcp         # the path an MCP client should start
tools/releases.sh PREFIX         # retire alarm: live pids per release; RETIRABLE = no live process, not current

install.sh overwrites and removes nothing: it refuses (exit 2) a release name that exists, naming the live processes that run from it, a PREFIX/current that is not a symlink, and a build/omc that is not the pin. Rollback is mv -T PREFIX/current.rollback PREFIX/current. releases.sh never deletes; remove a release only after it lists that release as RETIRABLE. A server installed the old way, directly as PREFIX/omega-mcp, stays in place and is listed as legacy.

Which servers run from which release, and which client configurations still name the legacy path, is what tools/releases.sh prints; it is not recorded here. tools/releases.sh PREFIX CONFIG[=PENDING]... prints, for each configuration that still names the legacy path, legacy path still configured in FILE:LINE. The legacy files are retired only when that alarm shows no live process for them and no configuration naming them, and then by a manual rm by whoever sees it; nothing deletes them automatically.

Gates

export OMEGA_SRC=/path/to/omega-mv
ev=evidence/$(sed -n 's/^omega-mv //p' PIN | cut -c1-8); mkdir -p $ev    # results are filed per pin
python3 gates/smoke.py --out $ev/smoke-transcript.jsonl
python3 gates/trust.py --out $ev/trust-gate.json
python3 tools/check-reference.py --omega-src $OMEGA_SRC --omc build/omc --self-test
python3 gates/upgrade.py --out $ev/upgrade-gate.txt
sh gates/pincheck-cases.sh

pincheck-cases.sh checks build/pincheck itself: restating the revision or the omc sha256 of PIN is refused; with a fixture PIN whose revision and sha256 start with 8 digits, 8-, 12- and 16-character, upper-case and full restatements and another hash-like word are refused while dates, counts, near misses and the hex alphabet pass; and five mutants of the prefix comparison, compiled with build/omc, are each caught.

smoke.py also runs the pin case: a program with a 20-byte variable name and for i ulong n bound 8 must compile and run through tools/call (exit 10), the same loop past its bound must trap 4, and the older omc named in gates/fixtures/pin-case-refuser (read from $OMEGA_SRC with git show) must refuse the program with omc: line 3: error 13. The no-caps case is a unit with 20,000 text records and a main with 20,000 calls: it must compile and run through tools/call (stdout ok, exit 36), and the omc named in gates/fixtures/nocaps-case-refuser (8192 names in scope) must refuse it with omc: line 8193: error 14. Each evidence/<first 8 of the revision>/ holds the results at that pin; the files directly under evidence/ are an older record. Evidence is never edited.

trust.py sends, through the run tool, a read of a canary under ~/.local/state, a fork bomb, an infinite loop and a 10 GiB write, and requires each to be refused or killed with no process left behind. A second server started with --test-only-no-isolation runs bounded versions of the same attacks and must see them succeed, so a gate that cannot see an escape fails. check-reference.py re-derives every keyword, error and trap entry from the pinned source, compiles and runs every example with the pinned omc, and runs three negative controls. tools/gen-reference.py writes that data from the source at the pin: it finds every cited quote by its text and writes the line numbers itself, and stops when a quote is missing or occurs more than once.

These gates are host evidence on Linux arm64 (bubblewrap 0.9.0, util-linux 2.39.3); they say nothing about other kernels or about a sandbox configuration other than the one in src/sandbox.om. upgrade.py installs two releases with tools/install.sh under live servers and requires every server to keep compiling, refusals where the procedure must refuse, and the retire alarm to follow the live processes; its negative control replaces a running server's executable in place and must break it.

There is no hosted CI. Run the gates above on Linux arm64 in a fresh rad clone of this repository with OMEGA_SRC set to a clone of omega-mv at the pin, after ./build.sh; each gate exits 0 on PASS.

Agent-file maintenance MCP

sh build.sh also builds a separate native executable from maintenance/UNITS with the same pinned compiler: build/agent-maintenance-mcp --root /absolute/canonical/agent-directory. It exposes inventory, read_file, validate, propose, apply and rollback. It never invokes a shell, a privileged updater, or the compiler sandbox.

Default mode is read/propose only. --allow-write permits replacement of existing files in an explicitly selected unprotected directory. /srv/aien-keep and its descendants always refuse writable mode. Protected installations use their existing operator-approved update procedure; this MCP does not bypass their lock.

Supported logical file IDs are RULES.md, WATCHDOG.yml, config.yml, and agents/<slug>.md. Slugs contain lowercase ASCII letters, digits, underscores and hyphens, start with a letter or digit, and have at most 64 bytes. Files are held in fixed buffers of ammax bytes (maintenance/state.om, 65536 today: Omega has no heap yet, so they cannot be sized from the file); a larger file or request is refused, never cut. The gate's size alarm fails when a real agent file passes three quarters of that. Absolute paths, traversal, symlinks, executable files, hardlinks and nonregular files refuse. The root and every traversed directory are descriptor-pinned. Linux procfs is required for privilege/capability checks.

propose takes file, complete replacement content, and expected_sha256. Its structured result contains exact before/after content and hashes. Review this full replacement, including any removed settings, before invoking apply with the returned proposal_id. A new proposal invalidates the old proposal and rollback token, even when the new proposal refuses. Tokens and recovery bytes are connection-scoped; retain the before-content preview for recovery after disconnect. No file creation or deletion is exposed.

Validation is structural, not a full OMP schema or policy audit. Existing YAML is readable. Proposed settings/rosters must be JSON objects, which are valid YAML. Proposed agent definitions use a JSON object between --- frontmatter delimiters, with matching name, nonempty description and valid optional model/effort fields. Unknown model availability, credentials, effective policy and runtime compatibility are not verified. Non-JSON YAML proposals refuse rather than claiming validation. Saving a file does not prove the active CLI has reloaded it.

Apply and rollback serialize cooperating writers, reread the expected bytes under the lock, stage and sync a replacement, recheck the target and rename atomically. Rollback restores the captured original bytes, including legacy YAML. An intervening edit refuses instead of being overwritten. Rename is the commit point: a later sync error reports committed state with uncertain durability, not an unchanged failure. These checks do not serialize nonparticipating writers or isolate hostile same-UID processes. Bind-mount aliases require trusted operator configuration. Crash-left lock/stage files require operator recovery; the MCP does not remove others' locks. Content and basic permissions are preserved; this is not an ACL/xattr backup system.

Run sh gates/maintenance-cases.sh [/absolute/agent-directory] after sh build.sh. It compiles a mutant with the default read-only guard removed and runs gates/maintenance.py with it as the negative control: the oracle requires an actual fixture write by the mutant and failure of the normal read-only check. With a directory it also reads the real files (inventory and read only, never --allow-write) and runs the size alarm. All mutation scenarios use disposable fixture directories. Never register a mutant in a CLI.

Agent Q&A MCP

Shared questions and answers for coding agents: a place where an agent that hits an error can look for a fix another agent already proved, and, if its person allows it, leave what it learned. sh build.sh builds `build/agent-qa-mcp --store /absolute/store-directory --agent NAME [--consent /absolute/consent-file]`.

Not built yet: sharing between machines. The store is designed to be copied between machines over the private network, whose trust layer is omnet's Tailnet Lock work; no transport is in this repository.

Registering both servers in the locked agent files (Drake, 2026-11-15) is sh tools/register-locked.sh --keep /srv/aien-keep --prefix PREFIX/current after tools/install.sh has put the two binaries in that release. The command stages the new JSON outside the lock and installs it only with aien-keep update, which keeps the previous copy. It writes home/.omp/agent/mcp.json, and home/.claude.json and home/.claude/settings.json when those already exist. The question store and the empty consent file are created under $HOME, outside the lock. Sharing stays off until the person adds allow omp or allow claude to the consent file. sh gates/register-cases.sh proves the previous copy restores and that a direct write is refused.

Run sh gates/qa-cases.sh after sh build.sh: gates/qa.py (protocol, consent, privacy, entries, damage, paging) must pass on the server and fail on three mutants compiled with the pinned omc (consent line not needed, privacy filter skipped, hash check skipped).

Layout

License: Apache-2.0 (see LICENSE and NOTICE).

Human-Directed Agentic Engineering

Development follows Human-Directed Agentic Engineering (HDAE): humans define goals, architecture, constraints, acceptance criteria, and stopping points; agents implement, execute checks, diagnose failures, and revise within those boundaries. Human review retains responsibility for claims, acceptance, and release decisions. This describes the development method, not a change to runtime autonomy or historical evidence.

For the documented method and a systems-software case study, see Gregory M. Kurtzer (2026), *Ginux: Building an Independent Kernel That Runs Linux Userspace through Human-Directed Agentic Engineering*, technical report, v1, Zenodo, https://doi.org/10.5281/zenodo.23682548.