The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
feat: delete used sessions by tombstoning terminal receipts
Tekniumaa8d4fedb921
diff --git a/hermes_state_mutations.py b/hermes_state_mutations.pyindex 89ab2974c57..ba4dcecb566 100644--- a/hermes_state_mutations.py+++ b/hermes_state_mutations.py@@ -62,24 +62,10 @@ def apply_action(db, conn, session_id, operation, payload, *, prepared=None):def _delete(db, conn, session_id, payload):- from hermes_state_mutation_guards import require_idle, delete_targets- targets = delete_targets(conn, session_id)- require_idle(db, conn, targets)- # Completed receipts remain queryable. Until storage has durable tombstones,- # retaining the row is safer than erasing retry/adoption evidence.- for sid in targets:- if (conn.execute('SELECT 1 FROM session_admissions WHERE target_session_id=? LIMIT 1', (sid,)).fetchone()- or conn.execute('SELECT 1 FROM worker_executions WHERE session_id=? LIMIT 1', (sid,)).fetchone()):- raise RuntimeStoreError('retained_receipts')- from hermes_state_mutation_retirement import retire_routes- retire_routes(conn, targets)- for sid in targets:- db._bump_conversation_generation(conn, sid, 'session_reset')- conn.execute('UPDATE sessions SET parent_session_id=NULL, runtime_revision=runtime_revision+1 WHERE parent_session_id=?', (sid,))- conn.execute('DELETE FROM messages WHERE session_id=?', (sid,))- conn.executemany('DELETE FROM sessions WHERE id=?', [(sid,) for sid in targets])- db._delete_unreferenced_system_prompts(conn)- return set(), {'deleted_ids': targets}+ # Terminal admission/worker rows become digest tombstones so exact retries and+ # adoption checks still resolve after the transcript is gone.+ from hermes_state_mutation_retirement import delete_in_transaction+ return delete_in_transaction(db, conn, session_id, payload)def _rewind(db, conn, session_id, payload):diff --git a/tests/gateway/fixtures/terminal_retirement_daemon.py b/tests/gateway/fixtures/terminal_retirement_daemon.pydeleted file mode 100644index b3fd6956645..00000000000--- a/tests/gateway/fixtures/terminal_retirement_daemon.py+++ /dev/null@@ -1,7 +0,0 @@-"""Compose the reported deletion dispatch hook; all transports remain ordinary."""-import runpy-import hermes_state_mutations-from hermes_state_mutation_retirement import delete_in_transaction--hermes_state_mutations._delete = delete_in_transaction-runpy.run_module('gateway.run', run_name='__main__')diff --git a/tests/gateway/test_used_delete_restart.py b/tests/gateway/test_used_delete_restart.pyindex 7597cc9ae4f..0bf780a6c4a 100644--- a/tests/gateway/test_used_delete_restart.py+++ b/tests/gateway/test_used_delete_restart.py@@ -106,8 +106,7 @@ def test_used_api_and_native_delete_restart_exact_retry(tmp_path):assert db.execute("SELECT 1 FROM session_admissions WHERE request_id='busy-once'").fetchone()try:- # Only dispatch is composed until the action lane installs the reported hook.- with daemon(root, home, env, barrier=True, fixture='terminal_retirement_daemon.py') as (proc, desc):+ with daemon(root, home, env, barrier=True) as (proc, desc):first = asyncio.run(api_request())native_sid = asyncio.run(native_turn(desc))asyncio.run(busy_delete_refused(desc))