Add --workers flag to pact run + pact daemon#5
Merged
Conversation
Unifies the worker-count vocabulary established by `pact adopt --workers` in the v0.14.x line. The flag overrides parallel_components + max_concurrent_agents for a single invocation; the project / global config is unchanged. Surface: pact run <dir> --workers off # force sequential pact run <dir> --workers 4 # 4 parallel workers pact run <dir> --workers auto # heuristic against leaf count + budget pact daemon <dir> --workers ... # same flag on the event-driven daemon Implementation: Scheduler grows a workers_override parameter that, when set, mutates the resolved ParallelConfig at the two call sites (implement + integrate phases). For "auto", _resolve_workers() (reused from src/pact/adopt.py) is consulted with implementable-leaf count as the eligible-files input. Bad input (negative, garbage strings) is rejected at Scheduler construction with a clear ValueError so the user sees the failure before the implement phase starts. `pact build <cid>` is single-component and is intentionally not given this flag — there is no parallel dimension at single-component scope. Tests: 7 new in tests/test_scheduler.py covering - no override → defers to config - "off" forces sequential even when config says parallel - integer N overrides max_concurrent - string-integer accepted - "auto" uses implementable count as input - garbage input rejected at construction - zero rejected at construction Full suite: 2107 passed (was 2100 before this change). Lint: clean. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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
Followup to #4. Unifies the
--workersvocabulary across pact's CLI:pact adopt --workersshipped in #4; this brings the same surface topact runandpact daemon, the two commands that drive the parallel implement/integrate phases.The override beats project/global config for the single invocation; config is unchanged. `pact build ` is intentionally not given this flag — single-component scope has no parallel dimension.
Implementation
`Scheduler` grows a `workers_override` parameter that, when set, mutates the resolved `ParallelConfig` at the two parallel call sites (implement + integrate). For "auto", `_resolve_workers()` (reused from `src/pact/adopt.py`) is consulted with implementable-leaf count as the eligible-files input. Bad input (negative, garbage strings) is rejected at `Scheduler` construction with a clear `ValueError` so the user sees it before the implement phase starts, not deep inside it.
Test plan