interplane.Get Omega
Read in your language

mailhand

mailhand: agents look after a person's email in seeded Omega. Maildir + MIME parsing, JSONL CLI and MCP, rule triage, policy-gated sending, hash-chained audit. Free (Apache-2.0).

Brought by drakestapleton

branch main Branches Tags History

mailhand / tests / scenarios

cd5ef74 PIN (omega-mv 3537baad... via PIN only) read by build.sh and the gate, gate pincheck over git ls-files; omtls by one commit in DEPS (tools/deps.om as build/depsgen, = fixture lines), unit lists @omtls/@omtlssrv generated into build/gen, stubs removed; core sc renamed scell (clashed with an omtls local); real TLS 1.3 in 60-imap/70-smtp-tls with refused handshakes (wrong host, expired, untrusted root) and roots_missing; mutants m-roots-imap m-roots-smtp m-tls-connect Drake Stapleton committed 2026-11-11
..
00-setup.txt360
10-maildir.txt5858
20-mime.txt5514
30-send.txt12319
40-mcp.txt9589
50-robust.txt1960
55-creds.txt3545
60-imap.txt20056
70-smtp-tls.txt11038
README.md4571

README.md

Scenario language

The gate runs every *.txt file in this directory, in byte order. Each scenario gets a fresh directory at build/gate/s/NAME.txt.

Build the gate: OMC=../omc ./build.sh tests/GATE_UNITS build/gate-bin. Run it from the repository root: build/gate-bin ../omc [SCENARIO-DIR [MUTANTS-FILE]].

Syntax

  • Each non-blank line is one step. A line starting with # is a comment.
  • Fields are separated by spaces or tabs.
  • In arguments:
    • @S expands to the absolute scenario directory.
    • @B expands to the absolute build/gate directory.
    • @R expands to the repository root.
  • Paths are relative to the gate's current directory, which is the repository root. Use @S/... for files in the scenario directory.

Setup steps

  • mkdir PATH creates PATH and any missing parents.
  • copy SRC DST copies a regular file or a directory tree. Symlinks are copied as symlinks.
  • write PATH TEXT and append PATH TEXT write the rest of the line. Only these two steps decode the escapes \n, \r, \t and \\.
  • symlink TARGET LINK creates LINK pointing at TARGET.
  • flip PATH OFFSET XORs the byte at OFFSET with 1.
  • gen KIND PATH ARGS... compiles tests/units/KIND.txt into build/gate/gen-KIND, then runs it as gen-KIND ARGS... PATH. The generator must exit 0.

Running programs

  • run EXIT STDIN -- PROGRAM ARGS... runs one program. STDIN is - (meaning /dev/null) or a file. PROGRAM is:
    • mh: the gate-built mailhand;
    • sink: the gate-built sink;
    • srv: the gate-built fake mail servers and helpers from tests/srv/UNITS (srv imap DIR, srv smtp DIR SCRIPT COUNT, srv acct OUT DIR NAME KIND HOST USER PASS MODE, srv big OUT N; see the notes in tests/srv/*.om). Each server picks a random loopback port in 19000..19999 and writes it to DIR/port; srv acct waits for it and writes the accounts file;
    • any other path: run as given.
  • bg PROGRAM ARGS... starts one background process (stdin /dev/null); PROGRAM as for run.
  • wait EXIT reaps the background process, then copies its stdout and stderr into place as the "last run" for the checks below.

Checks on the last run

  • out-eq FILE: stdout equals FILE byte for byte.
  • out-has TEXT / out-not TEXT: stdout contains / does not contain TEXT.
  • out-lines N: stdout has exactly N newline bytes.
  • err-has TEXT / err-not TEXT: stderr contains / does not contain TEXT.
  • out-sha256 HEX: SHA-256 of stdout, in lowercase hex, equals HEX.
  • max-ns N: an alarm, not a limit. Fails when the last run's wall time, measured with monons from spawn to reap, is above N; the process is never killed early.

File checks

  • file-eq PATH FILE: PATH equals FILE byte for byte.
  • file-has PATH TEXT / file-not PATH TEXT: PATH contains / does not contain TEXT.
  • exists PATH / absent PATH: PATH exists / does not exist, without following a final symlink.
  • tree-not DIR TEXT: no regular file under DIR (walked without following symlinks) contains TEXT; a hit prints tree-not hit: PATH. The credential leak scans use it.

Failures and limits

  • A run fails when its exit status differs from EXIT. A signal, or an exit status in the trap range 101..114, is always a failure.
  • Each child process has 120 seconds; each compile has 300.
  • Fixed host boundaries:
    • execprog packets: at most 1024 arguments and 65536 bytes;
    • each argument: 131072 bytes (MAX_ARG_STRLEN);
    • paths: 4096 bytes (PATH_MAX);
    • two-path link packets: 4096 bytes.
  • Scenario files, file contents, the directory stack and the list of names are all held in stores, so they have no size limit.

Robustness

  • rob FILE feeds mh parse many damaged copies of FILE on stdin, one run per copy. Each copy is written fresh to @S/rob.in. The copies are:
    • FILE cut at 64 evenly spaced lengths k*(n-1)/63 for k = 0..63, which includes 0 and n-1;
    • FILE with each of 256 evenly spaced bytes k*n/256 (k = 0..255) xored with 0xff;
    • for every 4th of those positions (k rem 4 = 3), a second copy with that byte set to 0x00.
  • Each run must exit 0, or exit 4 with stdout being exactly one LF-terminated JSONL line that contains "refused". A trap (101..114), a signal, the 120 s limit or any other exit fails the step.
  • Every failing input is printed as ROB FAIL FILE cut|xor|zero POSITION exit STATUS.
  • After the step, the gate prints rob FILE runs=N ok=A refused=B. Before its final line it prints the totals as MHGATE rob runs=R ok=A refused=B.
  • In mutant runs, the gate stops at the first failure.