Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
3c4851e
chore(quest): claim quest/m1/ffi-proofs/protocol.md
kixelated Nov 19, 2026
1e2e9ba
Test the ownership protocol against a model through the C ABI
kixelated Nov 19, 2026
5876a45
Shape protocol scripts by what a driver's surface can run
kixelated Nov 19, 2026
6629d25
Model the runtime's futures and threads under loom
kixelated Nov 19, 2026
96a4024
Run the protocol scripts through the C++ header
kixelated Nov 19, 2026
7920dd6
Move a lend's holder into calls in the protocol scripts
kixelated Nov 19, 2026
4f72c6b
Refuse what a borrow checker refuses in scripts for a surface that ha…
kixelated Nov 19, 2026
accdf4a
Merge commit '7920dd6e' into protocol-swift-cpp
kixelated Nov 19, 2026
569e07f
WIP: Kotlin protocol driver and profile flags
kixelated Nov 19, 2026
56c9817
Merge commit '7920dd6e' into protocol-kt-dart
kixelated Nov 19, 2026
3474c43
Run the protocol scripts through the web binding
kixelated Nov 19, 2026
a5fe5ea
Merge commit '7920dd6e' into protocol-ts
kixelated Nov 19, 2026
09eca7b
Run the protocol scripts through the Python binding
kixelated Nov 19, 2026
5827e9d
Merge the parent's protocol branch
kixelated Nov 19, 2026
3cb4017
Run tallied and stored through the Python protocol driver
kixelated Nov 19, 2026
4fad7c0
Run the web binding's protocol scripts on Deno too, and drain before …
kixelated Nov 19, 2026
1eb991f
Run the protocol scripts through the Swift
kixelated Nov 19, 2026
a22f62a
Home a future Swift makes from nothing that is not Send in its scripts
kixelated Nov 19, 2026
3d958ef
Run the protocol scripts through the Go binding
kixelated Nov 19, 2026
b531c91
Run the protocol scripts through the Kotlin and Dart bindings
kixelated Nov 19, 2026
41056fa
Merge the Python and Go protocol drivers
kixelated Nov 19, 2026
a35d27c
Merge the Swift and C++ protocol drivers
kixelated Nov 19, 2026
308ed2b
Merge the Kotlin and Dart protocol drivers
kixelated Nov 19, 2026
5192ba7
Document the bindings' protocol drivers and finish the quest
kixelated Nov 19, 2026
e5c5978
Build the Swift module once per process and batch the protocol driver…
kixelated Nov 19, 2026
ef8ca6e
Answer the bots' review of the protocol tests
kixelated Nov 19, 2026
e4d0d49
End a driver's whole process group at its deadline
kixelated Nov 19, 2026
8456235
Back off a driver's exit poll from a millisecond
kixelated Nov 19, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,11 @@ jobs:
- name: Shapes
run: nix develop --command just ffi shapes

# Longer random protocol scripts through the C ABI and each binding, against the
# model of what each step returns; the gate runs fewer.
- name: Protocol
run: nix develop --command just ffi protocol

# What exports, and every refusal, ranked.
- name: Census
run: nix develop --command just ffi census
Expand Down
5 changes: 5 additions & 0 deletions ffi/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ publish = false
[package.metadata.rust-analyzer]
rustc_private = true

# Mounted by `#[path]` into a copy of an export, or by more than one test, which cargo-shear
# does not follow.
[package.metadata.cargo-shear]
ignored-paths = ["tests/miri/*.rs", "tests/protocol/*.rs"]

