Skip to content

The agent that grows with you

fix(dashboard): log the owner-lock refusal a bulk session write gets

Teknium30fa377ff170
diff --git a/hermes_cli/web_server_sessions.py b/hermes_cli/web_server_sessions.py
index dd2fd3cd5ea..85e318de8a1 100644
--- a/hermes_cli/web_server_sessions.py
+++ b/hermes_cli/web_server_sessions.py
@@ -300,6 +300,9 @@ def _with_session_maintenance(profile, operation, *args):
with exclusive_maintenance([home]):
return operation(*args)
except OwnershipConflict as exc:
+ # uvicorn runs at log_level=warning, so a handled 4xx leaves no server-side trace and the
+ # refusal reads as a UI bug (#138915). Bulk store maintenance has no owner verb: name it.
+ _log.warning('session write refused for %s: %s', home, exc)
raise HTTPException(status_code=409, detail=str(exc)) from exc
diff --git a/tests/hermes_cli/test_session_mutation_standalone.py b/tests/hermes_cli/test_session_mutation_standalone.py
index 87dfa033395..1330d43d7a4 100644
--- a/tests/hermes_cli/test_session_mutation_standalone.py
+++ b/tests/hermes_cli/test_session_mutation_standalone.py
@@ -60,7 +60,7 @@ async def test_standalone_edits_commit_with_owner_guards(tmp_path, monkeypatch):
@pytest.mark.asyncio
-async def test_standalone_edit_refuses_while_a_gateway_owns_the_store(tmp_path, monkeypatch):
+async def test_standalone_edit_refuses_while_a_gateway_owns_the_store(tmp_path, monkeypatch, caplog):
app = _standalone_app(tmp_path, monkeypatch)
with SessionDB(db_path=tmp_path / 'state.db') as db:
db.create_session('owned', source='cli')
@@ -72,6 +72,8 @@ async def test_standalone_edit_refuses_while_a_gateway_owns_the_store(tmp_path,
refused = await client.patch('/api/sessions/owned',
json={'request_id': 'r1', 'expected_revision': 0, 'title': 'X'})
assert refused.status_code == 409, refused.text
+ # uvicorn logs no handled 4xx: the refusal itself must leave a server-side trace (#138915).
+ assert 'session write refused' in caplog.text
# A composed gateway whose authority is not up yet never falls back to a writer.
app.state.gateway_runner = object()
pending = await client.patch('/api/sessions/owned',