RFC-006 Phase 3: Migrate workflow-manager process logic to WorkerRuntime #295

Merged
xingyue merged 2 commits from refactor/rfc-006-workflow-runtime into main 2026-04-30 14:14:06 +00:00
Owner

Summary

Migrates all process management (fork, crash recovery, stderr capture, shutdown) from workflow-manager.ts to WorkerRuntime.

Changes

Production code

  • workflow-manager.ts: 792 → 498 lines. No more fork(), ChildProcess, crash counting, or teeCapturedStderr. Delegates entirely to WorkerRuntime.
  • workflow-manager-support.ts (new): 256 lines of extracted pure functions — IPC dispatch, thread recovery, exit code extraction, constants.
  • worker-runtime.ts: Added onCrashLimitReached callback, WorkerDrainOpts for per-call shutdown timeout override.
  • worker-pool.ts: Updated for new evict(key, opts) / drain(key, opts) signature.

Hot reload approach

Uses evict + conditional start instead of drain — allows skipping respawn when a workflow is removed from config.

Tests

  • Added microtask flushes and ready event emissions for async fork scheduling
  • All 167 daemon tests pass

Closes #282

## Summary Migrates all process management (fork, crash recovery, stderr capture, shutdown) from `workflow-manager.ts` to `WorkerRuntime`. ## Changes ### Production code - **`workflow-manager.ts`**: 792 → 498 lines. No more `fork()`, `ChildProcess`, crash counting, or `teeCapturedStderr`. Delegates entirely to `WorkerRuntime`. - **`workflow-manager-support.ts`** (new): 256 lines of extracted pure functions — IPC dispatch, thread recovery, exit code extraction, constants. - **`worker-runtime.ts`**: Added `onCrashLimitReached` callback, `WorkerDrainOpts` for per-call shutdown timeout override. - **`worker-pool.ts`**: Updated for new `evict(key, opts)` / `drain(key, opts)` signature. ### Hot reload approach Uses `evict` + conditional `start` instead of `drain` — allows skipping respawn when a workflow is removed from config. ### Tests - Added microtask flushes and `ready` event emissions for async fork scheduling - All 167 daemon tests pass Closes #282
xiaomo added 1 commit 2026-04-30 13:59:12 +00:00
- workflow-manager.ts: 792 → 498 lines, no more fork/ChildProcess/crash counting
- Extract pure functions to workflow-manager-support.ts (256 lines)
- WorkerRuntime gains: onCrashLimitReached callback, WorkerDrainOpts for per-call timeout
- worker-pool.ts updated for new evict/drain signature (null opts)
- All 167 daemon tests pass

Closes #282
xiaomo added 1 commit 2026-04-30 14:12:18 +00:00
1. sendToWorker: IPC send failure now marks thread as failed + dequeues next
2. crashLimitBlocked Set: prevents new startWorkflow from bypassing crash limit
3. "respawning" log skipped when crash limit is active
4. logWorkflowEvent payload: unknown | null (project convention, not ?:)
xingyue merged commit 7ce46e7735 into main 2026-04-30 14:14:06 +00:00
This repo is archived. You cannot comment on pull requests.
No Reviewers
No Label
1 Participants
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: uncaged/nerve#295