@@ -351,7 +351,72 @@ respondEither cfg@ProxyConfig{boosterState} booster kore req = case req of
351
351
<$> accumulatedLogs
352
352
)
353
353
r{ExecuteRequest. state = execStateToKoreJson simplifiedBoosterState}
354
- -- if we stop for a reason in fallbackReasons (default [Aborted, Stuck],
354
+ -- TODO this is an experimental code path. It needs to be guarded with an CLI option before merging
355
+ -- if we stop because of branching, simplify the next states to prune them and optionally
356
+ -- execute a fallback rewrite step from the pre-state in Kore con confirm the branch
357
+ | boosterResult. reason == Branching -> do
358
+ Booster.Log. withContext CtxProxy $
359
+ Booster.Log. logMessage $
360
+ " Booster " <> displayExecuteResultVerbose boosterResult
361
+ prunedBoosterResult <- simplifyExecResult logSettings r. _module def boosterResult
362
+ case prunedBoosterResult of
363
+ Left (_prunedToOneNext, _logs) -> do
364
+ Booster.Log. withContext CtxProxy $
365
+ Booster.Log. logMessage $
366
+ " After simplification: Booster "
367
+ <> displayExecuteResultVerbose boosterResult{nextStates = take 1 <$> boosterResult. nextStates}
368
+ Right stillBranching ->
369
+ Booster.Log. withContext CtxProxy $
370
+ Booster.Log. logMessage $
371
+ " After simplification: Booster " <> displayExecuteResultVerbose stillBranching
372
+
373
+ -- attempt to do one step in the old backend
374
+ Booster.Log. withContext CtxProxy $
375
+ Booster.Log. logMessage (" Executing fall-back request" :: Text )
376
+ (koreResult, _kTime) <-
377
+ Stats. timed $
378
+ kore
379
+ ( Execute
380
+ r
381
+ { state = execStateToKoreJson boosterResult. state
382
+ , maxDepth = Just $ Depth 1
383
+ , assumeStateDefined = Just True
384
+ }
385
+ )
386
+ case koreResult of
387
+ Right (Execute result) ->
388
+ Booster.Log. withContext CtxProxy $
389
+ Booster.Log. logMessage $
390
+ " Kore " <> displayExecuteResultVerbose result
391
+ _err ->
392
+ Booster.Log. withContext CtxProxy $
393
+ Booster.Log. withContext CtxWarn $
394
+ Booster.Log. logMessage (" Kore returned error" :: Text )
395
+ -- continue with the pruned Booster's result
396
+ case prunedBoosterResult of
397
+ Left (nextState, newLogs) -> do
398
+ let prunedBoosterBranchStep
399
+ | boosterResult. reason == Branching = 1
400
+ | otherwise = 0
401
+ executionLoop
402
+ logSettings
403
+ def
404
+ ( currentDepth + boosterResult. depth + prunedBoosterBranchStep
405
+ , time + bTime
406
+ , koreTime
407
+ , postProcessLogs <$> combineLogs (rpcLogs : boosterResult. logs : newLogs)
408
+ )
409
+ r{ExecuteRequest. state = nextState}
410
+ Right result -> do
411
+ logStats ExecuteM (time + bTime, koreTime)
412
+ pure . Right $
413
+ Execute
414
+ result
415
+ { depth = currentDepth + boosterResult. depth
416
+ , logs = postProcessLogs <$> combineLogs [rpcLogs, result. logs]
417
+ }
418
+
419
+ -- if we stop for a reason in fallbackReasons (default [Aborted, Stuck]),
355
420
-- revert to the old backend to re-confirm and possibly proceed
356
421
| boosterResult. reason `elem` cfg. fallbackReasons -> do
357
422
Booster.Log. withContext CtxProxy $
0 commit comments