Peios Learn
Documentation

Peios

Peios Peios Kernel Universal Directory Project

Developer Tools

Trail Acta Provium clackatoo CAF GCSL Pekit

Applications

Framewright

Standards and Conventions

Standards and Conventions Peios Specifications
clackatoo

Development

Single-page view · as markdown

Benchmarks

clackatoo / Development

clackatoo's goal is to be very fast and very light, so speed is measured, not assumed. There are two suites:

  • Emulator throughput feeds terminal output straight into clackatoo-term, the crate that turns output into a grid of cells, and into alacritty_terminal, the emulator inside Alacritty, so the two can be compared on the same machine.
  • End to end starts the real release binary and drives it the way a user would: it starts daemons, opens terminals and windows, types into them and floods them with output.

Both compare each run with the previous one, so a regression shows up as a number.

Run everything #

cargo bench

That builds in release mode and runs both suites, which takes a few minutes. To run one suite on its own:

cargo bench -p clackatoo-bench          # emulator throughput
cargo bench -p clackatoo --bench e2e    # end to end

Close anything busy first, such as builds, browsers playing video, or other benchmarks. A desktop's timings wander by a few percent anyway, with CPU frequency scaling and background load, and both suites treat changes under 5% as noise.

Workloads #

Both suites use the same workloads. They are generated in code from a fixed seed, so every run sees identical bytes and nothing large is committed. Each one leans on a different part of the emulator:

WorkloadStands for
asciiPlain text scrolling, like cat of a log. Lines vary in length, and some wrap.
highlightWords in 24-bit colors, some bold, like syntax-highlighted code.
denseA different style in every cell, redrawing the whole screen. The worst case for style handling.
regionScrolling inside a scroll region, the way pagers and editors scroll part of the screen.
unicodeWide CJK characters and emoji, combining accents, and emoji joined with ZWJ (zero width joiner).
cursorShort writes at random places, sometimes recolored, like a full-screen program redrawing.
vimA recorded vim session (open, edit, quit), repeated. Emulator suite only.

Generated workloads play in a 120x40 terminal, a typical window. The vim recording plays at the size it was recorded at.

Emulator throughput #

Each benchmark feeds a workload to one emulator in 64 KiB pieces, the size the daemon reads from a PTY at a time. The emulator is reused from one iteration to the next, so its 10,000-line scrollback is full and every new line pushes an old one out. That's the steady state of a terminal that has been open a while. Neither emulator does any I/O or drawing.

For each workload there are three results: clackatoo, clackatoo-eager, and alacritty. A flood never pauses, so by default clackatoo never compacts its scrollback during the benchmark, much as alacritty never does. clackatoo-eager compacts every line as it scrolls off, so the cost of compacting stays measured.

ascii/clackatoo         time:   [23.467 ms 23.522 ms 23.601 ms]
                        thrpt:  [84.745 MiB/s 85.029 MiB/s 85.228 MiB/s]
ascii/alacritty         time:   [15.675 ms 15.724 ms 15.780 ms]
                        thrpt:  [126.74 MiB/s 127.20 MiB/s 127.60 MiB/s]

thrpt is throughput: how much output the emulator gets through per second. The middle number is the best estimate, and the outer two bound it. The benchmarks use criterion, which also prints how each result changed since the last run.

Before benchmarking a workload, the suite plays it through both emulators and checks they end up showing the same screen. Otherwise the two wouldn't be doing the same work. One difference is expected: alacritty draws a ZWJ emoji sequence such as 👩‍💻 as two separate emoji, while clackatoo joins it into one, as kitty, WezTerm and Ghostty do. So on unicode, alacritty's lines wrap sooner, and the suite prints a note saying so. Any other difference prints a warning with both screens.

alacritty also records which lines changed as it goes, for its renderer. clackatoo doesn't do that, so the gap would narrow a little if it did.

End to end #

