The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(gateway): a CLI barrier check that clears a goal barrier repaints the other viewers
Tekniumb86be0c09870
diff --git a/gateway/session_viewer_automation.py b/gateway/session_viewer_automation.pyindex 825f523cf16..d998b5e8d17 100644--- a/gateway/session_viewer_automation.py+++ b/gateway/session_viewer_automation.py@@ -158,9 +158,12 @@ async def automation(connection, ref, params):from gateway.session_commands import _session_workspacewith _profile_runtime_scope(home), _session_workspace(runner, live.source):return invoke(runner, kind, target, call, args, kwargs)+ rows = lambda: tuple(authority.db.get_meta(f"{k}:{target}") for k in ("goal", "loop", "heartbeat"))+ # A "read" can still write: is_waiting / goal_blocks_tick clear a satisfied goal barrier.+ before = rows() if call in _READS else None# The judge and gates block for seconds: off the loop, with the caller's context (profile scope).result = await asyncio.to_thread(run)- if call not in _READS:+ if before is None or rows() != before:# The classic CLI drives this session's automation: other viewers (Ink, Desktop) repaint from the event.from gateway.session_control_actions import publishpublish(authority, ref.session_id)diff --git a/tests/gateway/test_session_viewer_automation.py b/tests/gateway/test_session_viewer_automation.pyindex 17c4a1a3a33..17dd71909f0 100644--- a/tests/gateway/test_session_viewer_automation.py+++ b/tests/gateway/test_session_viewer_automation.py@@ -118,3 +118,30 @@ async def test_cli_driven_loop_changes_repaint_the_other_viewers(owner):await owner.call('loop', 'state')await owner.call('loop', 'goal_blocks_tick')assert len(updates) == 2++[email protected]('kind, call', [('goal', 'is_waiting'), ('loop', 'goal_blocks_tick')])+async def test_a_read_that_clears_a_goal_barrier_repaints_the_other_viewers(owner, kind, call):+ """``is_waiting`` / ``goal_blocks_tick`` drop a satisfied barrier (the goal resumes, the loop defers to+ it): that write must reach the other viewers even though an unchanged poll stays quiet."""+ import asyncio+ import sys+ child = await asyncio.create_subprocess_exec(sys.executable, '-c', 'import sys; sys.stdin.read()',+ stdin=asyncio.subprocess.PIPE)+ try:+ await owner.call('goal', 'set', 'wait for the child')+ await owner.call('goal', 'wait_on', child.pid)+ await owner.call('loop', 'set', 'check the queue', interval_seconds=60)+ updates = []+ owner.authority.sessions[owner.ref.session_id].event_stream.observers.add(+ lambda frame: frame['params']['type'] == 'session.control.update'+ and updates.append(frame['params']['payload']))+ await owner.call(kind, call)+ assert updates == [] # barrier still holds: nothing changed, nothing published+ finally:+ child.stdin.close()+ await asyncio.wait_for(child.wait(), 10)+ await owner.call(kind, call)+ assert len(updates) == 1 and 'wait_barrier' not in updates[0]['control']['goal']+ assert updates[0]['control']['loop']['deferred_by_goal'] is True