Repository navigation
feat: concurrent test execution across worker processes - #4
Merged
Merged
Conversation
Implements the workers setting (spec 11-lifecycle.md): file-target units are scheduled across child worker processes. Each worker re-loads the config module, owns one driver instance, and runs one unit at a time; per-target setup tests gate ordinary units, serial groups stay atomic on one worker, and workers are discarded after failing units or infrastructure faults. In-memory configs keep the sequential in-process path.
The worker scheduler was only reachable with a file-backed config; an in-memory rawConfig fell back to a separate sequential loop in the runner. That duplicated setup gating, non-run record construction, and interrupt handling, and left the whole test suite exercising the fallback while users only ever hit the scheduler. Introduce a UnitRunner transport seam. The scheduler is now the only engine and spawns either a child process or an in-process worker; both drive the same TargetWorker core. Dispatch-time gating moves entirely to the scheduler, so TargetExecutor.run, dependencySkip, failedSetupSessions, and its duplicate non-run emitters are deleted. Split TestIdentity out of CollectedTest and point ResultRecord at it. Wire messages carry identities, which removes the CollectedTest cast in decodeResult, the synthesized test with a fake fn in the worker, and stops test functions leaking into records. Fix scheduler defects: - take a unit before acquiring a worker, so a spawn is never left idle - count retired-but-live workers against the cap - snapshot the worker list before retiring during interrupt broadcast - derive setup gating instead of tracking a hand-maintained counter - requeue a worker's queued unit on exit before failing its target, which otherwise deadlocked the run loop after repeated boot failures - drop unused unitId fields; validate the one that remains Add scheduler unit tests against a fake transport, now possible via the seam.
okwasniewski
force-pushed
the
oskar/concurrent-workers
branch
from
July 27, 2026 14:34
4e93a8d to
816ba7b
Compare
A worker that dies before becoming ready owns a unit that is already off its queue. Requeueing it in onExit before the target is failed is what keeps those pairs in the report; without it the setup case reports nothing at all. Add regression coverage for the setup-unit case and for an interrupt arriving while a worker is still starting, and document why retire() drops a queued unit rather than requeueing it.
3 of 5 tasks
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.
Implements the
workerssetting: execution now schedules file-target units across child worker processes per spec/11-lifecycle.md. Closes the "accepted but serial" gap documented in the READMEs.Design
Scheduling (spec 11-lifecycle.md "Execution hierarchy")
setup-failedskips at dispatch time.Worker processes (spec 09-drivers.md driver concurrency contract)
configDigestmatches the runner's. This also yields exactly one driver instance per worker with strictly serialized sessions.ResolvedTargetnever crosses the wire (results carrytargetName, the runner rehydrates).WORKER_CRASHfailed attempt, unfinished pairs skip asinfrastructure-unavailable, and aWORKER_EXITrun error is recorded (infra failures are not retry eligible). Two consecutive boot failures fail the target's remaining units.timeout + cleanupTimeoutforce-kill budget.Fallback: in-memory configs (programmatic
rawConfig) cannot cross process boundaries and keep the sequential in-process path.Reporting: serial groups are now sorted file → declarationIndex → target index like results, keeping report order independent of completion time (spec 13-reporting.md).
Changes
src/run/units.ts— work-unit planner (setup units, file units, immediate non-run pairs)src/run/worker/{protocol,entry,handle}.ts— IPC protocol, worker process entry, runner-side process lifecyclesrc/run/scheduler.ts— dispatch loop, setup gating, worker pool with target affinity, discard/crash handlingsrc/run/execute.ts—TargetExecutor.runsplit into reusablerunSetupUnit/runFileUnit; newonSerialGroup/onPairStarteventssrc/run/runner.ts— parallel path for file-backed configs (all worker counts), fallback otherwisesrc/run/sessions.ts— injectable session keysrc/report/build.ts— deterministic serial-group orderingTesting
--workers 1Note: found a pre-existing ~10s process-exit lag (two lingering socket handles) that reproduces on the sequential path too — left out of scope, worth a separate issue.