[workspace]
# Its own workspace, apart from the repo's: the driver builds on ts's pinned nightly,
# which rust-toolchain.toml links.
Expand Down
36 changes: 34 additions & 2 deletions ffi/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -880,7 +880,9 @@ value of a Rust type crosses as one Swift type that holds it exactly, and back u
any executor awaits it.
- **Checks**: a borrow or move Rust's rules refuse at run time, such as a borrow of a value
that is not `Sync` on a second thread, throws a `CheckError`, holding the function and
the rule, before any Rust code runs, so the call changed nothing. So every function whose objects can fail a check `throws`, and a
the rule, before any Rust code runs, so the call changed nothing, but that a call
consuming an object took it, as its parameter consumes it whether or not the value moves,
and frees it as a scope's end would. So every function whose objects can fail a check `throws`, and a
field read stays a property whose getter throws, except one of a noncopyable value,
whose getter Swift cannot let throw, which is a method, `firstGet()`. Of a type whose
checks can fail, or a record or enum holding one, `description` and `debugDescription`
Expand Down Expand Up @@ -1425,6 +1427,7 @@ just ffi moq-swift # the same export, running only moq/moq.swift
just ffi moq-api <target> # stage moq's API on another target into target/moq-api, which the exports above merge
just ffi census # census each into target/census
just ffi shapes # round-trip every sampled type shape in every language but KNOWN's, as the nightly does
just ffi protocol # run longer protocol scripts from more seeds through the C ABI and every binding, as the nightly does
nix develop .#bench --command just ffi browsers # api's TypeScript in headless Chromium and Firefox, as the nightly runs it
nix develop .#android --command just ffi android # the Kotlin test, shrunk by R8, on the Android device adb reaches
nix develop .#bench --command just ffi bench # the binding benchmark: bench/ffi/README.md's cases from Rust, and through the export from C, C++, Kotlin, Python, Swift, Go, and Dart
Expand Down Expand Up @@ -1483,6 +1486,34 @@ the nightly does. `KNOWN` lists what a binding still gets wrong, each with the q
fixes it; the driver skips those shapes, so the fix deletes its entry, and the nightly fails
on an entry that matches no exported shape. A new IR `Type` variant fails `ir_covered`
until the sampler covers it.
The protocol tests run random sequences of borrows, exclusive lends, moves, drops, frees,
polls, and cancels over the api fixture's checked types, on the thread that made a value
and another, against `tests/protocol/model.rs`: an executable model of what this README
says each step returns, the status a check fails with included. A seed makes a script of
steps and the model's transcript of their outcomes, shaped by what a driver's surface can
run, and each driver runs the script through its surface and prints the outcomes back, which
must match line for line, with the counts of the script's waker where it polls with one.
`tests/protocol.c` runs them through the C ABI, `tests/miri/protocol.rs` under Miri, and
`just ffi sanitize` runs the C driver under ASan and TSan. Each binding runs them through
its own wrapper too, from `tests/protocol.cpp`, `.swift`, `.py`, `.go`, `.kt`, `.dart`, and
`.ts`: its `Profile` in the model leaves out what the binding cannot write, such as a free
where its collector frees or a failed check where it aborts, and adds what the binding does
its own way, such as a close that refuses before Rust's check, a future made only as it is
awaited, or one made on a home. `protocol_profiles` checks that each flag keeps its
scripts to it. The gate runs 500 scripts of 100 steps through the C ABI, failing unless
they meet every status and make every kind of handle, and 40 to 500 through each binding;
`just ffi protocol`, run nightly, runs 20,000 of 400 steps through the C ABI and 1,000 to
5,000 through each binding.
`tests/borrow.rs` and `tests/hold.rs` model the borrow check and the bindings' hold counts
under loom, and `tests/future.rs` and `tests/thread.rs` model the runtime's futures and
threads, each mounting the runtime's own source over loom's primitives. The futures' model
races a wake from another thread against a poll, a change of waker, a start, and a free:
each C waker drops once and is never woken after, a pending poll is always woken, and a
future that is not `Send` refuses a poll elsewhere and drops on its own thread. The threads'
model races a free elsewhere against its thread's check, wake, drain, and exit, and lends
calls to homes that call each other: each value drops once on its own thread, or leaks once
that thread exited, and each home goes idle once no value or call holds it. Each explores
every interleaving, or for homes those within a preemption bound, in the gate.
The `reject` fixture's expected errors, each with its notes, are `fixtures/reject/expected.txt`.
The `lock` test exports the `lock` fixture for wasm32, staged, and the host, then again
against that export's `api.json`: its `added` feature only adds and must pass, and its `next`
Expand All @@ -1491,7 +1522,8 @@ error matching `fixtures/lock/expected.txt`.
`just ffi sanitize`, run nightly, rebuilds the `api` export with std under AddressSanitizer
and then ThreadSanitizer, runs `tests/api.c` and `tests/api.cpp` against it, and matches
their output to the native transcript; it runs `tests/api.go` under Go's race detector;
and it drives the C ABI from `tests/miri/api.rs` under Miri with strict provenance.
and it drives the C ABI from `tests/miri/api.rs` and the protocol scripts from
`tests/miri/protocol.rs` under Miri with strict provenance.
moq's crates export through `target/moq-ffi`, an empty library on each that `just ffi moq`
writes in place of moq-ffi's remainder. The export serves the host and each target
`just ffi moq-api` staged in `target/moq-api` from the same moq sources, and fails on a
Expand Down
4 changes: 4 additions & 0 deletions ffi/justfile
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ test *args:
shapes:
cargo test --locked --test fixtures shapes::nightly -- --ignored

# Run longer protocol scripts from more seeds through the C ABI and every binding, as the nightly does; the gate runs fewer.
protocol:
cargo test --locked --test fixtures protocol_nightly -- --ignored

# Run the api fixture's web test in headless Chromium and Firefox, in the bench shell, which carries them: nix develop .#bench.
browsers:
cargo test --locked --test fixtures -- --ignored --exact api_browsers
Expand Down
Loading