packages feed

keiro-dsl-0.2.0.0: test/conformance-intake-runtime/Generated/HospitalCapacity/IncidentInbox/Inbox.hs

{-# OPTIONS_GHC -Wno-unused-top-binds #-}

-- @generated by keiro-dsl; do not edit. Regenerated from the .keiro spec.
module Generated.HospitalCapacity.IncidentInbox.Inbox (
    InboxAck (..),
    inboxDedupePolicy,
    inboxPersistence,
    inboxDisposition,
) where

import Keiro.Inbox.Types (InboxDedupePolicy (..), InboxPersistence (..), InboxResult (..))

-- The dedupe policy (hole-kind 4), lowered to the live InboxDedupePolicy.
inboxDedupePolicy :: InboxDedupePolicy
inboxDedupePolicy = PreferIntegrationMessageId

{- | Success-path envelope retention passed to runInboxTransactionWith.
Failures always retain their full operator-facing dead-letter envelope.
Dedupe-only success rows decode with an empty payload.
-}
inboxPersistence :: InboxPersistence
inboxPersistence = PersistDedupeOnly

-- The service's ack decision for each inbox classification.
data InboxAck = InboxAckOk | InboxRetry | InboxDeadLetter
    deriving stock (Eq, Show)

-- The disposition table (hole-kind 2) over the LIVE Keiro.Inbox.Types.InboxResult.
-- duplicate => ackOk and previouslyFailed => deadLetter are the dangerous
-- inversions the spec states explicitly.
inboxDisposition :: InboxResult a -> InboxAck
inboxDisposition r = case r of
    InboxProcessed _ -> InboxAckOk
    InboxDuplicate -> InboxAckOk
    InboxInProgress -> InboxRetry
    InboxPreviouslyFailed _ -> InboxDeadLetter

-- handler-level failures (not InboxResult): decodeFailed => deadLetter, dedupeFailed => deadLetter, storeFailed => retry