@@ -372,6 +372,52 @@ describe("matrix approval reactions", () => {
372372 ) . toBeNull ( ) ;
373373 } ) ;
374374
375+ it ( "retains approval anchors and propagates transient Gateway failures for replay" , async ( ) => {
376+ const core = buildCore ( ) ;
377+ const cfg = buildConfig ( ) ;
378+ registerMatrixApprovalReactionTarget ( {
379+ roomId : "!ops:example.org" ,
380+ eventId : "$approval-msg" ,
381+ approvalId : "req-123" ,
382+ approvalKind : "exec" ,
383+ allowedDecisions : [ "allow-once" ] ,
384+ } ) ;
385+ const client = createReactionClient ( ) ;
386+ resolveMatrixApproval . mockRejectedValueOnce ( new Error ( "gateway 503" ) ) ;
387+
388+ await expect ( handleReaction ( { client, core, cfg } ) ) . rejects . toThrow ( "gateway 503" ) ;
389+ expect (
390+ await resolveMatrixApprovalReactionTargetWithPersistence ( {
391+ accountId : "default" ,
392+ roomId : "!ops:example.org" ,
393+ eventId : "$approval-msg" ,
394+ reactionKey : "✅" ,
395+ } ) ,
396+ ) . not . toBeNull ( ) ;
397+
398+ await handleReaction ( { client, core, cfg } ) ;
399+
400+ expect (
401+ await resolveMatrixApprovalReactionTargetWithPersistence ( {
402+ accountId : "default" ,
403+ roomId : "!ops:example.org" ,
404+ eventId : "$approval-msg" ,
405+ reactionKey : "✅" ,
406+ } ) ,
407+ ) . toBeNull ( ) ;
408+ expect ( resolveMatrixApproval ) . toHaveBeenCalledTimes ( 2 ) ;
409+ expect ( resolveMatrixApproval ) . toHaveBeenLastCalledWith ( {
410+ cfg,
411+ approvalId : "req-123" ,
412+ approvalKind : "exec" ,
413+ decision : "allow-once" ,
414+ channel : "matrix" ,
415+ accountId : "default" ,
416+ senderId : "@owner:example.org" ,
417+ } ) ;
418+ expect ( core . system . enqueueSystemEvent ) . not . toHaveBeenCalled ( ) ;
419+ } ) ;
420+
375421 it ( "terminalizes every sibling prompt when this surface wins" , async ( ) => {
376422 const core = buildCore ( ) ;
377423 const cfg = buildConfig ( ) ;
0 commit comments