feat: add reliable trigger and worker message blocks
Some checks failed
tamq-ci / test (push) Failing after 6s
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:
parent
72f22a13f7
commit
17b6bd7ae7
25 changed files with 588 additions and 67 deletions
|
|
@ -239,28 +239,93 @@ def test_real_tmux_pushy_mode_places_one_readable_input_without_enter(tmp_path,
|
|||
"pushy",
|
||||
)
|
||||
store.add("flex-auth", "audit-core", "What's next?\nsecond", provenance="operator_input")
|
||||
service = Service(store=store)
|
||||
service = Service(store=store, input_grace=0)
|
||||
service._deliver_once()
|
||||
|
||||
expected = "From:flex-auth/o: What's next?\\x0asecond"
|
||||
expected_lines = ["From:flex-auth/o: What's next?", "From:flex-auth/o: second"]
|
||||
deadline = time.monotonic() + 5
|
||||
while time.monotonic() < deadline:
|
||||
capture = manager._run("capture-pane", "-p", "-J", "-t", target)
|
||||
if expected in capture:
|
||||
if all(expected in capture for expected in expected_lines):
|
||||
break
|
||||
time.sleep(0.05)
|
||||
assert expected in capture
|
||||
assert all(expected in capture for expected in expected_lines)
|
||||
assert store.list()[0]["state"] == "injected"
|
||||
assert store.db.execute("SELECT COUNT(*) FROM leases").fetchone()[0] == 0
|
||||
|
||||
service._deliver_once()
|
||||
repeated_capture = manager._run("capture-pane", "-p", "-J", "-t", target)
|
||||
assert repeated_capture.count(expected) == 1
|
||||
assert all(repeated_capture.count(expected) == 1 for expected in expected_lines)
|
||||
finally:
|
||||
store.close()
|
||||
manager._run("kill-server", check=False)
|
||||
|
||||
|
||||
@pytest.mark.skipif(shutil.which("tmux") is None, reason="tmux is not installed")
|
||||
def test_real_tmux_trigger_clears_terminal_paste_window_before_enter(tmp_path):
|
||||
repo = tmp_path / "audit-core"
|
||||
repo.mkdir()
|
||||
fixture = tmp_path / "paste_sensitive_fixture.py"
|
||||
fixture.write_text(
|
||||
"import os, time, tty\n"
|
||||
"tty.setraw(0)\n"
|
||||
"os.write(1, b'READY\\r\\n')\n"
|
||||
"body = bytearray()\n"
|
||||
"last_text = 0.0\n"
|
||||
"while True:\n"
|
||||
" data = os.read(0, 4096)\n"
|
||||
" now = time.monotonic()\n"
|
||||
" for byte in data:\n"
|
||||
" if byte == 13:\n"
|
||||
" label = b'SUBMITTED:' if now - last_text >= 0.1 else b'NEWLINE:'\n"
|
||||
" os.write(1, label + bytes(body) + b'\\r\\n')\n"
|
||||
" raise SystemExit(0)\n"
|
||||
" body.append(byte)\n"
|
||||
" last_text = now\n",
|
||||
encoding="utf-8",
|
||||
)
|
||||
socket_name = f"tamq-trigger-paste-{uuid4().hex[:8]}"
|
||||
session = f"tamq-trigger-paste-{uuid4().hex[:8]}"
|
||||
tmux_command = ("tmux", "-L", socket_name)
|
||||
manager = TmuxManager(
|
||||
session,
|
||||
tmux_command=tmux_command,
|
||||
tamq_command=(sys.executable, "-m", "tamq.cli"),
|
||||
command_dir=tmp_path / "commands",
|
||||
)
|
||||
try:
|
||||
manager.ensure_plan(
|
||||
LaunchPlan(
|
||||
("audit-core",),
|
||||
{"audit-core": str(repo)},
|
||||
(sys.executable, str(fixture)),
|
||||
)
|
||||
)
|
||||
target = f"{session}:audit-core"
|
||||
deadline = time.monotonic() + 5
|
||||
while time.monotonic() < deadline:
|
||||
capture = manager._run("capture-pane", "-p", "-t", target)
|
||||
if "READY" in capture:
|
||||
break
|
||||
time.sleep(0.05)
|
||||
assert "READY" in capture
|
||||
|
||||
ControlModeClient(
|
||||
session, tmux_command=tmux_command, submit_delay=0.15
|
||||
).submit(target, "From:flex-auth: first delivery")
|
||||
|
||||
deadline = time.monotonic() + 5
|
||||
while time.monotonic() < deadline:
|
||||
capture = manager._run("capture-pane", "-p", "-t", target)
|
||||
if "SUBMITTED:" in capture:
|
||||
break
|
||||
time.sleep(0.05)
|
||||
assert "SUBMITTED:From:flex-auth: first delivery" in capture
|
||||
assert "NEWLINE:" not in capture
|
||||
finally:
|
||||
manager._run("kill-server", check=False)
|
||||
|
||||
|
||||
@pytest.mark.skipif(shutil.which("tmux") is None, reason="tmux is not installed")
|
||||
def test_real_tmux_to_route_triggers_once_without_feedback(tmp_path, monkeypatch):
|
||||
repo_a = tmp_path / "railiance-platform"
|
||||
|
|
@ -355,7 +420,7 @@ def test_real_tmux_to_route_triggers_once_without_feedback(tmp_path, monkeypatch
|
|||
assert row["body"] == "Hello!"
|
||||
assert row["endpoint_id"] == endpoint.instance_key
|
||||
|
||||
service = Service(store=store)
|
||||
service = Service(store=store, input_grace=0)
|
||||
service._deliver_once()
|
||||
expected = "From:railiance-platform/o: Hello!"
|
||||
deadline = time.monotonic() + 5
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue