Pixir.SessionSupervisor (pixir v0.1.6)

Copy Markdown View Source

DynamicSupervisor of Pixir.Session processes (ADR 0001). A Session is started on demand — for a new conversation or to resume a persisted one — and is :transient, so it stays down once it finishes cleanly. The CLI may also ask this supervisor to stop all currently running Sessions during process shutdown so filesystem writer leases are released before the OS process exits.

Summary

Functions

Returns a specification to start this module under a supervisor.

Start a Session. Accepts :id (generated if absent), :workspace, :role, :force_release_writer_lease?, and :force_release_reason. Forced lease release is a break-glass resume path for stale/ambiguous writer evidence; active leases are refused. Returns {:ok, session_id, pid} so the caller always learns the id.

Stop every live Session owned by this runtime.

Functions

child_spec(arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

start_link(init_arg)

start_session(opts \\ [])

@spec start_session(keyword()) :: {:ok, String.t(), pid()} | {:error, term()}

Start a Session. Accepts :id (generated if absent), :workspace, :role, :force_release_writer_lease?, and :force_release_reason. Forced lease release is a break-glass resume path for stale/ambiguous writer evidence; active leases are refused. Returns {:ok, session_id, pid} so the caller always learns the id.

stop_all_sessions()

@spec stop_all_sessions() :: {:ok, map()} | {:error, map()}

Stop every live Session owned by this runtime.

This is a CLI shutdown helper, not a stale-writer recovery path: it only terminates processes that are currently supervised in this BEAM instance. Stale lease files left by crashed or killed processes remain fail-closed for explicit resume handling.