Hive
fix(graph): materialize arg files from cmd_args
GitHub issue · Closed
What changed
This moves generated response-file handling into the graph action layer instead of leaving each target kind to hand-write files and keep them synchronized with argv.
- Added
cmd_args(args, use_arg_file = ...)as a structured Starlark command-line fragment. - Extended declared actions with generated argument-file metadata that the Rust executor materializes before running the action.
- Included generated argument-file metadata in the declared action digest so cache keys change when the generated arguments change.
- Switched the Rust target kind to pass Windows rustc feature flags through
cmd_args(..., use_arg_file = { "format": "line-delimited" }). - Updated the Starlark module reference and tests for the new command-line contract.
Why
The Windows release failure showed that response-file formatting is easy to get subtly wrong when each rule writes file contents directly. The rule author should state the command-line intent, while the Rust layer should own validation, materialization, and cache-key behavior for generated argument files.
Root cause
rustc reads @path files as line-oriented argument files. Each line becomes one argument without shell parsing. Escaping the embedded quotes produced arguments like feature=\"alloc\", and rustc rejected the preserved backslashes.
Approach
The new cmd_args fragment keeps the command-line pointer and generated file contents together. run_action flattens strings and cmd_args values, records generated argument files on the declared action, and the executor writes them as line-delimited files before lowering the action.
For line-delimited files, the Rust parser rejects arguments containing newline characters. The executor repeats that validation when materializing serialized declared actions. That makes the response-file format a graph primitive rather than a Rust-prelude convention.
Impact
Existing run_action(argv = ["tool", "arg"]) calls continue to work. Rule authors can now use a structured command-line fragment when a tool needs an argument file, without manually adding a separate write_path action or listing the generated file as a normal input.
For the current Rust release issue, Windows rustc feature flags still use a response file to avoid long command lines, but the file now contains literal arguments such as feature="alloc", which matches rustc’s expected format.
Validation
mise exec -- cargo test -p once-frontend analysis::tests::run_action_flattens_cmd_args_with_arg_filemise exec -- cargo test -p once-cli commands::graph::analysis::actions::tests::materialize_declared_arg_files_writes_line_delimited_argsmise exec -- cargo test -p once-frontend analysis::tests::run_action_rejects_line_delimited_arg_file_newlinesmise exec -- cargo test -p once-frontend --test prelude prelude_rust_windows_feature_cfgs_use_response_filemise exec -- cargo test -p once-frontend --test preludemise exec -- cargo test -p once-cli commands::graph::analysis::actionsmise exec -- cargo test -p once-frontend analysis::tests::mise exec -- cargo test -p once-frontendmise exec -- cargo test -p once-cli commands::graph::analysismise exec -- cargo test -p once-climise exec -- cargo fmt --all -- --checkgit diff --checkmise exec -- cargo clippy -p once-frontend -p once-cli --all-targets -- -D warnings
Investigate, reproduce, or fix this item in an isolated repository. Each Flight preserves its outcome and agent session.
Start a Flight and preserve its objective, outcome, and session here.
No GitHub comments yet.