Skip to content

Effective cost — slice 3 (confidence-gated learned-cost re-rank, d060)#69

Merged
Ryfter merged 9 commits into
masterfrom
effective-cost-rerank
Jun 27, 2026
Merged

Effective cost — slice 3 (confidence-gated learned-cost re-rank, d060)#69
Ryfter merged 9 commits into
masterfrom
effective-cost-rerank

Conversation

@Ryfter

@Ryfter Ryfter commented Jun 27, 2026

Copy link
Copy Markdown
Owner

Effective-cost slice 3 — confidence-gated learned-cost re-rank (d060)

Realizes the named-deferred §4.3 of the effective-cost design — the d026 "router that learns" payoff. When opted in, Select-Capability biases its economy ranking by each worker's learned effective cost (Acceptance-Gate quality ÷ spend, folded across runs): a worker that has cost more per unit quality yields toward the next cost tier; a learned-cheap worker reaches toward the tier below.

Design (d060)

  • Bounded adjacent-tier shift (±MaxShift, default 1.0) — captures the "cheap-but-rejected is actually expensive" insight without a 2-tier leap or undercutting saturation's −1 floor.
  • Confidence-gated (MinConfidence 0.5) — only trusted leaderboard rows move routing or anchor the peer median; the evaluated worker is excluded from its own median.
  • Default-OFF global learned_routing switch — off/absent ⇒ ranking is byte-for-byte unchanged (verified). Economy-only; champion mode never reads the board.
  • Box-private — leaderboard folds from the injectable -RunsRoot ($BATON_HOME/runs); shared references/fleet.yaml carries only a commented field doc.

Surface

  • effective-cost-lib.ps1: Read-EffectiveCostRecords (shared, -RunsRoot/-Glob), Get-LearnedRoutingEnabled, Get-LearnedCostAdjustment.
  • saturation-lib.ps1: Get-LearnedTierRank (saturation-floored effective rank).
  • routing-lib.ps1: Select-Capability gains injectable -RunsRoot + the §3c learned-cost step.

Review

Final adversarial review → CHANGES REQUIRED (1 Critical: --runs glob regression; 1 Important: NaN at MinConfidence=1.0; 3 Minor). All addressed; one Minor (re-add @()) rejected with empirical proof it would re-nest the unary-comma return. Confirmation review: CONFIRMED.

Tests

All green: effective-cost-lib, fleet-effective-cost (incl. C14/C15 --runs), saturation-lib (incl. L1–L4), routing-lib (incl. W_off1/W_on1/W_champ1 byte-for-byte + flip + champion-invariance), routing-dispatch, conductor-lib, bootstrap.

Plugin 1.4.0 → 1.4.1-rc.1 (advisory-first rc; default-off).

🤖 Generated with Claude Code

Ryfter and others added 9 commits June 26, 2026 22:14
Pure function mapping a worker s learned eff_cost_mean vs the peer-median
into a bounded (MaxShift=1.0), confidence-weighted rank shift.
Peer-exclusion from median ensures confidence weighting shows through.
Inert when untrusted/absent/empty board (fail-open).
E_adj1-E_adj8 all PASS.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Three edits to routing-lib.ps1: (a) dot-source effective-cost-lib.ps1,
(b) injectable -RunsRoot param (default BATON_HOME/runs), (c) 3c block
reads the box-private board and stamps learned_adjust on each candidate,
then the economy Sort-Object primary key becomes Get-LearnedTierRank.
Default-off invariant: learned_routing unset -> learned_adjust=0.0 ->
Get-LearnedTierRank(...,0) == Get-EffectiveTierRank, byte-for-byte same.

Fixes @(Get-WorkerEffectiveCost) double-wrap: comma-array return must be
assigned directly (without outer @()) to avoid nested array in $board.

Tests: W_off1 (switch gates bias even with records present), W_on1
(learned-bad local yields to learned-good free), W_champ1 (champion mode
ignores board). All 48 routing + 33 saturation + 8 dispatch checks pass.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…at MinConfidence=1.0 (Important), strengthen tests + doc comments