The harness runs as a bench target of the clackatoo package. That way, cargo always builds a fresh release binary before measuring it. Every daemon it starts gets a temporary runtime directory of its own, so it never touches a daemon you are using. It prints one table:

clackatoo end-to-end benchmarks
binary: /home/you/clackatoo/target/release/clackatoo
compared with baseline "base": commit d8c3b98, saved 2 hours ago

startup
  daemon start to accepting clients            677.2 µs  ±10.1%  -2.0% (noise)

Each line shows the median of several runs, then the spread: half the distance between the 10th and 90th percentiles, as a percentage of the median. The last column compares the result with the baseline.

What each group measures:

GroupMeasurementHow
sizeRelease binaryThe size of target/release/clackatoo.
startupDaemon start to accepting clientsFrom launching clackatoo daemon until a client can connect and say hello.
CLI commandclackatoo list, from launch to exit, against a running daemon.
New terminalFrom asking for a terminal until it's running.
New terminal to first textUntil your $SHELL shows any text, usually its prompt. Mostly the shell's own startup time.
latencyKeypress to echo in the gridA program that echoes keys runs in a terminal. One key is sent, and the time is measured until a screen capture shows the echoed key.
Screen capture round tripOne screen capture request and response.
Keypress to view updateThe same, following the terminal's view as the window does: timed until the update showing the echo arrives. This is the part of keypress-to-screen latency the daemon owns.
Keypress to view update, while another floodsThe same while a second terminal prints without end, which must not hold up the one being typed in.
Keypress to view update, through the bridgeThe same through clackatoo bridge, as --remote connects, over QUIC, but with no ssh or network in between: what the bridge and QUIC add.
Keypress to view update, through the bridge, while a followed terminal floodsThe same while a second terminal the client follows prints without end, so its updates share the connection with the echoes. The harness acknowledges each of the flood's updates at once, so this median also carries one flood update per key; a window acknowledges once a frame.
throughputEach workloadA script prints 16 MiB of the workload into a terminal. Timed from starting it until the daemon has processed everything.
Bare PTYThe same script, read straight from a PTY and thrown away. This is the most any terminal could manage on this machine.
cpuDaemon CPU per MiBFor each throughput workload, the CPU time the daemon spent per MiB of output, read to the nanosecond from /proc, in the same runs as throughput, which is the group to name for it. Throughput stops at the PTY's limit, so this is where the daemon's own speed shows.
Bare PTY reader per MiBThe CPU time the bare PTY reader spends per MiB: the floor, nearly all of it in the kernel's TTY layer.
memoryDaemon at restThe daemon's resident memory with no terminals.
Per terminalThe growth from opening 20 empty terminals, divided by 20. The programs running in them aren't counted.
Per scrollback lineThe growth from filling an 80-column terminal's scrollback with full lines, the worst case, divided by the number of lines. Measured once the daemon has compacted the scrollback, 300 ms after the output ends.
Per scrollback line, before compactionThe same, measured as soon as the output ends.
Per scrollback line, typicalThe same as the first, with lines of varying length, averaging half the width.
idleWakeupsHow often the daemon wakes up per second, with a client connected and three quiet terminals, one of which printed some history before going quiet. This should be zero. It is counted from the context switches in /proc.
gateKeypress to view update (cat), median and 99th percentileThe keystroke gate's first measurement: rounds of 1,000 keys typed into cat, each round on a new daemon, a pause apart. Each line gives the median of the rounds' medians, or of their 99th percentiles.
A terminal's frame built, median and 99th percentileIts second: how long the window takes to turn a 120x40 screen of coloured text into the rectangles and glyphs it draws, in rounds of 1,000 frames, typing changing the screen between them. Without a GPU, it's skipped.
windowStart to first frameFrom starting clackatoo to the window's first frame, in a process of its own (CLACKATOO_WINDOW_HOST=off), with the daemon already running. Most of it is the GPU driver starting up.
Start to first frame, first window of a process of windowsFrom starting clackatoo to the first frame of the first window, as by default: it forks the process of windows, which sets up the GPU and opens it. The process is ended after each.
Start to first frame, another windowFrom starting clackatoo to the first frame of a window it hands to the process of windows with a window open already, which opens it on the GPU it set up then, as the process's log says.
Frame drawn, during a floodHow long the window takes over each frame, from starting on it to handing it to the compositor, while its terminal prints for two seconds without stopping.
Wakeups of the window's own threadsHow often the window wakes up per second with nothing to draw. This should be zero.
Wakeups, the GPU driver's threads tooThe same, counting threads the GPU driver started inside the window. Some drivers wake up on their own: NVIDIA's Vulkan driver about 110 times a second, even with no window at all.

Most groups learn that a terminal has caught up by polling it. Throughput runs watch the terminal's title, which the script sets when it finishes, every 200 µs. The first keypress test captures the screen back to back, so its result includes up to one capture round trip on top of the true latency; the view-update tests don't poll.

The window group opens real windows, so it needs a display. Without one (no WAYLAND_DISPLAY or DISPLAY), it says so and is skipped. The windows open on the harness's own daemons, never on yours. The window logs its first frame, and how long each frame took when started with RUST_LOG=clackatoo_gui::frame=trace; the harness reads those from its output.

To run some groups only, name them:

cargo bench -p clackatoo --bench e2e -- startup memory

To measure a different build, such as another branch's, point the harness at its binary:

cargo bench -p clackatoo --bench e2e -- --binary ../other/target/release/clackatoo

Compare changes #

Both suites work like criterion's baselines:

  • By default, each run is compared with the previous run and replaces it.
  • --save-baseline NAME compares with the baseline called NAME and replaces it.
  • --baseline NAME compares with NAME without saving anything.

To measure a change, save a baseline before making it, then compare against it afterward:

cargo bench -- --save-baseline before
# … make the change …
cargo bench -- --baseline before

A change counts when it is bigger than 5% and outside both runs' spreads. Otherwise it's marked (noise). Measurements that don't vary, like the binary's size, report any change.

Criterion keeps its baselines in target/criterion/. The end-to-end harness keeps its own in target/clackatoo-bench/ as tab-separated files, along with the commit they were measured on.

The keystroke gate #

Typing must never get slower. The keystroke gate measures the two things between a key and the screen that clackatoo's own code decides, and checks them against a baseline kept in the repository, crates/bench/gate.tsv:

  • Key to echo: a key typed into cat in a terminal, through the daemon, until the view update showing it arrives, as a window follows it.
  • Frame built: the window turning a screen of text into what it draws.

scripts/release runs it before making a release, and stops if it fails:

CARGO_INCREMENTAL=0 cargo bench --profile gate -p clackatoo --bench e2e -- --gate

It's built with the gate profile, into target/gate/: an optimised build without whole-program optimisation, as quick is, so it's quicker to build than a release, and it leaves the release build in target/release/, which may be the one you're running, alone. Unlike quick, it's never built incrementally. An incremental build inlines far less from one part of a crate into another, and the same code built that way took up to 1.6 times as long to build a frame, which would fail the gate with nothing changed. So the baseline must be measured with the same profile, and --gate and --update-gate refuse to run built with any other. Cargo's CARGO_INCREMENTAL variable overrides any profile, so the commands here set it to 0.

How it keeps from crying wolf #

A desktop running other work makes timings slower, never faster: another program takes the CPU, or the other half of its core, and caches go cold. On a desktop busy with builds, a few hundred milliseconds of measuring can come out two to four times slower than the same a few seconds later, and a busy spell can last minutes. So:

  • Each measurement is taken in rounds, 15 to a batch, half a second apart, each with a daemon, and a renderer, of its own. The gate compares the least of the rounds, the moment the machine let it alone, for each round's median and its 99th percentile, the slowest key in a hundred.
  • Each round also times a yardstick: hashing 16 KiB, work on the CPU that's none of clackatoo's. While even its least round takes over 10% longer than the baseline's, the machine is busier than when the baseline was made, and the gate judges nothing.
  • If anything comes out slower than allowed, or the gate can't judge, it takes another batch, up to three, the least of all their rounds counting. A busy spell passes; a real slowdown doesn't.
  • The least round's median may take up to 25% longer than the baseline's, and its 99th percentile up to 50%.

