@@ -687,6 +687,67 @@ describe("the computer gateway", () => {
687687 expect ( rows [ 0 ] ?. targetId ) . toBe ( "bot-2" ) ;
688688 } ) ;
689689
690+ /*
691+ * "The most destructive button we have. Every login the Bot had is gone and no undo exists, so the
692+ * row is written whatever happens next."
693+ *
694+ * The profile is destroyed by `provider.reset` before either of the two Postgres deletes runs, so
695+ * a delete that fails cannot put it back -- it can only take the row with it, which is the one
696+ * thing that note rules out.
697+ */
698+ test ( "resetComputer records the reset even when clearing the stored page fails" , async ( ) => {
699+ const { provider, fetchImpl } = fakeComputer ( {
700+ resetResult : { cleared : true } ,
701+ } ) ;
702+ const { store, rows } = fakeAudit ( ) ;
703+ const snapshots : SnapshotStore = {
704+ ...createInMemorySnapshotStore ( ) ,
705+ clear : async ( ) => {
706+ throw new Error ( "connection reset by peer" ) ;
707+ } ,
708+ } ;
709+ const gateway = createComputerGateway ( {
710+ provider,
711+ fetchImpl,
712+ auditStore : store ,
713+ policy : ( ) => PERMISSIVE ,
714+ snapshots,
715+ } ) ;
716+
717+ await expect ( gateway . resetComputer ( "bot-1" , ACTOR ) ) . rejects . toThrow (
718+ "connection reset by peer" ,
719+ ) ;
720+
721+ expect ( rows . map ( ( row ) => row . eventType ) ) . toContain ( "computer.reset" ) ;
722+ expect ( rows [ 0 ] ?. targetId ) . toBe ( "bot-1" ) ;
723+ } ) ;
724+
725+ test ( "resetComputer records the reset even when clearing the screenshots fails" , async ( ) => {
726+ const { provider, fetchImpl } = fakeComputer ( {
727+ resetResult : { cleared : true } ,
728+ } ) ;
729+ const { store, rows } = fakeAudit ( ) ;
730+ const gateway = createComputerGateway ( {
731+ provider,
732+ fetchImpl,
733+ auditStore : store ,
734+ policy : ( ) => PERMISSIVE ,
735+ pageFrames : {
736+ clear : async ( ) => {
737+ throw new Error ( "statement timeout" ) ;
738+ } ,
739+ } as unknown as NonNullable <
740+ Parameters < typeof createComputerGateway > [ 0 ] [ "pageFrames" ]
741+ > ,
742+ } ) ;
743+
744+ await expect ( gateway . resetComputer ( "bot-1" , ACTOR ) ) . rejects . toThrow (
745+ "statement timeout" ,
746+ ) ;
747+
748+ expect ( rows . map ( ( row ) => row . eventType ) ) . toContain ( "computer.reset" ) ;
749+ } ) ;
750+
690751 test ( "computers maps provider status 'running' and 'stopped' directly and preserves egress distinctions" , async ( ) => {
691752 const locations : ComputerLocation [ ] = [
692753 {
0 commit comments