Skip to content

Pipeline Plan 13

Seth Ford edited this page Feb 12, 2026 · 2 revisions

The plan file write requires permission. Here's the complete implementation plan:


Implementation Plan: Pipeline Dry-Run Mode for CI Validation

Summary

Enhance the existing --dry-run flag in sw-pipeline.sh to produce detailed output (stage plan, per-stage model routing, estimated iterations, estimated cost) and validate config/template integrity. Currently the dry-run exit (line 5636-5639) only prints "Dry run — no stages will execute" and returns 0. The enhancement adds a print_dry_run_summary() function that walks the loaded pipeline config and produces a structured report.

Files to Modify

File Action Purpose
scripts/sw-pipeline.sh Modify Add print_dry_run_summary() function; wire into dry-run exit block
scripts/sw-pipeline-test.sh Modify Expand test_dry_run() + add 3 new tests

Implementation Steps

Step 1 — Add print_dry_run_summary() function to sw-pipeline.sh (~line 415, after cost tracking vars). It:

  • Reads the already-loaded $PIPELINE_CONFIG JSON
  • Iterates stages via jq -c '.stages[]' printing a table: stage ID, enabled/disabled, gate type, model (per-stage override or pipeline default), stage config highlights (max_iterations, coverage_min, etc.)
  • Computes estimated cost using token heuristics per stage type and model rates from $COST_MODEL_RATES (line 393)
  • Validates config: no enabled stages → error exit 1; invalid JSON → error exit 1; build without test → warning
  • Prints summary footer with total enabled stages, estimated cost, "Config valid/invalid"

Step 2 — Replace the dry-run exit block (lines 5636-5639) to call print_dry_run_summary and return its exit code

Step 3 — Expand existing test_dry_run() (line 742) to also assert output contains stage details, model info, "Estimated cost", and "Config valid"

Step 4 — Add test_dry_run_shows_stage_details() with custom template (build max_iterations=10, test coverage_min=80), asserting those values appear in output

Step 5 — Add test_dry_run_cost_estimation() asserting output contains dollar cost estimate

Step 6 — Add test_dry_run_invalid_config() with all-disabled template, asserting exit code 1 and error message

Step 7 — Register 3 new test functions in the tests=() array (line 823)

Task Checklist

  • Task 1: Add print_dry_run_summary() function with stage table output
  • Task 2: Add per-stage cost estimation using token heuristics + model rates
  • Task 3: Add config validation checks (no enabled stages, invalid JSON)
  • Task 4: Wire print_dry_run_summary() into dry-run exit block
  • Task 5: Expand existing test_dry_run() with new assertions
  • Task 6: Add test_dry_run_shows_stage_details() test
  • Task 7: Add test_dry_run_cost_estimation() test
  • Task 8: Add test_dry_run_invalid_config() test (exit code 1)
  • Task 9: Register new tests in tests=() array
  • Task 10: Run ./scripts/sw-pipeline-test.sh — all 18 tests pass

Testing Approach

  1. Each new test uses existing mock environment and invokes the real pipeline script (no logic reimplementation)
  2. Existing test_dry_run is expanded, not replaced — backwards compatibility preserved
  3. Negative test creates deliberately broken template → verifies non-zero exit
  4. Full suite run ensures no regressions in the other 14 tests

Definition of Done

  • shipwright pipeline start --issue N --dry-run prints stage plan without executing
  • Shows: stages, models per stage, estimated iterations, estimated cost
  • Validates: config loading, template selection, stage ordering
  • Exit code 0 if valid, non-zero if config is broken
  • All 18 pipeline tests pass (15 existing + 3 new)
  • Bash 3.2 compatible, follows project conventions

Clone this wiki locally