Skip to content

Commit

Permalink
Abort when Kore's simplifier throws DecidePredicateUnknown (#392)
Browse files Browse the repository at this point in the history
Fixes
#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 <goodlyrottenapple@gmail.com>
Co-authored-by: github-actions <github-actions@github.com>
Co-authored-by: rv-jenkins <admin@runtimeverification.com>
  • Loading branch information
4 people authored Dec 8, 2023
1 parent c841bfa commit 9469f18
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
2 changes: 1 addition & 1 deletion dev-tools/kore-rpc-dev/Server.hs
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ main = do
jsonRpcServer
srvSettings
(const $ respond koreRespond)
[handleErrorCall, handleSomeException]
[Kore.handleDecidePredicateUnknown, handleErrorCall, handleSomeException]
interruptHandler _ = do
when (logLevel >= LevelInfo) $
hPutStrLn stderr "[Info#proxy] Server shutting down"
Expand Down
12 changes: 10 additions & 2 deletions tools/booster/Proxy.hs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ module Proxy (

import Control.Concurrent.MVar qualified as MVar
import Control.Monad (when)
import Control.Monad.Catch (MonadCatch (..), catch)
import Control.Monad.IO.Class (MonadIO, liftIO)
import Control.Monad.Logger qualified as Log
import Control.Monad.Trans.Except (runExcept)
Expand Down Expand Up @@ -43,6 +44,7 @@ import Kore.JsonRpc.Types qualified as ExecuteRequest (ExecuteRequest (..))
import Kore.JsonRpc.Types qualified as SimplifyRequest (SimplifyRequest (..))
import Kore.JsonRpc.Types.Log qualified as RPCLog
import Kore.Log qualified
import Kore.Log.DecidePredicateUnknown (DecidePredicateUnknown, externaliseDecidePredicateUnknown)
import Kore.Syntax.Definition (SentenceAxiom)
import Kore.Syntax.Json.Types qualified as KoreJson
import SMT qualified
Expand Down Expand Up @@ -72,7 +74,7 @@ serverError detail = ErrorObj ("Server error: " <> detail) (-32032)
respondEither ::
forall m.
Log.MonadLogger m =>
MonadIO m =>
(MonadIO m, MonadCatch m) =>
ProxyConfig ->
Respond (API 'Req) m (API 'Res) ->
Respond (API 'Req) m (API 'Res) ->
Expand Down Expand Up @@ -418,7 +420,13 @@ respondEither ProxyConfig{statsVar, forceFallback, boosterState} booster kore re
postExecSimplify ::
LogSettings -> TimeSpec -> Maybe Text -> KoreDefinition -> API 'Res -> m (API 'Res)
postExecSimplify logSettings start mbModule def = \case
Execute res -> Execute <$> simplifyResult res
Execute res ->
Execute
<$> ( simplifyResult res
`catch` ( \(err :: DecidePredicateUnknown) ->
pure res{reason = Aborted, unknownPredicate = Just . externaliseDecidePredicateUnknown $ err}
)
)
other -> pure other
where
-- timeLog :: TimeDiff -> Maybe [LogEntry]
Expand Down
2 changes: 1 addition & 1 deletion tools/booster/Server.hs
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ main = do
jsonRpcServer
srvSettings
(const $ Proxy.respondEither proxyConfig boosterRespond koreRespond)
[handleErrorCall, handleSomeException]
[Kore.handleDecidePredicateUnknown, handleErrorCall, handleSomeException]
interruptHandler _ = do
when (logLevel >= LevelInfo) $
hPutStrLn stderr "[Info#proxy] Server shutting down"
Expand Down

0 comments on commit 9469f18

Please sign in to comment.