This repository was archived by the owner on Sep 15, 2026. It is now read-only.
Active Saturation Driver (d-wa-5) — spend the pre-paid allotment first - #64
Merged
Merged
Conversation
…se never boosts (d-sat-2) Final-review finding: ConvertFrom-FleetValue only coerces literal true/false, so 'saturate: no'/'off' stayed a string that both skipped '-not' and read truthy in the [bool] sort key. Normalize the flag to a strict boolean: only a literal $true opts in. Adds S29. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
This PR introduces the “Active Saturation Driver” to Baton’s capability routing so that, in economy mode, an opt-in budgeted fleet worker is temporarily up-ranked to spend its pre-paid/free allotment first (targeting ~99.9% utilization), while preserving existing route-around and champion behavior.
Changes:
- Added a new pure saturation decision library (
Get-CandidateUtilization,Get-SaturationDecision,Get-EffectiveTierRank) and integrated it intoSelect-Capabilityranking. - Extended fleet/provider candidate metadata to carry saturation configuration and annotate boosted candidates (
saturate,sat_util, updatedwhy). - Added a dedicated saturation test suite and updated bootstrap packaging/tests, reference docs, and plugin version.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| scripts/saturation-lib.ps1 | New saturation decision helpers used by routing to compute utilization, apply/skip boost, and floor effective tier rank. |
| scripts/routing-lib.ps1 | Wires saturation into Select-Capability (usage governance pass + economy ranking changes using effective tier rank). |
| scripts/test-saturation-lib.ps1 | New tests for saturation helpers plus integration coverage for Select-Capability behavior. |
| scripts/bootstrap.ps1 | Ensures saturation-lib.ps1 is deployed by bootstrap. |
| scripts/test-bootstrap.ps1 | Extends bootstrap tests to assert saturation-lib.ps1 is deployed. |
| references/fleet.yaml | Documents saturate and saturation_target fields and provides a default-off example. |
| .claude-plugin/plugin.json | Bumps plugin version to 1.4.0-rc.1. |
Comment on lines
+33
to
+35
| foreach ($t in @($rowsArr | Where-Object { $_.event -eq 'tick' -and $_.worker -eq $Worker })) { | ||
| if ((ConvertTo-UsageDateTime ([string]$t.ts)) -ge $windowStart) { $consumed += [int]$t.count } | ||
| } |
| $ranked = $filtered | | ||
| Select-Object *, @{n='score'; e={ (Get-CostTierRank $_.cost_tier) - ($_.quality * 0.001) }} | | ||
| Sort-Object @{e='score'}, @{e={ -$_.quality }}, @{e='name'} | ||
| Select-Object *, @{n='score'; e={ (Get-EffectiveTierRank $_.cost_tier ([bool]$_.saturate)) - ($_.quality * 0.001) }} | |
Comment on lines
+176
to
+178
| } catch { | ||
| Write-Host "ERROR: $($_.Exception.Message)"; exit 1 | ||
| } |
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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 Active Saturation Driver (d-wa-5, deferred from Sprint 6), the first slice of the v1.4 line.
What
Select-Capabilitynow actively up-ranks an under-utilized, opt-in, budgeted fleet worker so the cost-optimal selector spends its pre-paid/free allotment first — toward the 99.9%-utilization north star. It is the symmetric inverse of the Sprint-2 route-around: route-around down-ranks the unavailable; saturation floors an under-used budgeted worker's effective cost-tier rank to −1 (belowlocal) while headroom remains, then route-around takes over once exhausted.How
scripts/saturation-lib.ps1(new, pure):Get-CandidateUtilization,Get-SaturationDecision,Get-EffectiveTierRank.scripts/routing-lib.ps1: §2 passthrough ofbudget/saturate/saturation_target; §3b saturation pass; §4 economy score uses the effective-tier floor (champion untouched).references/fleet.yaml: field docs +saturate: falseexample (budget stays box-private).1.3.0 → 1.4.0-rc.1; bootstrap manifest + assert.Decisions (d057)
d-sat-1 effective-tier floor · d-sat-2 opt-in default-off · d-sat-3 binary threshold (default 99.9) · d-sat-4 economy-only, conserve-suppressed · d-sat-5 never un-filters (runs after cost-cap/RequireLocal/route-around).
Tests
test-saturation-lib.ps1: S1–S29 ALL PASS (pure + Select-Capability integration; S29 covers the d-sat-2 non-canonical-false hardening).test-routing-lib/dispatch/learn/calibrate/cascade+ bootstrap all exit 0. Non-saturating selection byte-for-byte unchanged.5dcf13e+ S29; invariant + box-private verified clean.Spec:
docs/superpowers/specs/2026-06-21-active-saturation-driver-design.mdPlan:
docs/superpowers/plans/2026-06-21-active-saturation-driver.md🤖 Generated with Claude Code