# Development $ cmake -B build -DCMAKE_BUILD_TYPE=Debug $ cmake --build build $ ctest --test-dir build -j8 The suites: - `unit`: the core on a platform layer with an in-memory file system and a fake clock (`src/main_test.cpp`). - `selftest`: `prospero --selftest`, the real platform layer: threads, the file system, and processes. On macOS, `selftest_disclaimed` runs it again as its own responsible process, as an app runs. - `scenarios`: the engine end to end against a fault-injecting fake provider (`tests/fake_provider.py`), and for the desktop tool, a fake helper (`tests/fake_desktop.py`). On Linux with Xvfb, the real X11 helper too, on displays of their own (`tests/xprobe.py`), under each window manager installed of openbox, xfwm4, metacity, kwin_x11, icewm and fluxbox (`desktop_x11_wms`; with zenity, a GTK dialog too). - `cleanup`: the harness killed hard while its tools run, which must leave no process behind. - `remote`, `includes`, `deploy`: hosts and their clients, URL includes against a fake web server, and deploying through a fake ssh and scp. - `desktop_unit`, `desktop` (macOS): the desktop helper's own layer (`src/test/desktop_macos_test.cpp`), and the helper itself, its commands and frames, with its permissions treated as missing, so that nothing touches the screen. `tests/desktop_live_macos.py` drives TextEdit for real, under supervision; its header says how, and `tests/desktop_live_wayland.py` drives GNOME Text Editor or Kate on a Wayland desktop. On Linux, the `desktop_x11` scenarios also run the helper as if under Wayland, against no session bus and against a `dbus-daemon` of their own. - `bundle` (macOS): Prospero.app's bundle identifier and signatures, never the real app's in a build without a signing identity. - `sectrust` (macOS): the system's trust in https servers, through the HTTP layer (`src/main_edgetest.cpp`), with certificates that openssl makes for the test and that are never installed. With `--net`, real servers too, badssl.com's bad ones among them. - `arenalint`: the sources, for one arena given to a call both as the place for its results and, by value, as its scratch (`f(&a, a)`), and for a Buf left bound to a local arena (`tests/arenalint.py`). Debug builds, and `unit` always, check arenas for aliasing as they run (`src/arenacheck.cpp`; `-DPROSPERO_ARENACHECK=OFF` to leave it out): an arena allocating again over bytes another one allocated over while it held them, a copy allocating over what a live copy of the same arena holds, or an allocation through an arena already destroyed. Each is reported on stderr as an "arena fault", with where the arenas were made, and traps; the suites fail on one. Where the toolchain has AddressSanitizer (not Windows, nor a static build), Debug builds also run under it (`-DPROSPERO_ASAN=OFF` to leave it out), and arena memory that no live arena holds is poisoned: a region's fresh space, a copy's allocations once the copy ends, and what a restore gives back. ASan then reports a read of results left in a callee's scratch, or of anything after its arena moved on. The Python suites need [uv][]. They also run against other machines from this one: `--host` runs Prospero on a Windows host over ssh, `--xp` on Windows XP, and `--ssh` connects and deploys to a real remote host. `tests/gui.py` drives the GUI through a scripted checklist, which fails on a stale frame, and `tests/imports.py` checks a headless Windows engine's imports, its desktop helper's among them, against what XP exports (CTest runs it in those builds). The scenario `desktop_xp`, run by name with `--xp` and `PROSPERO_TEST_XP_DESKTOP=1`, drives Notepad on XP's desktop with the real helper. Each script's header says how to run it. `tools/showcase.py` makes the state behind the README's screenshot: a small C project and four sessions, with subagents, a plan, a todo list and images, recorded against the fake provider. It then opens the GUI on that state, and with `--shot` saves the window as a PNG (`prospero gui --quit-after S --shot FILE`, SDL builds only): $ uv run tools/showcase.py --prospero build/Prospero.app --work ~/src/mandel build-showcase $ uv run tools/showcase.py --prospero build/Prospero.app build-showcase --open --shot docs/screenshot.png $ sips -Z 1440 docs/screenshot.png `--theme dark` takes the same shot in dark colors, as `docs/screenshot-dark.png`, which the itch.io page shows. ## bash (builtin) The shell `builtin` is libunabashed ([Building](building.md)), run in a process of its own for each command, as a host bash would be: the reaper's program on Linux and macOS, the program in the call's job on Windows. That process is `prospero` itself, which runs one command and exits with its status: prospero --bash [--root DIR] [--carry IN] [--state OUT] -c CMD The arguments after the options are bash's own (`-c CMD`, `-l`), with `$0` `bash`; `src/bashstate.cpp`'s head describes them all. `--root`, on Windows, is the directory of the Unix tools Prospero found for it (`ub_config.root`), whose install's `/`, fstab and profile the library then takes as its own. `--state OUT` is where a command that ended on its own (by `exit` or its end, not by a signal) leaves the directory it ended in, for the next: `out/STEM.state`, beside the command's output in the session's records, for foreground calls only. It is NUL-separated: a version line, `pwd` and `cwd` (logical and native), then, only once the library reports what a command itself exported, those exports, then `changed` and `end`; a file cut short or of another version reads as none. `--carry IN` names the file whose exports the command starts with. Its exports are those it started with, with the changes the library reports (`ub_exit.delta`, from unabashed 0.7.0) over them, and `changed` says whether there were any; the directory carries as the next command's working directory and `PWD`. By hand: $ build/prospero --bash --state st -c 'cd /tmp; exit 3'; echo $? 3 A build without the library prints that bash (builtin) is not in it, and exits 126, as does a run that fails to start (2 when out of memory); an option without its value exits 2. A Terminal tab of a session whose shell is bash (builtin) runs, on Linux and macOS, an interactive one on its terminal: prospero --bash --term [-l] with the hooks' `--init-file` after it, as for a bash tab. It carries nothing, so it takes no other option. It runs under `--reap-tty`, which makes it its terminal's session leader with its group in front, as the library's terminal mode (`UB_TERMINAL`, unabashed 0.8.0) requires; elsewhere it refuses to start and exits 2. It forwards every signal but SIGCHLD to the run plainly, as it comes. This is the library's first stage, `bash +m`: programs stay in its process group, `set -m` is refused, and a hang-up ends what it started but what ignores SIGHUP (`nohup`). Windows refuses `--term`: the GUI's executable has no console to give the library. Its programs share its group, so a tab is busy by the hooks' marks (from a C to its D), not by its foreground group, and without them (`[terminal] integration = false`) never. By hand, in a terminal of its own, on macOS and on Linux: $ script -q /dev/null build/prospero --bash --term $ script -q -c 'build/prospero --bash --term' /dev/null A command killed by a signal exits as its own bash would have, but for the signals that would dump core and leave a crash report naming `prospero`: QUIT, ILL, TRAP, ABRT, BUS, FPE, SEGV, SYS, XCPU, XFSZ, and EMT on macOS. For those it exits 128+n, as for a program killed by one, so `kill -ABRT $$` reads as exit code 134. On Windows every signal death exits 0xE0550000 plus 128+n, which Prospero reads back as signal n. A soft stop there is the named event `Local\prospero-stop-PID`, PID the host's own process ID, which the engine makes as it starts the host and sets to stop it, since a GUI build's host can't take CTRL_BREAK; the host sends TERM to the command and to every program it runs. On Linux and macOS a stop's TERM goes to the host, which passes it on the same way, since each program leads a session of its own. Either way, the library kills what its programs left running as soon as the command ends, so they get no stop grace of their own yet. On Linux and macOS, the host raises its soft limit on open files to 1024, or the hard limit if lower, when it is below 512, and the programs a command runs inherit that limit. In a Debug build on Linux other than x86-64, whose fibers switch with `swapcontext`, ASan warns on standard error, once for each command, that it doesn't fully support `swapcontext`; the warning lands in the command's output, and means nothing more. ## Evals `prospero eval` measures models on a suite of tasks: how often each passes, and what it took, so that a model's edit format and the harness's heuristics can be chosen from data. A suite is a directory of task files, `NAME.ini`, with settings for all of them in `suite.ini`: prompt = "Change wrold to world in greet.txt." fixture = base # copied as the working directory patch = typo.patch # a mutation, in the edit tool's patch format expect = base # these files, byte for byte, afterward check = sh "$PROSPERO_EVAL_SUITE/test.sh" # and exit 0 timeout = 600 # seconds, not counting the endpoint's queue steps = 100 # model requests at most tools = read edit grep glob `setup` runs a command before the agent starts, `prompt_file` reads the prompt from a file (a task's own `prompt` or `prompt_file` wins over `suite.ini`'s), `role` names a configured role, and `check_timeout` limits setup and check commands. Each run works on its own copy in a temporary directory, so no repository is ever touched: a fixture may hold a `.git` directory, but not a `.git` file (a worktree's or a submodule's), which would have the copy share another repository. The session is unattended, so asks are denied, gets the project's instruction files but not the user's own, and never moves to a fallback model; commands run without the variables that endpoints' keys come from. prospero eval -m MODEL,... [-e ENDPOINT] [-f FORMAT,...|all] [-n N] [-j N] [-t TASK,...] [-o FILE] [-c FILE] SUITE... prospero eval --report [-c FILE] FILE... Every model runs every task in each edit format, `-n` times, up to `-j` runs at once. A model is `MODEL` at the `-e` endpoint, or `ENDPOINT/MODEL` with a configured endpoint. Model requests wait their turn at each endpoint as any session's do (its `max_concurrent`, `max_models`, and a model's `max_concurrent`), and runs go model by model, so a llama.cpp router that keeps one model loaded swaps rarely. Each run appends a JSON line to the results file (`-o`, by default `eval.jsonl`): pass or fail and why, steps and tool calls, failed edits (alike in every format) and tool errors by kind (edit misses, invalid calls), guard denials, what the harness repaired, nudges, retries, tokens with cache reads, the run's own time and its time in the queue, and the diff it left. A run already in the file is skipped, so an eval stopped part way goes on where it stopped. A run that measured no model, because the model never answered (a key refused, an endpoint down), is recorded as an error and made again next time; after three such runs of a model in a row (or `-j`, if more), its runs not yet started are left out, and the eval exits 1. The summary, printed after the runs and by `--report`, is a table by model and format, the failed runs, and for each model the edit format to give it, with the numbers that decide it: formats are compared on the runs each made of the same tasks, task by task, and one is recommended only if it did better than every other beyond chance (sign tests, p < 0.05), on the pass rate, else failed edits, steps or tokens. Otherwise the model keeps its own. `tests/bench/editbench` is the edit-format benchmark as a suite: 40 one-line bugs in real code, to fix with the file tools alone. For a llama.cpp router on this machine, and a model at Anthropic: $ prospero eval -e http://localhost/ -m MODEL1,MODEL2 -f all -n 2 \ -o local.jsonl tests/bench/editbench $ prospero eval -m anthropic/claude-haiku-5-5 -f all -t t00-operator,t09-delete \ -o claude.jsonl tests/bench/editbench `tests/bench/starter` is six small agentic tasks (write a program, fix a failing test, rename across files, add a feature, answer from the code), each checked by a script, for tuning what small local models such as the built-in one are given: compare roles with a copy of the suite whose `suite.ini` adds `role = NAME`. `tests/pdfcorpus.py` builds a corpus of PDFs for testing PDF reading, from this machine's programs (TeX Live, Chrome, Quartz, Ghostscript, qpdf, tesseract), each skipped if missing: real producers' output, structural variants (object streams, LZW and other filters, an incremental update), damaged and hostile files, oddities of text (Type 3 fonts, ToUnicode, forms, invisible text) and images in every encoding. Its manifest says what each file is and what a reader should make of it; Poppler's reading of each is recorded beside. Its eval suite asks one question a task, answered through `read` alone: $ uv run tests/pdfcorpus.py build-pdfcorpus $ prospero eval -m MODEL -o pdf.jsonl build-pdfcorpus/eval The built-in PDF reader, which `read`, `web_fetch` and attachments use for models not sent PDFs as documents, runs alone too: `prospero --pdf FILE` prints a PDF's text as `read` would show it, with `--offset N` and `--limit N` for a window, `--all` for the whole text, and `--images DIR` to write the images that window shows, as a vision model would get them, with stats on standard error. `tests/pdfcheck.py` (CTest `pdfcorpus`, skipped when the corpus's programs are missing) builds the corpus and checks the reader's text and images against its manifest, known gaps listed in its XFAIL table: $ prospero --pdf report.pdf --offset 100 --limit 50 --images /tmp/imgs $ uv run tests/pdfcheck.py --prospero build/prospero The reader, its text encodings and its image decoding are fuzzed with AFL++, as the targets `FUZZ_PDF`, `FUZZ_PDFENC` and `FUZZ_PDFIMG` of `src/main_fuzz.cpp`, whose head gives the build and the seeds; the PDF target has a dictionary, `tests/pdffuzz.dict`: $ afl-clang-fast -O2 -g3 -fsanitize=address,undefined \ -fsanitize-trap=undefined -I build/_deps/wuffs-src \ -c -o wuffs.o src/wuffs.c $ afl-clang-fast++ -std=c++20 -fno-exceptions -fno-rtti -g3 \ -fsanitize=address,undefined -fsanitize-trap=undefined \ -DFUZZ_PDF -o fuzzpdf src/main_fuzz.cpp wuffs.o $ afl-fuzz -i i -o o -x tests/pdffuzz.dict ./fuzzpdf A crash too big for the fuzzer's 64 KiB inputs is triaged with `prospero --pdf`. [uv]: https://docs.astral.sh/uv/