How Tide works

Eight ideas, each with a command to run.

Each part below explains one feature in plain terms, gives a command that shows it, and says what it does not do. The commands run from a clone of the repository after installing the driver. The "under the hood" parts point at the code.

1. Capabilities: no ambient authority

In most languages any function can read a file, open a connection or read the clock. It just calls the standard library. That is ambient authority, and it means a signature such as fn parse(text: &str) -> Config tells you nothing about what the function might do.

Tide removes it. Every operation that touches the outside world, except writing output, is a method on a capability: Fs for files, Net for TCP connections, one HTTP GET and name lookup, Proc for starting other programs, Rand for random draws, Clock, Env, Stdin and Tasks. A function that wants to read a file must be handed an Fs, so its signature shows it. Capabilities come from one place, the program's main(root: Root), which hands each callee only what it needs and can narrow them first, for example to one directory, read-only.

Tide makes this stick by compiling your code against its own std, which has no std::fs::read or Instant::now() to call, and by admitting from Rust's lower layers only an allowlist of items that cannot reach the world.

result/bin/tide-admit --crate-type=bin --out-dir target/guide/ambient \
  docs/owner-guide/examples/ambient/src/main.rs
result/bin/tide-admit --crate-type=bin --out-dir target/guide/granted \
  docs/owner-guide/examples/granted/src/main.rs

The first program, written with Rust habits, fails with TD0501 for each ambient call and TD0503 for passing the whole root around. The second, the Tide way, is admitted and prints nothing.

Printing is not a capability, by design, so data can leave a program through its output. The claim is no accidental ambient authority in admitted safe code, apart from printing and outside the unsafe grant (--tide-grant=unsafe), and it rests on rustc being sound (part 3). Today the driver checks one crate and there are no dependencies yet.

Under the hood

The list of ambient paths the driver rejects lives in crates/tide-admit/src/policy.rs. The owner's guide has the full walkthrough in chapter 1.

2. Admission: what Tide checks, and what it trusts rustc for

Tide has no compiler of its own. Every Tide program is ordinary Rust, compiled by a pinned, unmodified nightly rustc. Tide adds a gate in front, admission. tide-admit is a rustc driver: it runs rustc's own code as a library and adds checks between its stages, so it sees exactly the names and types rustc sees. A program that fails one of its rules gets TD errors, code that rustc itself rejects gets rustc's own errors, and either way no output is written.

It checks authority, the allowlist, the unsafe grant, concurrency habits, a smaller language (no user macros, no lossy number conversions, a ceiling on trait power) and that the driver owns the build: no build scripts and no compiler flags from the program. rustc keeps parsing, types and the borrow checker, which proves memory safety and freedom from data races.

result/bin/tide-admit --tide-print-codes
result/bin/tide-admit --crate-type=lib --crate-name=unsafe_hole \
  --out-dir target/guide/unsafe docs/owner-guide/examples/unsafe_hole/src/lib.rs
result/bin/tide-admit --crate-type=lib --crate-name=unsafe_hole --tide-grant=unsafe \
  --out-dir target/guide/unsafe docs/owner-guide/examples/unsafe_hole/src/lib.rs

The first lists every TD code. The second is rejected with TD0901, because an unsafe block needs a grant that only the operator can give. The third gives it, and the program is admitted.

The driver links rustc's internal libraries on one pinned nightly, which have no stability promise. That coupling is a chosen cost. Each check today is a full rustc run plus admission: under a second on the benchmark's small programs, and a rebuild after a one-line edit takes 5 to 6 times incremental Rust's time. A fast incremental front end is planned and not built.

Under the hood

Every rule is checked by the conformance corpus, which runs each case through both plain rustc and the driver. A case is a small program whose comments hold the expected verdicts, for example conformance/cases/authority/cap_ambient.rs. See chapter 2.

3. rustc's soundness bugs, and what Tide closed

A soundness bug is a case where a compiler accepts a program that breaks its own promises. rustc has some, and several have been open for years. They matter to Tide because its capability rules rest on rustc's type system: if safe code can make a short borrow look permanent, or read one type's bytes as another, it could keep or forge a capability.

A probe showed the driver admitted rustc's own test case for rust-lang/rust#25860, open since 2015, and a variant that turns a borrowed &Fs into a permanent one. TD0206 now rejects that function-pointer route. A red team then found that admission let through one more known route, rust-lang/rust#57893, open upstream since 2019, which gives safe code a general transmute, and the review of its fix found a second form, also on record upstream. TD0402 now rejects both.

result/bin/tide-admit --crate-type=lib --out-dir target/guide/capability-forge \
  conformance/cases/memory/closure_fnptr_capability.rs
result/bin/tide-admit --crate-type=lib --out-dir target/guide/dyn-overlap \
  conformance/cases/memory/escape_dyn_overlap_transmute.rs

The first is rejected with TD0206, the second with TD0402.

Both rules are conservative and reject some harmless code too. rustc has other open soundness bugs, and the #100051 family stays open in the design. Test runs the driver starts sit inside a kernel sandbox (part 8). Deployed programs get kernel enforcement only in v1.

