Files
hermes-agent/tests/gateway/test_shared_session_controls.py
Teknium e1a10b0bc2 ci: bring the branch's own code under main's strict ruff config
Main made the strict ruff config the default (`ruff check .`, blocking), and
the branch's code carried 278 findings under it (main itself is clean). Fixed:

- PLW1510 (86): `check=False` on each subprocess.run, preserving behaviour,
  as main's own sweep (0006a5e229) did.
- ASYNC220 (9, test fixtures only): `noqa` with the reason, main's convention
  for a Popen that returns at once and whose handle the test drives.
- ruff's safe autofixes plus the narrow unsafe ones (UP006/UP037/RUF100/RUF013/
  PLR0402/RUF059 underscore renames/UP031/UP041/UP017/FURB167/PIE807/RUF007/
  RUF015/RUF022/FURB162), and by hand: four %-formats to f-strings, three
  unused unpacked names, one fixture loop over `.items()`.

No behaviour change. `ruff check .` passes; scripts/check passes; the 412 test
files mirroring every edited file pass (3 tests/pm files that fail only under
that batch's uv lookup pass solo, before and after this commit).
2026-10-10 17:59:08 -07:00

29 lines
1.4 KiB
Python

"""Shared control behavior through real execution and transport boundaries."""
import json
import os
from pathlib import Path
import subprocess
import sys
def test_shared_approval_outlives_viewer_and_bypasses_fifo(tmp_path):
repo = Path(__file__).resolve().parents[2]
home, state = tmp_path / 'home', tmp_path / 'state'
home.mkdir()
state.mkdir()
env = {k: os.environ[k] for k in ('PATH', 'SYSTEMROOT', 'LANG', 'TZ', 'TIRITH_ENABLED') if k in os.environ}
env.update(HOME=str(home), USERPROFILE=str(home), HERMES_HOME=str(state), PYTHONPATH=str(repo))
result = subprocess.run([sys.executable, str(Path(__file__).parent / 'fixtures' / 'authority_controls_peer.py')],
cwd=repo, env=env, stdin=subprocess.DEVNULL, capture_output=True, text=True, timeout=100, check=False)
assert result.returncode == 0, result.stdout + '\n' + result.stderr
receipt = json.loads((state / 'receipt.json').read_text())
print(json.dumps(receipt))
assert receipt['real_terminal_effect'] and receipt['fifo_bypassed'] and receipt['detach_kept_pending']
def test_control_identity_rejects_foreign_and_retired_workers(tmp_path, monkeypatch):
import asyncio
import runpy
fixture = runpy.run_path(str(Path(__file__).parent / 'fixtures' / 'control_boundaries.py'))
asyncio.run(fixture['exercise_control_boundaries'](tmp_path, monkeypatch))