@@ -126,6 +126,41 @@ test("requires a fresh discovery and explicit Pi approval for every advanced act
126126 }
127127} ) ;
128128
129+ test ( "clears discovered actions after an MCP transport reset" , async ( ) => {
130+ const originalCall = EngraphisMcpClient . prototype . callTool ;
131+ const originalGeneration = EngraphisMcpClient . prototype . generation ;
132+ let generation = 0 ;
133+ EngraphisMcpClient . prototype . generation = function ( ) { return generation ; } ;
134+ EngraphisMcpClient . prototype . callTool = async function ( name : string ) {
135+ if ( name === "engraphis_discover_actions" ) {
136+ return { content : [ { type : "text" , text : JSON . stringify ( { actions : [ {
137+ capability_id : "cap_restart" , canonical_action : "retire" ,
138+ schema_digest : "1234567890abcdef" , side_effect : "state_change" , title : "Retire memory" ,
139+ } ] } ) } ] } ;
140+ }
141+ generation += 1 ;
142+ throw new Error ( "stdio transport closed" ) ;
143+ } ;
144+ try {
145+ const { tools } = extensionHarness ( ) ;
146+ const discover = tools . find ( ( tool ) => tool . name === "engraphis_discover_actions" ) ! ;
147+ const recall = tools . find ( ( tool ) => tool . name === "engraphis_recall_context" ) ! ;
148+ const execute = tools . find ( ( tool ) => tool . name === "engraphis_execute_action" ) ! ;
149+ await discover . execute ( "discover" , { task : "retire stale memory" } , undefined ) ;
150+ await assert . rejects ( recall . execute ( "recall" , { query : "trigger reset" } , undefined ) ) ;
151+ await assert . rejects (
152+ execute . execute ( "action" , {
153+ arguments : { } , capability_id : "cap_restart" , schema_digest : "1234567890abcdef" ,
154+ } , undefined , undefined , { hasUI : true , ui : { confirm : async ( ) => true } } ) ,
155+ / n o t i s s u e d b y t h e c u r r e n t E n g r a p h i s d i s c o v e r y s e s s i o n / ,
156+ ) ;
157+ } finally {
158+ EngraphisMcpClient . prototype . callTool = originalCall ;
159+ EngraphisMcpClient . prototype . generation = originalGeneration ;
160+ }
161+ } ) ;
162+
163+
129164test ( "fails closed when Pi cannot present an action approval dialog" , async ( ) => {
130165 const original = EngraphisMcpClient . prototype . callTool ;
131166 EngraphisMcpClient . prototype . callTool = async function ( name : string ) {
0 commit comments