status that governs what may be done with it. A freshly created session is
open and fully writable. From there it can be closed — frozen read-only while its history is
preserved — reopened, or deleted, which permanently removes it and everything it contains.
Statuses
closed is read-only, not read-blocked. Everything in a closed session — objects, thread items,
graph elements, execution history — stays fully readable. That is the point of closing rather than
deleting. Finished executions are still removed once they pass retention, 90 days by
default, in a closed session as in an open one.* Reads during deleting succeed only until the underlying data is purged; once teardown completes
the session no longer exists and reads return 403.Transitions
Only these transitions are legal. Every one is applied atomically, so concurrent callers cannot both win — the loser receives409.
Anything else is rejected:
close_session, reopen_session and delete_session all require the write role on the blob.
The write gate
The moment a session leavesopen, every mutating operation on it is rejected with 409 session_not_open. This
includes upload_session_object, delete_session_object,
post_session_thread_item, apply_session_graph_mutations and create_execution.
Reads are never gated: get_session, list_sessions, list_session_events,
download_session_object, list_session_objects and the thread and graph read commands all keep
working, in every status, until the session is actually gone.
Closing is asynchronous
close_session returns immediately with status: "closing". The write gate is already in force at
that point, so no new work can start. In the background BlobHub then stops every execution still
running in the session and waits for each to reach a terminal status. Only once the session is
quiescent does it become closed.
A close therefore takes a little time to complete even though the command returns at once —
typically tens of seconds when executions must be stopped, and near-immediate when there is nothing
running. Clients should treat closing as a transient state and wait for session.closed (or poll
get_session) rather than assuming the close is finished when the command returns.
Executions stopped by a close or delete finish with status
stopped, and each one ends the way any
execution does: an execution.ended event with status: "stopped" lands on the session’s stream. To observe
a drained execution, follow that event or read its status with get_execution.Deleting is permanent
delete_session is a hard delete. There is no tombstone and no undo. Once teardown completes, the
session and everything belonging to it are gone:
- every session object, including thread items and graph elements
- the session’s execution history and execution events
- the session’s stream, apart from the closing
session.deletedevent, which is kept for 24 hours - the session row itself
status: "deleting" and
the teardown proceeds in the background.
Nothing is purged while work is running
Deletion drains before it purges. Any execution still running is stopped and must reach a terminal status before the first piece of data is removed. This ordering is what prevents an in-flight execution from writing into a session that is being torn down and leaving orphaned data behind. Deleting anopen session therefore performs the whole sequence — stop the work, then purge — as a
single action. It does not pass through closed, and consequently raises no session.closed
event on the way (see Session Events).
After a delete
Once the session is gone, requests that reference it return403, including download_session_object for objects it
used to contain, and it no longer appears in list_sessions. Its slot in
blobhub.compute.workflow.sessions_per_revision was freed when it entered deleting.
Choosing between close and delete
Reacting to lifecycle changes
Every transition is a stored event on the session’s stream, such assession.closing, session.closed,
session.reopened, session.deleting and session.deleted. Each carries session: {status}. They are read
with list_session_events and pushed to a WebSocket by a
connection listener. A declared listener
acts only while the session is open, so it can act on session.created, session.updated and session.reopened; for
the events raised once the session is closing, closed or deleting, it records the outcome skipped with the reason
session_not_open.
session.deleted is the stream’s last event. It is written after the purge, outlives it, and is kept 24 hours,
so a client that follows a session to its end sees it. A delete from open produces no session.closed.
See Session Events for payloads and the ordering rules.
Related
Close Session
Freeze a session read-only.
Reopen Session
Return a closed session to writable.
Delete Session
Permanently remove a session.
Session Events
The events emitted by each transition.

