roadmap

What the review read and ran

An appendix to the milestone.

The crate

partsfoundry/grant_plan at 69aedfbc9adb70d877435c6a62dc4983ef035e0d, version 0.1.0, publish = false. Read in full: Cargo.toml, README.md, CHANGELOG.md, CONTRIBUTING.md, docs/stranger-test.md, the ci and fuzz workflow callers, the two exemption lists under .github/ and examples/plan_a_line.rs. Read as library text, every file under src/: lib.rs, lexing.rs, word.rs, command.rs, escalation.rs, parsing.rs, planning.rs, refusal.rs, line.rs, expansion.rs and navigation.rs. Read in part: the Kani harnesses of word and line, refusal/tests.rs and test_support.rs. The other test files were not read. The review read grant_contract at f84cd7e6 for the names of its public items only. The baseline read: the block of milestone 1094 (what an outside maintainer would fix before it leaves), its prior-art, later-items and ruled-decisions appendices, and the cleared package.

The commands

Run on a Linux x86_64 host with rustc 1.100.0, with the build directory outside the clone.

The probe

A scratch binary that depends on the crate by path, run in a debug and a release build.

call result
Expander::batch(b"*", Resume::Start), ten names offered, then finish() debug: panics on the debug_assert!; release: Ok, a set of 8 names (P0-1)
Expander::new(b"*"), one name offered, then finish_batch() debug: panics; release: Ok, a batch of 1
a batch offered b to h, a 200-byte name, then a; and a set of the same eight names built by try_push the two iterate alike, and == answers false (P1-1)
component(1) on a path one level deep an empty slice
component(depth()) on a path that fills all 512 bytes, and component(600) on any path panics: index out of bounds (P0-5)
descend(b"a/b") on the root, result ignored the path stays at the root (P1-8)
render into a 4-byte buffer returns 4, the text cut short, as documented
Name::new, NameSet::one and Expander matching a*, each on a:b and on a name holding a zero byte all accept it
navigation::path and is_valid_component on the same two names both refuse it (P1-2)
word::read(b"'it's'") PartlyQuoted: no line spells a name that holds both quote characters (D10)
parse(b"--mem 4") Run, with an empty program name and a memory grant of 4 (P2-6)
parse(b"-r count") Run, program count, option r
rm_report::status(-1) 18,446,744,073,709,551,615 (P2-6)
Refusal::ScopeCannotRestore.message() ends "'swish -c', side is reserved and not built yet" (P1-3)

The probe printed these sizes in bytes on the 64-bit host. The planning values: Endowment 4,344, ShellHoldings 3,312, Streams 2,368, Bindings 2,240 and DirectoryGrant 1,080. The parts: Sink 792, FileGrant 784, Expansion 568, NameSet 544, DirectoryPath 528, Resume 254 and Name 253. The parse: CommandLine 184, ParsedInvocation 184, Line 128, Manifest 80 and Refusal 24.

The probe then generated three million lines of up to 39 bytes from a fixed seed. Its alphabet holds letters, white space, both quotes, the operators, the pattern bytes, /, ., -, %, :, a zero byte and --mem. Each line went through word::read, line_verb, check_words, write_argument_page, the four operand classifiers and last_component_has_magic. It went through navigation::path with apply and resolve_path. It went through line::split with parse and plan_against_with_streams, against six manifests and a shell with a mounted tree and a bound name. It planned 206,870 stages and caught no panic, in a debug build and in a release build.

The benchmark

A scratch crate that depends on grant_plan by path, on shlex at =2.0.1 and on brush-parser at =0.5.0. It ran under cargo run --release on a Linux x86_64 host (an Intel Xeon Platinum 8160 at 2.10 GHz) with rustc 1.100.0. The timing loop is the one milestone 1154 (the release review of boot_ladder) describes. Inputs and results pass through std::hint::black_box. The two inputs:

The harness asserts that tokenize with word::read and shlex::bytes::split yield the same twelve words before it times either.

measurement time what it includes
tokenize into 16 slots, word::read on each token 217.0 ns no allocation; the sum of the word lengths
for_each_word 457.7 ns the callback, and one tokenize call for each word
shlex::bytes::Shlex, iterated 482.1 ns a Vec<u8> allocated and freed for each word
shlex::bytes::split 590.6 ns the same, and the outer Vec
parse, which runs parse_invocation 284.9 ns tokens, quotes, options and positionals classified
line::split, then parse on each of three stages 365.4 ns the pipeline line
brush_parser::uncached_tokenize_str, then parse_tokens 5,048.1 ns the pipeline line, to a syntax tree, with default options
brush_parser::uncached_tokenize_str alone 2,751.8 ns the pipeline line, to tokens
parse, then plan_against, for count -v notes.txt 592.3 ns one file grant planned, and the 4,344-byte Endowment returned
a copy of one Endowment 57.3 ns the copy alone

shlex does less than the crate (words only) and brush-parser more (the whole bash grammar), so neither row is a like-for-like rival. No comparator plans a grant, so the last two rows stand alone.

The comparators read

Each .crate file came from crates.io at the version the prior-art table gives, into a directory of its own.

Fourteen crates.io queries, sorted by recent downloads, found no crate that plans a grant from a line: capability shell, shell parser, shell grammar, pipeline redirection parser, no_std shell, command line planner, shell lexer, least authority, pola shell, manifest command line, posix shell, embedded shell, glob expansion and argv no_std.

The system outside Rust

Plash, from https://github.com/mseaborn/plash at commit 1d77bb2fec3d9cdeb3547c42682818c447492bf4, under plash/:

Plash is under the GNU Lesser General Public License; the review read it for its interface shape only.

What was not run