Skip to content
Developer Preview

SyncSession

One conversation, on the blocking surface — the sync twin of Session.

Class in muse_code

The read views (fold, pending) are the async session’s own objects: they are plain synchronous reads already, and a wrapped copy would be a second surface to keep honest. The handler registrations (on_approval …) delegate unchanged — the handlers run on the private loop while a blocking verb is pumping it. The synchronous MUTATORS (turn, stop_retrying, replay_answered) route through the runner’s lock: they touch structures the loop’s own tasks touch, and an unlocked turn() racing a pumping verb can double-mint a handle.

SyncSession(session: Session[_I], runner: _LoopRunner)

Property Type Description
session_id str The server-named session id.
opening SessionOpening | None Which verb opened this session, and what it answered.
durability SessionDurabilityProfile The profile this session discharges a host death under.
fold SessionFoldView The fold’s read view (the async session’s own object).
pending PendingCommandView[_I] The set’s read/safe-drive view; same threading caveat as fold — read from the verb-driving thread.
Method Signature Description
send_user_turn send_user_turn(options: SendUserTurnOptions[_I]) -> 'SyncTurn' Submit a user turn and block for its ack (twin of send_user_turn).
turn turn(turn_id: str) -> 'SyncTurn' The handle for a turn, created on first mention from either side.
on_approval on_approval(handler: ApprovalHandler) -> None Answer approvals with handler, unchanged.
on_approval_error on_approval_error(handler: ApprovalFailureHandler) -> None Observe approval round trips that did not complete.
on_gap_error on_gap_error(handler: GapFillFailureHandler) -> None Observe fills that did not complete.
stop_retrying stop_retrying(command_id: str) -> PendingRetirement[_I] | None “Abandoned”: stop one entry’s retry loop (sync, locked).
replay_answered replay_answered(command_id: str, answer: ReplayAnswer[_I]) -> PendingRetirement[_I] | Literal['held'] Feed a consumer-driven replay’s answer through the rules.
resolve_snapshot_join resolve_snapshot_join(facts: SnapshotJoinFacts) -> tuple[PendingRetirement[_I], ...] Blocking twin of resolve_snapshot_join.
resolve_reconnect resolve_reconnect() -> tuple[PendingRetirement[_I], ...] Blocking twin of resolve_reconnect.
Source

clients/sdk-py/src/muse_code/sync_facade.py:321