Deleting a session
session.delete() stops the session's run (and background work it owns), ends its readers, and hides
it at once: listSessions() leaves it out, and every call of it rejects with SessionNotFoundError.
Its data goes once the instance's storage is closed, since pi-durable cannot delete a conversation
under an open Harness: when the instance next closes (an idle close, close(), or the next close
after a crash) the runtime hands the deleted sessions to the host's erase(), with the lease held.
A failure is reported as erase_failed and tried again at the next close. A host without erase()
only hides the session.
The runtime keeps its sessions in one document (runtime.sessions): each session's creation and update
times, title, first message's start, metadata, approval rule and request ID, a child session's sub-agent
and parent, and the deleted sessions still to erase. listSessions() is one read of it, and a
conversation is a session only while it lists it. The commit that deletes a session stores the document
whole, and pi-durable drops its earlier revisions with it: the deleted session's title, first message
and metadata leave storage then, before its conversation is erased.
A store on pi-durable's SQLite schema erases with @chia1104/motoko-core/sqlite, the statements every
such store shares:
eraseConversations(database, conversations, { prefix?, label? }): Promise<void>database is chord's SqliteDatabase (@earendil-works/chord/sqlite), over a file in Node or a
Durable Object's database. In one transaction it erases each conversation, the conversations its tasks
made, and their entries, tasks, submissions and documents; it skips a conversation that still has
unfinished work or that another conversation forks from. pi-durable has no way to delete a
conversation, so it writes pi-durable's tables directly, against its SQLite schema version 2
(pi-durable 1.6), and refuses a database in any other version, changing nothing. It deletes rows;
overwriting their bytes (PRAGMA secure_delete) is the store's to arrange where its database allows it.