feat(herdr): complete Herdr 0.8.0 adaptation and sanitize module
This commit is contained in:
@@ -22,11 +22,11 @@ def test_h1_to_h8_shim_contract(mam_sandbox, mock_herdr, mock_agents):
|
||||
tmp_path = mam_sandbox
|
||||
lib_path = tmp_path / ".agents" / "skills" / "lib.sh"
|
||||
|
||||
# Test H-1 & H-4: Allowed flags and absolute path preservation
|
||||
# Test H-1 & H-4: Allowed flags and 0.8.0 contract
|
||||
cmd_str = f"""
|
||||
source {lib_path}
|
||||
_init_herdr_isolation
|
||||
herdr new-session -d -s "test-h1-sess" -c "{tmp_path}" "/usr/bin/python3 -c 'print(1)'"
|
||||
herdr new-session -d -s "test-h1-creator-claude" -c "{tmp_path}" "claude --dangerously-skip-permissions"
|
||||
"""
|
||||
res = subprocess.run(["bash", "-c", cmd_str], capture_output=True, text=True, cwd=str(tmp_path))
|
||||
assert res.returncode == 0, f"Stderr: {res.stderr}\nStdout: {res.stdout}"
|
||||
@@ -39,7 +39,8 @@ def test_h1_to_h8_shim_contract(mam_sandbox, mock_herdr, mock_agents):
|
||||
agent_start_calls = [c for c in calls if len(c) > 1 and c[0] == "agent" and c[1] == "start"]
|
||||
assert len(agent_start_calls) > 0
|
||||
|
||||
whitelist = {"--cwd", "--workspace", "--tab", "--split", "--env", "--focus", "--no-focus", "--kind", "--pane", "--timeout"}
|
||||
whitelist = {"--kind", "--pane", "--timeout"}
|
||||
forbidden = {"--cwd", "--workspace", "--tab", "--split", "--env", "--focus", "--no-focus"}
|
||||
for call in agent_start_calls:
|
||||
try:
|
||||
dd_idx = call.index("--")
|
||||
@@ -49,14 +50,14 @@ def test_h1_to_h8_shim_contract(mam_sandbox, mock_herdr, mock_agents):
|
||||
opts = call[3:]
|
||||
argv = []
|
||||
|
||||
# H-1: Check no un-whitelisted flags like --kind or --pane
|
||||
# H-1: Check only 0.8.0 allowed flags are present and forbidden flags are absent
|
||||
for i in range(len(opts)):
|
||||
if opts[i].startswith("--"):
|
||||
assert opts[i] in whitelist, f"Forbidden flag in agent start: {opts[i]}"
|
||||
assert opts[i] in whitelist, f"Unexpected flag in agent start: {opts[i]}"
|
||||
assert opts[i] not in forbidden, f"Forbidden 0.7.4 flag in agent start: {opts[i]}"
|
||||
|
||||
# H-4: Check executable absolute path preserved
|
||||
if argv:
|
||||
assert argv[0] == "/usr/bin/python3", f"Executable path mutated: {argv[0]}"
|
||||
assert "--kind" in opts, "Missing required --kind in agent start"
|
||||
assert "--pane" in opts, "Missing required --pane in agent start"
|
||||
|
||||
def test_h9_mock_response_contract_schema(mock_herdr):
|
||||
"""H-9: Verify mock_herdr responses match tests/fixtures/herdr_contract.json schema."""
|
||||
@@ -98,7 +99,7 @@ def test_h11_to_h13_layout_policy(mam_sandbox, mock_herdr, mock_agents):
|
||||
_init_herdr_isolation
|
||||
export MAM_MIN_PANE_COLS=60
|
||||
export MAM_MIN_PANE_ROWS=20
|
||||
herdr new-session -d -s "test-h11-sess" -c "{tmp_path}" "python3 -c 'print(1)'"
|
||||
herdr new-session -d -s "test-h11-creator-claude" -c "{tmp_path}" "claude --dangerously-skip-permissions"
|
||||
"""
|
||||
res = subprocess.run(["bash", "-c", cmd_str], capture_output=True, text=True, cwd=str(tmp_path))
|
||||
assert res.returncode == 0, f"Stderr: {res.stderr}"
|
||||
@@ -111,7 +112,7 @@ def test_h14_mock_concurrency_lock_invariant(mock_herdr):
|
||||
import subprocess
|
||||
procs = []
|
||||
for i in range(10):
|
||||
p = subprocess.Popen(["python3", "{mock_state.parent / 'bin' / 'herdr'}", "agent", "start", f"agent_{{i}}", "--cwd", "/tmp", "--", "claude"])
|
||||
p = subprocess.Popen(["python3", "{mock_state.parent / 'bin' / 'herdr'}", "agent", "start", f"agent_{{i}}", "--kind", "claude", "--pane", f"w1:p{{i}}"])
|
||||
procs.append(p)
|
||||
for p in procs:
|
||||
p.wait()
|
||||
|
||||
Reference in New Issue
Block a user