Separate Ninja generation steps from runner reporting (#343)#374
Conversation
`generate_ninja` mixed query-style generation work (load manifest, build graph, synthesise Ninja text) with reporter side effects, making the conversion path hard to reuse for dry-run or background generation. Introduce `runner::generation` with three pure, composable steps — `load_manifest`, `build_graph`, and `ninja_text` — none of which require a `StatusReporter`. Manifest-stage observation is an optional callback (`StageObserver`), so the pure path simply passes `None`. The runner keeps reporting in thin orchestration wrappers: `generate_ninja` interleaves `report_pipeline_stage` calls between the pure steps (same stage sequence as before), and `load_manifest_with_stage_reporting` builds the reporter-mapping callback via the extracted `stage_reporting_callback`. The graph subcommand now shares `generation::build_graph` instead of duplicating context wrapping. A unit test exercises the composed pure pipeline end to end without any reporter.
|
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 GuideRefactors the Ninja generation pipeline into pure, composable steps in a new generation module, with runner-level reporting layered on top, and updates graph handling and tests to use the shared pipeline. Sequence diagram for generate_ninja with separated generation stepssequenceDiagram
participant Runner
participant Reporter
participant Generation
participant ManifestModule as manifest
participant BuildGraphType as BuildGraph
participant NinjaGen as ninja_gen
Runner->>Reporter: report_pipeline_stage(PipelineStage::IrGenerationValidation)
Runner->>Generation: generate_ninja
activate Generation
Generation->>BuildGraphType: build_graph(&manifest)
deactivate Generation
Runner->>Reporter: report_pipeline_stage(PipelineStage::NinjaSynthesisAndExecution)
Runner->>Generation: ninja_text(&graph)
activate Generation
Generation->>NinjaGen: generate(&graph)
deactivate Generation
Generation-->>Runner: NinjaContent
Flow diagram for manifest loading and reporting separationflowchart TD
A[load_manifest_with_stage_reporting]
B[stage_reporting_callback]
C[report_pipeline_stage]
D[generation::load_manifest]
E[manifest::from_path_with_policy]
A --> B
B --> C
A --> D
D --> E
File-Level Changes
Assessment against linked issues
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Summary
Closes #343
Splits generation into composable query-style steps with reporting kept in a thin runner wrapper, as proposed.
Changes
src/runner/generation.rs(new): pure stepsload_manifest(with an optionalStageObservercallback),build_graph, andninja_text— noStatusReporteranywhere; localised error contexts preserved.src/runner/mod.rs:generate_ninjanow interleavesreport_pipeline_stagecalls between the pure steps (identical stage sequence);stage_reporting_callbackmaps manifest stages to reporter updates;load_manifest_with_stage_reportingbecomes a thin wrapper.src/runner/graph.rs: sharesgeneration::build_graphinstead of duplicating context wrapping.Testing
generation_steps_run_without_reporterunit test composes the pure pipeline end to end (manifest file → graph → Ninja text) with no reporter.Validation
make check-fmt/make lint/make test— pass (37 suites)🤖 Generated with Claude Code
Summary by Sourcery
Extract Ninja generation into pure, composable steps and keep status reporting in a thin runner wrapper.
Enhancements:
Tests: