Skip to content

feat(#503): extract RunOrchestrator — decouple execution engine from CLI - #510

Merged
admarble merged 3 commits into
mainfrom
feature/503-arch-extract-runorchestrator-decouple-execution-en
Apr 9, 2026
Merged

admarble merged 3 commits into
mainfrom
feature/503-arch-extract-runorchestrator-decouple-execution-en

Conversation

@admarble

@admarble admarble commented Apr 8, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Extract RunOrchestrator class (src/lib/workflow/run-orchestrator.ts) to own the full execution lifecycle: config resolution → issue discovery → batch/chain/sequential dispatch → worktree management → result aggregation
  • Extract ConfigResolver class (src/lib/workflow/config-resolver.ts) for 4-layer config merge (defaults < settings < env < explicit) with type coercion
  • Reduce src/commands/run.ts from 661 to 184 lines — thin CLI adapter that parses flags, delegates to RunOrchestrator.run(), and displays results
  • Add backward-compatible re-exports in src/commands/run-compat.ts
  • Export RunOrchestrator, ConfigResolver, and related types from package entry point for programmatic use

AC Verification

AC Description Status Evidence
AC-1 RunOrchestrator owns full execution lifecycle ✅ run-orchestrator.ts — batch/sequential/chain dispatch
AC-2 run.ts becomes thin adapter (< 200 lines) ✅ 184 lines (wc -l)
AC-3 No Commander.js types in orchestrator ✅ 0 commander imports in source
AC-4 Importable without CLI context ✅ Exported from src/index.ts
AC-5 ConfigResolver extracted with unit tests ✅ 24 tests in config-resolver.test.ts
AC-6 Existing tests pass + new tests ✅ 53 new + 69 existing all pass
AC-7 normalizeCommanderOptions reduced ✅ Thin adapter at CLI boundary only
AC-8 Config validation rejects missing fields ✅ 3 validation tests
AC-9 No process.exit in orchestrator ✅ Source check + spy tests
AC-10 Boolean negation flags tested ✅ 7 tests for --no-mcp/--no-retry

Test plan

  • npm run build — passes
  • npm run lint — passes (0 errors, 0 warnings)
  • 53 new tests pass (config-resolver, run-orchestrator, integration)
  • 69 existing tests pass (parallel-execution, error-capture, mcp-run-async)
  • run.ts line count verified < 200

Closes #503

🤖 Generated with Claude Code

… CLI

Separate the execution engine from CLI wiring by extracting RunOrchestrator
and ConfigResolver classes. run.ts reduced from 661 to 184 lines as a thin
CLI adapter that delegates to RunOrchestrator.run().

- RunOrchestrator owns full lifecycle: config → dispatch → results (AC-1)
- run.ts is thin adapter: parse CLI → orchestrator → display (AC-2)
- No Commander.js types leak into orchestrator (AC-3)
- RunOrchestrator importable from package entry point (AC-4)
- ConfigResolver handles 4-layer config merge with unit tests (AC-5)
- 53 new tests covering batch/sequential/chain without Commander mocking (AC-6)
- normalizeCommanderOptions stays as thin CLI-boundary adapter (AC-7)
admarble added 2 commits April 8, 2026 21:21
…unit tests

resolveRunOptions() previously spread the full normalized options object
at the end of the merge, which could clobber env/settings values with
undefined when called programmatically. Filter out undefined keys before
spreading so only explicitly-set options participate in the override.

Also: fix CHANGELOG line count (661→1171), remove dead source field in
ConfigResolver, clean up self-contradicting comment.
@admarble
admarble merged commit 37443a0 into main Apr 9, 2026
3 of 5 checks passed
@admarble
admarble deleted the feature/503-arch-extract-runorchestrator-decouple-execution-en branch April 26, 2026 15:46
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.

arch: extract RunOrchestrator — decouple execution engine from CLI wiring

1 participant