StateReducer0

org.sigilaris.core.application.module.blueprint.StateReducer0
trait StateReducer0[F[_], Owns <: Tuple, Needs <: Tuple]

Path-agnostic state reducer.

A StateReducer0 operates on transactions without knowledge of where it will be mounted. The Path is unknown at this stage - it will be bound when the blueprint is mounted into a StateModule.

This allows writing reusable module logic that can be deployed at different paths in different applications.

Phase 5.5 update: StateReducer0 now explicitly models Owns and Needs:

  • Owns: tables that this module owns (will be created at mount time)
  • Needs: tables that this module needs from external providers
  • Combined schema (Owns ++ Needs) is what transactions operate over

Type parameters

F

the effect type

Needs

the needed schema tuple (tuple of Entry types)

Owns

the owned schema tuple (tuple of Entry types)

Attributes

Source
Blueprint.scala
Graph
Supertypes
class Object
trait Matchable
class Any
Known subtypes
class AccountsReducer[F]
class GroupsReducer[F]

Members list

Value members

Abstract methods

def apply[T <: Tx](signedTx: Signed[T])(using requiresReads: Requires[signedTx.value.Reads, Concat[Owns, Needs]], requiresWrites: Requires[signedTx.value.Writes, Concat[Owns, Needs]], ownsTables: Tables[F, Owns], provider: TablesProvider[F, Needs]): StoreF[F][(signedTx.value.Result, List[signedTx.value.Event])]

Apply a signed transaction to produce a result and events.

Apply a signed transaction to produce a result and events.

ADR-0012: All transactions must be wrapped in Signed[T] to ensure cryptographic signatures are present at compile time.

The reducer is polymorphic over the transaction type T, requiring only that T's read and write requirements are satisfied by this reducer's combined schema (Owns ++ Needs).

The reducer receives:

  • ownsTables: Tables[F, Owns] - tables owned by this module
  • provider: TablesProvider[F, Needs] - provider for external tables

Type parameters

T

the transaction type

Value parameters

ownsTables

the owned tables

provider

the provider for needed external tables

requiresReads

evidence that T's read requirements are in Owns ++ Needs

requiresWrites

evidence that T's write requirements are in Owns ++ Needs

signedTx

the signed transaction to apply (ADR-0012)

Attributes

Returns

a stateful computation returning the result and list of events

Source
Blueprint.scala