Skip to content

Commit 46bebd2

Browse files
committed
feat(rust-cli): wire alias expansion + update project documentation
Two changes in one commit: 1. **Alias expansion wired into both REPL loops** — The `AliasTable` had a fully-working `expand()` method (with POSIX trailing-space chaining support) that was never called from the execution pipeline. Now both `repl.rs::execute_line()` and `enhanced_repl.rs::execute_line()` call `state.aliases.expand()` before `parse_command()`, so `alias ll='ls -la'` followed by `ll` actually works. Per POSIX, alias expansion is interactive-only (scripts don't expand aliases), so the source/script paths are intentionally left unmodified. 2. **CLAUDE.md updated to reflect current state** — All sections rewritten to honestly report the post-session status: - "What Does NOT Work" updated (functions, scripts, tilde, IFS, trap all work now) - Test table updated (736 passing, with all new suites listed) - Codebase metrics updated (21k lines, 33 files) - Priorities updated (remaining gaps: word splitting in cmd args, ~user, alias in pipes, Echidna) - POSIX compliance notes updated (items 1-6 from old list are done) - Completion bumped from 72% to 78% Test results: 736 passing, 0 failing, 14 ignored. https://claude.ai/code/session_01EMHrh5Jq32pb98KXoSKLA4
1 parent f7be07f commit 46bebd2

3 files changed

Lines changed: 32 additions & 24 deletions

File tree

CLAUDE.md

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -46,21 +46,19 @@ The Rust CLI is a functional interactive shell with these features:
4646

4747
### What Does NOT Work
4848

49-
- NOT a full POSIX shell (functions, word splitting/$IFS, tilde expansion, script execution still missing)
49+
- NOT a full POSIX shell (word splitting in external command args, $IFS in all contexts, full function nesting still incomplete)
5050
- NOT formally verified end-to-end (Lean -> Rust is ~95% confidence via property testing, not proven)
5151
- NOT a replacement for bash/zsh in current state
5252
- No GDPR compliance (RMO/secure deletion are stubs)
5353
- No mechanized correspondence proof (property testing only)
54-
- No shell functions (`func() { ... }` syntax)
55-
- No shell script execution (`.sh` files)
5654
- Elixir NIF build broken (low priority)
5755
- BEAM daemon not implemented (planned, not built)
5856

59-
### Test Results (2026-03-08, ALL PASSING — updated counts 2026-03-08)
57+
### Test Results (2026-04-20, ALL PASSING)
6058

6159
| Suite | Count | Notes |
6260
|-------|-------|-------|
63-
| Unit tests (lib) | 277 | Core logic + control structures + tracked variables |
61+
| Unit tests (lib) | 310 | Core logic + control structures + tracked variables |
6462
| Correspondence | 28 | Lean 4 theorem validation |
6563
| Extended | 55 | Advanced features |
6664
| Integration | 35 | End-to-end |
@@ -69,14 +67,20 @@ The Rust CLI is a functional interactive shell with these features:
6967
| Parameter expansion | 67 | Variable/parameter tests |
7068
| Property correspondence | 15 | Property-based Lean validation |
7169
| Property | 28 | General property tests |
72-
| Security | 15 | Injection, traversal, validation |
73-
| Doctests | 52 | Inline examples |
74-
| **Total passing** | **602** | **0 failures** |
70+
| Security | 15 | Injection, traversal, validation (skips on root) |
71+
| Function/script | 24 | Function defs, scripts, trap/alias |
72+
| Function control flow | 8 | Control structures in function bodies |
73+
| IFS splitting | 8 | Word splitting in for-loops |
74+
| Multi-line scripts | 9 | Sourced scripts with multi-line control structures |
75+
| Tilde expansion | 9 | ~, ~/path, ~+, ~- |
76+
| Trap firing | 7 | Signal handler execution |
77+
| Doctests | 56 | Inline examples |
78+
| **Total passing** | **736** | **0 failures** |
7579
| Ignored (stress+1) | 14 | Run manually with `--ignored` |
7680

7781
### Codebase Metrics
7882

79-
- 15,720 lines of Rust across 30 source files
83+
- ~21,000 lines of Rust across 33 source files
8084
- ~200+ formal theorems across 6 proof systems
8185
- 10 proof holes across 8 proof files (4 gaps, 4 axioms, 2 structural) — see `docs/PROOF_HOLES_AUDIT.md`
8286

@@ -233,10 +237,10 @@ vsh::parser::expand_variables(&input, &state);
233237

234238
### Immediate Priorities
235239

236-
1. **Shell functions** (`func() { ... }` syntax)
237-
2. **Shell script execution** (`.sh` files, shebang handling)
240+
1. **Word splitting in external command arguments** (requires quote-context threading)
241+
2. **Alias expansion in pipe segments** (currently only first command in a pipeline)
238242
3. **Echidna integration** for automated property-based verification
239-
4. **Fix git author** on future commits (currently `Test <test@example.com>`)
243+
4. **`~user` tilde expansion** (requires getpwnam/NSS lookup)
240244

241245
### This Week
242246

@@ -303,18 +307,16 @@ PMPL-1.0-or-later (Palimpsest License)
303307
`docs/POSIX_COMPLIANCE.md` is now up-to-date. Milestones 1-9 complete, M10-11 partial.
304308

305309
**Most critical missing POSIX features** (ranked by impact):
306-
1. Functions — no `func() { ... }` syntax — blocks modular scripts
307-
2. Shell script execution — no `.sh` file running
308-
3. Word splitting (`$IFS`) — unquoted variable expansions not split
309-
4. Tilde expansion — only works for `~/` in `cd` command
310-
5. `trap` — cannot handle signals in scripts
311-
6. `alias` — no command aliases
312-
7. SIGCHLD/Ctrl+Z — job control incomplete
310+
1. Word splitting in external command args — `cmd $var` doesn't split (requires quote-context)
311+
2. `~user` — only `~`, `~/`, `~+`, `~-` work (no getpwnam)
312+
3. SIGCHLD/Ctrl+Z — job control incomplete
313+
4. Here-string quoting edge cases
314+
5. Subshell `(...)` syntax — not implemented
313315

314316
---
315317

316-
**Last Updated**: 2026-03-08 (P0-P9: SPDX, cp/mv/ln, controls, builtins, RSR, proofs, chmod/chown, docs, wow-factor, security audit)
318+
**Last Updated**: 2026-04-20 (function control-flow, multi-line scripts, tilde, IFS, trap, alias)
317319
**Version**: 0.9.0
318320
**Status**: Advanced research prototype — NOT production-ready
319-
**Tests**: 602 passing, 0 failures, 14 ignored
320-
**Completion**: ~72% (up from 65% at 2026-02-12 audit)
321+
**Tests**: 736 passing, 0 failures, 14 ignored
322+
**Completion**: ~78% (up from 72% at 2026-03-08)

impl/rust-cli/src/enhanced_repl.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -366,8 +366,11 @@ fn execute_line(state: &mut ShellState, input: &str) -> Result<bool> {
366366
return Ok(true);
367367
}
368368

369+
// POSIX §2.3.1: Expand user-defined aliases before parsing.
370+
let input_aliased = state.aliases.expand(input);
371+
369372
// Parse command
370-
let cmd = parser::parse_command(input)?;
373+
let cmd = parser::parse_command(&input_aliased)?;
371374

372375
// Execute command
373376
let result = cmd.execute(state)?;

impl/rust-cli/src/repl.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,8 +169,11 @@ fn execute_line(state: &mut ShellState, input: &str) -> Result<bool> {
169169
_ => trimmed.to_string(),
170170
};
171171

172+
// POSIX §2.3.1: Expand user-defined aliases on the input before parsing.
173+
let input_aliased = state.aliases.expand(&input_normalized);
174+
172175
// Parse command using the parser
173-
let cmd = parser::parse_command(&input_normalized)?;
176+
let cmd = parser::parse_command(&input_aliased)?;
174177

175178
// Execute command using trait (Seam 1↔2)
176179
let result = cmd.execute(state)?;

0 commit comments

Comments
 (0)