packages feed

keiro-dsl-0.22.0.0: test/conformance-mapped-structural-enum-equality/Generated/MappedStructuralEnumEquality/ScopeGate/Harness.hs

{-# LANGUAGE OverloadedLabels #-}
-- @generated by keiro-dsl 0.22.0.0 (language keiro-dsl 6) from aggregate ScopeGate; do not edit.
module Generated.MappedStructuralEnumEquality.ScopeGate.Harness (harnessAssertions) where

import Generated.MappedStructuralEnumEquality.ScopeGate.Domain
import Generated.MappedStructuralEnumEquality.ScopeGate.Codec (encodeScopeGateEvent, parseScopeGateEvent, scopeGateCodec, encodeRequestMapped, decodeRequestMapped, encodeRequiredScopeMapped, decodeRequiredScopeMapped)
import Generated.MappedStructuralEnumEquality.ScopeGate.Transducer (scopeGateTransducer)
import Keiki.Core (applyEventsEither, defaultValidationOptions, step, validateTransducer, fieldWitnessGet, (!))
import Keiro.Codec (eventType)
import Data.Aeson qualified as Aeson
import Data.Aeson.Key qualified as AesonKey
import Data.Aeson.KeyMap qualified as AesonKeyMap
import Data.Either (isLeft)
import Data.List.NonEmpty qualified as NonEmpty
import Data.Text qualified as T
import Keiro.Codec.Structural (FixtureCases (..))
import Generated.MappedStructuralEnumEquality.StructuralProjections qualified as StructuralProjections
import Conformance.MappedStructuralEnumEquality.Bindings qualified as Bindings

-- | (label, passed). A driver runs these and exits non-zero on any False,
-- naming the failing assertion. Filling a hole wrongly turns a specific
-- entry False; the scaffold cannot.
harnessAssertions :: [(String, Bool)]
harnessAssertions =
  [ ("validateTransducer is empty", null (validateTransducer defaultValidationOptions scopeGateTransducer))
  -- clock-free: spec samples no wall clock (verified at scaffold time)
  , ("golden round-trip: Matched", roundTrips sampleEventMatched)
  , ("golden round-trip: Differed", roundTrips sampleEventDiffered)
  , ("golden round-trip: EqRightAccepted", roundTrips sampleEventEqRightAccepted)
  , ("golden round-trip: EqLeftAccepted", roundTrips sampleEventEqLeftAccepted)
  , ("golden round-trip: NeRightAccepted", roundTrips sampleEventNeRightAccepted)
  , ("golden round-trip: NeLeftAccepted", roundTrips sampleEventNeLeftAccepted)
  , ("golden round-trip: SelfAccepted", roundTrips sampleEventSelfAccepted)
  , ("accepts Match from ScopeGateReady", acceptMatch)
  , ("accepts Differ from ScopeGateReady", acceptDiffer)
  , ("accepts EqRight from ScopeGateReady", acceptEqRight)
  , ("accepts EqLeft from ScopeGateReady", acceptEqLeft)
  , ("accepts NeRight from ScopeGateReady", acceptNeRight)
  , ("accepts NeLeft from ScopeGateReady", acceptNeLeft)
  , ("accepts Self from ScopeGateReady", acceptSelf)
  ]
  ++ mappedConformanceAssertions
  ++ forwardReplayMatch
  ++ forwardReplayDiffer
  ++ forwardReplayEqRight
  ++ forwardReplayEqLeft
  ++ forwardReplayNeRight
  ++ forwardReplayNeLeft
  ++ forwardReplaySelf

roundTrips :: ScopeGateEvent -> Bool
roundTrips e = parseScopeGateEvent (eventType scopeGateCodec e) (encodeScopeGateEvent e) == Right e

sampleEventMatched :: ScopeGateEvent
sampleEventMatched = Matched (MatchedData (snd (NonEmpty.head (fixtureCases Bindings.requiredScopeFixtures))) (snd (NonEmpty.head (fixtureCases Bindings.requestFixtures))))

sampleEventDiffered :: ScopeGateEvent
sampleEventDiffered = Differed (DifferedData (snd (NonEmpty.head (fixtureCases Bindings.requiredScopeFixtures))) (snd (NonEmpty.head (fixtureCases Bindings.requestFixtures))))

sampleEventEqRightAccepted :: ScopeGateEvent
sampleEventEqRightAccepted = EqRightAccepted (EqRightAcceptedData (snd (NonEmpty.head (fixtureCases Bindings.requiredScopeFixtures))) (snd (NonEmpty.head (fixtureCases Bindings.requestFixtures))))

sampleEventEqLeftAccepted :: ScopeGateEvent
sampleEventEqLeftAccepted = EqLeftAccepted (EqLeftAcceptedData (snd (NonEmpty.head (fixtureCases Bindings.requiredScopeFixtures))) (snd (NonEmpty.head (fixtureCases Bindings.requestFixtures))))

sampleEventNeRightAccepted :: ScopeGateEvent
sampleEventNeRightAccepted = NeRightAccepted (NeRightAcceptedData (snd (NonEmpty.head (fixtureCases Bindings.requiredScopeFixtures))) (snd (NonEmpty.head (fixtureCases Bindings.requestFixtures))))

sampleEventNeLeftAccepted :: ScopeGateEvent
sampleEventNeLeftAccepted = NeLeftAccepted (NeLeftAcceptedData (snd (NonEmpty.head (fixtureCases Bindings.requiredScopeFixtures))) (snd (NonEmpty.head (fixtureCases Bindings.requestFixtures))))

sampleEventSelfAccepted :: ScopeGateEvent
sampleEventSelfAccepted = SelfAccepted (SelfAcceptedData (snd (NonEmpty.head (fixtureCases Bindings.requiredScopeFixtures))) (snd (NonEmpty.head (fixtureCases Bindings.requestFixtures))))

acceptMatch :: Bool
acceptMatch =
  case step scopeGateTransducer (ScopeGateReady, initialScopeGateRegs) (Match (MatchData Bindings.initialScope (snd (NonEmpty.head (fixtureCases Bindings.requestFixtures))))) of
    Just (v, _, _) -> v == ScopeGateDone
    Nothing -> False

acceptDiffer :: Bool
acceptDiffer =
  case step scopeGateTransducer (ScopeGateReady, initialScopeGateRegs) (Differ (DifferData (case [value | (_, value) <- NonEmpty.toList (fixtureCases Bindings.requiredScopeFixtures), value /= Bindings.initialScope] of value : _ -> value; [] -> error "enum guard requires a matching supplied fixture") (snd (NonEmpty.head (fixtureCases Bindings.requestFixtures))))) of
    Just (v, _, _) -> v == ScopeGateDone
    Nothing -> False

acceptEqRight :: Bool
acceptEqRight =
  case step scopeGateTransducer (ScopeGateReady, initialScopeGateRegs) (EqRight (EqRightData (case [value | (_, value) <- NonEmpty.toList (fixtureCases Bindings.requiredScopeFixtures), fieldWitnessGet StructuralProjections.requiredScopeWitness value == "pipeline"] of value : _ -> value; [] -> error "enum guard requires a matching supplied fixture") (snd (NonEmpty.head (fixtureCases Bindings.requestFixtures))))) of
    Just (v, _, _) -> v == ScopeGateDone
    Nothing -> False

acceptEqLeft :: Bool
acceptEqLeft =
  case step scopeGateTransducer (ScopeGateReady, initialScopeGateRegs) (EqLeft (EqLeftData (case [value | (_, value) <- NonEmpty.toList (fixtureCases Bindings.requiredScopeFixtures), fieldWitnessGet StructuralProjections.requiredScopeWitness value == "pipeline"] of value : _ -> value; [] -> error "enum guard requires a matching supplied fixture") (snd (NonEmpty.head (fixtureCases Bindings.requestFixtures))))) of
    Just (v, _, _) -> v == ScopeGateDone
    Nothing -> False

acceptNeRight :: Bool
acceptNeRight =
  case step scopeGateTransducer (ScopeGateReady, initialScopeGateRegs) (NeRight (NeRightData (case [value | (_, value) <- NonEmpty.toList (fixtureCases Bindings.requiredScopeFixtures), fieldWitnessGet StructuralProjections.requiredScopeWitness value /= "diagnostic"] of value : _ -> value; [] -> error "enum guard requires a matching supplied fixture") (snd (NonEmpty.head (fixtureCases Bindings.requestFixtures))))) of
    Just (v, _, _) -> v == ScopeGateDone
    Nothing -> False

acceptNeLeft :: Bool
acceptNeLeft =
  case step scopeGateTransducer (ScopeGateReady, initialScopeGateRegs) (NeLeft (NeLeftData (case [value | (_, value) <- NonEmpty.toList (fixtureCases Bindings.requiredScopeFixtures), fieldWitnessGet StructuralProjections.requiredScopeWitness value /= "diagnostic"] of value : _ -> value; [] -> error "enum guard requires a matching supplied fixture") (snd (NonEmpty.head (fixtureCases Bindings.requestFixtures))))) of
    Just (v, _, _) -> v == ScopeGateDone
    Nothing -> False

acceptSelf :: Bool
acceptSelf =
  case step scopeGateTransducer (ScopeGateReady, initialScopeGateRegs) (Self (SelfData (snd (NonEmpty.head (fixtureCases Bindings.requiredScopeFixtures))) (snd (NonEmpty.head (fixtureCases Bindings.requestFixtures))))) of
    Just (v, _, _) -> v == ScopeGateDone
    Nothing -> False

-- forward/replay equality (plan 147): cross the persisted codec boundary,
-- replay the emitted chain, and compare the final vertex and every register.
forwardReplayMatch :: [(String, Bool)]
forwardReplayMatch =
  case step scopeGateTransducer (ScopeGateReady, initialScopeGateRegs) (Match (MatchData Bindings.initialScope (snd (NonEmpty.head (fixtureCases Bindings.requestFixtures))))) of
    Nothing -> [(prefix <> "forward step accepted", False)]
    Just (forwardVertex, forwardRegs, emitted) ->
      case mapM (\event -> parseScopeGateEvent (eventType scopeGateCodec event) (encodeScopeGateEvent event)) emitted of
        Left _ -> [(prefix <> "emitted chain decodes", False)]
        Right decodedEvents ->
          case applyEventsEither scopeGateTransducer (ScopeGateReady, initialScopeGateRegs) decodedEvents of
            Left _ -> [(prefix <> "replay succeeds", False)]
            Right (replayVertex, replayRegs) ->
              [ (prefix <> "final vertex", replayVertex == forwardVertex)
              , (prefix <> "register requiredScope", (replayRegs ! #requiredScope) == (forwardRegs ! #requiredScope))
              ]
  where
    prefix = "forward/replay equality: Match from ScopeGateReady -- "

-- forward/replay equality (plan 147): cross the persisted codec boundary,
-- replay the emitted chain, and compare the final vertex and every register.
forwardReplayDiffer :: [(String, Bool)]
forwardReplayDiffer =
  case step scopeGateTransducer (ScopeGateReady, initialScopeGateRegs) (Differ (DifferData (case [value | (_, value) <- NonEmpty.toList (fixtureCases Bindings.requiredScopeFixtures), value /= Bindings.initialScope] of value : _ -> value; [] -> error "enum guard requires a matching supplied fixture") (snd (NonEmpty.head (fixtureCases Bindings.requestFixtures))))) of
    Nothing -> [(prefix <> "forward step accepted", False)]
    Just (forwardVertex, forwardRegs, emitted) ->
      case mapM (\event -> parseScopeGateEvent (eventType scopeGateCodec event) (encodeScopeGateEvent event)) emitted of
        Left _ -> [(prefix <> "emitted chain decodes", False)]
        Right decodedEvents ->
          case applyEventsEither scopeGateTransducer (ScopeGateReady, initialScopeGateRegs) decodedEvents of
            Left _ -> [(prefix <> "replay succeeds", False)]
            Right (replayVertex, replayRegs) ->
              [ (prefix <> "final vertex", replayVertex == forwardVertex)
              , (prefix <> "register requiredScope", (replayRegs ! #requiredScope) == (forwardRegs ! #requiredScope))
              ]
  where
    prefix = "forward/replay equality: Differ from ScopeGateReady -- "

-- forward/replay equality (plan 147): cross the persisted codec boundary,
-- replay the emitted chain, and compare the final vertex and every register.
forwardReplayEqRight :: [(String, Bool)]
forwardReplayEqRight =
  case step scopeGateTransducer (ScopeGateReady, initialScopeGateRegs) (EqRight (EqRightData (case [value | (_, value) <- NonEmpty.toList (fixtureCases Bindings.requiredScopeFixtures), fieldWitnessGet StructuralProjections.requiredScopeWitness value == "pipeline"] of value : _ -> value; [] -> error "enum guard requires a matching supplied fixture") (snd (NonEmpty.head (fixtureCases Bindings.requestFixtures))))) of
    Nothing -> [(prefix <> "forward step accepted", False)]
    Just (forwardVertex, forwardRegs, emitted) ->
      case mapM (\event -> parseScopeGateEvent (eventType scopeGateCodec event) (encodeScopeGateEvent event)) emitted of
        Left _ -> [(prefix <> "emitted chain decodes", False)]
        Right decodedEvents ->
          case applyEventsEither scopeGateTransducer (ScopeGateReady, initialScopeGateRegs) decodedEvents of
            Left _ -> [(prefix <> "replay succeeds", False)]
            Right (replayVertex, replayRegs) ->
              [ (prefix <> "final vertex", replayVertex == forwardVertex)
              , (prefix <> "register requiredScope", (replayRegs ! #requiredScope) == (forwardRegs ! #requiredScope))
              ]
  where
    prefix = "forward/replay equality: EqRight from ScopeGateReady -- "

-- forward/replay equality (plan 147): cross the persisted codec boundary,
-- replay the emitted chain, and compare the final vertex and every register.
forwardReplayEqLeft :: [(String, Bool)]
forwardReplayEqLeft =
  case step scopeGateTransducer (ScopeGateReady, initialScopeGateRegs) (EqLeft (EqLeftData (case [value | (_, value) <- NonEmpty.toList (fixtureCases Bindings.requiredScopeFixtures), fieldWitnessGet StructuralProjections.requiredScopeWitness value == "pipeline"] of value : _ -> value; [] -> error "enum guard requires a matching supplied fixture") (snd (NonEmpty.head (fixtureCases Bindings.requestFixtures))))) of
    Nothing -> [(prefix <> "forward step accepted", False)]
    Just (forwardVertex, forwardRegs, emitted) ->
      case mapM (\event -> parseScopeGateEvent (eventType scopeGateCodec event) (encodeScopeGateEvent event)) emitted of
        Left _ -> [(prefix <> "emitted chain decodes", False)]
        Right decodedEvents ->
          case applyEventsEither scopeGateTransducer (ScopeGateReady, initialScopeGateRegs) decodedEvents of
            Left _ -> [(prefix <> "replay succeeds", False)]
            Right (replayVertex, replayRegs) ->
              [ (prefix <> "final vertex", replayVertex == forwardVertex)
              , (prefix <> "register requiredScope", (replayRegs ! #requiredScope) == (forwardRegs ! #requiredScope))
              ]
  where
    prefix = "forward/replay equality: EqLeft from ScopeGateReady -- "

-- forward/replay equality (plan 147): cross the persisted codec boundary,
-- replay the emitted chain, and compare the final vertex and every register.
forwardReplayNeRight :: [(String, Bool)]
forwardReplayNeRight =
  case step scopeGateTransducer (ScopeGateReady, initialScopeGateRegs) (NeRight (NeRightData (case [value | (_, value) <- NonEmpty.toList (fixtureCases Bindings.requiredScopeFixtures), fieldWitnessGet StructuralProjections.requiredScopeWitness value /= "diagnostic"] of value : _ -> value; [] -> error "enum guard requires a matching supplied fixture") (snd (NonEmpty.head (fixtureCases Bindings.requestFixtures))))) of
    Nothing -> [(prefix <> "forward step accepted", False)]
    Just (forwardVertex, forwardRegs, emitted) ->
      case mapM (\event -> parseScopeGateEvent (eventType scopeGateCodec event) (encodeScopeGateEvent event)) emitted of
        Left _ -> [(prefix <> "emitted chain decodes", False)]
        Right decodedEvents ->
          case applyEventsEither scopeGateTransducer (ScopeGateReady, initialScopeGateRegs) decodedEvents of
            Left _ -> [(prefix <> "replay succeeds", False)]
            Right (replayVertex, replayRegs) ->
              [ (prefix <> "final vertex", replayVertex == forwardVertex)
              , (prefix <> "register requiredScope", (replayRegs ! #requiredScope) == (forwardRegs ! #requiredScope))
              ]
  where
    prefix = "forward/replay equality: NeRight from ScopeGateReady -- "

-- forward/replay equality (plan 147): cross the persisted codec boundary,
-- replay the emitted chain, and compare the final vertex and every register.
forwardReplayNeLeft :: [(String, Bool)]
forwardReplayNeLeft =
  case step scopeGateTransducer (ScopeGateReady, initialScopeGateRegs) (NeLeft (NeLeftData (case [value | (_, value) <- NonEmpty.toList (fixtureCases Bindings.requiredScopeFixtures), fieldWitnessGet StructuralProjections.requiredScopeWitness value /= "diagnostic"] of value : _ -> value; [] -> error "enum guard requires a matching supplied fixture") (snd (NonEmpty.head (fixtureCases Bindings.requestFixtures))))) of
    Nothing -> [(prefix <> "forward step accepted", False)]
    Just (forwardVertex, forwardRegs, emitted) ->
      case mapM (\event -> parseScopeGateEvent (eventType scopeGateCodec event) (encodeScopeGateEvent event)) emitted of
        Left _ -> [(prefix <> "emitted chain decodes", False)]
        Right decodedEvents ->
          case applyEventsEither scopeGateTransducer (ScopeGateReady, initialScopeGateRegs) decodedEvents of
            Left _ -> [(prefix <> "replay succeeds", False)]
            Right (replayVertex, replayRegs) ->
              [ (prefix <> "final vertex", replayVertex == forwardVertex)
              , (prefix <> "register requiredScope", (replayRegs ! #requiredScope) == (forwardRegs ! #requiredScope))
              ]
  where
    prefix = "forward/replay equality: NeLeft from ScopeGateReady -- "

-- forward/replay equality (plan 147): cross the persisted codec boundary,
-- replay the emitted chain, and compare the final vertex and every register.
forwardReplaySelf :: [(String, Bool)]
forwardReplaySelf =
  case step scopeGateTransducer (ScopeGateReady, initialScopeGateRegs) (Self (SelfData (snd (NonEmpty.head (fixtureCases Bindings.requiredScopeFixtures))) (snd (NonEmpty.head (fixtureCases Bindings.requestFixtures))))) of
    Nothing -> [(prefix <> "forward step accepted", False)]
    Just (forwardVertex, forwardRegs, emitted) ->
      case mapM (\event -> parseScopeGateEvent (eventType scopeGateCodec event) (encodeScopeGateEvent event)) emitted of
        Left _ -> [(prefix <> "emitted chain decodes", False)]
        Right decodedEvents ->
          case applyEventsEither scopeGateTransducer (ScopeGateReady, initialScopeGateRegs) decodedEvents of
            Left _ -> [(prefix <> "replay succeeds", False)]
            Right (replayVertex, replayRegs) ->
              [ (prefix <> "final vertex", replayVertex == forwardVertex)
              , (prefix <> "register requiredScope", (replayRegs ! #requiredScope) == (forwardRegs ! #requiredScope))
              ]
  where
    prefix = "forward/replay equality: Self from ScopeGateReady -- "

mappedConformanceAssertions :: [(String, Bool)]
mappedConformanceAssertions =
  concat
    [ matchedRequiredScopeAssertions
    , matchedRequestAssertions
    , differedRequiredScopeAssertions
    , differedRequestAssertions
    , eqRightAcceptedRequiredScopeAssertions
    , eqRightAcceptedRequestAssertions
    , eqLeftAcceptedRequiredScopeAssertions
    , eqLeftAcceptedRequestAssertions
    , neRightAcceptedRequiredScopeAssertions
    , neRightAcceptedRequestAssertions
    , neLeftAcceptedRequiredScopeAssertions
    , neLeftAcceptedRequestAssertions
    , selfAcceptedRequiredScopeAssertions
    , selfAcceptedRequestAssertions
    , structuralWirePolicyAssertions
    ]

matchedRequiredScopeAssertions :: [(String, Bool)]
matchedRequiredScopeAssertions =
  [ ("mapped codec round-trip: Matched/requiredScope/" <> T.unpack label, roundTrips (Matched (MatchedData mappedValue (snd (NonEmpty.head (fixtureCases Bindings.requestFixtures))))))
  | (label, mappedValue) <- NonEmpty.toList (fixtureCases Bindings.requiredScopeFixtures)
  ]

matchedRequestAssertions :: [(String, Bool)]
matchedRequestAssertions =
  [ ("mapped codec round-trip: Matched/request/" <> T.unpack label, roundTrips (Matched (MatchedData (snd (NonEmpty.head (fixtureCases Bindings.requiredScopeFixtures))) mappedValue)))
  | (label, mappedValue) <- NonEmpty.toList (fixtureCases Bindings.requestFixtures)
  ]

differedRequiredScopeAssertions :: [(String, Bool)]
differedRequiredScopeAssertions =
  [ ("mapped codec round-trip: Differed/requiredScope/" <> T.unpack label, roundTrips (Differed (DifferedData mappedValue (snd (NonEmpty.head (fixtureCases Bindings.requestFixtures))))))
  | (label, mappedValue) <- NonEmpty.toList (fixtureCases Bindings.requiredScopeFixtures)
  ]

differedRequestAssertions :: [(String, Bool)]
differedRequestAssertions =
  [ ("mapped codec round-trip: Differed/request/" <> T.unpack label, roundTrips (Differed (DifferedData (snd (NonEmpty.head (fixtureCases Bindings.requiredScopeFixtures))) mappedValue)))
  | (label, mappedValue) <- NonEmpty.toList (fixtureCases Bindings.requestFixtures)
  ]

eqRightAcceptedRequiredScopeAssertions :: [(String, Bool)]
eqRightAcceptedRequiredScopeAssertions =
  [ ("mapped codec round-trip: EqRightAccepted/requiredScope/" <> T.unpack label, roundTrips (EqRightAccepted (EqRightAcceptedData mappedValue (snd (NonEmpty.head (fixtureCases Bindings.requestFixtures))))))
  | (label, mappedValue) <- NonEmpty.toList (fixtureCases Bindings.requiredScopeFixtures)
  ]

eqRightAcceptedRequestAssertions :: [(String, Bool)]
eqRightAcceptedRequestAssertions =
  [ ("mapped codec round-trip: EqRightAccepted/request/" <> T.unpack label, roundTrips (EqRightAccepted (EqRightAcceptedData (snd (NonEmpty.head (fixtureCases Bindings.requiredScopeFixtures))) mappedValue)))
  | (label, mappedValue) <- NonEmpty.toList (fixtureCases Bindings.requestFixtures)
  ]

eqLeftAcceptedRequiredScopeAssertions :: [(String, Bool)]
eqLeftAcceptedRequiredScopeAssertions =
  [ ("mapped codec round-trip: EqLeftAccepted/requiredScope/" <> T.unpack label, roundTrips (EqLeftAccepted (EqLeftAcceptedData mappedValue (snd (NonEmpty.head (fixtureCases Bindings.requestFixtures))))))
  | (label, mappedValue) <- NonEmpty.toList (fixtureCases Bindings.requiredScopeFixtures)
  ]

eqLeftAcceptedRequestAssertions :: [(String, Bool)]
eqLeftAcceptedRequestAssertions =
  [ ("mapped codec round-trip: EqLeftAccepted/request/" <> T.unpack label, roundTrips (EqLeftAccepted (EqLeftAcceptedData (snd (NonEmpty.head (fixtureCases Bindings.requiredScopeFixtures))) mappedValue)))
  | (label, mappedValue) <- NonEmpty.toList (fixtureCases Bindings.requestFixtures)
  ]

neRightAcceptedRequiredScopeAssertions :: [(String, Bool)]
neRightAcceptedRequiredScopeAssertions =
  [ ("mapped codec round-trip: NeRightAccepted/requiredScope/" <> T.unpack label, roundTrips (NeRightAccepted (NeRightAcceptedData mappedValue (snd (NonEmpty.head (fixtureCases Bindings.requestFixtures))))))
  | (label, mappedValue) <- NonEmpty.toList (fixtureCases Bindings.requiredScopeFixtures)
  ]

neRightAcceptedRequestAssertions :: [(String, Bool)]
neRightAcceptedRequestAssertions =
  [ ("mapped codec round-trip: NeRightAccepted/request/" <> T.unpack label, roundTrips (NeRightAccepted (NeRightAcceptedData (snd (NonEmpty.head (fixtureCases Bindings.requiredScopeFixtures))) mappedValue)))
  | (label, mappedValue) <- NonEmpty.toList (fixtureCases Bindings.requestFixtures)
  ]

neLeftAcceptedRequiredScopeAssertions :: [(String, Bool)]
neLeftAcceptedRequiredScopeAssertions =
  [ ("mapped codec round-trip: NeLeftAccepted/requiredScope/" <> T.unpack label, roundTrips (NeLeftAccepted (NeLeftAcceptedData mappedValue (snd (NonEmpty.head (fixtureCases Bindings.requestFixtures))))))
  | (label, mappedValue) <- NonEmpty.toList (fixtureCases Bindings.requiredScopeFixtures)
  ]

neLeftAcceptedRequestAssertions :: [(String, Bool)]
neLeftAcceptedRequestAssertions =
  [ ("mapped codec round-trip: NeLeftAccepted/request/" <> T.unpack label, roundTrips (NeLeftAccepted (NeLeftAcceptedData (snd (NonEmpty.head (fixtureCases Bindings.requiredScopeFixtures))) mappedValue)))
  | (label, mappedValue) <- NonEmpty.toList (fixtureCases Bindings.requestFixtures)
  ]

selfAcceptedRequiredScopeAssertions :: [(String, Bool)]
selfAcceptedRequiredScopeAssertions =
  [ ("mapped codec round-trip: SelfAccepted/requiredScope/" <> T.unpack label, roundTrips (SelfAccepted (SelfAcceptedData mappedValue (snd (NonEmpty.head (fixtureCases Bindings.requestFixtures))))))
  | (label, mappedValue) <- NonEmpty.toList (fixtureCases Bindings.requiredScopeFixtures)
  ]

selfAcceptedRequestAssertions :: [(String, Bool)]
selfAcceptedRequestAssertions =
  [ ("mapped codec round-trip: SelfAccepted/request/" <> T.unpack label, roundTrips (SelfAccepted (SelfAcceptedData (snd (NonEmpty.head (fixtureCases Bindings.requiredScopeFixtures))) mappedValue)))
  | (label, mappedValue) <- NonEmpty.toList (fixtureCases Bindings.requestFixtures)
  ]

structuralWirePolicyAssertions :: [(String, Bool)]
structuralWirePolicyAssertions =
  [ ("wire policy unknown fields: conformance.Request.v1", all (\(_, value) -> isLeft (decodeRequestMapped (insertObjectField "__keiro_unknown" (Aeson.Bool True) (encodeRequestMapped value)))) (NonEmpty.toList (fixtureCases Bindings.requestFixtures)))
  , ("wire enum arm: conformance.RequiredScope.v1/pipeline", any (\(_, value) -> encodeRequiredScopeMapped value == Aeson.String "pipeline" && decodeRequiredScopeMapped (Aeson.String "pipeline") == Right value) (NonEmpty.toList (fixtureCases Bindings.requiredScopeFixtures)))
  , ("wire enum arm: conformance.RequiredScope.v1/diagnostic", any (\(_, value) -> encodeRequiredScopeMapped value == Aeson.String "diagnostic" && decodeRequiredScopeMapped (Aeson.String "diagnostic") == Right value) (NonEmpty.toList (fixtureCases Bindings.requiredScopeFixtures)))
  , ("wire enum unknown tag: conformance.RequiredScope.v1", isLeft (decodeRequiredScopeMapped (Aeson.String "__keiro_unknown")))
  ]

insertObjectField :: T.Text -> Aeson.Value -> Aeson.Value -> Aeson.Value
insertObjectField key inserted (Aeson.Object objectValue) = Aeson.Object (AesonKeyMap.insert (AesonKey.fromText key) inserted objectValue)
insertObjectField _ _ value = value