Those margins come from runs on a desktop with six cores (a Ryzen 5 7600X) running other builds, at load averages of 6 to 42. While the yardstick held, the least of a batch nearly always stayed within 10% of the baseline for medians and 40% for 99th percentiles; one batch in about twenty came out slower than allowed, and the next batch put it right. While the yardstick didn't hold, the echo came out up to 2 times slower, and its 99th percentile 4 times. Of ten checks at load averages of 16 to 42, eight passed and two couldn't judge; none said anything was slower. The task CLACKA-241 has the numbers.

If it fails, it says either what took longer than allowed, or that the machine stayed too busy to judge, with its load. When it's too busy, run it again once the machine is quieter. When something took longer, the change made typing slower.

GitHub's runners #

CI runs the gate group on each push to main, but only to record its numbers: a runner's machine differs from one run to the next, so its numbers can't be checked against a baseline measured on another machine. Read them in the keystrokes job's log.

A new baseline #

When a change is meant to cost something, or the baseline is measured on a new machine, make a new one, and commit it with the change and the reason. Make it as releases are made: on the same machine, with what usually runs beside a release running. The least of many rounds finds the machine's quiet moments even while it's busy, but conditions count both ways: some batches at the busiest times had keys come back faster (25 µs, against 31 µs at quieter ones), so a check on a machine with nothing else running may come out slower than a baseline made on a busy one.

CARGO_INCREMENTAL=0 cargo bench --profile gate -p clackatoo --bench e2e -- --update-gate

That takes all three batches, about half a minute, and writes them to crates/bench/gate.tsv, with the commit it was measured on; the gate reads the least round of each. The baseline is only meaningful on the machine releases are made on.

Profile a workload #

To see where the time goes, replay one workload through the emulator in a loop and point a profiler at it:

cargo run --release -p clackatoo-bench --example replay -- dense 20

That plays dense for 20 seconds and prints its throughput. Release builds use link-time optimization, so build with CARGO_PROFILE_RELEASE_DEBUG=true to get the function names back in a profiler.

Pane status and focus #

The manual pane_status_and_focus_timing test measures the desk's status composition and focus changes for terminals, chats, editors, explorers, boards, reviews and browsers, without a GPU or daemon:

CARGO_PROFILE_DEV_DEBUG=line-tables-only CARGO_INCREMENTAL=0 cargo test -p clackatoo-gui --lib pane_status_and_focus_timing --locked -- --ignored --nocapture

It reports the median of seven batches for each operation. Compare the same harness and build profile on both revisions, with other builds finished. The default test profile is unoptimized: these numbers help find changes in dispatch cost, but do not measure release frame latency. There is no timing assertion because a shared machine's load varies.

The ignored pane_input_dispatch_timing test measures text-target lookup, pending-key lookup and one wheel event together for the same pane kinds:

CARGO_PROFILE_DEV_DEBUG=line-tables-only CARGO_INCREMENTAL=0 cargo test -p clackatoo-gui --lib pane_input_dispatch_timing --locked -- --ignored --nocapture

Each sample is a batch of 10,000 routing sequences; the report takes the median of seven batches. The same build-profile and idle-machine rules apply. This measures routing, not rendering or a populated pane's scrolling throughput.

List input #

Explorer, Board and Review use vim::list::ListPane for key parsing, movement and paging, search routing and leaving a pane. Their own actions and prompts enter through hooks; Explorer also keeps its tree flattened before and after each stroke. The trait is statically dispatched.

The three ignored list_input_timing tests exercise navigation and search through each real pane, without drawing or daemon I/O:

