|
| 1 | +// SPDX-License-Identifier: PMPL-1.0-or-later |
| 2 | += impl/rust-cli/src/ — Primary Rust Shell Source |
| 3 | + |
| 4 | +Source tree for the Rust valence-shell binary `vsh` (v0.9.0). Roughly |
| 5 | +32 source files; entry points, REPL machinery, parser, executor, state |
| 6 | +machine, and verification glue. |
| 7 | + |
| 8 | +Tests live in `../tests/`; the FFI library lives in `../../../ffi/rust/` |
| 9 | +(separate crate, not linked from here). |
| 10 | + |
| 11 | +== Files by concern |
| 12 | + |
| 13 | +=== Entry points |
| 14 | + |
| 15 | +[cols="1,3"] |
| 16 | +|=== |
| 17 | +| File | Purpose |
| 18 | +| `main.rs` | Binary entry; argument handling; spawns the REPL. |
| 19 | +| `lib.rs` | Library root; module declarations + public API. |
| 20 | +|=== |
| 21 | + |
| 22 | +=== Parsing |
| 23 | + |
| 24 | +[cols="1,3"] |
| 25 | +|=== |
| 26 | +| File | Purpose |
| 27 | +| `parser.rs` | Tokeniser + command parser; variable expansion; |
| 28 | + parameter expansion (`${VAR:-...}`, etc.); heredoc |
| 29 | + extraction; control-flow recognition. |
| 30 | +| `quotes.rs` | Quote-aware segmentation (single, double, |
| 31 | + backslash); feeds the parser. |
| 32 | +| `glob.rs` | POSIX glob expansion (literal-leading-dot |
| 33 | + discipline) + brace expansion. |
| 34 | +| `arith.rs` | `$((expr))` arithmetic parser + evaluator; |
| 35 | + precedence, bitwise, comparison, logical. |
| 36 | +| `quotes.rs` | Quote-aware tokenisation. |
| 37 | +|=== |
| 38 | + |
| 39 | +=== Execution |
| 40 | + |
| 41 | +[cols="1,3"] |
| 42 | +|=== |
| 43 | +| File | Purpose |
| 44 | +| `commands.rs` | Built-in command dispatch (mkdir, rmdir, undo, |
| 45 | + redo, checkpoint, restore, fg/bg, kill, etc.). |
| 46 | +| `commands/` | Module subtree for larger built-ins |
| 47 | + (`secure_deletion.rs`, ...). |
| 48 | +| `executable.rs` | External-command launch; PATH lookup; shell |
| 49 | + function dispatch. |
| 50 | +| `external.rs` | External-command pipeline construction; |
| 51 | + stdio + redirect wiring. |
| 52 | +| `functions.rs` | Shell function table + frame stack. |
| 53 | +| `redirection.rs` | I/O redirection setup (`>`, `>>`, `<`, `2>`, |
| 54 | + `&>`, `2>&1`). |
| 55 | +| `process_sub.rs` | Process substitution `<(cmd)` / `>(cmd)` via |
| 56 | + FIFO. |
| 57 | +| `posix_builtins.rs` | POSIX-defined builtins (echo, read, source, |
| 58 | + eval, set, unset, true, false, ...). |
| 59 | +| `test_command.rs` | `test` / `[` / `[[ ]]` conditionals. |
| 60 | +|=== |
| 61 | + |
| 62 | +=== State + reversibility |
| 63 | + |
| 64 | +[cols="1,3"] |
| 65 | +|=== |
| 66 | +| File | Purpose |
| 67 | +| `state.rs` | `ShellState`; operation history; undo/redo |
| 68 | + stacks; tracked variables. |
| 69 | +| `history.rs` | Command-history persistence (interactive |
| 70 | + REPL). |
| 71 | +| `audit_log.rs` | Append-only audit log for filesystem ops |
| 72 | + (JSON-line format, integrity check). |
| 73 | +| `secure_erase.rs` | RMO (Remove-Match-Obliterate) primitives; |
| 74 | + currently stubs per `CLAUDE.md`. |
| 75 | +|=== |
| 76 | + |
| 77 | +=== REPL + UX |
| 78 | + |
| 79 | +[cols="1,3"] |
| 80 | +|=== |
| 81 | +| File | Purpose |
| 82 | +| `repl.rs` | Interactive REPL loop. |
| 83 | +| `enhanced_repl.rs` | reedline-backed REPL with history search. |
| 84 | +| `highlighter.rs` | Syntax highlighting for the REPL. |
| 85 | +| `pager.rs` | Output pagination (height-threshold gated). |
| 86 | +| `help.rs` | `help` builtin; per-command documentation. |
| 87 | +| `correction.rs` | zsh-style "Did you mean?" Levenshtein |
| 88 | + suggestions. |
| 89 | +| `friendly_errors.rs` | Human-readable error formatting. |
| 90 | +| `confirmation.rs` | Y/N prompts for destructive ops. |
| 91 | +| `signals.rs` | Signal handling (SIGINT, SIGCHLD). |
| 92 | +|=== |
| 93 | + |
| 94 | +=== Verification + correspondence |
| 95 | + |
| 96 | +[cols="1,3"] |
| 97 | +|=== |
| 98 | +| File | Purpose |
| 99 | +| `proof_refs.rs` | References from runtime ops to formal |
| 100 | + proof artefacts in `../../proofs/`. |
| 101 | +| `verification.rs` | Runtime precondition checks. |
| 102 | +| `echidna_integration.rs` | Property-test registry feeding the |
| 103 | + Echidna validator (workflow gated). |
| 104 | +|=== |
| 105 | + |
| 106 | +=== Job control |
| 107 | + |
| 108 | +[cols="1,3"] |
| 109 | +|=== |
| 110 | +| File | Purpose |
| 111 | +| `job.rs` | `JobTable`; bash-style %N / %+ / %- / %prefix specs. |
| 112 | +|=== |
| 113 | + |
| 114 | +== Conventions used here |
| 115 | + |
| 116 | +* `--safe` Rust: every public function is panic-free at the contract |
| 117 | + layer. The `.expect("TODO: handle error")` anti-pattern was swept |
| 118 | + out in commits `712e3a1..b5cc0cc` (2026-04-19); `cargo audit` and |
| 119 | + `cargo clippy` should remain clean post-sweep. |
| 120 | +* SPDX header on every source file (`PMPL-1.0-or-later`). |
| 121 | +* Tests live in `../tests/`; doctests inline. |
| 122 | + |
| 123 | +== See also |
| 124 | + |
| 125 | +* `../tests/README.adoc` — test-suite breakdown |
| 126 | +* `../../../proofs/` — formal specs |
| 127 | +* `../../../docs/PROOF_HOLES_AUDIT.md` — proof-debt status |
0 commit comments