fix(coreutils-port): accept let-bound Command chain in uu_app validator#1624
Open
chaliy wants to merge 1 commit into
Open
fix(coreutils-port): accept let-bound Command chain in uu_app validator#1624chaliy wants to merge 1 commit into
chaliy wants to merge 1 commit into
Conversation
Upstream uutils refactored truncate's uu_app() to `let cmd = Command::new(...); configure_localized_command(cmd).arg(...)...`. The Rewriter folds the wrapper call to `cmd`, leaving a two-statement `let <ident> = <chain>; <ident>.<method>(...)` body — which the strict single-expression validator was rejecting, breaking the weekly Coreutils Args Drift workflow on every regen. Decompose `validate_uu_app_body` into `validate_command_chain_expr` and a new `validate_let_bound_command_body` that requires a simple `let <ident>` pattern, a Command::new-rooted initializer, and a tail method-chain whose innermost receiver is exactly the let-bound identifier. Both branches share the existing `UuAppExprValidator` (disallowed methods, closures, macros, blocks) so TM-INF-025's trust boundary is unchanged. New regression tests cover the happy path (with the real `configure_localized_command` wrapper the Rewriter strips), a non-command initializer, a tail not chained off the binding, and a 3-statement body. Verified by regenerating all 11 ported utils against the pinned rev (byte-identical to repo after cargo fmt) and against upstream HEAD (truncate now regenerates cleanly). Specs: updated coreutils-args-port.md and threat-model.md TM-INF-025 to document the broadened accepted shapes and new regression tests.
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
bashkit | 92d6ab6 | Commit Preview URL Branch Preview URL |
May 11 2026, 09:34 AM |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Extend the args-mode
uu_app()validator inbashkit-coreutils-portto accept the safe two-statement shapein addition to the existing single tail-expression shape.
Why
The weekly Coreutils Args Drift workflow is currently red: upstream uutils refactored
truncate'suu_app()intoThe
Rewriteralready foldsconfigure_localized_command(cmd)to justcmd, leaving a cleanlet+ tail-chain body. The strict single-expression validator (added under TM-INF-025) rejected that shape, so the codegen aborts with:This pattern is structurally just a chain split across a binding — no executable side effect — and is the natural way upstream is going to keep writing
uu_app(). Permanently rejecting it would mean every drift run fails until someone hand-edits.How
validate_uu_app_bodyintovalidate_command_chain_expr(shared) and a newvalidate_let_bound_command_body.let <ident>pattern (no destructuring, nolet-else, no attrs/ref/subpat),Command::new),Command::newor unrelated expression.UuAppExprValidatorvisitor, so the TM-INF-025 trust boundary on closures, macros, blocks, async/unsafe, loops/matches, and side-effecting methods (spawn/status/unwrap/...) is unchanged.Tests
Five new tests in
crates/bashkit-coreutils-port/src/args.rs:accepts_let_bound_command_with_tail_chainconfigure_localized_command(cmd)wrapper — Rewriter folds it, validator accepts the result, generated body usescmd.arg(...).rejects_let_with_non_command_initializerlet cmd = std::process::Command::new(...).status().unwrap();fails codegen.rejects_tail_not_chained_off_let_bindinglet cmd = Command::new(...); Command::new(...).arg(...)fails (tail must chain on the binding).rejects_three_statement_bodylet cmd = ...; std::process::abort(); cmd.arg(...)fails (only 2 stmts allowed).rejects_executable_statements_in_uu_app,rejects_non_clap_command_root_chain,rejects_unexpected_macro_in_builder_chainEnd-to-end verification:
cat,ls,mktemp,od,readlink,realpath,shuf,stat,tac,tee,truncate) against the pinned rev39364b6— byte-identical to repo aftercargo fmt.truncateagainst current uutilsHEAD(where the multi-stmt body lives) — now produces a valid file instead of aborting.Specs
specs/coreutils-args-port.md— documents the two accepted body shapes.specs/threat-model.mdTM-INF-025 — updated to describe both shapes and lists all four positive/negative regression tests.Risk
Generated by Claude Code