Effective cost — slice 3 (confidence-gated learned-cost re-rank, d060)#69
Merged
Conversation
…tive-cost slice 3)
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>
…to 5 runs/worker for decisive flip
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
There was a problem hiding this comment.
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) toeffective-cost-lib.ps1. - Wires learned-cost adjustments into
Select-Capabilityeconomy ranking viaGet-LearnedTierRank, with an injectable-RunsRootseam 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 { @() } |
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
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-Capabilitybiases 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)
MaxShift, default 1.0) — captures the "cheap-but-rejected is actually expensive" insight without a 2-tier leap or undercutting saturation's −1 floor.MinConfidence0.5) — only trusted leaderboard rows move routing or anchor the peer median; the evaluated worker is excluded from its own median.learned_routingswitch — off/absent ⇒ ranking is byte-for-byte unchanged (verified). Economy-only; champion mode never reads the board.-RunsRoot($BATON_HOME/runs); sharedreferences/fleet.yamlcarries 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-Capabilitygains injectable-RunsRoot+ the §3c learned-cost step.Review
Final adversarial review → CHANGES REQUIRED (1 Critical:
--runsglob regression; 1 Important: NaN atMinConfidence=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