Option C Tools
Loading...
Searching...
No Matches
tests_mcp.test_mcp_hitl Namespace Reference

Classes

class  TestHITLFirstCallRequiresConfirmation
class  TestHITLSecondCallExecutes
class  TestFormatDoubleGuardE2E
class  TestBothCallsWriteAuditRecords
class  TestPolicyShortCircuit
class  TestValidationShortCircuit
class  TestRateLimitAcrossHITL
class  TestPrivilegeEscalation

Functions

McpMetrics _isolated_metrics ()
tuple[ServerState, McpAuditLogger_make_write_state (Path tmp_path, str sandbox_output="Done.", int sandbox_exit_code=0, str profile="default", bool safe_mode=False, int rate_limit=30, str session_id="hitl-test-session")
dict _last_audit_record (McpAuditLogger logger)

Detailed Description

Purpose
-------
Integration tests for the Phase 5B HITL (Human-in-the-Loop) pipeline.

Responsibilities
----------------
- Verify write-tool first-call (confirm=False) returns confirmation
  string; second-call (confirm=True) executes via mock sandbox.
- Verify oct_format double-guard (apply + confirm) and dry-run path.
- Verify audit records for both HITL calls.
- Verify policy denial and validation failure short-circuit before HITL.
- Verify rate-limit state preserved across calls.
- Verify T-06 privilege escalation and T-06b strict-profile denial.

Diagnostics
-----------
Domain: MCP-TESTS
Levels:
    L2 — test lifecycle
    L3 — assertion details
    L4 — deep tracing

Contracts
---------
- Tests use mock sandbox and ``tmp_path``; no real subprocess is
  spawned.

Function Documentation

◆ _isolated_metrics()

McpMetrics tests_mcp.test_mcp_hitl._isolated_metrics ( )
protected
McpMetrics on a private CollectorRegistry — avoids
``Duplicated timeseries`` collisions across tests.

Definition at line 59 of file test_mcp_hitl.py.

Here is the caller graph for this function:

◆ _last_audit_record()

dict tests_mcp.test_mcp_hitl._last_audit_record ( McpAuditLogger logger)
protected
Read the last line from the audit log as a dict.

Definition at line 106 of file test_mcp_hitl.py.

Here is the caller graph for this function:

◆ _make_write_state()

tuple[ServerState, McpAuditLogger] tests_mcp.test_mcp_hitl._make_write_state ( Path tmp_path,
str sandbox_output = "Done.",
int sandbox_exit_code = 0,
str profile = "default",
bool safe_mode = False,
int rate_limit = 30,
str session_id = "hitl-test-session" )
protected
Build a ServerState with SafetyGate for HITL integration tests.

Definition at line 68 of file test_mcp_hitl.py.

Here is the call graph for this function:
Here is the caller graph for this function: