LemonRouter.SessionCoordinator (lemon_router v0.1.0)

View Source

Router-owned owner of per-conversation queue semantics.

Queue mode behavior is implemented here so gateway remains execution-only. Reducer state changes live in LemonRouter.SessionTransitions; this module interprets reducer effects, owns registry/process IO, and emits router phases.

The internal LemonRouter.RunOrchestrator remains responsible for the initial LemonCore.EventBridge.subscribe_run/1 call on accepted router submissions. This coordinator only cleans up event bridge subscriptions when queued or pending submissions are later dropped from reducer state.

Summary

Functions

abort_run(run_id, reason \\ :user_requested)

@spec abort_run(binary(), term()) :: :ok

abort_session(session_key, reason \\ :user_requested)

@spec abort_session(binary(), term()) :: :ok

active_run(conversation_key)

@spec active_run(term()) :: {:ok, binary()} | :none

active_run_for_session(session_key)

@spec active_run_for_session(binary()) :: {:ok, binary()} | :none

busy?(session_key)

@spec busy?(binary()) :: boolean()

cancel(conversation_or_session, reason \\ :user_requested)

@spec cancel(binary() | term(), term()) :: :ok

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

list_active_sessions()

@spec list_active_sessions() :: [%{session_key: binary(), run_id: binary()}]

start_link(opts)

submit(conversation_key, submission, opts \\ [])

@spec submit(term(), LemonRouter.Submission.t() | map() | keyword(), keyword()) ::
  :ok | {:error, term()}

Submit a prepared router submission into the per-conversation coordinator.

Orchestrator-facing code is expected to subscribe the run on LemonCore.EventBridge before calling this function. The coordinator keeps later queue cleanup consistent, but it does not claim initial subscription ownership from the orchestrator boundary.