tegwick
14108533fb
feat: implement schema filename validation (Phase 1 complete)
Implements filename convention enforcement for schema files as part of
the schema-of-schemas implementation. All schemas must now follow the
naming pattern: {domain}-schema-v{major}.{minor}.md
## Phase 1 Deliverables
### Schema Naming Module
**File:** `markitect/schema_naming.py` (380 lines)
**Functions:**
- `validate_schema_filename()` - Validate filename against pattern
- `suggest_schema_filename()` - Generate valid filename from domain/version
- `extract_schema_metadata()` - Extract domain and version from filename
- `get_validation_errors()` - Detailed error messages for invalid filenames
- `is_valid_schema_filename()` - Simple boolean validation
- `format_validation_message()` - User-friendly error formatting
**Features:**
- Regex-based pattern matching
- Automatic normalization (spaces → hyphens, lowercase)
- Detailed error reporting
- Domain validation (must start with letter)
- Version validation (major.minor format)
### Comprehensive Test Suite
**File:** `tests/test_schema_naming.py` (500+ lines, 50 tests)
**Test Coverage:**
- ✅ Valid filename variations (simple, hyphenated, with numbers)
- ✅ Invalid filenames (wrong extension, missing components, wrong case)
- ✅ Filename suggestion with normalization
- ✅ Metadata extraction
- ✅ Error message generation
- ✅ Edge cases (long names, many hyphens, large versions)
- ✅ Pattern regex validation
**Results:** 50/50 tests passing (100%)
### Specification Document
**File:** `roadmap/schema-of-schemas/SCHEMA_NAMING_SPEC.md`
**Contents:**
- Formal specification of naming convention
- Regular expression pattern with explanation
- Valid and invalid examples
- Version numbering guidelines
- Domain naming best practices
- Normalization rules
- Migration strategy from legacy naming
- Implementation guide
## Naming Convention
### Format
```
{domain}-schema-v{major}.{minor}.md
```
### Examples
```
✓ manpage-schema-v1.0.md
✓ api-documentation-schema-v1.0.md
✓ terminology-schema-v1.0.md
✓ arc42-schema-v2.1.md
✗ manpage.json (wrong extension)
✗ ManPage-schema-v1.0.md (uppercase)
✗ manpage-v1.0.md (missing 'schema')
✗ manpage-schema-v1.md (missing minor version)
```
### Components
- **domain**: Lowercase, hyphen-separated, starts with letter
- **schema**: Literal keyword
- **version**: v{major}.{minor} (SemVer simplified)
- **extension**: .md (markdown)
## Implementation Highlights
### Automatic Normalization
```python
suggest_schema_filename("API Documentation", "2.1")
# → "api-documentation-schema-v2.1.md"
suggest_schema_filename("My_Custom Type", "1.0")
# → "my-custom-type-schema-v1.0.md"
```
### Detailed Error Reporting
```python
format_validation_message("invalid.json")
# → Detailed error list + suggested fix
```
### Metadata Extraction
```python
extract_schema_metadata("manpage-schema-v1.0.md")
# → {'domain': 'manpage', 'version': '1.0', 'major': 1, 'minor': 0}
```
## Migration Plan
Current schemas will be renamed:
```
Old → New
────────────────────────────────────────────────────────
terminology-schema.json → terminology-schema-v1.0.md
api-documentation → api-documentation-schema-v1.0.md
enhanced-manpage → manpage-schema-v2.0.md
markdown-manpage → DELETE (duplicate)
markdown-manpage-schema.json → DELETE (duplicate)
```
## Phase 1 Status: ✅ COMPLETE
### Completed
- [x] Schema naming module implementation
- [x] Comprehensive test suite (50 tests, 100% passing)
- [x] Specification document
- [x] TODO.md updated
### Next: Phase 2
- [ ] Update CLI schema-ingest with validation
- [ ] Implement markdown schema loader
- [ ] Parse frontmatter and JSON code blocks
- [ ] Update SchemaValidator for .md support
## Testing
```bash
# Run tests
pytest tests/test_schema_naming.py -v
# → 50 passed in 0.48s
# Test interactively
python -c "
from markitect.schema_naming import validate_schema_filename
print(validate_schema_filename('manpage-schema-v1.0.md'))
"
# → (True, {'domain': 'manpage', 'version': '1.0', ...})
```
## Files Changed
- markitect/schema_naming.py (NEW, 380 lines)
- tests/test_schema_naming.py (NEW, 500+ lines)
- roadmap/schema-of-schemas/SCHEMA_NAMING_SPEC.md (NEW)
- TODO.md (updated progress tracking)
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-01-04 23:51:29 +01:00
..
2025-10-02 00:45:06 +02:00
2025-09-29 12:18:25 +02:00
2025-10-02 09:32:16 +02:00
2025-09-27 02:14:23 +02:00
2025-09-29 12:18:25 +02:00
2025-10-06 02:11:28 +02:00
2025-11-09 09:22:26 +01:00
2025-09-26 22:36:35 +02:00
2025-10-02 15:33:32 +02:00
2025-10-02 09:14:24 +02:00
2025-11-09 09:22:26 +01:00
2025-10-01 21:05:36 +02:00
2025-09-22 02:04:19 +02:00
2025-10-02 09:14:24 +02:00
2025-10-01 21:05:36 +02:00
2025-09-30 03:31:48 +02:00
2025-09-30 03:31:48 +02:00
2025-10-01 21:05:36 +02:00
2025-10-01 21:05:36 +02:00
2025-09-22 02:04:19 +02:00
2025-10-03 10:45:43 +02:00
2025-10-03 10:53:44 +02:00
2025-10-06 18:04:05 +02:00
2025-10-06 17:46:54 +02:00
2025-10-06 17:46:54 +02:00
2025-10-01 21:05:36 +02:00
2025-09-30 23:33:43 +02:00
2025-09-30 13:09:37 +02:00
2025-10-01 12:48:48 +02:00
2025-10-01 02:59:40 +02:00
2025-10-01 08:03:11 +02:00
2025-10-02 15:33:32 +02:00
2025-10-02 15:33:32 +02:00
2025-10-02 15:33:32 +02:00
2025-10-27 21:31:08 +01:00
2025-10-07 01:22:09 +02:00
2025-10-07 01:32:47 +02:00
2025-10-07 12:47:59 +02:00
2025-10-28 03:50:21 +01:00
2025-10-07 15:44:30 +02:00
2025-10-07 15:44:30 +02:00
2025-10-07 15:44:30 +02:00
2025-10-12 19:57:31 +02:00
2025-10-07 22:47:05 +02:00
2025-10-12 19:57:31 +02:00
2025-10-07 22:47:05 +02:00
2025-10-12 19:57:31 +02:00
2025-10-07 22:47:05 +02:00
2025-10-07 23:11:33 +02:00
2025-10-12 19:57:31 +02:00
2025-11-09 09:22:26 +01:00
2025-10-12 19:57:31 +02:00
2025-10-12 19:57:31 +02:00
2025-10-14 19:29:08 +02:00
2025-11-09 09:22:26 +01:00
2025-11-09 10:41:28 +01:00
2025-11-09 10:41:28 +01:00
2025-10-14 23:42:42 +02:00
2025-10-15 00:19:52 +02:00
2025-10-15 20:00:25 +02:00
2025-10-15 20:00:25 +02:00
2025-10-15 20:00:25 +02:00
2025-10-15 20:00:25 +02:00
2025-12-17 12:10:25 +01:00
2025-11-04 21:59:22 +01:00
2025-10-12 20:17:41 +02:00
2025-10-12 22:30:06 +02:00
2025-10-13 20:26:08 +02:00
2025-10-13 23:09:18 +02:00
2025-10-13 23:09:18 +02:00
2025-10-13 23:09:18 +02:00
2025-10-14 07:53:38 +02:00
2025-11-10 11:04:51 +01:00
2025-11-10 10:53:37 +01:00
2025-09-29 12:18:25 +02:00
2025-11-09 10:41:28 +01:00
2025-09-29 12:18:25 +02:00
2025-09-30 23:33:43 +02:00
2025-10-06 16:46:26 +02:00
2025-10-13 20:26:08 +02:00
2025-09-30 23:33:43 +02:00
2025-10-01 21:05:36 +02:00
2025-09-29 12:18:25 +02:00
2025-10-03 05:37:17 +02:00
2025-09-30 22:13:07 +02:00
2025-09-30 23:33:43 +02:00
2025-11-09 10:41:28 +01:00
2025-09-29 12:18:25 +02:00
2025-09-29 12:18:25 +02:00
2025-10-29 23:12:44 +01:00
2025-11-10 11:43:25 +01:00
2025-10-04 01:53:31 +02:00
2025-10-04 01:53:31 +02:00
2025-10-13 20:26:08 +02:00
2026-01-04 21:33:37 +01:00
2026-01-04 23:51:29 +01:00
2026-01-04 21:33:37 +01:00
2025-10-03 05:37:17 +02:00
2025-12-17 12:10:25 +01:00