- Read-EffectiveCostRecords gains -Glob mode; CLI --runs honored again (was silently dropped when reader lifted into lib)
- Get-LearnedCostAdjustment: guard 0/0 NaN when MinConfidence=1.0
- tests: E_rdr3/4 (-Glob, neither), E_cfg5 (literal false), E_adj9 (no NaN), C14/15 (--runs glob), W_champ1 order assertion
- reject reviewer Minor 3 (re-add @() around $board): empirically re-nests the rows array; documented why in code+spec+plan
Copilot AI review requested due to automatic review settings June 27, 2026 08:18
@Ryfter
Ryfter merged commit 4bde54f into master Jun 27, 2026
@Ryfter
Ryfter deleted the effective-cost-rerank branch June 27, 2026 08:18

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

Implements effective-cost “slice 3” (d060): an opt-in, confidence-gated learned-cost adjustment that biases Select-Capability economy ranking using per-worker learned effective cost folded from effective-cost.json records.

Changes:

  • Adds shared record reading (Read-EffectiveCostRecords), fleet opt-in parsing (Get-LearnedRoutingEnabled), and the learned-cost adjustment function (Get-LearnedCostAdjustment) to effective-cost-lib.ps1.
  • Wires learned-cost adjustments into Select-Capability economy ranking via Get-LearnedTierRank, with an injectable -RunsRoot seam and champion-mode invariance.
  • Extends test suites and documentation; bumps plugin version to 1.4.1-rc.1.

Reviewed changes

Copilot reviewed 13 out of 13 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
scripts/effective-cost-lib.ps1 Introduces shared record reader, opt-in switch reader, and learned-cost adjustment math used by routing and CLI.
scripts/fleet-effective-cost.ps1 Switches CLI to use shared record reader; implements --runs glob override behavior.
scripts/routing-lib.ps1 Adds learned-cost re-rank step to economy selection and a -RunsRoot injection seam.
scripts/saturation-lib.ps1 Adds Get-LearnedTierRank to combine tier rank + learned adjustment with saturation floor.
scripts/test-effective-cost-lib.ps1 Adds unit tests for record reading, switch parsing, and adjustment math (incl. NaN guard).
scripts/test-fleet-effective-cost.ps1 Adds CLI tests to ensure --runs glob overrides -RunsRoot.
scripts/test-routing-lib.ps1 Adds integration tests for learned routing off/on behavior and champion-mode invariance.
scripts/test-saturation-lib.ps1 Adds tests for Get-LearnedTierRank saturation behavior and flooring.
references/fleet.yaml Documents the learned_routing field as box-private and default-off.
commands/effective-cost.md Clarifies the command is advisory and notes the opt-in routing consumer behavior.
docs/superpowers/specs/2026-06-26-effective-cost-rerank-design.md Adds the approved design spec for d060.
docs/superpowers/plans/2026-06-26-effective-cost-rerank.md Adds the implementation plan describing tasks, constraints, and tests.
.claude-plugin/plugin.json Bumps plugin version to 1.4.1-rc.1.

Comment on lines +240 to +245
foreach ($line in (Get-Content -LiteralPath $FleetPath)) {
if ($line -match '^\s*learned_routing\s*:\s*(.+?)\s*$') {
$val = $Matches[1].Trim().Trim('"').Trim("'")
return ($val -eq 'true')
}
}
Comment on lines +220 to +224
$files = if (-not [string]::IsNullOrWhiteSpace($Glob)) {
@(Get-ChildItem -Path $Glob -File -ErrorAction SilentlyContinue)
} elseif ((-not [string]::IsNullOrWhiteSpace($RunsRoot)) -and (Test-Path $RunsRoot)) {
@(Get-ChildItem -Path $RunsRoot -Filter 'effective-cost.json' -Recurse -File -ErrorAction SilentlyContinue)
} else { @() }
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.

2 participants