@@ -5,6 +5,7 @@ import * as NodeServices from "@effect/platform-node/NodeServices";
55import * as Effect from "effect/Effect" ;
66import * as Schema from "effect/Schema" ;
77import { assert , expect , it } from "@effect/vitest" ;
8+ import { vi } from "vite-plus/test" ;
89import { ComposerContextId , EnvironmentId , ThreadId } from "@t3tools/contracts" ;
910import { projectComposerContextForProvider } from "@t3tools/shared/composerContextReferences" ;
1011
@@ -32,6 +33,8 @@ import {
3233import { briefRoute , gradeDevice , shellInvocations } from "./device-grading.ts" ;
3334import { taskPrompt } from "../../apps/server/src/mcp/delegatedTaskModes.ts" ;
3435
36+ vi . mock ( "node:child_process" , { spy : true } ) ;
37+
3538it ( "grades Codex shell and subagent calls with the shared rules" , ( ) => {
3639 const calls = [
3740 { name : "exec_command" , input : { cmd : "sleep 60" } } ,
@@ -292,6 +295,46 @@ it("runs WebMCP expressions without host objects", () => {
292295 ) ;
293296} ) ;
294297
298+ it ( "rejects partial WebMCP results from an unexpectedly terminated replay" , ( ) => {
299+ const partial = '[0,"list_notes",{}]\n' ;
300+ using child = vi . spyOn ( NodeChildProcess , "spawnSync" ) ;
301+ for ( const [ status , signal ] of [
302+ [ 1 , null ] ,
303+ [ null , "SIGKILL" ] ,
304+ ] as const ) {
305+ child . mockReturnValue ( {
306+ pid : 1 ,
307+ output : [ null , partial , "" ] ,
308+ stdout : partial ,
309+ stderr : "" ,
310+ status,
311+ signal,
312+ } ) ;
313+ assert . throws (
314+ ( ) =>
315+ gradeSample (
316+ {
317+ webmcp : {
318+ tabId : "tab_1" ,
319+ origin : "https://acme.dev" ,
320+ tools : [ { name : "list_notes" , description : "List notes." } ] ,
321+ calls : [ { tool : "list_notes" } ] ,
322+ notCalls : [ "delete_note" ] ,
323+ } ,
324+ } ,
325+ {
326+ calls : [
327+ { step : 0 , tool : "preview_evaluate" , input : { tabId : "tab_1" , expression : "1" } } ,
328+ ] ,
329+ text : "" ,
330+ stopReason : "end_turn" ,
331+ } ,
332+ ) ,
333+ / W e b M C P r e p l a y t e r m i n a t e d / ,
334+ ) ;
335+ }
336+ } ) ;
337+
295338it ( "contains page rejections no expression handles" , ( ) => {
296339 const grader = new URL ( "./run.ts" , import . meta. url ) . href ;
297340 const script = `
0 commit comments