Analysis, proofs and the supply chain
An appendix to nifeos/nife:notes/scripts.md, the front door to script/. It holds the full
table rows for the static analyses, the proof and mutation checks, and the dependency checks. A
reader who only needs to run a command should not have to open it. The directory notes/scripts/
and this file's stem are provisional names; naming is calef's.
| script | what it does |
|---|---|
script/vendor-verify |
Prove each vendor/*.pin tree is the published tarball (sha256) plus exactly its divergence patch, byte for byte. --write-patch regenerates the patch after a deliberate change. Needs network on a cold cache. |
script/vendor-watch |
Ask what upstream has done since each vendor/*.pin was taken: newer crates.io releases, and upstream git commits since the pinned sha, merge commits dropped. Both, because releases here are months apart and a correctness fix can sit on master long before it is published. --write regenerates vendor/upstream-status.md and raises the pin when a newer release exists, which makes vendor-verify fail and turns the upgrade into a visible red check; it deliberately does not try to re-apply the divergence patch. Exit codes are the answer rather than a verdict: 0 current, 1 behind, 2 transiently unreachable, 3 permanently unreachable (a 404, meaning the watch itself is broken). The monthly vendor watch workflow runs it and opens one pull request on a fixed branch. Needs network. Name provisional. |
script/supply-chain |
The milestone-42 gate (a CI gate): cargo-deny (advisories, licenses, bans, duplicates, sources) over each workspace against deny.toml, then vendor-verify. Needs network; installs the cargo-deny pinned in .cargo-deny-version if the installed one differs, because 0.19 and 0.20 spell --config differently and default it to different directories. |
script/fuzz |
Coverage-guided fuzzing (cargo-fuzz/libFuzzer) over the parsers that read bytes we did not write: device_tree_blob_walk, device_tree_patch_initial_ramdisk, elf_parse, globally_unique_identifier_partition_table, http_response_feed, nifefs_roundtrip, package_archive_roundtrip, package_index_text, capability_manifest_note_decode, acpi_firmware_tables, machine_description_from_device_tree, video_terminal_feed (a CI gate). --time N sets the per-target budget (default 60s, 0 runs until stopped), --list explains each target, and a bare target name runs one. Installs the cargo-fuzz pinned in .cargo-fuzz-version on absence or mismatch. See notes/fuzzing.md. |
script/fuzz-status [--host] |
Is the continuous fuzz working? One PASS, FAIL or UNKNOWN line per check; exit 1 on any FAIL, and UNKNOWN means the check could not be made. Read-only, no sudo, counts and ages only. Default mode needs gh: the heartbeat runs, the fuzz-* releases, fuzz-loop-broken issues, advisories, and whether main's tip is green by the follower's rule. --host checks the service, the publish timer, a recent slot iteration in the journal, the follower's distance from main, the output directory, slot worktrees (#3264), clean-window growth and disk. --help lists the limits. Selftest: helpers/fuzz-status-selftest.sh. Name provisional. |
script/undefined-behavior-check |
The host-logic tests again, under Miri's interpreter: aliasing, pointer provenance, uninitialized reads, leaks, the rules no other gate checks. Weekly in CI plus on demand; not in test or gates, because the interpreter is minutes where the host tests are milliseconds. The exhaustive suites sample themselves under cfg(miri), so "Miri-clean" means the sampled paths. Extra args go to cargo miri test (script/undefined-behavior-check -p globally_unique_identifier_partition_table). See notes/undefined-behavior.md. |
script/stack-frame-check |
What one kernel function's stack frame costs, from -Z emit-stack-sizes, gated at 4096 bytes, the guard page (a frame larger than the guard page can step clean over it, so the guard page is the number and any fraction of the stack is not). The complement of milestone 84's watermark: that says how deep the suite went and cannot say which function is expensive, which is the question an overflow poses. Written after sched::reap_region_objects carried a 6816-byte frame, of which 4096 was one [u64; MAX_ENDPOINTS] scratch array, against 4712 bytes of measured headroom; it compiled without a warning and was found only because a milestone's CI faulted one run in five. Gates both ISAs (§19). --arch narrows, --report prints the deepest 40 and gates nothing. Needs no emulator, so it works from a machine with no QEMU. A CI job, not in gates: it builds the kernel test binary twice, which is more than gates promises. See notes/stack-high-water.md. |
script/stack-depth-check |
How deep a kernel thread stack can get, by walking the call graph: direct calls out of the disassembly, -Z emit-stack-sizes frames hung on the resulting graph, longest path from the entry points a thread stack starts at (thread_entry, user_thread_entry, the arch trap dispatcher). The third instrument, and the one both older notes named as the gap without building: a frame size is not a chain and a watermark sees only what the suite ran. It also checks the claim stack-frame-check's exception table makes by hand, that a given oversized frame cannot reach a thread stack. Fails when the worst chain does not fit in 24576 bytes (thread::STACK_PAGES, which said 16384 here for a day after #225 raised it), when the interrupt-stack chain does not fit 16384, when a context switch is reachable from the interrupt-stack entry point, or when any frame over the guard page is reachable; warns past 18432, the watermark's own thread row. --arch narrows, --report prints each chain and gates nothing. The switch-reachability check is milestone 124's, and it is the strong half of the rule that nothing on a per-CPU interrupt stack may context-switch away from it: a violation would corrupt a stack rather than fault, so it is checked statically every build instead of waited for. On 2026-08-16, after that milestone, it read 13456 bytes worst case on aarch64 and 13008 on riscv64, of which the handler leaves 3728 and 3552 on the thread and 3984 and 3888 on the interrupt stack. It is a lower bound rather than an upper one: indirect calls and assembly (which carries no .stack_sizes entry at all) are invisible to it. Runs in the stack-frame-check CI job, sharing its build. Name provisional. See notes/stack.md. |
script/build-is-reproducible |
The same commit builds the same bytes, from any path. Extracts git archive HEAD into two temporary trees at different paths, builds each into its own target directory, and compares the artifacts by sha256. The property was measured for the first time on 2026-09-18 and it held: three builds of the aarch64 release kernel, all 849a37e7eddca287..., 548360 bytes, with zero absolute paths in the binary. Nothing claimed it and nothing gated it, so it was true by construction rather than by intent: one build.rs embedding a timestamp, a git hash or CARGO_MANIFEST_DIR ends it, and the regression surfaces as two machines disagreeing about a binary months later. Both legs build HEAD rather than one from the working tree, because a dirty tree legitimately differs from HEAD and a gate that cries wolf on uncommitted work is one people learn to skip; the cost is that it cannot check work in progress. --keep holds both trees for inspection after a failure. A local row and a CI job, and the tier is a correction: it was filed as ci on the assumption that two cold builds are slow, and its own first CI run measured 11.1 seconds for both (2026-09-18), against 5 seconds for one cold -p kernel release build on the dev machine. That is cheaper than script/icount (its row), so it runs before a push, at the moment somebody writes the build.rs that would break it rather than one CI round later. Its own BUGS records what it does not cover, and the largest gap is that it reads the kernel only, not the user-program archive or the nifefs image, which is the artifact that actually ships to somebody else. Name provisional. |
script/fastpath-footprint |
An upper bound (whole symbol sizes) on the IPC fastpath's instruction footprint, which is the quantity Liedtke's On micro-Kernel Construction (SOSP 1995) identified as the real cost of Mach's IPC: a kernel that touches a lot of memory per IPC evicts the application's working set, so the bill arrives as capacity misses in the workload, not as kernel time. Three numbers: ipc_send_receive and ipc_call_reply are the closures of non-cold calls from each IPC shape's roots (milestone 188 (the IPC fastpath) added the second, the shape services run, 25 to 29% larger; ipc_fastpath is the worse of the two), and system_call_entry is the trap entry, dispatcher, return path and system_call::dispatch summed flat, since the decoder's own bytes are on every system call whichever arm it takes. aarch64 counts one 128-byte vector entry, not sixteen, because an svc fetches one. Shares script/stack-depth-check's call-graph walk and its blind spot: indirect calls are invisible. Gated at 5% growth against bench/fastpath-<arch>.txt, tighter than the icount tripwire's 10% because a symbol size moves only when the code moves. Excludes the teardown family reached through finish_switch's reap branch, which no IPC takes and which put 11.2 KiB on a 5.6 KiB figure, plus every function this workspace marks #[cold], read out of the source rather than listed in the gate. It is not a cache measurement: nothing in this tree models a cache yet, so it gates the quantity and not the harm. All three ISAs, per §19 (architectural parity is a tenet). --arch narrows, --save --why re-records and stamps it with the nightly, --features <name> builds an extra kernel feature in and reports without gating or saving (E3's footprint-perturbation experiment, milestone 134 (the register of measures)). A CI job, not in gates: it builds two release kernels. See notes/benchmarks.md. |
script/image-permissions |
The three shipped kernel images obey W^X: no PT_LOAD in kernel's ELF is both writable and executable, on aarch64, riscv64 and x86_64 (§19). Built because crates/static_elf refuses such a segment and page_tables::Flags cannot construct such a page, so W^X was enforced on every ELF this system loads and on nothing about the ELF this system is; the x86_64 image carried an RWX boot segment from the port until milestone 208, through every other gate in the tree, because nothing had ever parsed it. It reads p_type and p_flags at the offsets ELF64 fixes rather than calling Elf::parse, and the reason is not laziness: that parser binds its accepted e_machine at compile time, so a host tool built once can accept exactly one of the three kernels and a gate covering one architecture would fail §19 on the day it was written. It reports every violation rather than the first. --no-build checks what is already built. Seconds warm; a local row in script/ci-build and a CI job of its own, though not yet a required one. Name provisional. |
script/crate-probes |
Build fifty crates.io crates against the patched std and report the split (milestone 64's measurement, which milestones 99 and 66 consume through notes/crates-io-on-nife.md). Each probe is a [[bin]] whose main calls the crate, because a library target is never linked and an unreferenced dependency is compiled and never linked; both rules were learned by recording diesel as a pass twice. A probe that fails is rebuilt for the host and reports BODY instead of FAIL when the host fails too, so a wrong call site in this script cannot be read as a nife result. Seven crates are expected not to build (known_failure in the script, each with its class from notes/crates-io-on-nife.md); they are still measured and printed as KNOWN, and only an unlisted crate that stops building fails the run. --no-backend drops entropy_backend, which is the difference between 43 built and 39. Needs network, so script/test does not run it; it is a ci row of script/ci-build, run by the crate-probes job on every pull request; aarch64 only, since the PAL speaks the capability ABI rather than an ISA. Name provisional. See notes/crates-io-on-nife.md. |
script/crypto-probes |
Build every candidate TLS crypto provider, and every primitive one is assembled from, against nife's own target specifications on the pinned nightly, for all three architectures, and report what builds, for milestone 442 (a crypto provider rustls can use on all three bare-metal targets). script/crate-probes' sibling and its machinery, with three differences that are the point: all three ISAs, because the answer differs by ISA; providers and primitives rather than fifty representative crates; and a failure records which architecture it was on, since a row that passes on two and fails on one is the interesting shape. --soft reruns with every SIMD path forced off, which is the difference between one green column and four red ones on x86_64-unknown-nife. Its probe crates are built outside this repository, which is not tidiness: a probe under target/ inherits this repository's own rust-toolchain.toml, which beats RUSTUP_TOOLCHAIN for the rustc -Zbuild-std invokes, so std compiles unpatched and the failure reads exactly like the crate under test failing. Needs network, so it is not a CI gate and script/test does not run it. Name provisional. See notes/cryptography-provider.md. |
script/mutation |
Mutation testing (cargo-mutants) over the host crates: would any test notice if this line were wrong? A report, not a gate; the weekly mutation testing workflow runs it four-way sharded and publishes the per-crate table against .cargo/mutants-baseline.txt. --shard k/n splits the run, -p CRATE narrows it, --report summarizes finished output, --save-baseline rewrites the baseline. The host-excluded crates are derived at the call site from helpers/host-excluded-crates.sh; judgment exclusions (with reasons) in .cargo/mutants.toml; installs the cargo-mutants pinned in .cargo-mutants-version on absence or mismatch. Since milestone 277 (bound what one mutant may allocate) each mutant's test binary runs under a 4 GiB address-space ceiling (helpers/memory-bounded-runner.sh, tunable with MUTATION_MEMORY_LIMIT_KB), because cargo-mutants bounds a mutant on time and the failure that killed every scheduled run was an allocation. See notes/mutation-testing.md. |
script/mutation-census |
One row per crate, per census, committed. script/mutation --report prints a per-crate table from a finished run and the run output is then thrown away, so until milestone 518 (a census that cannot be attributed is a number nobody can act on) the tree had kept exactly one per-crate record in its life (.cargo/mutants-baseline.txt, 2026-08-03) and every comparison anybody wanted was made against it whether or not it was the right comparand. --add-run <id> captures a finished GitHub Actions census in one command (the artifacts expire at 90 days; the record does not), --add-baseline ingests the baseline file read-only, --list and --show read the record back, and --compare A B prints each crate's exact contribution to the corpus-level move, a column that sums to it rather than merely ranking. Resolves crate renames out of a committed table derived from lib.rs rather than Cargo.toml, because git pairs near-identical manifests across a multi-crate rename sweep and answers confidently wrong. Backfilled to all four censuses that have ever completed; a red run is refused, because a partial corpus read per crate is a sample and a sample cannot tell an absent mutant from a killed one. A report, not a gate, like script/mutation itself. Names provisional. See mutation-census.md. |
script/falsifications |
Can each Kani harness be made to fail? script/mutation asks that of the tests; this asks it of the proofs, which is not the same question, and DECISIONS §134 is why it is written down rather than remembered. Every harness carries a Falsification: block above #[kani::proof] in one of three states: replayable <path> (a patch at crates/<crate>/falsifications/<module.path>.<harness_fn_name>.patch, which is Kani's own fully qualified harness name with the separators changed, so the sweep filters with --exact), attested <date> (a person watched it fail, and nothing can re-check that), or unfalsified. Bare, it prints the table and the ratio; --unfalsified is the worklist, --check is the form gate lint runs (presence of a state, never replayable, exactly the line script/names --check draws), --sweep [crate...] applies each patch and requires that one harness to go red, and --affected-since <base> sweeps only what a diff can reach. A report weekly (falsification sweep), a gate per pull request through verify.yml, since a patch a commit staled is a defect in that commit. Refuses to sweep a dirty tree. See notes/falsification.md. |
script/crate-standalone [--no-kani] [--keep] <crate>... |
Would this crate stand on its own outside nife? Copies the crate's tracked files alone to a temporary directory and checks what a crate repository would meet: no path dependency or workspace inheritance, a rust-version, a README, LICENSE-MIT and LICENSE-APACHE, no citation of this tree (§N, milestone N, design/ and notes/ paths, provenance blocks, calef's name, target_os = "nife"), a build and test on stable for the host and its targets, and stock Kani proving every harness while each falsification patch turns its own harness red. Milestone 857 (crates released on their own) makes it a release gate for milestones 813 to 821. Name provisional. |
script/crate-review-packet [--out DIR] [--no-rustdoc] <crate>... |
Prepare the architect's by-hand review of a crate before it leaves nife (condition 4 of §247 (the split begins with basalt holding nife, and procps moves first)). Writes target/crate-review-packets/<crate>.md, never committed: size, public API (rustdoc JSON on the pinned toolchain, grep fallback), unsafe sites, dependencies and where each points, references back into nife (the static findings of script/crate-standalone), Kani harnesses and falsification patches, dependents, INTERFACE_ID/VERSION/MAGIC values and a reviewer checklist. Gathers facts; the judgments stay the reviewer's. Logic in helpers/crate_review_packet.py, checked by helpers/crate-review-packet-selftest.sh. Name provisional. |
What this file's numbers cite
Glossed here by the per-file rule. Each gloss is the record's own title.
- §134 (A harness carries a machine-replayable falsification record, or it is not evidence)
- milestone 64 (Enough
stdto run somebody else's crate) - milestone 84 (Stack high-water: measure kernel stack depth)
- milestone 124 (A thread is born where it lives: the spawn path's copies)
- milestone 208 (The x86_64 kernel image ships an RWX segment, and it is the reason a second ELF reader exists)