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
2 changes: 1 addition & 1 deletion src/runtime/strategy-evolution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ const compactLosses = (report: BenchmarkReport, detail: 'exact' | 'binary'): str
score: r2(c.score),
resolved: c.resolved,
usd: Math.round(c.usd * 10000) / 10000,
progression: c.progression.map(r2),
progression: (c.progression ?? []).map(r2),
},
]),
),
Expand Down
14 changes: 12 additions & 2 deletions src/runtime/strategy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -842,10 +842,20 @@ export function defineStrategy(
}
const r = await run(ctx)
// Override the body's self-reported score/resolved with the harness-verified
// values. The body's progression/completions/shots are advisory (display only).
// values. The body's progression/completions/shots are advisory (display only) —
// but NORMALIZED: an authored body that omits them must not poison downstream
// consumers (losses tables, anytime curves) with undefined.
return {
kind: 'done',
deliverable: { mode: name, ...r, score: verifiedBest, resolved: verifiedResolved },
deliverable: {
mode: name,
...r,
progression: Array.isArray(r.progression) ? r.progression : [],
completions: typeof r.completions === 'number' ? r.completions : 0,
shots: typeof r.shots === 'number' ? r.shots : 0,
score: verifiedBest,
resolved: verifiedResolved,
},
}
},
}),
Expand Down
23 changes: 23 additions & 0 deletions tests/loops/strategy-suite.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -660,3 +660,26 @@ describe('consult', () => {
expect(reply).toBe('DONE')
})
})

describe('advisory-field normalization', () => {
it('a body omitting progression/completions/shots yields a well-formed cell', async () => {
stubRouter()
const surface = fixtureSurface(() => ({ passes: 1, total: 2 }))
const sloppy = defineStrategy('sloppy', async ({ shot }) => {
await shot()
// An authored body returning only the verified-overridden fields.
return { score: 0, resolved: false } as never
})
const report = await runBenchmark({
environment: surface,
tasks: [task],
worker,
strategies: [sloppy],
budget: 1,
concurrency: 1,
})
const cell = report.perTask[0]?.cells?.sloppy
expect(cell?.progression).toEqual([])
expect(cell?.score).toBeCloseTo(0.5)
})
})
Loading