What the review read and ran
An appendix to the milestone.
The crate
partsfoundry/terminal_contract at 591aed99de4997584efdd74cd34bcb1ac22bd4e1, version 0.1.0, no
tag, a fresh clone of main. The census of milestone 1129 (the combine review) counted it at the
same commit.
The lane read in full: Cargo.toml, README.md, CHANGELOG.md, CONTRIBUTING.md,
SECURITY.md, docs/stranger-test.md, .github/mutants-exempts, .github/coverage-exemptions,
src/lib.rs and src/verification.rs. It read the names of the seven unit tests in
src/tests.rs and not their bodies.
The commands
Every command ran on a Linux x86_64 host under rustc 1.100.0, with CARGO_TARGET_DIR set to a
directory apart from the clone. Afterward git status --short printed nothing.
cargo buildpasses.cargo testpasses: 7 unit tests and 1 doctest.RUSTDOCFLAGS="-D warnings" cargo doc --no-depspasses with no warning.cargo clippy --all-targetspasses with no warning.cargo build --lib --target x86_64-unknown-nonepasses, as the README gives it, and so do the builds foraarch64-unknown-none-softfloatandriscv64imac-unknown-none-elf.cargo package --list --allow-dirtylists 41 files, 20 of them under.github/,.githooks/or named.gitignore(P2-4).- The crate declares no features, so there is one feature combination.
grep -c '^pub const [A-Z]' src/lib.rscounts 30 constants, andgrep -c 'pub const fn\|pub fn' src/lib.rscounts 6 functions (P0-6). One function,decode, carries an example and#[must_use](P1-4).grep -n 'forbid' src/lib.rsfinds nothing (P1-5).
A scratch program that depends on the crate by path printed, in a release build:
req(257, 5)is0x100000000000005, anddecodeof it isSome((1, 5)): operation 257 became operation 1 (P0-1).req(OPERATION_WRITE, 1 << 32 | 7)is0x100000000000007: the length became 7 (P0-1).admits(OPERATION_QUIESCE, SUPERVISOR_BADGE), with its arguments swapped, compiles and is false.admits(RAW_ONLY_BADGE, CTL_QUIT)andadmits(STDIN_BADGE, NOTE_ABSORBED)compile and are false (P0-1).FLAG_RETRY == NOTE_NOT_WRITTENis true.CTL_RESUME,RAW_ONLY_BADGE,OPERATION_WRITE,FLAG_EOF,START_HANDOFFandNOTE_ABSORBEDare all 1 (P0-1).decode(0)isSome((0, 0)), andadmits(0, 0)is false.decode(req(200, 0))isSome((200, 0))(P0-2).is_retry(0, FLAG_RETRY)is true.is_retry(0, FLAG_RETRY | FLAG_INTERRUPTED)andis_retry(0, FLAG_RETRY | 1 << 3)are false (P0-4).decode(req(OPERATION_BYTES, 9))isSome((3, 9))(P0-5).BAD_REQUESTis 18446744073709551615.operation(BAD_REQUEST)is 255 andlen(BAD_REQUEST)is 4294967295 (P0-3, P1-3).- The low four bytes of
QUIESCED, most significant first, areQUIT(P0-6).
The search for a comparator
On 2026-11-26 (UTC), https://crates.io/api/v1/crates?q=<words>&sort=recent-downloads&per_page=8
for each of: "terminal protocol", "tty no_std", "termios", "pty", "line discipline", "terminal
ipc", "serial console no_std" and "raw mode". No result publishes a terminal protocol over a
message call. "termios" found termios, rustix, termion and redox_termios. termios and
redox_termios publish the words a program and a terminal share, so they rank. rustix is a
system call layer; the lane read its termios module as the strongest typing of the same words.
The demand appendix of milestone 1129 lists no comparator for this crate.
The comparators read
Each crate came as its .crate file from static.crates.io, at the version the block's table
names, into a directory of its own.
termios0.3.3, the crate page and the list of public items insrc/lib.rs, and the file list ofsrc/os/. The root exports the POSIX constants by their C names (ICANON,VMIN,TCSANOW) and the functionstcgetattr,tcsetattr,cfmakerawand their kin, each over aRawFdand returningstd::io::Result.Termioswraps the C structure and gives it out throughDeref. The crate page carries three examples under "Getting Started". It needsstdandlibc.redox_termios0.1.4,src/lib.rswhole. It isno_stdwith no dependency. The words are constants of two type aliases,tcflag_tandcc_t.TermiosandWinsizeare#[repr(C)]structs with public fields, each handed out as bytes throughDerefandDerefMutoverslice::from_raw_parts.Termios::make_rawclears the canonical and signal flags. No function can fail, and no item carries documentation beyond one constant.rustix1.1.6,src/termios/types.rs(the structTermios, the fourbitflagsmode types,SpecialCodes,SpecialCodeIndex,OptionalActions,QueueSelector,ActionandWinsize) and the file list ofsrc/termios/. Each mode word is abitflagstype whose last member admits bits the crate does not name.SpecialCodeIndexis a newtype overusizewith one associated constant for each code, andSpecialCodesindexes by it alone.OptionalActionsis a#[repr(u32)]enum with a#[doc(alias)]for each C name.Debugfor a control code prints^Cand not 3.crossterm,console,vte,termion,nixandembedded-io: measured, not downloaded, not read.
The systems outside Rust
Each file came from a public mirror at the named commit.
- Fuchsia at
8ff2539fd32def0c2b9ed84b8c8873c31af81d22,sdk/fidl/fuchsia.hardware.pty/pty.fidl, whole.Deviceis a closed protocol of strict methods.OpenClientmakes a client with an identifier, and the client with identifier 0 alone may open others, read events and choose the active client.ClrSetFeaturetakes a mask to clear and a mask to set and returns the features in force;FEATURE_RAWis the one feature.ReadEventsreturns the pending events (EVENT_HANGUP,EVENT_INTERRUPT,EVENT_SUSPEND,EVENT_WINDOW_SIZE) and clears them, andDescribehands the client an event to wait on.GetWindowSizeandSetWindowSizecarry aWindowSize. Every reply opens with azx.Result. The library carries@available(added=11). - 9front at
d7e009b7866219fa6b2302941b939759ef2c2b68,sys/man/8/kbdfs, the section onconsandconsctl. A read ofconsreturns one line once a newline or^Dends it, and a later read returns the rest of a line a short read left. Writingrawontoconsctlstarts raw mode, which ends whenrawoffis written or the file is closed. The lane also fetchedsys/man/3/cons, which no longer describesconsctl.
The benchmark
A scratch crate outside the clone depends on terminal_contract by path and on nothing else.
The command is cargo run --release. The host is Linux x86_64, an Intel Xeon Platinum 8160 at
2.10 GHz with 80 threads, rustc 1.100.0. The benchmark runs on one thread.
Each measurement starts at 64 calls and doubles the count until one pass lasts 50 ms. It then
runs seven passes and reports the lowest, divided by the count. black_box wraps the loop
counter, which is the length, and the sum of the results.
| measurement | what a call includes | run 1 | run 2 |
|---|---|---|---|
req |
one shift, one mask, one OR | 0.65 ns | 0.74 ns |
req, then decode |
the above, the reserved-bits test, two field reads | 0.68 ns | 0.73 ns |
req, decode, then admits |
the above through one more black_box, and the badge match |
3.69 ns | 3.96 ns |
The block's table gives run 1. The lane ran no comparator: termios and rustix make a system
call for each operation, and redox_termios is constants and two structures.
What the lane did not run
- Kani and the falsification replay; the harness and patch counts are from the source.
- Mutation testing.
- The build at the minimum Rust version, 1.88.
- Any terminal or client that speaks the words; P1-7 and P2-3 rest on the documentation.
- The tests of the comparators.