diff --git a/guard_logs.jsonl b/guard_logs.jsonl index 3e7fcbc..a9e763e 100644 --- a/guard_logs.jsonl +++ b/guard_logs.jsonl @@ -7,3 +7,4 @@ {"contract_id": "guard-001", "plan": {"action": "move", "costs": {"time": 2.0}, "speed": 0.8}, "state": {"speed": 0.8, "distance_to_obstacle": 5}, "decision": "allow"} {"contract_id": "guard-001", "plan": {"action": "move", "costs": {"time": 2.0}, "speed": 0.8}, "state": {"speed": 0.8, "distance_to_obstacle": 5}, "decision": "allow"} {"contract_id": "guard-001", "plan": {"action": "move", "costs": {"time": 2.0}, "speed": 0.8}, "state": {"speed": 0.8, "distance_to_obstacle": 5}, "decision": "allow"} +{"contract_id": "guard-001", "plan": {"action": "move", "costs": {"time": 2.0}, "speed": 0.8}, "state": {"speed": 0.8, "distance_to_obstacle": 5}, "decision": "allow"} diff --git a/src/guardrail_space/contract.py b/src/guardrail_space/contract.py index 3d5f6c3..30ccbdb 100644 --- a/src/guardrail_space/contract.py +++ b/src/guardrail_space/contract.py @@ -56,11 +56,14 @@ class SafetyContract: def evaluate_pre(self, context: Dict[str, Any]) -> (bool, str): engine = PolicyEngine(self) # Pass a neutral action payload; tests use only context. - return engine.evaluate_pre({"action": None}, context) + ok, _reason = engine.evaluate_pre({"action": None}, context) + # Legacy API expected a boolean result. + return bool(ok) def evaluate_post(self, action: Dict[str, Any], context: Dict[str, Any]) -> (bool, str): engine = PolicyEngine(self) - return engine.evaluate_post(action, context) + ok, _reason = engine.evaluate_post(action, context) + return bool(ok) def to_dict(self) -> Dict[str, Any]: return {