ARIA's validation system ensures the integrity and correctness of policies and templates. The system supports multiple policy formats to accommodate both testing and production use cases.
-
Reliability
- Comprehensive checks
- Clear error messages
- Consistent results
-
Performance
- Fast validation
- Minimal memory usage
- Efficient algorithms
-
Extensibility
- Custom validators
- Plugin support
- Easy updates
-
Flexibility
- Support for multiple policy formats
- Strict and standard validation modes
- Customizable validation rules
ARIA supports two primary policy formats:
version: "1.0.0"
name: "Test Policy"
description: "A comprehensive test policy for validation."
capabilities:
- name: "test_capability"
description: "A detailed test capability description."
allowed: true
conditions:
- "Must follow all testing guidelines."
- "Must document all test cases."
restrictions:
- "No unauthorized testing."
- "Must follow security protocols."version: "1.0.0"
name: "Production Policy"
model: "assistant"
defaults:
allow:
- "review"
- "suggest"
require:
- "human_review"
paths:
"src/**/*.py":
allow:
- "analyze"
- "review"
"tests/**":
allow:
- "generate"
- "modify"graph TD
A[Input Policy] --> B[Required Fields Check]
B --> C[Type Validation]
C --> D[Format-Specific Validation]
D --> E1[Capability Validation]
D --> E2[Model-Based Validation]
E1 --> F[Strict Validation]
E2 --> F
F --> G[Validation Result]
The ValidationResult class stores validation outcomes:
class ValidationResult:
"""Represents a policy validation result."""
def __init__(self) -> None:
"""Initialize validation result."""
self.valid: bool = True
self.errors: List[str] = []
self.warnings: List[str] = []
def add_error(self, message: str) -> None:
"""Add an error message."""
def add_warning(self, message: str) -> None:
"""Add a warning message."""The PolicyValidator class performs the actual validation:
class PolicyValidator:
"""Validates AI participation policies."""
def validate_file(self, path: Union[str, Path], strict: bool = False) -> ValidationResult:
"""Validate a policy file."""
def validate_policy(self, policy: Dict[str, Any], strict: bool = False) -> ValidationResult:
"""Validate policy data."""- Required fields: version, name
- Version must be a string
- Name must be present
- Capabilities must be a list
- Each capability must have name, description, and allowed fields
- Conditions must be a list if present
- Restrictions must be a list if present
- Model must be a valid PolicyModel value
- Actions must be allowed for the specified model
- Requirements must be valid for the specified model
- Path patterns must be valid
- Version should follow semantic versioning
- Description should be sufficiently detailed
- Capability descriptions should be sufficiently detailed
- Conditions should end with a period
- Path patterns should not be too broad or too specific
- Always validate policies before applying them
- Use strict validation during development
- Provide clear error messages to users
- Handle validation errors and warnings appropriately
- Test with both policy formats if needed