Files
hermes-agent/tests/gateway/test_session_mutation_cold.py
Teknium 8b1040feb6 test: the Webapp login is the machine owner in the main tests that pinned it as a stranger
Teknium's ruling: Hermes is single-user, a signed-in Webapp/dashboard login IS the machine owner.
Eight origin/main tests asserted the dashboard login (session token, stub login or a second IdP
account) acted as a separate identity. Only that assertion changes in each; idempotent retries,
restart survival, atomic binding, FIFO, stop and approval checks stay.

- test_session_mutation_import_owner: the login's edit is the owner's (200, same receipt as the
  native exact retry), not a 403 steal.
- test_session_mutation_cold: the login's stale-revision edit after restart is a revision_conflict,
  not an ownership 403.
- test_session_mutation_retirement / test_used_delete_restart: the login's exact delete retry after
  restart replays the owner's receipt.
- test_operator_cross_surface[native|dashboard]: both admissions carry the owner's uid subject and
  no operator hand-off payload.
- test_hosted_room_auth_daemon (renamed test_every_signed_in_tab_shares_the_owners_hosted_rooms):
  a second IdP account cannot sign in; two owner tabs share one Group Chat list and either may stop
  or approve.
- test_sessions_adopt: the browser login opens an old chat itself (owner claim), adopt takes the rest.
2026-10-27 17:32:49 -07:00

32 lines
2.4 KiB
Python

"""Cold history authorization does not manufacture an execution route."""
import asyncio
import httpx
import pytest
from tests.gateway.test_native_http_auth import daemon, ticket, headers
from tests.gateway.test_session_mutation_retirement import create
@pytest.mark.platforms("linux")
def test_cold_import_mutation_binds_owner_across_restart(tmp_path):
with daemon(tmp_path) as (home, descriptor), httpx.Client(base_url=descriptor['api_origin'], trust_env=False) as client:
# Native creation remains independently authorized while cold history binds.
asyncio.run(create(home, descriptor))
response = client.post('/api/sessions/import', headers=headers(ticket(home, descriptor)), json={
'request_id': 'import', 'expected_revision': 0, 'sessions': [
{'id': 'cold', 'source': 'cli', 'messages': [{'role': 'user', 'content': 'history'}]}]})
assert response.status_code == 200, response.text
snapshot = client.get('/api/sessions/cold/mutation-snapshot', headers=headers(ticket(home, descriptor)))
assert snapshot.status_code == 200, snapshot.text
body = {'request_id': 'edit', 'expected_revision': snapshot.json()['runtime_revision'], 'title': 'Cold history'}
edited = client.patch('/api/sessions/cold', headers=headers(ticket(home, descriptor)), json=body)
assert edited.status_code == 200, edited.text
stale = client.patch('/api/sessions/cold', headers=headers(ticket(home, descriptor)), json=body | {'request_id': 'competitor', 'title': 'stale'})
assert stale.status_code == 409 and 'revision_conflict' in stale.text
with daemon(tmp_path) as (home, descriptor), httpx.Client(base_url=descriptor['api_origin'], trust_env=False) as client:
assert client.patch('/api/sessions/cold', headers=headers(ticket(home, descriptor)), json=body).json() == edited.json()
assert client.get('/api/sessions/cold/mutation-snapshot', headers=headers(ticket(home, descriptor))).status_code == 200
# The dashboard login is the owner the binding names: a new request on the stale revision is
# an ordinary revision conflict, not an ownership refusal.
login = client.patch('/api/sessions/cold', headers={'Authorization': 'Bearer normal-http-owner'}, json=body | {'request_id': 'login'})
assert login.status_code == 409 and 'revision_conflict' in login.text, login.text