Skip to content

Commit bfef6b5

Browse files
geo2agoodlyrottenapplegithub-actionsrv-jenkins
authored andcommitted
Abort when Kore's simplifier throws DecidePredicateUnknown (#392)
Fixes runtimeverification/hs-backend-booster#373 This PR makes `kore-rpc-booster` return `"execute"` responses with `"reason": "aborted"` in cases when Kore's simplifier fails due to `DecidePredicateUnknown` in the post-exec simplification in `Proxy.hs`. **Scenario before** ``` "execute" request -> booster execute (X steps) > kore execute (0-1steps) -> kore simplify -> DecidePredicateUnknown -> JsonRpcError` ``` returning `JsonRpcError` resulted in loosing information gained by executing in booster for X steps + in kore for up to 1 step. **Scenario now** ``` "execute" request -> booster execute (X steps) > kore execute (0-1steps) -> kore simplify -> DecidePredicateUnknown -> ExecuteResult {reason=Aborted, unknownPredicate = <predicate>}` ``` this this change, we return the reached state (may be branching) and do not lose information anymore. Additionaly, we return the unknown predicate, so that `pyk` can decide what to do with these. PR to `pyk` that takes advantage of this feature by intrroducing `Undecided` nodes to KCFG: runtimeverification/pyk#744 --------- Co-authored-by: Samuel Balco <[email protected]> Co-authored-by: github-actions <[email protected]> Co-authored-by: rv-jenkins <[email protected]>
1 parent 6e358d8 commit bfef6b5

File tree

3 files changed

+12
-4
lines changed

3 files changed

+12
-4
lines changed

booster/dev-tools/kore-rpc-dev/Server.hs

+1-1
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ main = do
180180
jsonRpcServer
181181
srvSettings
182182
(const $ respond koreRespond)
183-
[handleErrorCall, handleSomeException]
183+
[Kore.handleDecidePredicateUnknown, handleErrorCall, handleSomeException]
184184
interruptHandler _ = do
185185
when (logLevel >= LevelInfo) $
186186
hPutStrLn stderr "[Info#proxy] Server shutting down"

booster/tools/booster/Proxy.hs

+10-2
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ module Proxy (
1414

1515
import Control.Concurrent.MVar qualified as MVar
1616
import Control.Monad (when)
17+
import Control.Monad.Catch (MonadCatch (..), catch)
1718
import Control.Monad.IO.Class (MonadIO, liftIO)
1819
import Control.Monad.Logger qualified as Log
1920
import Control.Monad.Trans.Except (runExcept)
@@ -43,6 +44,7 @@ import Kore.JsonRpc.Types qualified as ExecuteRequest (ExecuteRequest (..))
4344
import Kore.JsonRpc.Types qualified as SimplifyRequest (SimplifyRequest (..))
4445
import Kore.JsonRpc.Types.Log qualified as RPCLog
4546
import Kore.Log qualified
47+
import Kore.Log.DecidePredicateUnknown (DecidePredicateUnknown, externaliseDecidePredicateUnknown)
4648
import Kore.Syntax.Definition (SentenceAxiom)
4749
import Kore.Syntax.Json.Types qualified as KoreJson
4850
import SMT qualified
@@ -72,7 +74,7 @@ serverError detail = ErrorObj ("Server error: " <> detail) (-32032)
7274
respondEither ::
7375
forall m.
7476
Log.MonadLogger m =>
75-
MonadIO m =>
77+
(MonadIO m, MonadCatch m) =>
7678
ProxyConfig ->
7779
Respond (API 'Req) m (API 'Res) ->
7880
Respond (API 'Req) m (API 'Res) ->
@@ -418,7 +420,13 @@ respondEither ProxyConfig{statsVar, forceFallback, boosterState} booster kore re
418420
postExecSimplify ::
419421
LogSettings -> TimeSpec -> Maybe Text -> KoreDefinition -> API 'Res -> m (API 'Res)
420422
postExecSimplify logSettings start mbModule def = \case
421-
Execute res -> Execute <$> simplifyResult res
423+
Execute res ->
424+
Execute
425+
<$> ( simplifyResult res
426+
`catch` ( \(err :: DecidePredicateUnknown) ->
427+
pure res{reason = Aborted, unknownPredicate = Just . externaliseDecidePredicateUnknown $ err}
428+
)
429+
)
422430
other -> pure other
423431
where
424432
-- timeLog :: TimeDiff -> Maybe [LogEntry]

booster/tools/booster/Server.hs

+1-1
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ main = do
168168
jsonRpcServer
169169
srvSettings
170170
(const $ Proxy.respondEither proxyConfig boosterRespond koreRespond)
171-
[handleErrorCall, handleSomeException]
171+
[Kore.handleDecidePredicateUnknown, handleErrorCall, handleSomeException]
172172
interruptHandler _ = do
173173
when (logLevel >= LevelInfo) $
174174
hPutStrLn stderr "[Info#proxy] Server shutting down"

0 commit comments

Comments
 (0)