Skip to content

Decouple runner process execution from Cli (#339)#371

Draft
leynos wants to merge 1 commit into
mainfrom
issue-339-decouple-process-from-cli
Draft

Decouple runner process execution from Cli (#339)#371
leynos wants to merge 1 commit into
mainfrom
issue-339-decouple-process-from-cli

Conversation

@leynos

@leynos leynos commented Jun 12, 2026

Copy link
Copy Markdown
Owner

Summary

Closes #339

The subprocess adapter in src/runner/process/mod.rs accepted &Cli in configure_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: new NinjaProcessOptions (working directory, job count, stderr suppression) — the narrow execution type the issue proposes. configure_ninja_*, NinjaBuildRequest, and NinjaToolRequest consume it; the module no longer imports Cli.
  • src/runner/mod.rs: ninja_process_options(&Cli) performs the CLI-to-process translation at the orchestration boundary; run_ninja/run_ninja_tool keep their public &Cli signatures 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:

  • Introduce a NinjaProcessOptions struct encapsulating working directory, job count, and stderr suppression for invoking Ninja processes.
  • Refactor process-layer Ninja build and tool invocation functions to depend on NinjaProcessOptions instead of the Cli type, removing the parser/config dependency from the subprocess module.
  • Add runner-level helpers that translate Cli into NinjaProcessOptions and delegate to the process-layer Ninja execution functions, preserving existing public CLI-facing APIs.
  • Adjust status-reporting build and tool paths to construct and reuse NinjaProcessOptions when invoking process-layer functions.

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.
@coderabbitai

coderabbitai Bot commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: b06f1bb8-e9fb-425d-be64-f0eafbafb708

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch issue-339-decouple-process-from-cli

Comment @coderabbitai help to get the list of available commands and usage tips.

@sourcery-ai

sourcery-ai Bot commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

Reviewer's Guide

Decouples 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 flow

sequenceDiagram
    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
Loading

File-Level Changes

Change Details Files
Introduce NinjaProcessOptions as the narrow configuration interface for the subprocess layer and remove direct Cli usage from process::run_ninja / run_ninja_tool and related helpers.
  • Add NinjaProcessOptions struct carrying working_dir, jobs, and suppress_stderr flags for ninja invocation.
  • Update configure_ninja_base / configure_ninja_build_command / configure_ninja_tool_command to consume NinjaProcessOptions instead of Cli.
  • Change NinjaBuildRequest and NinjaToolRequest to hold &NinjaProcessOptions and rewrite run_ninja / run_ninja_tool signatures and internal helpers to use options.suppress_stderr instead of cli.resolved_diag_json().
src/runner/process/mod.rs
Perform Cli-to-NinjaProcessOptions translation at the runner orchestration layer and keep existing public runner APIs stable while adapting status-reporting paths.
  • Add ninja_process_options(&Cli) helper that maps Cli.directory, Cli.jobs, and Cli.resolved_diag_json() into NinjaProcessOptions.
  • Introduce new public run_ninja and run_ninja_tool wrappers in runner::mod that accept &Cli, construct NinjaProcessOptions, and delegate to process::run_ninja / run_ninja_tool.
  • Update handle_build and handle_ninja_tool progress-enabled branches to construct NinjaProcessOptions once and pass references via NinjaBuildRequest / NinjaToolRequest instead of &Cli.
src/runner/mod.rs

Assessment against linked issues

Issue Objective Addressed Explanation
#339 src/runner/process/* no longer accepts or depends on &Cli; instead it uses a narrow execution/options type containing only the needed fields.
#339 Perform CLI-to-process translation at the runner orchestration boundary (e.g., in src/runner/mod.rs), mapping Cli into the narrow process options type.
#339 Preserve existing runner behaviour (including stderr suppression semantics) and keep tests/CI passing.

Possibly linked issues


Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@codescene-delta-analysis codescene-delta-analysis Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

See analysis details in CodeScene

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.

Comment thread src/runner/process/mod.rs
//! Internal to `runner`; public API is defined in `runner.rs`.

use super::{BuildTargets, NINJA_PROGRAM};
use crate::cli::Cli;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❌ Getting worse: Code Duplication
introduced similar code in: run_ninja_build_internal,run_ninja_tool_internal

Suppress

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Decouple runner process execution from Cli

1 participant