From cb094e9e875cd81a9f591073a195d90a65bc861d Mon Sep 17 00:00:00 2001 From: Seekers2001 Date: Sat, 31 Oct 2026 17:55:32 +0800 Subject: [PATCH] test: cover all benchmark trigger routing paths --- tests/lib/context-selection.test.js | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/tests/lib/context-selection.test.js b/tests/lib/context-selection.test.js index 67111ba61..9f2100a87 100644 --- a/tests/lib/context-selection.test.js +++ b/tests/lib/context-selection.test.js @@ -770,3 +770,32 @@ test('benchmark optimization is discoverable and loads through task context rout assert.ok(named.candidates.some(value => value.id === id)); assert.equal(named.reason, 'agent-selection-required', 'Overlapping benchmark names still require selection'); }); + +for (const [query, automatic] of [ + ['turn user goal into benchmark', false], + ['optimize task completion rate', true], + ['compare implementation variants', false], + ['improve correctness with fixed evaluation', true], + ['reduce cost per resolved task', true], + ['run bounded recursive optimization', true], + ['verify improvement on independent cases', true], + ['keep best measured admissible result', true], +]) { + test('benchmark trigger preserves routing admission: ' + query, () => { + const id = 'skill:benchmark-optimization-loop'; + const entry = routingEntries().entries.find(value => value.id === id); + assert.ok(entry.triggers.includes(query), 'The curated phrase must remain registered'); + const result = resolveTaskContext({ task: task({ query }), load: true }); + assert.ok(result.candidates.some(value => value.id === id)); + assert.deepEqual(result.selectedIds, automatic ? [id] : []); + assert.deepEqual(result.loadedIds, automatic ? [id] : []); + assert.equal(result.reason, automatic ? 'auto-selection' : 'agent-selection-required'); + assert.equal(result.nativeInvocation, 'unobserved'); + if (!automatic) { + const approved = resolveTaskContext({ task: task({ query, proposedIds: [id] }), load: true }); + assert.deepEqual(approved.selectedIds, [id]); + assert.deepEqual(approved.loadedIds, [id]); + assert.equal(approved.nativeInvocation, 'unobserved'); + } + }); +}