shikumi-tools-0.5.0.0: test/McpAdapterSpec.hs
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE OverloadedRecordDot #-}
-- | The MCP adapter against the released @baikai-mcp@ client: single-tool
-- adaptation, checked names, the owned registry and a ReAct run over a real
-- connection to an in-memory stdio server.
module McpAdapterSpec (tests) where
import Baikai qualified as B
import Baikai.Error (BaikaiError (..))
import Baikai.Error qualified as BE
import Baikai.Mcp.Client (McpOutcome (..), McpStreamConfig (..), Unfinished (..), UnfinishedReason (..), defaultMcpLimits, mcpStreamConfig, withMcpStream)
import Baikai.Mcp.Client qualified as Client
import Baikai.Mcp.Content (decodeContentBlock)
import Baikai.Mcp.Error (Delivery (..), McpErrorKind (..), mcpError)
import Baikai.Mcp.Protocol (defaultDrainLimits)
import Baikai.Mcp.Tool (McpTool (..), McpToolCall (..), McpToolError (..), McpToolResult (..), OutputCheck (..), StructuredContent (..))
import Baikai.Mcp.Transport.Stream (McpStream (..))
import Control.Concurrent.Async (async, cancel)
import Control.Concurrent.STM
import Control.Exception (finally)
import Control.Lens ((^.))
import Data.Aeson (Value (..), object, toJSON, (.=))
import Data.Aeson qualified as Aeson
import Data.Aeson.Key qualified as Key
import Data.Aeson.KeyMap qualified as KeyMap
import Data.Aeson.Types (Object)
import Data.ByteString (ByteString)
import Data.ByteString qualified as BS
import Data.ByteString.Char8 qualified as BS8
import Data.Either (isLeft)
import Data.Generics.Labels ()
import Data.IORef
import Data.Map.Strict qualified as Map
import Data.Text (Text)
import Data.Text qualified as T
import Data.Vector qualified as V
import Effectful (Eff, IOE, liftIO, runEff)
import Effectful.Dispatch.Dynamic (interpret)
import Effectful.Error.Static (Error, runErrorNoCallStack, throwError)
import Fixtures (expectedWeather, weatherQuestion, weatherRegistry, weatherSignature)
import Shikumi.Agent.ReAct
import Shikumi.Error (ShikumiError (..), isTransient)
import Shikumi.LLM (LLM (..))
import Shikumi.Testing (mkTextResponse, mkToolCallResponse, runEffScript)
import Shikumi.Tool
import Shikumi.Tool.Mcp
import Shikumi.Tool.Output
import Test.Tasty (TestTree, testGroup)
import Test.Tasty.HUnit
tests :: TestTree
tests =
testGroup
"MCP adapter"
[ names,
singleTool,
failures,
registry,
agent
]
-- ---------------------------------------------------------------------------
-- Descriptors and scripted invocation
objectSchema :: [(Text, Text)] -> Value
objectSchema props = object ["type" .= ("object" :: Text), "properties" .= object [(Key.fromText k, object ["type" .= t]) | (k, t) <- props]]
remoteTool :: Text -> McpTool
remoteTool n =
McpTool
{ name = n,
title = Nothing,
description = Just ("remote " <> n),
inputSchema = objectSchema [("msg", "string")],
outputSchema = Nothing,
annotations = Nothing,
headerMirrors = [],
raw = KeyMap.fromList [("name", String n)]
}
resultOf :: [Value] -> StructuredContent -> Bool -> McpToolResult
resultOf blocks structured err =
McpToolResult
{ content = map decodeContentBlock blocks,
structured = structured,
isError = err,
outputCheck = NoOutputSchema,
raw = KeyMap.fromList ([("content", toJSON blocks)] <> [("structuredContent", v) | StructuredContent v <- [structured]]),
continuationRounds = 0
}
textBlock :: Text -> Value
textBlock t = object ["type" .= ("text" :: Text), "text" .= t]
-- | A closure that records each call and answers with a fixed outcome.
scripted :: Either McpToolError (McpOutcome McpToolResult) -> IO (IORef [McpToolCall], McpInvoke)
scripted outcome = do
ref <- newIORef []
pure (ref, \call -> modifyIORef' ref (<> [call]) >> pure outcome)
adaptOrFail :: Text -> McpTool -> McpInvoke -> IO SomeTool
adaptOrFail s t invoke = either (assertFailure . T.unpack . renderMcpAdapterError) pure (mcpToolFor s t invoke)
runTool :: SomeTool -> Value -> IO (Either ShikumiError (Either ToolError ToolOutput))
runTool t args = runEffScript [] (runErasedOutput t args)
-- ---------------------------------------------------------------------------
names :: TestTree
names =
testGroup
"names"
[ testCase "sanitized and prefixed" $
mcpToolName "git.hub" "search/code" @?= "mcp__git_hub__search_code",
testCase "cut to 64 characters" $ do
let n = mcpToolName "srv" (T.replicate 100 "x")
T.length n @?= 64
maxToolNameLength @?= 64,
testCase "the model sees the public name, the description and the original schema" $ do
(_, invoke) <- scripted (Right (McpCompleted (resultOf [] NoStructuredContent False)))
t <- adaptOrFail "git" (remoteTool "status") invoke
someToolName t @?= "mcp__git__status"
someToolDescription t @?= "remote status"
someToolSchema t @?= objectSchema [("msg", "string")],
testCase "caller-chosen names are checked" $ do
(_, invoke) <- scripted (Right (McpCompleted (resultOf [] NoStructuredContent False)))
assertBool "overlay name accepted" (either (const False) ((== "overlay__git") . someToolName) (mcpToolNamed "overlay__git" (remoteTool "status") invoke))
assertBool "dot refused" (isLeft (mcpToolNamed "a.b" (remoteTool "status") invoke))
assertBool "empty server refused" (isLeft (mcpToolFor "" (remoteTool "status") invoke))
]
singleTool :: TestTree
singleTool =
testGroup
"single tool"
[ testCase "native name and arguments are forwarded unchanged" $ do
(calls, invoke) <- scripted (Right (McpCompleted (resultOf [textBlock "hi"] NoStructuredContent False)))
t <- adaptOrFail "srv" (remoteTool "echo.v2") invoke
let args = object ["msg" .= ("hi" :: Text), "nested" .= object ["n" .= (1 :: Int)]]
r <- runTool t args
r @?= Right (Right (textToolOutput "hi"))
sent <- readIORef calls
map (\c -> (c.tool.name, Object c.arguments)) sent @?= [("echo.v2", args)],
testCase "structured-only results, a present null included, are kept" $ do
let expect structured expected = do
(_, invoke) <- scripted (Right (McpCompleted (resultOf [] structured False)))
t <- adaptOrFail "srv" (remoteTool "calc") invoke
r <- runTool t (object [])
r @?= Right (Right (ToolOutput (B.ToolResult V.empty False) expected []))
expect (StructuredContent (object ["sum" .= (3 :: Int)])) (Just (object ["sum" .= (3 :: Int)]))
expect (StructuredContent Null) (Just Null)
expect NoStructuredContent Nothing,
testCase "a tool error stays model-visible, even when empty" $ do
(_, invoke) <- scripted (Right (McpCompleted (resultOf [] NoStructuredContent True)))
t <- adaptOrFail "srv" (remoteTool "fail") invoke
r <- runTool t (object [])
case r of
Right (Right o) -> do
o.result ^. #isError @?= True
assertBool "visible" ("Tool error:" `T.isPrefixOf` renderToolOutput o)
other -> assertFailure (show other),
testCase "mixed blocks keep images natively and everything else as JSON" $ do
let image = object ["type" .= ("image" :: Text), "data" .= ("aGk=" :: Text), "mimeType" .= ("image/png" :: Text)]
badImage = object ["type" .= ("image" :: Text), "data" .= ("%%%" :: Text), "mimeType" .= ("image/png" :: Text)]
audio = object ["type" .= ("audio" :: Text), "data" .= ("aGk=" :: Text), "mimeType" .= ("audio/wav" :: Text), "annotations" .= object ["priority" .= (1 :: Int)]]
link = object ["type" .= ("resource_link" :: Text), "uri" .= ("file:///a" :: Text), "name" .= ("a" :: Text)]
unknown = object ["type" .= ("hologram" :: Text)]
structured = object ["ok" .= True]
(_, invoke) <- scripted (Right (McpCompleted (resultOf [textBlock "caption", image, badImage, audio, link, unknown] (StructuredContent structured) False)))
t <- adaptOrFail "srv" (remoteTool "mixed") invoke
r <- runTool t (object [])
r
@?= Right
( Right
( ToolOutput
(B.ToolResult (V.fromList [B.ToolResultText (B.TextContent "caption"), B.ToolResultImage (B.ImageContent "hi" "image/png")]) False)
(Just structured)
[badImage, audio, link, unknown]
)
),
testCase "arguments that are not an object are refused before sending" $ do
(calls, invoke) <- scripted (Right (McpCompleted (resultOf [] NoStructuredContent False)))
t <- adaptOrFail "srv" (remoteTool "echo") invoke
r <- runTool t (toJSON [1 :: Int])
r @?= Right (Left (ToolArgsInvalid "mcp__srv__echo" "the arguments must be a JSON object"))
readIORef calls >>= (@?= []) . map (const ()),
testCase "unmirrorable arguments are an observation" $ do
(_, invoke) <- scripted (Left (ToolArgumentsUnmirrorable "msg is not a string"))
t <- adaptOrFail "srv" (remoteTool "echo") invoke
r <- runTool t (object [])
r @?= Right (Left (ToolArgsInvalid "mcp__srv__echo" "msg is not a string"))
]
failures :: TestTree
failures =
testGroup
"failures"
[ testCase "an uncertain call aborts once, non-retryable, and is not replayed" $ do
(calls, invoke) <- scripted (Left (ToolRequestFailed (mcpError TimedOut Uncertain "the request timed out")))
t <- adaptOrFail "srv" (remoteTool "deploy") invoke
r <- runTool t (object [])
case r of
Left e@(ProviderError be) -> do
assertBool "not transient" (not (isTransient e))
be.category @?= BE.OtherError
assertBool "names the tool" ("mcp__srv__deploy" `T.isInfixOf` be.message)
assertBool "says it may have run" ("may have processed" `T.isInfixOf` be.message)
other -> assertFailure (show other)
length <$> readIORef calls >>= (@?= 1),
testCase "refusals, drift, contract failures and unfinished calls abort" $ do
let violates = ToolOutputViolatesSchema [] (resultOf [] (StructuredContent Null) False)
outcomes =
[ Left (ToolRequestFailed (mcpError RemoteRpcError Answered "invalid params")),
Left (ToolRequestFailed (mcpError RequestDenied NotSent "denied by policy")),
Left (ToolDescriptorDrift (mcpError RemoteRpcError Answered "header mismatch")),
Left violates,
Left (ToolOutputUnverifiable "unsupported keyword" (resultOf [] (StructuredContent Null) False)),
Left (ToolResultMalformed "content must be an array"),
Right (McpUnfinished (Unfinished Nothing Nothing 1 NeedsClientInput))
]
mapM_
( \o -> do
(_, invoke) <- scripted o
t <- adaptOrFail "srv" (remoteTool "x") invoke
r <- runTool t (object [])
case r of
Left (ProviderError be) -> be.category @?= BE.OtherError
other -> assertFailure (show o <> " gave " <> show other)
)
outcomes
]
-- ---------------------------------------------------------------------------
discoveryOf :: Text -> [Text] -> IO McpDiscovery
discoveryOf s ns = do
(_, invoke) <- scripted (Right (McpCompleted (resultOf [textBlock s] NoStructuredContent False)))
either (assertFailure . T.unpack . renderMcpAdapterError) (\ts -> pure (McpDiscovery s ts [])) (mcpToolsFrom s invoke (map remoteTool ns))
expectError :: Either McpAdapterError a -> IO McpAdapterError
expectError = either pure (const (assertFailure "expected an adapter error"))
registry :: TestTree
registry =
testGroup
"owned registry"
[ testCase "tools that sanitize or truncate to one name are rejected" $ do
(_, invoke) <- scripted (Right (McpCompleted (resultOf [] NoStructuredContent False)))
e1 <- expectError (mcpToolsFrom "s" invoke [remoteTool "x.y", remoteTool "x_y"])
e1 @?= PublicNameCollision "mcp__s__x_y" (McpToolIdentity "s" "x_y") (McpOwned (McpToolIdentity "s" "x.y"))
let long suffix = T.replicate 70 "a" <> suffix
e2 <- expectError (mcpToolsFrom "s" invoke [remoteTool (long "1"), remoteTool (long "2")])
case e2 of
PublicNameCollision {} -> pure ()
other -> assertFailure (show other)
e3 <- expectError (mcpToolsFrom "s" invoke [remoteTool "dup", remoteTool "dup"])
e3 @?= DuplicateNativeTool (McpToolIdentity "s" "dup"),
testCase "servers whose names share a segment are rejected" $ do
a <- discoveryOf "a.b" ["one"]
b <- discoveryOf "a_b" ["two"]
r <- either (assertFailure . show) pure (registerMcpToolsFrom a (newMcpRegistry (mkRegistry [])))
e <- expectError (registerMcpToolsFrom b r)
e @?= ServerSegmentCollision "a_b" "a.b" "a_b",
testCase "delimiters inside names cannot steal another server's name" $ do
a <- discoveryOf "a" ["x__y"]
b <- discoveryOf "a__x" ["y"]
r <- either (assertFailure . show) pure (registerMcpToolsFrom a (newMcpRegistry (mkRegistry [])))
e <- expectError (registerMcpToolsFrom b r)
e @?= PublicNameCollision "mcp__a__x__y" (McpToolIdentity "a__x" "y") (McpOwned (McpToolIdentity "a" "x__y")),
testCase "a local tool is never shadowed" $ do
let localTool = mkDynTool "mcp__s__echo" "local" (object []) (\_ -> pure (Right (textToolOutput "local")))
base = newMcpRegistry (mkRegistry [localTool])
d <- discoveryOf "s" ["echo"]
e <- expectError (registerMcpToolsFrom d base)
e @?= PublicNameCollision "mcp__s__echo" (McpToolIdentity "s" "echo") LocalTool
registryNames (mcpRegistryTools base) @?= ["mcp__s__echo"],
testCase "refresh replaces exactly one server and is idempotent" $ do
git1 <- discoveryOf "git" ["status", "log"]
web <- discoveryOf "web" ["fetch"]
let base = newMcpRegistry weatherRegistry
r1 <- either (assertFailure . show) pure (registerMcpToolsFrom git1 base >>= registerMcpToolsFrom web)
registryNames (mcpRegistryTools r1) @?= ["get_weather", "mcp__git__log", "mcp__git__status", "mcp__web__fetch"]
git2 <- discoveryOf "git" ["status", "diff"]
r2 <- either (assertFailure . show) pure (refreshMcpToolsFrom git2 r1)
registryNames (mcpRegistryTools r2) @?= ["get_weather", "mcp__git__diff", "mcp__git__status", "mcp__web__fetch"]
r3 <- either (assertFailure . show) pure (refreshMcpToolsFrom git2 r2)
registryNames (mcpRegistryTools r3) @?= registryNames (mcpRegistryTools r2)
mcpRegistryOwner "mcp__git__diff" r3 @?= Just (McpOwned (McpToolIdentity "git" "diff"))
mcpRegistryOwner "get_weather" r3 @?= Just LocalTool
mcpRegistryOwner "mcp__git__log" r3 @?= Nothing
Map.keys (mcpRegistryServers r3) @?= ["git", "web"]
registryNames (mcpRegistryTools (unregisterMcpTools "git" r3)) @?= ["get_weather", "mcp__web__fetch"],
testCase "a failed refresh changes nothing" $ do
git1 <- discoveryOf "git" ["status"]
r1 <- either (assertFailure . show) pure (registerMcpToolsFrom git1 (newMcpRegistry weatherRegistry))
clash <- discoveryOf "git" ["status", "w"]
let bad = clash {tools = [if t.identity.nativeName == "w" then t {publicName = "get_weather"} else t | t <- clash.tools]}
e <- expectError (refreshMcpToolsFrom bad r1)
e @?= PublicNameCollision "get_weather" (McpToolIdentity "git" "w") LocalTool
registryNames (mcpRegistryTools r1) @?= ["get_weather", "mcp__git__status"]
e2 <- expectError (registerMcpToolsFrom git1 r1)
e2 @?= ServerAlreadyRegistered "git"
other <- discoveryOf "other" ["a"]
e3 <- expectError (refreshMcpToolsFrom other r1)
e3 @?= ServerNotRegistered "other"
]
-- ---------------------------------------------------------------------------
-- A real connection: an in-memory 2026-07-28 stdio server
data Pipe = Pipe {toServer :: TQueue (Maybe ByteString), toClient :: TQueue (Maybe ByteString)}
field :: Aeson.Key -> Value -> Maybe Value
field k = \case
Object o -> KeyMap.lookup k o
_ -> Nothing
paramsOf :: Value -> Object
paramsOf v = case field "params" v of
Just (Object o) -> o
_ -> KeyMap.empty
reply :: Value -> [(Aeson.Key, Value)] -> Value
reply req fields = object ["jsonrpc" .= ("2.0" :: Text), "id" .= field "id" req, "result" .= object fields]
-- | Serves @echo@ (text and structured) and @add@ (structured only, with an
-- output schema), and fails @flaky@ by closing its output mid-call.
fixtureServer :: IORef [Object] -> (Value -> IO ()) -> IO () -> Value -> IO ()
fixtureServer calls send closeOutput msg = case (field "method" msg, field "id" msg) of
(Just (String m), Just _) -> case m of
"server/discover" -> send (reply msg ["resultType" .= ("complete" :: Text), "supportedVersions" .= ["2026-07-28" :: Text], "capabilities" .= object ["tools" .= object []]])
"tools/list" ->
send
( reply
msg
[ "tools"
.= [ object ["name" .= ("echo" :: Text), "description" .= ("Echo a message." :: Text), "inputSchema" .= objectSchema [("msg", "string")]],
object
[ "name" .= ("add" :: Text),
"inputSchema" .= objectSchema [("a", "number"), ("b", "number")],
"outputSchema" .= object ["type" .= ("object" :: Text), "properties" .= object ["sum" .= object ["type" .= ("number" :: Text)]], "required" .= ["sum" :: Text]]
],
object ["name" .= ("flaky" :: Text), "inputSchema" .= objectSchema []]
]
]
)
"tools/call" -> do
let p = paramsOf msg
args = case KeyMap.lookup "arguments" p of
Just (Object a) -> a
_ -> KeyMap.empty
modifyIORef' calls (<> [p])
case KeyMap.lookup "name" p of
Just "echo" ->
let said = maybe Null id (KeyMap.lookup "msg" args)
in send (reply msg ["content" .= [object ["type" .= ("text" :: Text), "text" .= said]], "structuredContent" .= object ["echoed" .= said]])
Just "add" ->
let num k = case KeyMap.lookup k args of
Just (Number n) -> n
_ -> 0
in send (reply msg ["structuredContent" .= object ["sum" .= (num "a" + num "b")]])
Just "flaky" -> closeOutput
_ -> send (reply msg ["content" .= ([] :: [Value]), "isError" .= True])
_ -> send (object ["jsonrpc" .= ("2.0" :: Text), "id" .= field "id" msg, "error" .= object ["code" .= (-32601 :: Int), "message" .= ("Method not found" :: Text)]])
_ -> pure ()
withFixture :: (IORef [Object] -> Client.McpConnection -> IO a) -> IO a
withFixture k = do
p <- Pipe <$> newTQueueIO <*> newTQueueIO
calls <- newIORef []
let send v = atomically (writeTQueue p.toClient (Just (BS.toStrict (Aeson.encode v) <> "\n")))
closeOutput = atomically (writeTQueue p.toClient Nothing)
loop buffered = case BS8.elemIndex '\n' buffered of
Just i -> do
mapM_ (fixtureServer calls send closeOutput) (Aeson.decodeStrict (BS.take i buffered))
loop (BS.drop (i + 1) buffered)
Nothing -> atomically (readTQueue p.toServer) >>= maybe (pure ()) (loop . (buffered <>))
stream =
McpStream
{ readChunk = maybe "" id <$> atomically (readTQueue p.toClient),
writeChunk = \b -> atomically (writeTQueue p.toServer (Just b)),
closeStream = Just (atomically (writeTQueue p.toServer Nothing))
}
cfg = (mcpStreamConfig "fixture") {probeTimeout = 1, streamLimits = defaultMcpLimits {Client.requestTimeout = 5, Client.connectTimeout = 5}}
server <- async (loop BS.empty)
r <- withMcpStream cfg stream (k calls) `finally` cancel server
either (assertFailure . show) pure r
-- | Script the model and record every request context.
recording :: [B.Response] -> Eff '[LLM, Error ShikumiError, IOE] a -> IO (Either ShikumiError a, [B.Context])
recording script action = do
scriptRef <- newIORef script
contexts <- newIORef []
result <-
runEff
. runErrorNoCallStack
. interpret
( \_ -> \case
Complete _ ctx _ -> do
liftIO (modifyIORef' contexts (<> [ctx]))
next <- liftIO (atomicModifyIORef' scriptRef (\case [] -> ([], Nothing); x : rest -> (rest, Just x)))
maybe (throwError (ProviderFailure "unexpected model call")) pure next
Stream {} -> pure []
)
$ action
(result,) <$> readIORef contexts
cfgNative :: ReActConfig
cfgNative = defaultReActConfig {protocol = ProtocolNative}
agent :: TestTree
agent =
testGroup
"agent over a real connection"
[ testCase "discovers two tools, calls one and submits a typed answer" $
withFixture $ \calls c -> do
discovered <- mcpTools defaultDrainLimits c
d <- either (assertFailure . T.unpack . renderMcpAdapterError) pure discovered
map (.publicName) d.tools @?= ["mcp__fixture__echo", "mcp__fixture__add", "mcp__fixture__flaky"]
reg <- either (assertFailure . show) pure (registerMcpToolsFrom d (newMcpRegistry (mkRegistry [])))
let tools = mcpRegistryTools reg
args = object ["msg" .= ("bonjour" :: Text)]
turn1 = mkToolCallResponse "call-1" "mcp__fixture__echo" args
turn2 = mkToolCallResponse "final-1" finalToolName (toJSON expectedWeather)
(result, requests) <- recording [turn1, turn2] (startSession weatherSignature tools cfgNative weatherQuestion >>= runSession weatherSignature tools cfgNative)
case result of
Right (SessionFinished answer _) -> answer @?= expectedWeather
other -> assertFailure (show (fmap (const ()) other))
sent <- readIORef calls
map (KeyMap.delete "_meta") sent @?= [KeyMap.fromList [("name", String "echo"), ("arguments", args)]]
case requests of
[first, second] -> do
let offered = [(t ^. #name, t ^. #parameters) | t <- V.toList (first ^. #tools)]
lookup "mcp__fixture__echo" offered @?= Just (objectSchema [("msg", "string")])
lookup "mcp__fixture__add" offered @?= Just (objectSchema [("a", "number"), ("b", "number")])
let results = [p | B.ToolResultMessage p <- V.toList (second ^. #messages)]
case results of
[p] -> do
p ^. #toolCallId @?= "call-1"
p ^. #content
@?= V.fromList
[ B.ToolResultText (B.TextContent "bonjour"),
B.ToolResultText (B.TextContent "Structured JSON: {\"echoed\":\"bonjour\"}")
]
_ -> assertFailure ("expected one tool result, got " <> show (length results))
_ -> assertFailure ("expected two model requests, got " <> show (length requests)),
testCase "a structured-only result with a checked output schema is kept" $
withFixture $ \_ c -> do
d <- mcpTools defaultDrainLimits c >>= either (assertFailure . show) pure
case [t | t <- d.tools, t.publicName == "mcp__fixture__add"] of
[t] -> do
r <- runTool t.tool (object ["a" .= (2 :: Int), "b" .= (3 :: Int)])
r @?= Right (Right (ToolOutput (B.ToolResult V.empty False) (Just (object ["sum" .= (5 :: Int)])) []))
_ -> assertFailure "add not discovered",
testCase "a call lost mid-flight ends the run and is sent once" $
withFixture $ \calls c -> do
d <- mcpTools defaultDrainLimits c >>= either (assertFailure . show) pure
reg <- either (assertFailure . show) pure (registerMcpToolsFrom d (newMcpRegistry (mkRegistry [])))
let tools = mcpRegistryTools reg
turn1 = mkToolCallResponse "call-1" "mcp__fixture__flaky" (object [])
(result, requests) <- recording [turn1, mkTextResponse "unused"] (startSession weatherSignature tools cfgNative weatherQuestion >>= runSession weatherSignature tools cfgNative)
case result of
Left e@(ProviderError be) -> do
assertBool "not transient" (not (isTransient e))
assertBool "uncertain" ("may have processed" `T.isInfixOf` be.message)
other -> assertFailure (show (fmap (const ()) other))
length requests @?= 1
length <$> readIORef calls >>= (@?= 1)
]