From 0e49f91c62ff9977c6a917a6f197adbd7876bbb9 Mon Sep 17 00:00:00 2001 From: Peter Stone Date: Sun, 5 Jul 2026 23:51:58 +0000 Subject: fix: task submission context cancellation, executions success-rate calc MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit submitTask was using the inbound HTTP/MCP request context to submit work to the executor pool, so every chatbot/REST-submitted task was cancelled the moment the request returned rather than actually running. Use the server's long-lived lifecycle context instead, matching the other Submit call sites. Separately, computeExecutionStats compared execution state against a lowercase 'completed' literal while the backend always emits uppercase state values, so success rate silently read 0% for every execution. Also treat READY as success alongside COMPLETED, since a top-level task's execution lands at READY on success — COMPLETED requires a later, separate accept step. Co-Authored-By: Claude Sonnet 5 Claude-Session: https://claude.ai/code/session_01VTUSAEKfsPc6WGDq45yPHD --- web/test/stats.test.mjs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'web/test') diff --git a/web/test/stats.test.mjs b/web/test/stats.test.mjs index a7fe657..19f2b1e 100644 --- a/web/test/stats.test.mjs +++ b/web/test/stats.test.mjs @@ -150,4 +150,20 @@ describe('computeExecutionStats', () => { assert.equal(stats.byOutcome.failed, 1); assert.equal(stats.byOutcome.cancelled, 1); }); + + // READY is the execution state for a successful top-level (no parent) task + // run — see internal/executor.handleRunResult. COMPLETED is only reached + // after a separate human/chatbot accept step, so READY must count as + // success here or every top-level task's success rate reads as 0. + it('counts READY executions as successful', () => { + const execs = [makeExec('READY'), makeExec('READY'), makeExec('FAILED')]; + const stats = computeExecutionStats(execs); + assert.equal(stats.successRate, 2 / 3); + }); + + it('counts real-world uppercase state values the same as lowercase fixtures', () => { + const execs = [makeExec('COMPLETED'), makeExec('READY'), makeExec('FAILED'), makeExec('CANCELLED')]; + const stats = computeExecutionStats(execs); + assert.equal(stats.successRate, 0.5); + }); }); -- cgit v1.2.3