auradefi 0.1.1
PyPI GitHub

MemorySyncState

auradefi.embed.state · source

Dict-backed SyncStatePort with hard per-tenant isolation.

Constructed empty with no arguments: MemorySyncState(). Every method validates tenant_id first: anything that is not a non-empty, non-whitespace str raises auradefi.errors.TenantIsolationError (MemoryLedger's tenant hygiene, copied). One tenant's connection ids are indistinguishable from nonexistent ids for every other tenant.

__init__

__init__(self) -> None

get_state

get_state(self, tenant_id: str, connection_id: str) -> SyncState

Stored state for one connection; SyncState() when absent.

Parameters

tenant_idrequired, str

none

connection_idrequired, str

none

put_state

put_state(self, tenant_id: str, connection_id: str, state: SyncState) -> None

Store state under (tenant, connection); last write wins.

Parameters

tenant_idrequired, str

none

connection_idrequired, str

none

staterequired, SyncState

none

connections

connections(self, tenant_id: str) -> tuple[ConnectionRecord, ...]

This tenant's connection records, in creation order.

Parameters

tenant_idrequired, str

none

add_connection

add_connection(self, tenant_id: str, record: ConnectionRecord) -> None

Register record; duplicate id → ConflictError with existing_id=record.id, original record retained.

Parameters

tenant_idrequired, str

none

recordrequired, ConnectionRecord

none

Raises

ConflictError

tenants

tenants(self) -> tuple[str, ...]

Tenants known through a record OR a cursor, first-seen order.

A read never registers a tenant: only add_connection and put_state do, so enumerating cannot conjure a tenant a caller merely asked about.