CARGO_PROFILE_DEV_DEBUG=line-tables-only CARGO_INCREMENTAL=0 cargo test -p clackatoo-gui --lib list_input_timing --locked -- --ignored --nocapture --test-threads=1

Each reports nanoseconds per stroke, taking the median of seven batches: 10,000 navigation sequences or 100 search sequences, whose pattern compilation is much more expensive in an unoptimized build. The search query matches entries in the board and explorer; the review fixture exercises a missing query. Compare identical harnesses and build profiles, with compilation finished. These default unoptimized test timings compare dispatch cost, not release input latency.

Looking at the Window

clackatoo / Development

The look example runs the real window, drawn into a picture instead of onto the screen, against a daemon of its own in a temporary home, so it never touches yours.

cargo build -p clackatoo-daemon --example fake_agent --example fake_language_server --example daemon
cargo run -p clackatoo-gui --example look -- crates/gui/looks/*.look target/looks

A script has a command a line: size 1400x860, scale 2, file PATH, keys :Explore<CR>, type, shell, click X Y, drag, scroll, wait-for TEXT, sleep MS, shot NAME. Chats talk to a fake agent, and .fk files have a fake language server. The full language is at the top of crates/gui/examples/look.rs, and crates/gui/looks/ has a script for each of the window's main parts.

Each shot waits until nothing changes and no timer is due, then writes NAME.png. LOOK_LOG=info shows what the window and its daemon log. timings.txt says, for each key or click, how long the window took to show its first change and its last. Those are a debug build's drawing plus reading the picture back, so they're for comparing one step with another, not the window's real latency; --profile quick comes nearer a release build.

Everything but the surface is the window's own: its layout, fonts, and renderer. The interface font follows this machine's desktop settings, so shots match from run to run on one machine, not across machines.

Tracing Agents

clackatoo / Development

A chat talks to its agent through the agent's adapter, a program speaking the Agent Client Protocol (ACP): JSON-RPC messages, one a line, over the adapter's stdin and stdout. When a chat does something you didn't expect, the messages show whether the agent said it or clackatoo made it so.

Turning a trace on #

Start the daemon with CLACKATOO_ACP_TRACE set to a directory:

CLACKATOO_ACP_TRACE=~/acp-traces clackatoo daemon

Every agent the daemon starts from then on writes to a new file of its own there, named for the agent and the adapter's process ID, as claude-12345.log. A chat whose agent stops and starts again gets a new file. A file is never added to: if the name is taken, as when a process ID comes round again, the trace goes to claude-12345.log.2, .3 and so on.

The directory is made if it isn't there, readable by you only, and each file is readable by you only. A directory of your own that others can read, as one made 0755, is fine: they can see the files' names, not what's in them. The daemon traces nowhere if the directory isn't yours, if anyone else can write in it, or if it's a symbolic link, and the log says why. Files are made in it directly, never through a link.

Each line is one message or one line the adapter wrote to stderr:

2026-10-28T22:08:42.021Z agent claude[12345] -> {"jsonrpc":"2.0","id":0,"method":"initialize",...}

The time is in UTC. -> is what clackatoo sent, <- what the adapter sent, and !! a line of its stderr.

What's left out #

A trace is meant to be shareable, so obvious secrets are replaced by [redacted]:

  • the string values of fields named for keys, tokens, passwords, secrets, cookies and credentials, told by the words in their names (api_key, refreshToken); a token to go on from, as nextPageToken, stays, as do tokenizer and counts like inputTokens;
  • every value of a Model Context Protocol (MCP) server's environment and headers (their names stay);
  • bearer tokens, and API keys by their prefixes, such as sk-, ghp_ and xoxb-, wherever they start a word, as in OPENAI_API_KEY=sk-…;
  • the values of names for secrets given one in text: GITHUB_TOKEN=…, ?token=…, api_key: …, "password": "…", and Authorization: Basic …, whose scheme, Basic, Bearer, Digest, Token or Negotiate, stays.

API keys known by their prefixes are Anthropic's and OpenAI's (sk-), GitHub's (ghp_, gho_, ghs_, ghu_, github_pat_), GitLab's (glpat-), Slack's (xoxb-, xoxp-), AWS's access keys (AKIA) and Google's API keys (AIza).

This is a safety net, not a guarantee: files' text and your messages are in a trace as they were sent, so read one before you share it.

A message over 1 MiB, such as an edit to a big file, whose diff carries the whole file, is traced as its first 64 KiB and its length. Smaller ones are checked for secrets as they pass, which costs the daemon a little time on each, so leave the trace off when you aren't using it.

How big it gets #

Past 16 MiB, a trace file is set aside as ….log.1, replacing the one set aside before, and a new one begun. So each agent keeps at most about 32 MiB, however long the daemon runs with the trace on. Old files aren't deleted: clear the directory when you're done.

Tests with real agents #

The daemon's tests named a_real_… talk to a real Claude Code or Codex. Each is ignored unless asked for, uses the cheapest model, and traces to $TMPDIR/acp-NAME:

cargo build --workspace --examples
cd crates/daemon
CLACKATOO_DISPLAY=off cargo test --test daemon a_real_session_of_six_turns -- --ignored --nocapture

Run them one at a time. They use the accounts claude and codex are signed in to. Most run the adapter the daemon would run, unless CLACKATOO_REAL_AGENT (Claude Code) or CLACKATOO_REAL_CODEX (Codex) gives a command, and with none say they were skipped and pass; a few older ones need CLACKATOO_REAL_AGENT.

Fuzzing

clackatoo / Development

A fuzzer runs a piece of code over and over with input it makes up, keeping the inputs that reach code it hadn't reached before, until something panics, takes too long or uses too much memory. clackatoo's fuzz targets are in fuzz/ at the top of the repository. They run with cargo-fuzz, which drives LLVM's libFuzzer and needs a nightly Rust.

What's fuzzed #

TargetWhat it readsWhat it checks, beyond never panicking
parserwhat a program writes to its terminalthe parser reports what vte, its oracle, reports, however the bytes are cut
terminalthe same, onto the whole emulator, with resizes, searches and scrollbacka snapshot, as an upgrade hands it over, makes the same terminal again
framesprotocol frames, at every version the compatibility window holdsa message read is encoded at that version to what reads back the same; what relays read without decoding agrees with decoding
transformedits made at once to one texteach made after the other, transformed, gives one text; compose, invert, and coarsen agree with making the edits
historyseveral authors editing, undoing, and sending late editsevery edit the history gives fits the text; bringing an edit up to date keeps to its budget
handovera handover file of any version, from any bytesit's read or refused, and what's read is made into workspaces, screens, buffers and chats
workspacesthe saved workspaces filewhat's read writes back the same
agents_tomlan old agents.toml, moved into the daemon's Luau config as the first build with it moves onewhat it's moved to runs, and its limits on subagents stay in their ranges
json_rpcwhat agents and language servers write, framed either wayread in pieces, or handed over midway, the messages are the same as read whole; the walkers keep to their caps
imageswhat programs, agents and files send as an imageits header is read or refused; what's kept is of a size that may be; a small one decodes without panicking

Code a target can't reach otherwise is reached through a fuzzing feature of clackatoo-term and clackatoo-daemon. The feature is only for the fuzzer. client/startup.toml is read by the clackatoo program itself, which nothing can link to, so property tests in its config.rs check it instead.

Running a target #

Install the nightly toolchain and cargo-fuzz once:

rustup toolchain install nightly --component rust-src
cargo install cargo-fuzz

Then, in fuzz/, fill the corpus with seeds from the repository's fixtures, and run a target:

./seed
cargo +nightly fuzz run frames corpus/frames -- -max_total_time=1800 -timeout=5 -rss_limit_mb=1024 -malloc_limit_mb=512 -max_len=65536

The first build takes a while: it builds the daemon and everything it uses, with AddressSanitizer. --codegen-units 16 after run builds faster, and the targets run a little slower.

  • -timeout=5 treats an input that takes over 5 seconds as a failure. Most of these readers run on the daemon's loop, where that is a bug.
  • -malloc_limit_mb treats a single allocation that big as a failure. That's how a reader that allocates far more than it was sent is caught.
  • -fork=2 -ignore_crashes=1 runs two processes and keeps going after a failure, saving each one. Leave a core or two free for the rest of the machine.

The fuzz targets are a workspace of their own, so builds and tests of the rest never build them. CI only checks that they still compile, on the nightly its fuzz job pins, so a change to what they reach inside the crates can't leave them broken. Their build goes in fuzz/target. corpus/ and artifacts/ stay out of git.

When it finds something #

The input that failed is saved under artifacts/TARGET/. To run it again, with the panic's message:

cargo +nightly fuzz run frames artifacts/frames/crash-…

Make it smaller with cargo +nightly fuzz tmin frames artifacts/frames/crash-…, then find the cause. Fix it in the product, and add an ordinary unit test with the smallest input, beside the code it tests, so the fix holds without the fuzzer. A failure in a target's own checks can be the check's fault: read what it asserts before changing the product.

Lifecycle tests

clackatoo / Development

Most of clackatoo's tests start a daemon as a plain child process and stop it with a signal. That isn't how it ends on a real machine. There, the daemon runs in a scope of its own: a cgroup, the kernel's group of processes, that the user's systemd made for it, divided into leaves for the daemon, its terminals and its agents (see clackatoo priority). At a shutdown, systemd signals everything in the scope at once, the daemon's leaf last, so the programs in its terminals end a moment before the daemon hears it's to stop. A daemon that took their ends for ordinary exits would close their panes, and their workspaces, before keeping them. That once lost workspaces at a real shutdown, and no test that signals the daemon alone could have caught it.

The lifecycle tests run the real clackatoo daemon in a scope made the way the daemon makes its own, fill it with workspaces of terminals, chats and editors, end it, start it again, and check that every workspace, tab, pane and folder came back. They end it four ways:

TestHow the daemon ends
…after_systemd_stops_the_daemons_scopesystemctl --user stop on its scope, as a shutdown or a logout without lingering does.
…after_a_shutdown_logind_said_was_comingA fake logind, systemd's login manager, says a shutdown is coming (PrepareForShutdown); the daemon keeps its workspaces and lets go of its lock, then the scope is stopped.
…outlives_an_upgrade_in_its_scope_and_a_stop_afterclackatoo upgrade: the same programs run on, the next build stays in the daemon's leaf and starts new programs in theirs; then the scope is stopped.
…after_the_daemon_is_killedSIGKILL to the daemon alone, as a crash.

Each test also checks the scope is divided as the daemon divides its own: the daemon in its leaf, each terminal's program in terminals, and the agent in agents/serve, as agents is divided again.

Run them #

They need a systemd user manager, so they're left out of cargo test unless asked for, with the lifecycle feature. Build the daemon crate's examples first, for the fake agent the chats talk to:

cargo build -p clackatoo-daemon --examples
cargo test -p clackatoo --features lifecycle --test lifecycle

Without a user manager to make scopes in (systemd-run --user --scope true fails), every test fails at once, saying so.

The tests never touch a daemon you're using. Each daemon has a runtime, state, config and data directory of its own, in a temporary directory, and runs in a scope named as a daemon names its own, app-clackatoo-N.scope, but with more digits than any process ID has, so it can never be a real daemon's. Only scopes a test made are ever stopped.

In CI #

GitHub's runners have no user manager running for the job's user, so the lifecycle job in .github/workflows/ci.yml asks logind to keep one (loginctl enable-linger), points the tests at it, and then runs them.

Peios Learn — documentation for Peios software.

Built with Trail.