Skip to content

Commit 1b62f7c

Browse files
committed
test: add ESP-001 real commit gate bridge test
1 parent 9e951b3 commit 1b62f7c

1 file changed

Lines changed: 51 additions & 0 deletions

File tree

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
"""
2+
ESP-001 real CommitGate bridge test.
3+
4+
This remains synthetic and in-memory, but it calls commit_gate_core.gate.CommitGate
5+
through enterprise-execution-readiness/adapters/commit_gate_bridge.py.
6+
7+
It proves that the real CommitGate returns DENY:NO_DECISION_RECORD before the
8+
mocked email adapter can be called.
9+
"""
10+
11+
from __future__ import annotations
12+
13+
import importlib.util
14+
from pathlib import Path
15+
16+
17+
ROOT = Path(__file__).resolve().parents[1]
18+
ADAPTER_PATH = ROOT / "adapters" / "mock_email_adapter.py"
19+
BRIDGE_PATH = ROOT / "adapters" / "commit_gate_bridge.py"
20+
21+
adapter_spec = importlib.util.spec_from_file_location("mock_email_adapter", ADAPTER_PATH)
22+
mock_email_adapter = importlib.util.module_from_spec(adapter_spec)
23+
assert adapter_spec.loader is not None
24+
adapter_spec.loader.exec_module(mock_email_adapter)
25+
MockEmailAdapter = mock_email_adapter.MockEmailAdapter
26+
27+
bridge_spec = importlib.util.spec_from_file_location("commit_gate_bridge", BRIDGE_PATH)
28+
commit_gate_bridge = importlib.util.module_from_spec(bridge_spec)
29+
assert bridge_spec.loader is not None
30+
bridge_spec.loader.exec_module(commit_gate_bridge)
31+
dispatch_esp001_through_real_gate = commit_gate_bridge.dispatch_esp001_through_real_gate
32+
33+
34+
def test_real_commit_gate_missing_decision_record_blocks_mock_email_send() -> None:
35+
adapter = MockEmailAdapter()
36+
37+
result = dispatch_esp001_through_real_gate(adapter)
38+
39+
assert result.gate_result.allowed is False
40+
assert result.gate_result.code == "DENY:NO_DECISION_RECORD"
41+
assert result.downstream_send is False
42+
assert result.send_call_count == 0
43+
assert adapter.sent_messages == []
44+
assert result.receipt_written is True
45+
assert len(result.audit_events) == 1
46+
47+
audit_event = result.audit_events[0]
48+
assert audit_event["event_type"] == "GATE_EVALUATION"
49+
assert audit_event["allowed"] is False
50+
assert audit_event["code"] == "DENY:NO_DECISION_RECORD"
51+
assert audit_event["attempted"]["action"] == "SEND_EXTERNAL_EMAIL"

0 commit comments

Comments
 (0)