Skip to content

Pipeline Plan 13

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

The plan is complete. Here's the implementation plan for pipeline dry-run mode:


Implementation Plan: Pipeline Dry-Run Mode for CI Validation

Summary

Add a comprehensive --dry-run mode to shipwright pipeline start that validates the full pipeline configuration, shows what stages would execute, displays per-stage model routing and estimated cost, and exits with code 0 (valid) or non-zero (broken config). The existing --dry-run flag and DRY_RUN variable already exist (line 158, 303 of sw-pipeline.sh) but the current stub at line 5630 just prints "Dry run — no stages will execute" and returns — this plan replaces that with real logic.

Architecture Decision

Inline in sw-pipeline.sh rather than a separate module. The dry-run logic needs access to $PIPELINE_CONFIG, stage iteration, $COST_MODEL_RATES, and model routing — all already in scope. ~150 lines added.

Files to Modify

File Action Purpose
scripts/sw-pipeline.sh Modify Add dry_run_report() function; replace stub at line 5630; guard initialize_state
scripts/sw-pipeline-test.sh Modify Expand existing test_dry_run + add 4 new dry-run test cases

Implementation Steps

Step 1: Add dry_run_report() function (~line 5453)

  • Iterate all stages from $PIPELINE_CONFIG using jq
  • For each: show ID, enabled/disabled, gate type, model (from .config.model // defaults.model // $MODEL), stage-specific config
  • Validate: JSON parse, recognized stage IDs, stage ordering
  • Estimate cost per stage using $COST_MODEL_RATES + token heuristics (plan ~15K, build ~25K/iteration, etc.)
  • Return 0 if valid, 1 if broken

Step 2: Replace dry-run stub (line 5630)

# Before:
if [[ "$DRY_RUN" == "true" ]]; then
    info "Dry run — no stages will execute"
    return 0
fi

# After:
if [[ "$DRY_RUN" == "true" ]]; then
    dry_run_report
    return $?
fi

Step 3: Guard side effects in pipeline_start()

  • Wrap initialize_state and existing-pipeline check with if [[ "$DRY_RUN" != "true" ]]
  • Skip CI resume branch context restoration in dry-run mode
  • Keep preflight_checks, gh_init, load_pipeline_config (non-destructive, needed for display)

Step 4: Add 5 test cases to sw-pipeline-test.sh

  1. test_dry_run (modify existing): Assert "Stage Plan", "Cost Estimate", "Dry run passed"
  2. test_dry_run_shows_all_stages: Autonomous template → all 12 stage IDs in output
  3. test_dry_run_shows_cost_estimate: Dollar amounts present
  4. test_dry_run_invalid_config: Broken JSON → non-zero exit
  5. test_dry_run_no_side_effects: No state file, no artifacts, no branches

Task Checklist

  • Task 1: Add dry_run_report() function with stage iteration and formatted output
  • Task 2: Add config validation logic (JSON parse, stage IDs, ordering)
  • Task 3: Add per-stage cost estimation using $COST_MODEL_RATES and token heuristics
  • Task 4: Replace dry-run stub at line 5630 with call to dry_run_report
  • Task 5: Guard initialize_state and pipeline existence check with DRY_RUN != true
  • Task 6: Update existing test_dry_run test to verify new output format
  • Task 7: Add test_dry_run_shows_all_stages test case
  • Task 8: Add test_dry_run_shows_cost_estimate test case
  • Task 9: Add test_dry_run_invalid_config test case (broken JSON → non-zero exit)
  • Task 10: Add test_dry_run_no_side_effects test case
  • Task 11: Run full test suite (npm test) and fix any regressions

Testing Approach

  1. Unit-level: Each test runs real sw-pipeline.sh as subprocess with mock environment
  2. Negative testing: Malformed JSON → validates non-zero exit
  3. Side-effect testing: No state files, artifacts, or branches created
  4. Full regression: npm test (all 22 suites)

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
  • No side effects (no state writes, no branches, no API calls)
  • 5 dry-run tests passing + all 22 existing suites pass
  • Bash 3.2 compatible

Clone this wiki locally