keiro-dsl-0.22.0.0: test/conformance-mapped-structural-enum-equality/Generated/MappedStructuralEnumEquality/ScopeGate/EventStream.hs
-- @generated by keiro-dsl 0.22.0.0 (language keiro-dsl 6) from aggregate ScopeGate; do not edit.
module Generated.MappedStructuralEnumEquality.ScopeGate.EventStream
( scopeGateCategory
, scopeGateCommandCategory
, scopeGateEventStream
, scopeGateEventStreamDef
, ScopeGateEventStream
, ScopeGateEventStreamDef
, scopeGateSnapshotFixture
) where
import Generated.MappedStructuralEnumEquality.ScopeGate.Domain
import Generated.MappedStructuralEnumEquality.ScopeGate.Codec (scopeGateCodec)
import Generated.MappedStructuralEnumEquality.ScopeGate.Transducer (scopeGateFoldFingerprint, scopeGateTransducer)
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.
scopeGateCategory :: Stream.StreamCategory ScopeGateEventStreamDef
scopeGateCategory = Stream.categoryUnsafe "scopeGate"
-- The same category text, typed for command envelopes such as PMCommand.
scopeGateCommandCategory :: Stream.StreamCategory ScopeGateCommand
scopeGateCommandCategory = Stream.categoryUnsafe "scopeGate"
type ScopeGateEventStreamDef =
EventStream (HsPred ScopeGateRegs ScopeGateCommand) ScopeGateRegs ScopeGateVertex ScopeGateCommand ScopeGateEvent
type ScopeGateEventStream =
ValidatedEventStream (HsPred ScopeGateRegs ScopeGateCommand) ScopeGateRegs ScopeGateVertex ScopeGateCommand ScopeGateEvent
scopeGateEventStreamDef :: ScopeGateEventStreamDef
scopeGateEventStreamDef =
EventStream
{ transducer = scopeGateTransducer,
initialState = ScopeGateReady,
initialRegisters = initialScopeGateRegs,
eventCodec = scopeGateCodec,
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 scopeGateFoldFingerprint (defaultStateCodec 1))
}
scopeGateSnapshotFixture :: (Int, Text)
scopeGateSnapshotFixture = (1, "scope-gate-v1")
scopeGateEventStream :: ScopeGateEventStream
scopeGateEventStream =
mkEventStreamOrThrow "ScopeGate" scopeGateEventStreamDef