RFC-006 Phase 2: Migrate SenseWorkerPool to WorkerRuntime #292

Merged
xingyue merged 3 commits from refactor/rfc-006-worker-runtime into main 2026-04-30 13:44:56 +00:00
Owner

Summary

Migrates SenseWorkerPool from hand-rolled fork/IPC management to the new WorkerRuntime abstraction (RFC-006).

Changes

Production code

  • worker-runtime.ts: Added trySendSync(), hasDisconnectedChild(), forwardStderr, allowRespawn, onReady(key, msg)
  • worker-pool.ts: Rewritten as thin wrapper around WorkerRuntime — from 195 lines of manual fork/IPC to ~106 lines of delegation. Uses evicting Set for async eviction visibility.

Test fixes

  • Mock children now include connected: true (required by trySendSync/isActive)
  • Added flushSenseWorkerForkMicrotasks() helper to flush async fork scheduling
  • worker-pool crash test: removed shouldAdvanceTime: true to avoid spurious extra forks

Test results

  • daemon: 167 tests
  • core: 57 tests
  • store: 76 tests
  • cli: 213 tests
  • workflow-utils: 34 tests
  • khala: 2 tests
## Summary Migrates `SenseWorkerPool` from hand-rolled `fork`/IPC management to the new `WorkerRuntime` abstraction (RFC-006). ## Changes ### Production code - **`worker-runtime.ts`**: Added `trySendSync()`, `hasDisconnectedChild()`, `forwardStderr`, `allowRespawn`, `onReady(key, msg)` - **`worker-pool.ts`**: Rewritten as thin wrapper around `WorkerRuntime` — from 195 lines of manual fork/IPC to ~106 lines of delegation. Uses `evicting` Set for async eviction visibility. ### Test fixes - Mock children now include `connected: true` (required by `trySendSync`/`isActive`) - Added `flushSenseWorkerForkMicrotasks()` helper to flush async fork scheduling - `worker-pool` crash test: removed `shouldAdvanceTime: true` to avoid spurious extra forks ## Test results - daemon: 167 tests ✅ - core: 57 tests ✅ - store: 76 tests ✅ - cli: 213 tests ✅ - workflow-utils: 34 tests ✅ - khala: 2 tests ✅
xiaomo added 2 commits 2026-04-30 13:37:25 +00:00
RFC-006 Phase 1: ManagedWorker state machine + WorkerRuntime<K> with
cold start, crash respawn, drain/evict, graceful shutdown.
8 test cases covering all lifecycle scenarios.
- Add trySendSync() for synchronous send when worker is ready+connected
- sendCompute uses sync path first, async fallback for cold start
- Add forwardStderr, allowRespawn, hasDisconnectedChild, onReady(key,msg)
- Tests: add connected:true to mocks, flush async fork microtasks
- All 167 daemon tests pass
xiaomo added 1 commit 2026-04-30 13:43:45 +00:00
1. trySendSync: wrap child.send in try/catch — IPC race between connected check and send
2. gracefulStop: same try/catch for shutdown send
3. Remove crashTimestamps reset on ready — crash window detection was being bypassed
xingyue merged commit fbf63e0266 into main 2026-04-30 13:44:56 +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#292