Enhanced Schema Validation with Real-World Edge Cases
Enhanced Schema Validation
Objective
Improve OSSA JSON Schema validation to handle real-world edge cases and provide clear error messages for specification violations.
Scope
1. Schema Validation Improvements
- Add regex pattern validation for agent IDs (DNS-1123 compliance)
- Validate semantic versioning format
- Add enum value validation for runtime types
- Implement conditional schema validation (e.g., k8s runtime requires image)
2. Error Message Quality
- Replace generic AJV errors with human-readable messages
- Provide examples of valid values in error output
- Add context about which part of spec is violated
3. Additional Validation Rules
- Capability name uniqueness within agent
- Port number ranges (1-65535)
- Resource request/limit validation (k8s format)
- Environment variable name format
Acceptance Criteria
-
All edge cases from spec/examples/ validate correctly -
Invalid manifests produce clear, actionable error messages -
Custom validation functions for complex rules -
Test coverage >90% for validator -
Documentation with validation error catalog
Technical Approach
```typescript // Example: Enhanced validation const validateAgentId = (id: string): ValidationResult => { const dns1123 = /^a-z0-9?$/; if (!dns1123.test(id)) { return { valid: false, error: "Agent ID must be DNS-1123 compliant", example: "compliance-scanner-v2", hint: "Use lowercase letters, numbers, and hyphens only" }; } return { valid: true }; }; ```
References
- Current schema: `spec/ossa-1.0.schema.json`
- Validation tests: `tests/validation-suite/schema-validator.test.ts`
- DNS-1123: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/
Labels
`enhancement`, `validation`, `quality`
Milestone
v0.2.x - Specification Stability