roadmap BUILT

151. Notification objects: async multiplexing without wait-any

Built 2026-09-26 (PR #1351). A notification object with the four methods of §101 (notification objects) and its TCB binding, on aarch64, riscv64 and x86_64, proved (four Kani harnesses, each falsified) and tested through the system call boundary by a real program on all three. One part of §101 could not be built as written, because its premise was false: how a woken receiver tells a notification from a message. calef ruled on it the same day (option B, below). Minted 2026-08-22, from DECISIONS §101's own sequencing (step 2), which specified this milestone's shape and scope without a number.

Why this exists

A concrete, waiting bug forces it: milestone 40's terminal_sink_caretaker narrowing (§101 step 1, DECISIONS §106 (take the terminal_sink_caretaker narrowing)) can outrun its own completion signal. A child's exit is delivered cleanly today via §26's fault/exit endpoint, but the caretaker's own trailing delivery to line_editor is a second, independent CALL with no ordering primitive against the shell printing its next prompt. notes/tail-output-narrowing.md names this precisely: a page's last line and the next $ can interleave under contention. A display glitch, not a confinement or correctness failure, and it is being carried as a documented BUGS entry on milestone 40 until this milestone lands.

Three other consumers are already named and waiting on the same primitive (§101's own table). The shell multiplexing child-output-or-exit into one wait, the compositor's per-client wakeup, the FS server's async-event notification, and the network stack retiring its yield-and-re-poll spin (milestone 106's current interim).

What to build

Exactly §101's spec, no re-derivation needed:

Explicitly out of scope, per §101: badged capabilities (a separate, later decision already named in notes/supervision.md, notes/compositor.md, notes/dir-capability.md) and timed wait (milestone 106, orthogonal: WAIT blocks indefinitely here exactly as RECV does today).

What was built

piece where
the state machine: a word, a wait queue, signal/wait/poll, and the binding as one boolean crates/inter_process_communication/src/notification.rs
four Kani harnesses: every operation preserves "a non-zero word and a queued waiter never coexist", a signal loses no bit, a waiter is woken before the bound receiver, a wait never returns zero; each carries a replayable falsification patch, and script/falsifications --sweep inter_process_communication turned all ten of the crate's harnesses red same file, falsifications/notification.verification.*.patch
objtype::NOTIFICATION = 4, abi::notification::{SIGNAL, WAIT, POLL, BIND, BOUND} crates/moho_abi/src/lib.rs
Object::Notification, the registry (MAX_NOTIFICATIONS = 256), RETYPE_OBJ's arm kernel/src/cap.rs, kernel/src/sched.rs, kernel/src/system_call.rs
the binding: a signal reaches the bound thread parked in RECV, RECV_CAP or Irq::WAIT, unlinks it from that endpoint's queue and wakes it; a receive takes a word counted while the thread was elsewhere, on entry sched::signal_locked, bound_receiver, deliver_bound, take_bound_signal
one signal path for a thread and for the kernel: signal_notification_from_interrupt is the entry milestone 106's timer will call from the tick, placed load-aware as irq_notify is kernel/src/sched.rs
teardown: a region's notifications are swept (waiters aborted with Gone) before its threads are finished; a thread blocked in WAIT is unlinked by finish_blocked_resident reap_region_notifications
Wait is an enum (Rendezvous(id, role) or Notification(id)), so a notification's name cannot be read as a rendezvous's kernel/src/thread.rs
user wrappers: notification_{signal,wait,poll,bind}, and recv_bound returning Received::{Message, Notification} crates/user_mode_runtime/src/lib.rs
seven kernel tests, all three ISAs, 7/7 on each locally before CI; one drives fixtures/src/notification_binder.rs through the real boundary kernel/src/user/notification_tests.rs

Method semantics are in abi::notification's doc comments, and the reasoning is in notes/notification-objects.md. Method and opcode numbers are §101's (SIGNAL 0, WAIT 1, POLL 2, BIND 3, NOTIFICATION 4), recorded here for the maintainer to confirm in design/decisions/.

Decided in the build: how a woken receiver tells a notification from a message

calef, 2026-09-26: option B. §101's encoding (w0 = 2 on a bound delivery, w0 = 0 for a message) rested on a false premise: RECV's w0 is the sender's own first data word, so any sender could forge a notification. The kernel now writes abi::notification::BOUND (2) into w4 on every receive that the bound notification ends, on all three receive methods, and keeps §101's w0 = 2 with the word in w1. w4 is written only by the kernel, and is 0 on every other receive. The options, costs and prior art are in notes/notification-objects.md; a maintainer is recording the ruling as an amendment to §101.

What it cost, measured

Code size on the IPC fastpath (script/fastpath-footprint, release build, against the base commit 256815e5 on the same nightly, not against the recorded baseline, which main had already drifted from by +2.0% to +3.9%):

ISA ipc_send_recv ipc_call_reply system_call_entry
riscv64 4778 -> 4854 (+76 B, +1.6%) 6082 -> 6186 (+104 B, +1.7%) 1892 -> 1894 (+2 B)
x86_64 6464 -> 6512 (+48 B, +0.7%) 8398 -> 8542 (+144 B, +1.7%) 1701 -> 1701
aarch64 5500 -> 5572 (+72 B, +1.3%) 7172 -> 7280 (+108 B, +1.5%) 1508 -> 1512 (+4 B)

The aarch64 row is CI's measurement, and the local one disagreed. A local macOS run measured this commit at 4664, 6052 and 1988: LLVM appeared to stop inlining IrqSafeMutex<IpcTables>::lock, so every IPC function shrank while system_call::dispatch grew. The same commit built by CI's fastpath-footprint job showed no such flip, and the baseline records CI's numbers. The cause of the local difference was not found; see BUGS. About 1.5% to 1.7% on the call/reply shape, on every ISA.

Where the riscv64 and x86_64 bytes are. The entry check (a load of bound_notification and a branch, with the body in a #[cold] function) costs ipc_recv about 80 to 90 bytes after one round of shrinking. The first version returned early from inside the lock hold, which duplicated the unlock path and cost 138 and 174 bytes. Joining the decision's other arms instead halved it. The RECV_CAP store to x4 and the five-word return cost ipc_recv_cap 34 bytes (riscv64) and 54 (x86_64) on their own, measured by compiling the entry check out; that is the cost of option B on the call/reply path. After rebasing onto a main that had re-recorded its own baselines, this change sits inside the gate's 5% band on every ISA, so bench/fastpath-*.txt keep main's figures.

Instructions (the bench job's TCG + icount counts, deterministic, CI run 36258812324), against the recorded baselines in bench/baseline-*.txt:

ISA ipc_rtt call_reply ipc_rtt_el0
aarch64 1034642 -> 1045327 (+1.03%) 1057883 -> 1061673 (+0.36%) 10994714 -> 11034763 (+0.36%)
riscv64 170436 -> 171076 (+0.38%) 177088 -> 177534 (+0.25%) 1861156 -> 1865150 (+0.21%)
x86_64 17254582 -> 17313622 (+0.34%) 17788619 -> 17830619 (+0.24%) not measured on this ISA

All inside the tripwire's 10%, and all under about one percent. These are against the recorded baselines rather than the base commit, so they include whatever main had drifted since the baselines were saved. The footprint figures above say that drift is real, so the notification share is at most these numbers.

Size against §101's estimate ("the same scale as 19a"): 19a (66553029e) was 377 lines added across 8 files. This is about 1,800 across 13, of which the kernel's own logic is about 470 lines of sched.rs (whitespace-insensitive), the proved crate 458 with its harnesses, and the tests 544. About five times 19a, and the binding (reaching into another object's queue, and the teardown it implies) is most of the difference.

What it unblocks

BUGS

Follow-on

Index row

BUILT 2026-09-26. A notification object (DECISIONS §101): a data word and a wait queue, with SIGNAL, WAIT, POLL and BIND under the existing SYS_INVOKE. Its TCB binding wakes a thread blocked in RECV, RECV_CAP or Irq::WAIT on either a message or a signal. Proved in inter_process_communication, tested through the system call boundary on all three ISAs. §101's receive encoding was forgeable; calef ruled the kernel-written w4 tag on 2026-09-26. About 1.5% to 1.7% on the call/reply fastpath, on every ISA. Unblocks milestone 106's timer and the retrofits §101's table names (the shell, the compositor, the FS server, net_stack).