Under the hood

TD0206 lives in crates/tide-admit/src/walk/reify.rs. The red team's record lists every route it tried. See chapter 3.

4. Structured tasks and Shared

A task is one strand of work that runs alongside others, and under v0 each is an operating system thread. Tide replaces Rust's concurrency habits. Instead of a thread nobody waits for, a task can only start inside a scope, which ends only when every child has finished, and the first child to fail cancels its siblings. Starting one needs the Tasks capability, so a signature shows whether a function can run work concurrently. Instead of a Mutex, a Shared cell runs a closure that may hold no capability and no other Shared. So while holding the cell it cannot read a file, take another cell or wait through a capability. It can still print, and printing can briefly block when the output is backed up. And there is no async or await.

result/bin/tide-admit --crate-type=lib --out-dir target/guide/habits \
  docs/owner-guide/examples/habits/src/lib.rs

The three habits are rejected with TD0602 for a bare thread, TD0604 for a Mutex and TD0603 for a closure that reaches a capability inside Shared::with.

Cancellation is cooperative, so deadlines are soft: a task that keeps computing past its deadline keeps its scope waiting until it reaches a checkpoint. Shared data can still race at the level of logic, which is what the simulator is for.

Under the hood

The demo's service, demo/service/src/hits.rs, is a small concurrent program built this way. See chapter 4.

5. Seeds and the simulator

A race shows up only when tasks run in an unlucky order, and on a real machine that order depends on luck. In a test, Tide hands the code a simulated root: the same capabilities, backed by models. The simulator runs one task at a time and picks the next one at each scheduling point using a seed. Time is virtual and jumps ahead only when every task is waiting. So a seed is a schedule: run seeds 0 to 15 and you have tried 16 seeded schedules, and a failing seed fails the same way every time.

This works because every source of nondeterminism goes through a capability, and test code cannot name the real Root. A #[sim_test(seeds = 16)] runs the test under 16 seeds.

nix --extra-experimental-features 'nix-command flakes' develop
cargo run -p tide-demo

The demo finds a lost update on 8 of 16 seeds, then shows the fixed revision passing all 16.

The simulator does not model CPU time, so a slow computation never fires a deadline. Nor does it model memory exhaustion, disk faults, other TCP hosts, signals or real child processes. Fault injection and crashable nodes are planned.

Under the hood

The demo's simulated test is demo/tests/src/hits_sim.rs. See chapter 5.

6. Replay: what it reproduces, and what it doesn't

When the driver runs a test with --tide-run-test NAME --seed N, it records a manifest, holding the seed, hashes of the source, compiler, std and every loaded library, and every input the run consumed, and a trace of every event. --replay MANIFEST first checks that the current build is exactly the recorded one and refuses if anything differs. Then it reruns the test, feeds back the recorded choices, and compares the traces byte for byte.

The demo you ran in part 5 records seed 0 and replays it twice. The recording and both replays have 40 events and identical hashes, and its log prints the replay command, which you can run yourself.

Replay reproduces the model, not the program, and only on the same machine with identical pinned artifacts. Any edit makes it refuse, by design: use --seed N for a fresh run of the same seed on changed code. Production record and replay is planned for v1.

Under the hood

The demo's record and replay steps are in crates/tide-demo/src/lib.rs. See chapter 6.

7. The trust diff

Each time the driver admits a library, it writes a trust artifact next to it, <crate>.interface.json. It lists the declared authority of every exported item, with the path to each capability, and every place the unsafe grant let in. tide-admit --tide-diff BASE HEAD compares two artifacts and prints only what changed: authority widened or narrowed, and holes added or removed. It is a summary of what a change may do.

cat target/guide/unsafe/unsafe_hole.interface.json
cat target/tide-demo/out/interface-head/hits.interface.json

The first artifact is the one part 2 wrote, with its unsafe site listed as a trust hole. The second is from the demo, whose patch gives the service's public function a Net parameter, and the diff lists hits::serve as widened.

It lists declared authority of exported items only. A capability narrowed less than it should be, a held capability put to a new use, or data sent out through standard output does not appear in it. The E3 pilot gives no evidence that it helps reviewers catch planted widening (E3).

Under the hood

The demo's widening patch is demo/patches/metrics-report.patch. See chapter 7.

8. The test sandbox

Parts 1 to 3 are about what the type system lets code do, and part 3 showed it has holes. So Tide adds a second fence that does not depend on rustc: the kernel. When the driver runs a test (--tide-run-test, --replay), it starts the test as a child process under Landlock, which limits the files it may read, write or run, and seccomp, which forbids sockets, starting programs and other system calls. The process cannot lift either, whatever tricks it played on its compiler.

Step 4 of the install runs a test this way. The driver prints sandbox: full or sandbox: partial, not enforced, naming what the kernel lacks.

Landlock does not hide file metadata, such as whether a path exists. A test binary run directly gets no sandbox, the build itself is not sandboxed, and deployed programs get kernel enforcement only in v1. The sandbox runs on Linux only.

Under the hood

The child's setup between fork and exec is in crates/tide-admit/src/invocation/sandbox.rs. See chapter 8.