Skip to content

feat(#404): parallel execution as default mode for multi-issue runs - #419

Merged
admarble merged 5 commits into
mainfrom
feature/404-default-execution-mode-is-serial-despite-being-lab
Mar 25, 2026
Merged

admarble merged 5 commits into
mainfrom
feature/404-default-execution-mode-is-serial-despite-being-lab

Conversation

@admarble

Copy link
Copy Markdown
Contributor

Summary

  • Replace serial for...of loop with Promise.allSettled + p-limit for concurrent issue execution in default (non-sequential) mode
  • Add --concurrency <n> CLI flag (default: 3) to control max concurrent issues
  • Refactor LogWriter to support concurrent issue tracking via Map<number, IssueLog> instead of single currentIssue slot
  • Add real-time progress indicator showing per-issue status during parallel execution
  • Remove unused forceParallel field from ExecutionConfig (replaced by concurrency)

Pre-PR AC Verification

AC Source Description Status Evidence
AC-1 Original Default mode runs concurrently ✅ Implemented run.ts parallel block with Promise.allSettled + p-limit
AC-2 Original Concurrency limit configurable ✅ Implemented --concurrency in CLI, RunOptions, ExecutionConfig, RunSettings
AC-3 Original Output isolation ✅ Implemented Buffered output per-issue (each completes before next renders)
AC-4 Original Failure isolation ✅ Implemented Promise.allSettled ensures all issues run regardless of failures
AC-5 Original --sequential unchanged ✅ Unchanged Sequential code path untouched
AC-6 Original Progress indication ✅ Implemented Real-time status line: #100 ✓ #101 ⏳ #102 ⏳
AC-7 Original Graceful shutdown ✅ Implemented Shutdown check before each issue starts in limiter
AC-8 Original Log writer concurrent handling ✅ Implemented Map-based tracking with issue-specific logPhase/setPRInfo/completeIssue
AC-9 Derived Invalid concurrency validation ✅ Implemented Rejects 0, negative, non-integer values
AC-10 Derived Remove unused forceParallel ✅ Implemented Replaced with concurrency field

Test plan

  • 13 unit tests pass (__tests__/parallel-execution.test.ts)
  • 9 integration tests pass (__tests__/integration/parallel-execution.integration.test.ts)
  • 41 existing log-writer tests pass (updated for new error messages)
  • 120 existing run.test.ts tests pass (updated forceParallel → concurrency)
  • npm run build passes
  • npm run lint passes
  • Manual test: sequant run <issues> runs concurrently
  • Manual test: sequant run <issues> --concurrency 1 runs serially
  • Manual test: sequant run <issues> --sequential stops on failure

Closes #404

🤖 Generated with Claude Code

Replace the serial for...of loop with Promise.allSettled + p-limit for
concurrent issue execution. Issues now run in parallel by default with
configurable concurrency (--concurrency N, default: 3).

Key changes:
- Add p-limit dependency for concurrency limiting
- Add --concurrency CLI flag, RunOptions/ExecutionConfig/RunSettings fields
- Refactor LogWriter to Map-based concurrent issue tracking
- Add real-time progress indicator for parallel execution
- Remove unused forceParallel from ExecutionConfig
- Validate concurrency values (must be positive integer)
- Add unit and integration tests (22 tests)

Closes #404

Entire-Checkpoint: 55f951e8c3c4
…wn gaps

AC-3 (Output isolation): Suppress PhaseSpinner creation and per-issue
console output when running in parallel mode. Each concurrent issue now
uses a no-op logger instead of console.log, preventing multiple ora
spinners from competing for stdout. The updateProgress status line in
run.ts remains the sole terminal output source during parallel execution.

AC-7 (Graceful shutdown): Replace ShutdownManager's single
abortController slot with Set<AbortController>. Each concurrent
executePhase call registers its own controller via addAbortController
and removes it via removeAbortController on completion. On SIGINT, all
registered controllers are aborted — not just the last one registered.

Adds 5 new tests for concurrent abort controller management and
parallel config flag.
- Print per-issue completion line with timing and error detail as each
  issue finishes in parallel mode (e.g., "✓ Issue #100 completed (1m 23s)")
- Support non-TTY environments: completion lines use console.log instead
  of \r overwrite, so CI/piped output gets progress visibility
- Fix issueNumber: 0 fallback in rejected-promise handler — use array
  index to map back to the correct issue number
Covers usage, configuration, execution modes, troubleshooting,
and non-TTY behavior for the new concurrent issue execution.
@admarble
admarble force-pushed the feature/404-default-execution-mode-is-serial-despite-being-lab branch from 2c8fa96 to 5305cd2 Compare March 25, 2026 00:41
@admarble
admarble merged commit e86ebbe into main Mar 25, 2026
5 checks passed
@admarble
admarble deleted the feature/404-default-execution-mode-is-serial-despite-being-lab branch March 25, 2026 00:44
admarble added a commit that referenced this pull request Jul 30, 2026
The post-run SUMMARY header duration was `results.reduce((s, r) => s + r.durationSeconds)`. That was wall clock only while `sequant run` executed issues serially; #419 replaced the loop with `Promise.allSettled` + `p-limit` (default concurrency 3) and left the summation untouched, so every multi-issue run since has over-reported by ~the concurrency factor — a 36m 18s run printed `1h 12m`. The stored log was always correct (`finalizeRunLog` uses `(end - start)/1000`), so `sequant logs` and the live summary disagreed by ~2x about the same run.

The orchestrator — the only component that brackets the whole run — now captures a single `runStartedAt` origin before any service or log setup (so it holds under `--no-log` and when log init fails) and computes the run wall clock once. Every consumer derives from that one value: the printed summary via a new `RunResult.wallClockDurationSeconds`, the metrics record, and the run log via a threaded `startTime`, so `sequant logs --last 1` and the SUMMARY header report the same number.

Sibling recompute sites carrying the identical double-count are fixed alongside: `recordMetrics` (the stored metrics duration) and, in the CI-integration module, `formatMultiOutputs` (the GitHub Actions `duration` output) and `formatSummary` (the step summary's Total duration) — the latter two now take the run wall clock as a required argument, since the per-issue durations they receive cannot express it.

No historical log data is affected. A concurrency-1 run is unchanged, since sum and wall clock coincide there.

Mutation-verified (AC-8), results as observed: restoring the `reduce` in `run-display.ts` fails exactly the gate test (`expected 3600 to be 1200`); restoring it in `formatMultiOutputs` and in `formatSummary` each fails exactly one test; breaking the orchestrator's `wallClock()` fails all 3 producer tests. The AC-4 sequential test stays green throughout.

Closes #867
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.

Default execution mode is serial despite being labeled parallel

1 participant