Cap concurrent heavy builds with an M=8 host semaphore.

Build-serializer (M=8 semaphore)

Intent — A host-level counting semaphore (M=8) over the adjacent heavy-compute tools (dotnet build, tsc, csharp-query, jedi lints, pyright), so concurrent worktrees get parallelism up to the machine's capacity without oversubscribing it.

SummaryCap concurrent heavy builds with an M=8 host semaphore.
TargetAgent · Mediators & resource locks
Formvalidation
EnforcementHard (deterministic) · blocking — a byte-range semaphore caps concurrency at 8; five tool enforcers refuse the raw call

Motivation — the failure it kills

The heavy build tools are the same shared-host hazard as dotnet test: N worktrees compiling, type-checking, and running Roslyn queries at once saturate CPU and memory and slow everyone. But unlike dotnet test, these tools are numerous and mostly parallel-safe, so the failure to avoid is both oversubscription (too many at once melts the host) and over-serialization (N=1 would waste cores and stall the fleet).

Why it's not just "use the test-serializer for builds too" (N=1)

dotnet test is mutually destructive (port/artifact contention), so single-writer is correct there. Builds are parallel-safe but heavy and far more frequent, so N=1 would leave most cores idle and throttle throughput needlessly. The right primitive is a bounded semaphore (M=8): allow concurrency up to the host's capacity, cap it there. What decides the lock's cardinality? The resource's contention profile: a single-writer lock for mutually-destructive work, a bounded-concurrency semaphore for parallel-safe-but-heavy work. Same mediator pattern, different M.

Mechanism

The build serializer holds a byte-range semaphore (M slots) on a shared host lock; the five adjacent tools acquire a slot before running and release after. Per-run logs are written with timestamps. Each of the five tools has an active enforcer that refuses the un-mediated call. The sibling test-serializer handles dotnet test at N=1.

Prerequisites

Consequences & costs

Known uses

Related mechanisms