Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions bench/src/flywheel-evolve.mts
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ async function main(): Promise<void> {
...(process.env.OBJECTIVE === 'cost'
? { objective: 'cost' as const, scoreTolerance: Number(process.env.SCORE_TOLERANCE ?? 0.05) }
: {}),
...(process.env.CHAMPION_EPSILON ? { championEpsilon: Number(process.env.CHAMPION_EPSILON) } : {}),
...(process.env.LOSSES_DETAIL === 'binary' ? { lossesDetail: 'binary' as const } : {}),
...(process.env.REPRO ? { reproducerCheck: {} } : {}),
// Endurance: phase ledger on disk (resume skips completed phases) + the gym recycled
Expand Down
7 changes: 6 additions & 1 deletion src/runtime/strategy-evolution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,12 @@ export async function runStrategyEvolution(cfg: StrategyEvolutionConfig): Promis
const populationSize = cfg.populationSize ?? 2
const baselines = cfg.baselines ?? [sample, refine, sampleThenRefine]
const policy = cfg.champion ?? 'costAware'
const epsilon = cfg.championEpsilon ?? 0.01
// FUNNEL ALIGNMENT: the search-side tie band must be no stricter than the promotion
// criterion, or the gate never sees the candidates it was designed to judge. Under the
// cost objective the gate accepts score within −scoreTolerance; a candidate that the
// gate would promote must therefore be able to DISPLACE in search at that same band.
const epsilon =
cfg.championEpsilon ?? (cfg.objective === 'cost' ? (cfg.scoreTolerance ?? 0.05) : 0.01)
const byName = new Map<string, Strategy>(baselines.map((s) => [s.name, s]))
const codeByName = new Map<string, string>()

Expand Down
24 changes: 24 additions & 0 deletions tests/loops/strategy-evolution.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -628,3 +628,27 @@ describe('checkpoint and resume', () => {
expect(phases).toEqual(['gen0', 'gen1', 'holdout'])
})
})

describe('funnel alignment under the cost objective', () => {
it('the search tie-band defaults to the gate tolerance: a near-tie cheaper candidate displaces', () => {
const r = {
n: 1,
excluded: 0,
perStrategy: {
incumbent: { score: 0.733, resolved: 0, usd: 0.0249, ms: 0 },
cheaper: { score: 0.696, resolved: 0, usd: 0.0141, ms: 0 },
},
perTask: [],
pareto: [],
}
// ε=1pp (the score-objective default): the incumbent holds.
expect(pickChampion(r.perStrategy, ['incumbent', 'cheaper'], 'costAware', 0.01).name).toBe(
'incumbent',
)
// ε=5pp (the cost-objective default = the gate's scoreTolerance): the cheaper
// within-band candidate displaces and REACHES the gate.
expect(pickChampion(r.perStrategy, ['incumbent', 'cheaper'], 'costAware', 0.05).name).toBe(
'cheaper',
)
})
})
Loading