feat: configurators declare sandbox skip-permission flags and binds
Add sandbox_skip_permission_flags class attr and sandbox_binds() method to HarnessConfigurator ABC; thread sandboxed: bool = False through all build_spawn_config / build_resume_config signatures. Claude and Codex append their respective skip-permission flags when sandboxed=True; Kiro and Generic accept the param but add no flags. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
+57
-5
@@ -4,8 +4,11 @@ import time
|
||||
from pathlib import Path
|
||||
from unittest.mock import patch
|
||||
|
||||
from hqt.harnesses.configurators.codex import CodexConfigurator
|
||||
from hqt.harnesses.base import HarnessConfigurator
|
||||
from hqt.harnesses.configurators.claude import ClaudeConfigurator
|
||||
from hqt.harnesses.configurators.codex import CodexConfigurator
|
||||
from hqt.harnesses.configurators.generic import GenericConfigurator
|
||||
from hqt.harnesses.configurators.kiro import KiroConfigurator
|
||||
from hqt.harnesses.registry import discover_harnesses
|
||||
|
||||
|
||||
@@ -129,8 +132,6 @@ def test_codex_captures_session_id_flag():
|
||||
|
||||
def test_base_captures_session_id_flag_false():
|
||||
"""HarnessConfigurator base class default must be False."""
|
||||
from hqt.harnesses.base import HarnessConfigurator
|
||||
|
||||
assert HarnessConfigurator.captures_session_id is False
|
||||
|
||||
|
||||
@@ -287,8 +288,6 @@ CODEX_IDLE_SCREEN = """\
|
||||
|
||||
def test_base_parse_status_returns_none():
|
||||
"""Base HarnessConfigurator.parse_status always returns None."""
|
||||
from hqt.harnesses.configurators.kiro import KiroConfigurator
|
||||
|
||||
k = KiroConfigurator()
|
||||
assert k.parse_status("anything") is None
|
||||
assert k.parse_status("") is None
|
||||
@@ -346,3 +345,56 @@ def test_codex_parse_status_none_for_empty():
|
||||
"""CodexConfigurator: empty text → None."""
|
||||
c = CodexConfigurator()
|
||||
assert c.parse_status("") is None
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Task 3: sandbox skip-permission flags and binds
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
|
||||
def test_base_skip_flags_default_empty():
|
||||
assert HarnessConfigurator.sandbox_skip_permission_flags == []
|
||||
|
||||
|
||||
def test_base_sandbox_binds_default_empty():
|
||||
# GenericConfigurator does not override sandbox_binds; verifies the base default.
|
||||
assert GenericConfigurator(["mytool"]).sandbox_binds() == []
|
||||
|
||||
|
||||
def test_claude_skip_flag_added_when_sandboxed():
|
||||
c = ClaudeConfigurator()
|
||||
sid = c.generate_session_id(1)
|
||||
cfg = c.build_spawn_config(Path("/tmp"), sid, sandboxed=True)
|
||||
assert "--dangerously-skip-permissions" in cfg.command
|
||||
|
||||
|
||||
def test_claude_skip_flag_absent_when_not_sandboxed():
|
||||
c = ClaudeConfigurator()
|
||||
sid = c.generate_session_id(1)
|
||||
cfg = c.build_spawn_config(Path("/tmp"), sid, sandboxed=False)
|
||||
assert "--dangerously-skip-permissions" not in cfg.command
|
||||
|
||||
|
||||
def test_claude_resume_skip_flag_when_sandboxed():
|
||||
c = ClaudeConfigurator()
|
||||
sid = c.generate_session_id(1)
|
||||
cfg = c.build_resume_config(Path("/tmp"), sid, sandboxed=True)
|
||||
assert "--dangerously-skip-permissions" in cfg.command
|
||||
|
||||
|
||||
def test_claude_sandbox_binds_includes_dot_claude():
|
||||
c = ClaudeConfigurator()
|
||||
binds = c.sandbox_binds()
|
||||
assert any(b.src == Path.home() / ".claude" and b.writable for b in binds)
|
||||
|
||||
|
||||
def test_codex_skip_flag_added_when_sandboxed():
|
||||
c = CodexConfigurator()
|
||||
cfg = c.build_spawn_config(Path("/tmp"), "1", sandboxed=True)
|
||||
assert "--dangerously-bypass-approvals-and-sandbox" in cfg.command
|
||||
|
||||
|
||||
def test_generic_sandboxed_is_noop_flagwise():
|
||||
g = GenericConfigurator(["mytool"])
|
||||
cfg = g.build_spawn_config(Path("/tmp"), "1", sandboxed=True)
|
||||
assert cfg.command == ["mytool"]
|
||||
|
||||
Reference in New Issue
Block a user