feat: TDD-enabled TypeScript migration for workflow scripts#9
Closed
feat: TDD-enabled TypeScript migration for workflow scripts#9
Conversation
Plan 1 implementation - establishes TDD foundation: - Add Vitest testing framework with coverage support - Add TypeScript with strict settings - Create Hexagonal Architecture port interfaces: - IGitHubClient for GitHub CLI interactions - IClaudeClient for Claude CLI interactions - IProcessRunner for process spawning - Add initial port interface tests Closes #4
Plan 2 implementation - mock adapters and functional core: - Add mock adapters (MockGitHubClient, MockClaudeClient, MockProcessRunner) - Implement workflow state management with pure functions - State transitions: setup → planning → implementing → verifying → completed/failed - All transitions return Result types for error handling - Query functions: getCurrentPlan, getProgress, isTerminalState, canRetry 26 tests passing, zero vi.mock usage - pure functional testing! Closes #5
Plan 3 implementation - completing core logic: - Add error-detector.ts with hash-based stuck detection - Port detect_stuck from ci-ralph.sh to pure TypeScript - Add category-aware stuck detection for smarter detection - Add phase-manager.ts with state machine transitions - Configure 80% coverage threshold for core/ directory - 95%+ coverage achieved on all core modules 94 tests passing, zero vi.mock usage! Closes #6
Plan 4 implementation - imperative shell layer: - Add GitHubCLIAdapter implementing IGitHubClient - CI status, runs, comments, PR operations - Polling with configurable intervals and timeouts - Job logs retrieval - Add ClaudeCLIAdapter implementing IClaudeClient - Prompt execution with streaming support - Session continuation and resumption - Availability and version checks - Add integration tests (skip when CLIs unavailable) - Add execa dependency for process execution 101 tests passing (4 skipped for CLI availability) Closes #7
Plan 5 implementation - workflow orchestration: - Add XState state machine for phase orchestration - States: idle → setup → planning → implementing → submitting → verifying → completed/failed - Fixing state for CI retry logic - Guards for plan completion and retry limits - Add retry service with exponential backoff - Configurable delays, max attempts, jitter - Deterministic mode for testing - retryWhile for polling patterns - Add CI poller service - Poll until completion or timeout - Progress callbacks for monitoring - Human-readable status messages - Add public API index.ts exporting all modules 161 tests passing, comprehensive workflow coverage! Closes #8
Owner
Author
|
Superseded by PR #10 (V2 implementation) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Migrates shell scripts (ci-ralph.sh, workflow-ralph.sh, comments-ralph.sh) to a testable TypeScript architecture with TDD enabled by default, following the recommendations from deep research.
Architecture
Key Components
src/core/src/ports/src/adapters/src/workflows/src/services/Test Coverage
vi.mockusage - pure functional testingResearch-Driven Decisions
Based on
research/research-workflows-tdd-migration-deep.md:Test Plan
bun run test- all 161 tests passbun run test:coverage- 95%+ on core modulesbun run tsc --noEmit)Related Issues
Closes #4, #5, #6, #7, #8
Migration Notes
This is the foundation for migrating the bash scripts. The actual script replacement will be a follow-up PR that uses these TypeScript modules.