The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(webapp): a separately launched dashboard forwards a signed-in owner's session edits again
Tekniumb3bfb3779a6b
diff --git a/hermes_cli/web_server_sessions.py b/hermes_cli/web_server_sessions.pyindex b9cdb24b48e..e6baa732143 100644--- a/hermes_cli/web_server_sessions.py+++ b/hermes_cli/web_server_sessions.py@@ -243,8 +243,13 @@ async def _mutate_via_gateway_owner(profile, actor, params):('session_id', 'request_id', 'expected_revision', 'operation', 'payload') if key in params}if params.get('expected_generation') is not None:call['expected_generation'] = params['expected_generation']+ # A sign-in is the machine owner (owner_identity), which is this same-user socket's own peer+ # subject: let the socket mint it natively. The verifier lets a peer NAME only a structured+ # login subject, so forwarding the owner's OS subject explicitly would be refused.+ from gateway.owner_identity import host_owner_subject+ subject = None if actor.subject == host_owner_subject() else actor.subjecttry:- async with connect_gateway(endpoint=endpoint, subject=actor.subject) as client:+ async with connect_gateway(endpoint=endpoint, subject=subject) as client:return await client.rpc('session.mutate', **call)except GatewayRPCError:# The owner's own refusal frame: a verdict the caller maps to the direct path's status.diff --git a/tests/hermes_cli/test_web_server_session_owner_forward.py b/tests/hermes_cli/test_web_server_session_owner_forward.pyindex ffe2bc4b239..98b6734291b 100644--- a/tests/hermes_cli/test_web_server_session_owner_forward.py+++ b/tests/hermes_cli/test_web_server_session_owner_forward.py@@ -364,3 +364,36 @@ async def test_owner_restarted_between_discovery_and_mint_is_a_retryable_503(tmpfor peer in peers:peer.close()assert (exc.value.status_code, exc.value.detail) == (503, 'owner_unreachable')+++async def test_a_signed_in_owner_forwards_through_the_real_ticket_verifier(tmp_path, monkeypatch):+ """A dashboard sign-in is the machine owner, so a standalone dashboard forwarding its edit must+ get a ticket from the running gateway's real control verifier, and the ticket names the owner.+ The verifier only lets a peer name a structured login subject; the owner's own OS subject is+ the peer's, so naming it explicitly would be refused and every edit would 503."""+ from gateway.control_socket import GatewayControlServer+ from gateway.owner_identity import host_owner_subject+ from gateway.runtime_bootstrap import TicketStore+ from hermes_cli import web_server_sessions++ request = _standalone_request(monkeypatch, tmp_path)+ request.state.session = SimpleNamespace(user_id='admin', provider='basic', issuer='')+ _discover(monkeypatch, _real_endpoint(_closed_port()))+ server = GatewayControlServer(tmp_path)+ server.ticket_store = TicketStore('i-main', frozenset({'p-main'}))+ monkeypatch.setattr('hermes_cli.gateway_client.private_control_query',+ lambda home, line, timeout=5: server.handle_request_line(+ line.strip(), peer_subject=host_owner_subject()))+ grants = []++ def admitted(endpoint, ticket):+ grants.append(server.ticket_store.redeem(ticket, profile_id=None, purpose='interactive'))+ raise _StopAfterMint++ monkeypatch.setattr('hermes_cli.gateway_client.gateway_ws_target', admitted)+ with pytest.raises(_StopAfterMint):+ await web_server_sessions._mutate_session_request(+ request, None, 'session-8', request_id='req-8', expected_revision=0,+ operation='archive', payload={})+ assert [grant['subject'] for grant in grants] == [host_owner_subject()]