Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/mailhand/blob/main/tests/scenarios/README.md # 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 Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `mailhand / tests / scenarios / README.md` 77 lines ยท 4571 bytes Raw Blame History Rendered 1 # Scenario language 2 3 The gate runs every `*.txt` file in this directory, in byte order. Each scenario gets a fresh directory at `build/gate/s/NAME.txt`. 4 5 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]]`. 6 7 ## Syntax 8 9 - Each non-blank line is one step. A line starting with `#` is a comment. 10 - Fields are separated by spaces or tabs. 11 - In arguments: 12 - `@S` expands to the absolute scenario directory. 13 - `@B` expands to the absolute `build/gate` directory. 14 - `@R` expands to the repository root. 15 - Paths are relative to the gate's current directory, which is the repository root. Use `@S/...` for files in the scenario directory. 16 17 ## Setup steps 18 19 - `mkdir PATH` creates PATH and any missing parents. 20 - `copy SRC DST` copies a regular file or a directory tree. Symlinks are copied as symlinks. 21 - `write PATH TEXT` and `append PATH TEXT` write the rest of the line. Only these two steps decode the escapes `\n`, `\r`, `\t` and `\\`. 22 - `symlink TARGET LINK` creates LINK pointing at TARGET. 23 - `flip PATH OFFSET` XORs the byte at OFFSET with 1. 24 - `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. 25 26 ## Running programs 27 28 - `run EXIT STDIN -- PROGRAM ARGS...` runs one program. `STDIN` is `-` (meaning `/dev/null`) or a file. `PROGRAM` is: 29 - `mh`: the gate-built mailhand; 30 - `sink`: the gate-built sink; 31 - `srv`: the gate-built fake mail servers and helpers from `tests/srv/UNITS` (`srv imap DIR`, 32 `srv smtp DIR SCRIPT COUNT`, `srv acct OUT DIR NAME KIND HOST USER PASS MODE`, `srv big OUT N`; 33 see the notes in `tests/srv/*.om`). Each server picks a random loopback port in 19000..19999 34 and writes it to DIR/port; `srv acct` waits for it and writes the accounts file; 35 - any other path: run as given. 36 - `bg PROGRAM ARGS...` starts one background process (stdin /dev/null); PROGRAM as for run. 37 - `wait EXIT` reaps the background process, then copies its stdout and stderr into place as the "last run" for the checks below. 38 39 ## Checks on the last run 40 41 - `out-eq FILE`: stdout equals FILE byte for byte. 42 - `out-has TEXT` / `out-not TEXT`: stdout contains / does not contain TEXT. 43 - `out-lines N`: stdout has exactly N newline bytes. 44 - `err-has TEXT` / `err-not TEXT`: stderr contains / does not contain TEXT. 45 - `out-sha256 HEX`: SHA-256 of stdout, in lowercase hex, equals HEX. 46 - `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. 47 48 ## File checks 49 50 - `file-eq PATH FILE`: PATH equals FILE byte for byte. 51 - `file-has PATH TEXT` / `file-not PATH TEXT`: PATH contains / does not contain TEXT. 52 - `exists PATH` / `absent PATH`: PATH exists / does not exist, without following a final symlink. 53 - `tree-not DIR TEXT`: no regular file under DIR (walked without following symlinks) contains TEXT; 54 a hit prints `tree-not hit: PATH`. The credential leak scans use it. 55 56 ## Failures and limits 57 58 - 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. 59 - Each child process has 120 seconds; each compile has 300. 60 - Fixed host boundaries: 61 - `execprog` packets: at most 1024 arguments and 65536 bytes; 62 - each argument: 131072 bytes (MAX_ARG_STRLEN); 63 - paths: 4096 bytes (PATH_MAX); 64 - two-path link packets: 4096 bytes. 65 - Scenario files, file contents, the directory stack and the list of names are all held in stores, so they have no size limit. 66 67 68 ## Robustness 69 70 - `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: 71 - FILE cut at 64 evenly spaced lengths `k*(n-1)/63` for k = 0..63, which includes 0 and n-1; 72 - FILE with each of 256 evenly spaced bytes `k*n/256` (k = 0..255) xored with 0xff; 73 - for every 4th of those positions (k rem 4 = 3), a second copy with that byte set to 0x00. 74 - 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. 75 - Every failing input is printed as `ROB FAIL FILE cut|xor|zero POSITION exit STATUS`. 76 - 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`. 77 - In mutant runs, the gate stops at the first failure.