packages feed

keiro-dsl-0.7.0.0: test/conformance-behavior-complete/Generated/BehaviorComplete/Journey/EventStream.hs

-- @generated by keiro-dsl; do not edit. Regenerated from the .keiro spec.
module Generated.BehaviorComplete.Journey.EventStream
  ( journeyCategory
  , journeyEventStream
  , journeyEventStreamDef
  , JourneyEventStream
  , JourneyEventStreamDef
  , journeySnapshotFixture
  ) where

import Generated.BehaviorComplete.Journey.Domain
import Generated.BehaviorComplete.Journey.Codec (journeyCodec)
import Generated.BehaviorComplete.Journey.Transducer (journeyFoldFingerprint, journeyTransducer)
import Keiki.Core (HsPred)
import Keiro.EventStream (EventStream (..), SnapshotPolicy (..))
import Keiro.EventStream.Validate (ValidatedEventStream, mkEventStreamOrThrow)
import Data.Text (Text)
import Keiro.Snapshot.Codec (defaultStateCodec, withFoldFingerprint)
import Keiro.Stream qualified as Stream

-- The validated aggregate stream category (hole-kind 5: referenced, never retyped).
-- Entity streams are '<category>-<id>' via Keiro.Stream.entityStream.
-- categoryUnsafe is safe here because this generated literal passed the DSL category proof.
journeyCategory :: Stream.StreamCategory a
journeyCategory = Stream.categoryUnsafe "journey"

type JourneyEventStreamDef =
  EventStream (HsPred JourneyRegs JourneyCommand) JourneyRegs JourneyVertex JourneyCommand JourneyEvent

type JourneyEventStream =
  ValidatedEventStream (HsPred JourneyRegs JourneyCommand) JourneyRegs JourneyVertex JourneyCommand JourneyEvent

journeyEventStreamDef :: JourneyEventStreamDef
journeyEventStreamDef =
  EventStream
    { transducer = journeyTransducer
    , initialState = JourneyEmpty
    , initialRegisters = initialJourneyRegs
    , eventCodec = journeyCodec
    , resolveStreamName = Stream.streamName
    , snapshotPolicy = Every 1
    -- The snapshot discriminator composes: the spec's state-codec version (bump it
    -- in the spec's `state-codec version=` clause), keiki's register and
    -- control-state shape hashes, and this fold fingerprint derived from the
    -- spec's transition surface (guards, writes, emits, states, register
    -- initials, referenced rules). Spec-visible fold changes invalidate old
    -- snapshots automatically. Version-2 Hole-owned transitions additionally
    -- compose their explicit hand-owned FoldVersion tokens here; bump the
    -- corresponding token whenever that Hole behavior changes.
    , stateCodec = Just (withFoldFingerprint journeyFoldFingerprint (defaultStateCodec 1))
    }

journeySnapshotFixture :: (Int, Text)
journeySnapshotFixture = (1, "behavior-complete-v1")

journeyEventStream :: JourneyEventStream
journeyEventStream =
  mkEventStreamOrThrow "Journey" journeyEventStreamDef