Hive Hive
Sign in

fix(graph): materialize arg files from cmd_args

GitHub issue · Closed

Metadata
Source
tuist/once #137
Updated
Jul 5, 2026
Domains
Once
Details

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_file
  • mise exec -- cargo test -p once-cli commands::graph::analysis::actions::tests::materialize_declared_arg_files_writes_line_delimited_args
  • mise exec -- cargo test -p once-frontend analysis::tests::run_action_rejects_line_delimited_arg_file_newlines
  • mise exec -- cargo test -p once-frontend --test prelude prelude_rust_windows_feature_cfgs_use_response_file
  • mise exec -- cargo test -p once-frontend --test prelude
  • mise exec -- cargo test -p once-cli commands::graph::analysis::actions
  • mise exec -- cargo test -p once-frontend analysis::tests::
  • mise exec -- cargo test -p once-frontend
  • mise exec -- cargo test -p once-cli commands::graph::analysis
  • mise exec -- cargo test -p once-cli
  • mise exec -- cargo fmt --all -- --check
  • git diff --check
  • mise exec -- cargo clippy -p once-frontend -p once-cli --all-targets -- -D warnings
Flights

Investigate, reproduce, or fix this item in an isolated repository. Each Flight preserves its outcome and agent session.

New Flights are paused Configure model inference, GitHub, and a sandbox provider to start another Flight. Existing results remain available below.
No Flights yet

Start a Flight and preserve its objective, outcome, and session here.

Comments

No GitHub comments yet.