Decouple runner process execution from Cli (#339)#371
Conversation
The low-level subprocess adapter in `runner::process` accepted `&Cli` through command construction and its request structs, coupling it to the parser/config domain type and making reuse and testing harder. Introduce `NinjaProcessOptions` — the narrow execution type carrying only what the process layer needs (working directory, job count, and the stderr-suppression flag) — and translate from `Cli` once at the orchestration boundary via `runner::ninja_process_options`. The public `run_ninja`/`run_ninja_tool` entry points keep their `&Cli` signatures but now live in `runner::mod` as thin translating wrappers, so existing callers and tests are unchanged. `runner::process` no longer imports `Cli` at all; making the stderr flag a named policy type is tracked separately in #340.
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
Reviewer's GuideDecouples the runner subprocess layer from the Cli type by introducing a narrow NinjaProcessOptions struct and performing Cli-to-process translation at the runner orchestration boundary, keeping public runner APIs unchanged while updating internal request/command configuration plumbing. Sequence diagram for run_ninja decoupled call flowsequenceDiagram
participant Caller
participant runner as runner
participant process as process
participant cmd as Command
Caller->>runner: run_ninja(program, cli, build_file, targets)
runner->>runner: ninja_process_options(cli)
runner->>process: run_ninja(program, options, build_file, targets)
process->>cmd: configure_ninja_build_command(cmd, options, build_file, targets)
process->>process: run_command_and_stream(cmd, status_observer, options.suppress_stderr)
process-->>runner: io::Result
runner-->>Caller: io::Result
File-Level Changes
Assessment against linked issues
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Gates Failed
Enforce advisory code health rules
(1 file with Code Duplication)
Our agent can fix these. Install it.
Gates Passed
5 Quality Gates Passed
Reason for failure
| Enforce advisory code health rules | Violations | Code Health Impact | |
|---|---|---|---|
| mod.rs | 1 advisory rule | 9.39 → 9.10 | Suppress |
Quality Gate Profile: Pay Down Tech Debt
Install CodeScene MCP: safeguard and uplift AI-generated code. Catch issues early with our IDE extension and CLI tool.
| //! Internal to `runner`; public API is defined in `runner.rs`. | ||
|
|
||
| use super::{BuildTargets, NINJA_PROGRAM}; | ||
| use crate::cli::Cli; |
There was a problem hiding this comment.
❌ Getting worse: Code Duplication
introduced similar code in: run_ninja_build_internal,run_ninja_tool_internal
Summary
Closes #339
The subprocess adapter in
src/runner/process/mod.rsaccepted&Cliinconfigure_ninja_base, both request structs, and the public entry points, coupling the process layer to the parser/config domain type.Changes
src/runner/process/mod.rs: newNinjaProcessOptions(working directory, job count, stderr suppression) — the narrow execution type the issue proposes.configure_ninja_*,NinjaBuildRequest, andNinjaToolRequestconsume it; the module no longer importsCli.src/runner/mod.rs:ninja_process_options(&Cli)performs the CLI-to-process translation at the orchestration boundary;run_ninja/run_ninja_toolkeep their public&Clisignatures as thin wrappers, so existing behaviour, callers, and tests are unchanged.Replacing the boolean stderr flag with an explicit policy type is #340, designed together with this change and stacked on it.
Validation
make check-fmt/make lint/make test— pass (37 suites; runner behaviour covered by existing tests, unchanged)🤖 Generated with Claude Code
Summary by Sourcery
Decouple the runner subprocess adapter from the CLI type by introducing a narrow Ninja process options struct and translating CLI state at the runner boundary.
Enhancements: