Skip to content

Add --workers flag to pact run + pact daemon#5

Merged
jmcentire merged 1 commit into
mainfrom
feat/run-workers
May 3, 2026
Merged

Add --workers flag to pact run + pact daemon#5
jmcentire merged 1 commit into
mainfrom
feat/run-workers

Conversation

@jmcentire
Copy link
Copy Markdown
Owner

Summary

Followup to #4. Unifies the --workers vocabulary across pact's CLI: pact adopt --workers shipped in #4; this brings the same surface to pact run and pact daemon, the two commands that drive the parallel implement/integrate phases.

pact run <dir>    --workers off|N|auto
pact daemon <dir> --workers off|N|auto

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

  • 7 new tests in `tests/test_scheduler.py::TestSchedulerWorkersOverride` covering: no-override defers to config, `off` forces sequential, integer overrides max_concurrent, string-integer accepted, auto uses implementable count, garbage rejected at construction, zero rejected at construction.
  • Full suite: 2107 passed (was 2100 before this change).
  • Lint: clean.
  • CLI `--help` text describes the flag and references the adopt parity.

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>
@jmcentire jmcentire merged commit 10449f4 into main May 3, 2026
1 check passed
@jmcentire jmcentire deleted the feat/run-workers branch May 3, 2026 18:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant