fix(lib): resolve B-8 send_keys_safe agy verification bypass and add submission retry test

This commit is contained in:
2026-08-14 09:35:17 +09:00
parent f8bfa07fac
commit 720f8ad224
10 changed files with 307 additions and 8 deletions
+29
View File
@@ -0,0 +1,29 @@
import os
import subprocess
import pytest
def test_send_keys_safe_b8_verification(tmp_path):
"""Verify that send_keys_safe for agy sessions goes through submission verification and does not return 0 blindly on failure."""
# Test script that mocks herdr commands and tests send_keys_safe behavior for agy
test_script = f"""#!/usr/bin/env bash
set -euo pipefail
SKILL_DIR="{os.path.abspath('.agents/skills')}"
source "$SKILL_DIR/lib.sh"
# Mock _pane_quiescent to succeed
_pane_quiescent() {{ return 0; }}
_pane_dialog_open() {{ return 1; }}
# Mock _sks_herdr commands
_sks_herdr() {{ return 0; }}
# Mock _pane_capture to simulate fixed pane content (no execution token, no pane change)
_pane_capture() {{ echo "static content"; }}
# Running send_keys_safe for agy session when submission is NOT accepted
send_keys_safe "test-workspace-creator-agy" "test prompt" "job-123"
"""
res = subprocess.run(["bash", "-c", test_script], capture_output=True, text=True)
# Since submission failed after 3 tries (pane static, no token), it must return exit code 4 (not 0)
assert res.returncode == 4, f"Expected returncode 4 on submission failure for agy, got {res.returncode}. Output: {res.stdout} {res.stderr}"
assert "Enter not accepted after 3 tries" in res.stderr