keiro-dsl-0.18.0.0: test/conformance-refined-base16/Generated/RefinedBase16/HashStore/EventStream.hs
-- @generated by keiro-dsl 0.18.0.0 (language keiro-dsl 6) from aggregate HashStore; do not edit.
module Generated.RefinedBase16.HashStore.EventStream
( hashStoreCategory
, hashStoreCommandCategory
, hashStoreEventStream
, hashStoreEventStreamDef
, HashStoreEventStream
, HashStoreEventStreamDef
, hashStoreSnapshotFixture
) where
import Generated.RefinedBase16.HashStore.Domain
import Generated.RefinedBase16.HashStore.Codec (hashStoreCodec)
import Generated.RefinedBase16.HashStore.Transducer (hashStoreFoldFingerprint, hashStoreTransducer)
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.
hashStoreCategory :: Stream.StreamCategory HashStoreEventStreamDef
hashStoreCategory = Stream.categoryUnsafe "hashStore"
-- The same category text, typed for command envelopes such as PMCommand.
hashStoreCommandCategory :: Stream.StreamCategory HashStoreCommand
hashStoreCommandCategory = Stream.categoryUnsafe "hashStore"
type HashStoreEventStreamDef =
EventStream (HsPred HashStoreRegs HashStoreCommand) HashStoreRegs HashStoreVertex HashStoreCommand HashStoreEvent
type HashStoreEventStream =
ValidatedEventStream (HsPred HashStoreRegs HashStoreCommand) HashStoreRegs HashStoreVertex HashStoreCommand HashStoreEvent
hashStoreEventStreamDef :: HashStoreEventStreamDef
hashStoreEventStreamDef =
EventStream
{ transducer = hashStoreTransducer,
initialState = HashStoreEmpty,
initialRegisters = initialHashStoreRegs,
eventCodec = hashStoreCodec,
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 hashStoreFoldFingerprint (defaultStateCodec 1))
}
hashStoreSnapshotFixture :: (Int, Text)
hashStoreSnapshotFixture = (1, "refined-base16-v1")
hashStoreEventStream :: HashStoreEventStream
hashStoreEventStream =
mkEventStreamOrThrow "HashStore" hashStoreEventStreamDef