CB-554: weight <= 0 excludes a profile from automatic placement #63

Closed
agent wants to merge 0 commits from worker/cb554-e8e224-3 into main
Member

Fixes gitea issue #28.

weight: 0 (or a negative weight) was normalised to 1.0 by BridgedConfig.Profile's compact constructor, so it read as "never auto-select this profile" but behaved as "select it as often as anyone else". Two live profiles (opus, sol) rely on weight: 0 meaning excluded; the bug is silent today only because placement runs fixed.

What changed:

  • BridgedConfig.Profile compact constructor: absent weight still normalises to 1.0; an explicit 0 or negative value now normalises to 0.0 instead of 1.0.
  • PlacementCandidate.excluded(): weight <= 0 means excluded from automatic selection.
  • PlacementPolicyUtil.available()/emptyException(): follows the same seam CB-578 stage B used for quarantine — weight-excluded candidates are filtered the same way, and a new bucket in the empty-set message names "weight 0" as the cause (checked first so a candidate excluded for two reasons is never double-counted).
  • FixedPlacementPolicy: now also walks past a weight-0 default/candidate, same as it already does for quarantine.
  • RoundRobinPlacementPolicy/WeightedRoundRobinPolicy: no code change needed — both already route through PlacementPolicyUtil.available().
  • An explicit bridge_spawn{profile:"..."} is untouched: it bypasses placement entirely (verified with a new test), so opus/sol stay reachable by name.
  • bridged.example.yaml weight: doc updated to describe the new semantics.

Tests: 752 tests, 0 failures, 0 errors (mvn clean install, unpiped, BUILD SUCCESS). New coverage: 8 cases in PlacementPolicyTest (weighted/round-robin/fixed skip weight-0, all-weight-0 pool throws naming the cause, negative weight treated as excluded not an error, weight-0 + quarantined not double-counted), 2 cases in BridgedConfigTest (explicit 0 stays 0, negative normalises to 0), 2 cases in CompositePeerLauncherTest (unqualified spawn skips weight-0, explicit spawn on a weight-0 profile still succeeds).

Decision not settled by the ticket, flagged here: the exact wording of the new exception messages (e.g. "all worker profiles have weight 0 (excluded from automatic selection)", "N weight-0" in the mixed-cause message) — I picked wording consistent with the existing quarantine messages; happy to adjust if a different phrasing is preferred.

Fixes gitea issue #28. `weight: 0` (or a negative weight) was normalised to 1.0 by `BridgedConfig.Profile`'s compact constructor, so it read as "never auto-select this profile" but behaved as "select it as often as anyone else". Two live profiles (`opus`, `sol`) rely on `weight: 0` meaning excluded; the bug is silent today only because placement runs `fixed`. **What changed:** - `BridgedConfig.Profile` compact constructor: absent weight still normalises to 1.0; an explicit 0 or negative value now normalises to 0.0 instead of 1.0. - `PlacementCandidate.excluded()`: `weight <= 0` means excluded from automatic selection. - `PlacementPolicyUtil.available()`/`emptyException()`: follows the same seam CB-578 stage B used for quarantine — weight-excluded candidates are filtered the same way, and a new bucket in the empty-set message names "weight 0" as the cause (checked first so a candidate excluded for two reasons is never double-counted). - `FixedPlacementPolicy`: now also walks past a weight-0 default/candidate, same as it already does for quarantine. - `RoundRobinPlacementPolicy`/`WeightedRoundRobinPolicy`: no code change needed — both already route through `PlacementPolicyUtil.available()`. - An explicit `bridge_spawn{profile:"..."}` is untouched: it bypasses placement entirely (verified with a new test), so `opus`/`sol` stay reachable by name. - `bridged.example.yaml` `weight:` doc updated to describe the new semantics. **Tests:** 752 tests, 0 failures, 0 errors (`mvn clean install`, unpiped, BUILD SUCCESS). New coverage: 8 cases in PlacementPolicyTest (weighted/round-robin/fixed skip weight-0, all-weight-0 pool throws naming the cause, negative weight treated as excluded not an error, weight-0 + quarantined not double-counted), 2 cases in BridgedConfigTest (explicit 0 stays 0, negative normalises to 0), 2 cases in CompositePeerLauncherTest (unqualified spawn skips weight-0, explicit spawn on a weight-0 profile still succeeds). **Decision not settled by the ticket, flagged here:** the exact wording of the new exception messages (e.g. "all worker profiles have weight 0 (excluded from automatic selection)", "N weight-0" in the mixed-cause message) — I picked wording consistent with the existing quarantine messages; happy to adjust if a different phrasing is preferred.
agent added 1 commit 2026-08-15 12:54:29 +02:00
CB-554: weight <= 0 excludes a profile from automatic placement, not 1.0
CI / contract (pull_request) Successful in 44s
CI / build (pull_request) Successful in 52s
a1f4dc365a
ltms closed this pull request 2026-08-15 13:09:37 +02:00
Some checks are pending
CI / contract (pull_request) Successful in 44s
CI / build (pull_request) Successful in 52s

Pull request closed

Sign in to join this conversation.