State Management
A domain's StateManager is the aggregate-facing persistence boundary. Applications normally subclass it, bind the appropriate data manager/connector, and assign it through Domain.__statemgr__.
Inside an aggregate action:
class UserAggregate(Aggregate):
@action("user-created", resources="user")
async def create_user(self, data):
record = self.init_resource(
"user",
**serialize_mapping(data),
_id=self.aggroot.identifier,
)
await self.statemgr.insert(record)
return record
@action("user-invalidated", resources="user")
async def invalidate_user(self):
await self.statemgr.invalidate(self.rootobj)
The domain processor opens and closes the relevant transaction and records command activity. Use data_query for declared read helpers; expose client-facing reads through DomainQueryManager and QueryResource.
Optimistic concurrency is governed by FLUVIUS_IF_MATCH_VERIFY and FLUVIUS_IF_MATCH_HEADER. Do not bypass resource scoping or mutate the underlying connector directly from command code.