The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix: prepared mutations after compression skip the closed ancestor's transcript guard
Teknium412e3f862526
diff --git a/hermes_state_mutation_guards.py b/hermes_state_mutation_guards.pyindex c5c45cfd011..7a463dd3acb 100644--- a/hermes_state_mutation_guards.py+++ b/hermes_state_mutation_guards.py@@ -1,4 +1,5 @@"""Transcript mutation guards evaluated on the receipt's writer connection."""+from hermes_state_common import _ENDED_ROW_SQL, _ended_by_compressionfrom hermes_state_runtime import RuntimeStoreError@@ -11,6 +12,10 @@ def require_idle(db, conn, session_ids):raise RuntimeStoreError('unknown_execution')if states:raise RuntimeStoreError('session_busy')+ # A logical owner closed by compression is an ancestor, not a transcript+ # target; its live successor (also in session_ids) carries the lease/lock.+ if _ended_by_compression(conn.execute(_ENDED_ROW_SQL, (sid,)).fetchone()):+ continuedb._check_transcript_write_guards(conn, sid, None,reject_active_turn_lease=True, reject_active_compression_lock=True)diff --git a/tests/gateway/test_session_mutation_compress.py b/tests/gateway/test_session_mutation_compress.pyindex e9b6bcf7e8c..7482a625f94 100644--- a/tests/gateway/test_session_mutation_compress.py+++ b/tests/gateway/test_session_mutation_compress.py@@ -88,6 +88,14 @@ def test_compress_runs_summary_and_next_inference_on_atomic_successor(tmp_path):count = len(peer.requests)assert await call('session.mutate', **params) == resultassert len(peer.requests) == count+ # The logical owner row is now closed by compression; later prepared+ # mutations must still target the live successor, not crash on the parent.+ after = await call('session.resume', session_id=sid)+ branch = await call('session.mutate', session_id=sid, request_id='branch-after-compress',+ operation='branch', payload={}, expected_revision=after['revision'],+ expected_generation=after['execution_generation'])+ child = await call('session.resume', session_id=branch['branched_session_id'])+ assert 'SUMMARY_RETAINED_FACTS' in json.dumps(child['messages'])with sqlite3.connect(home / 'state.db') as db:assert db.execute('SELECT end_reason FROM sessions WHERE id=?', (sid,)).fetchone()[0] == 'compression'assert db.execute('SELECT count(*) FROM messages WHERE session_id=?', (sid,)).fetchone()[0] > 0