22 lines
620 B
Python
22 lines
620 B
Python
from __future__ import annotations
|
|
|
|
from dataclasses import dataclass
|
|
from typing import List
|
|
from .planner import Action
|
|
|
|
|
|
@dataclass
|
|
class SafetyContract:
|
|
pre_conditions: List[str] = None
|
|
post_conditions: List[str] = None
|
|
|
|
def validate_plan(self, actions: List[Action]) -> bool:
|
|
# Very small stub: ensure there is at least one action and no explicitly unsafe actions
|
|
if not actions:
|
|
return False
|
|
# If any action name contains 'unsafe', reject the plan
|
|
for a in actions:
|
|
if "unsafe" in a.name.lower():
|
|
return False
|
|
return True
|