Files
FusionAGI/fusionagi/schemas/policy.py
defiQUG c052b07662
Some checks failed
Tests / test (3.10) (push) Has been cancelled
Tests / test (3.11) (push) Has been cancelled
Tests / test (3.12) (push) Has been cancelled
Tests / lint (push) Has been cancelled
Tests / docker (push) Has been cancelled
Initial commit: add .gitignore and README
2026-02-09 21:51:42 -08:00

30 lines
809 B
Python

"""Policy engine schemas: hard constraints independent of LLM."""
from datetime import datetime, timezone
from enum import Enum
from typing import Any
from pydantic import BaseModel, Field
def _utc_now() -> datetime:
return datetime.now(timezone.utc)
class PolicyEffect(str, Enum):
"""Allow or deny."""
ALLOW = "allow"
DENY = "deny"
class PolicyRule(BaseModel):
"""Single policy rule: condition -> effect."""
rule_id: str = Field(..., min_length=1)
effect: PolicyEffect = Field(...)
condition: dict[str, Any] = Field(default_factory=dict, description="e.g. tool_name, domain, data_class")
reason: str = Field(default="")
priority: int = Field(default=0, ge=0, description="Higher = evaluated first")
created_at: datetime = Field(default_factory=_utc_now)