@@ -206,6 +206,29 @@ describe('runCloudPi', () => {
206206 expect ( mockExecuteTool ) . not . toHaveBeenCalled ( )
207207 } )
208208
209+ it ( 'does not commit, push, or open a PR when the run reports an error on a zero exit' , async ( ) => {
210+ mockRun . mockImplementation (
211+ ( command : string , options : { onStdout ?: ( chunk : string ) => void } ) => {
212+ if ( command . includes ( 'git clone' ) ) {
213+ return Promise . resolve ( { stdout : '__BASE_SHA__=abc' , stderr : '' , exitCode : 0 } )
214+ }
215+ if ( command . includes ( 'pi -p' ) ) {
216+ options . onStdout ?.( '{"type":"error","error":"model exploded"}\n' )
217+ return Promise . resolve ( { stdout : '' , stderr : '' , exitCode : 0 } )
218+ }
219+ return Promise . resolve ( {
220+ stdout : '__CHANGED__=src/x.ts\n__NEEDS_PUSH__=1' ,
221+ stderr : '' ,
222+ exitCode : 0 ,
223+ } )
224+ }
225+ )
226+
227+ await expect ( runCloudPi ( baseParams ( ) , { onEvent : vi . fn ( ) } ) ) . rejects . toThrow ( / m o d e l e x p l o d e d / )
228+ expect ( mockExecuteTool ) . not . toHaveBeenCalled ( )
229+ expect ( mockRun . mock . calls . some ( ( [ cmd ] : [ string ] ) => cmd . includes ( 'push' ) ) ) . toBe ( false )
230+ } )
231+
209232 it ( 'surfaces the real git push error when the push fails, with the token scrubbed' , async ( ) => {
210233 mockRun . mockImplementation ( ( command : string ) => {
211234 if ( command . includes ( 'git clone' ) ) {
0 commit comments