feat: add readable duplex messaging
Some checks failed
tamq-ci / test (push) Failing after 6s

Assistant: codex
Assistant-Model: gpt-5.6-sol
Assistant-Session: 01a03397-4d51-7fd1-8ff2-946eb22ea2bc
This commit is contained in:
tegwick 2026-08-25 19:26:27 +02:00
parent 788eb8e2ed
commit 92881b6b56
35 changed files with 1206 additions and 806 deletions

View file

@ -98,6 +98,15 @@ def test_preflight_rejects_foreign_session(tmp_path, monkeypatch):
manager.preflight(["a"])
def test_tap_refuses_managed_session_without_duplex_protocol(tmp_path, monkeypatch):
manager = tmux.TmuxManager("tamq-test", command_dir=tmp_path / "commands")
plan = tmux.LaunchPlan(("a",), {"a": str(tmp_path)}, ("sh",))
monkeypatch.setattr(manager, "_existing_session_identity", lambda: (42, "tmux-amq-42-old"))
monkeypatch.setattr(manager, "_run", lambda *args, **kwargs: "")
with pytest.raises(tmux.TmuxError, match="predates readable duplex"):
manager.ensure_plan(plan, tap=True)
def test_tmux_only_plan_starts_agent_without_tap(tmp_path, monkeypatch):
manager = tmux.TmuxManager("tamq-test", command_dir=tmp_path / "commands")
calls = []
@ -152,39 +161,27 @@ def test_neutral_plan_starts_shell_without_sending_keystrokes(tmp_path, monkeypa
assert "TAMQ_REPO=b" in new_window
assert f"PATH={command_dir}{os.pathsep}" in " ".join(new_session)
assert f"PATH={command_dir}{os.pathsep}" in " ".join(new_window)
assert (command_dir / "@a").is_file()
assert (command_dir / "@a:").is_file()
assert (command_dir / "@b").is_file()
assert (command_dir / "@b:").is_file()
assert (command_dir / "@").is_file()
assert (command_dir / "To:a:").is_file()
assert (command_dir / "To:b:").is_file()
assert (command_dir / "Cmd:").is_file()
assert not any(path.name.startswith("@") for path in command_dir.iterdir())
def test_address_commands_preserve_message_arguments(tmp_path):
def test_protocol_commands_absorb_forwarded_shell_lines(tmp_path):
command_dir = tmp_path / "commands"
manager = tmux.TmuxManager(
"tamq-test", tamq_command=("echo",), command_dir=command_dir,
)
manager._install_address_commands(["audit-core"])
for name in ("@audit-core", "@audit-core:"):
for name in ("To:audit-core:", "Cmd:"):
result = subprocess.run(
[str(command_dir / name), "Some message!", "$value", "; literal", "--from"],
[str(command_dir / name), "Some message!", "$value"],
text=True,
capture_output=True,
check=True,
)
assert result.stdout == "send -- @audit-core: Some message! $value ; literal --from\n"
result = subprocess.run(
[str(command_dir / "@"), "Some reply!", "$value", "--literal"],
text=True,
capture_output=True,
check=True,
)
assert result.stdout == "reply -- Some reply! $value --literal\n"
generic = (command_dir / "@").read_text(encoding="utf-8")
assert 'TAMQ_RECIPIENTS=' in generic
assert '["audit-core"]' in generic
assert result.stdout == ""
def test_address_commands_reject_unsafe_repository_names(tmp_path):
@ -196,7 +193,7 @@ def test_address_commands_reject_unsafe_repository_names(tmp_path):
def test_address_commands_do_not_replace_unowned_commands(tmp_path):
command_dir = tmp_path / "commands"
command_dir.mkdir()
existing = command_dir / "@audit-core"
existing = command_dir / "To:audit-core:"
existing.write_text("#!/bin/sh\necho mine\n", encoding="utf-8")
manager = tmux.TmuxManager("tamq-test", command_dir=command_dir)
@ -205,10 +202,10 @@ def test_address_commands_do_not_replace_unowned_commands(tmp_path):
assert existing.read_text(encoding="utf-8") == "#!/bin/sh\necho mine\n"
def test_address_commands_do_not_replace_unowned_bare_reply(tmp_path):
def test_address_commands_do_not_replace_unowned_command_lane(tmp_path):
command_dir = tmp_path / "commands"
command_dir.mkdir()
existing = command_dir / "@"
existing = command_dir / "Cmd:"
existing.write_text("#!/bin/sh\necho mine\n", encoding="utf-8")
manager = tmux.TmuxManager("tamq-test", command_dir=command_dir)