Skip to content
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
Ryfter merged 4 commits into
masterfrom
saturation-driver
Jun 22, 2026
Merged

Ryfter merged 4 commits into
masterfrom
saturation-driver

Conversation

@Ryfter

@Ryfter Ryfter commented Jun 22, 2026

Copy link
Copy Markdown
Owner

Implements the Active Saturation Driver (d-wa-5, deferred from Sprint 6), the first slice of the v1.4 line.

What

Select-Capability now 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 (below local) 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 of budget/saturate/saturation_target; §3b saturation pass; §4 economy score uses the effective-tier floor (champion untouched).
  • references/fleet.yaml: field docs + saturate: false example (budget stays box-private).
  • Plugin 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).
  • Regression gate green: test-routing-lib/dispatch/learn/calibrate/cascade + bootstrap all exit 0. Non-saturating selection byte-for-byte unchanged.
  • Final adversarial opus whole-branch review: 0 Critical; 1 Important (non-canonical YAML-false opt-in) fixed in 5dcf13e + S29; invariant + box-private verified clean.

Spec: docs/superpowers/specs/2026-06-21-active-saturation-driver-design.md
Plan: docs/superpowers/plans/2026-06-21-active-saturation-driver.md

🤖 Generated with Claude Code

Ryfter and others added 4 commits June 21, 2026 18:07
…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>
Copilot AI review requested due to automatic review settings June 22, 2026 00:08
@Ryfter
Ryfter merged commit cf5aa19 into master Jun 22, 2026
@Ryfter
Ryfter deleted the saturation-driver branch June 22, 2026 00:08

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 into Select-Capability ranking.
  • Extended fleet/provider candidate metadata to carry saturation configuration and annotate boosted candidates (saturate, sat_util, updated why).
  • 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 }
}
Comment thread scripts/routing-lib.ps1
$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
}
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants