markitect-main/markitect/schemas/markitect-metaschema.json

209 lines
8.3 KiB
JSON
Raw Normal View History

feat: Complete Issue #50 - Define metaschema for JSON schema structure Implement comprehensive MarkiTect metaschema that extends standard JSON Schema with MarkiTect-specific features for document analysis and generation. 🎯 TDD8 Implementation Complete: - ISSUE: Analyzed existing schema system and requirements - TEST: 15 comprehensive tests covering all features - RED: Verified tests fail before implementation - GREEN: Implemented metaschema JSON and validation logic - REFACTOR: Clean, extensible validator architecture - DOCUMENT: Updated CLI help and comprehensive documentation - REFINE: 100% test success rate and CLI integration - PUBLISH: Ready for production use ✅ Key Features Implemented: - Heading text capture support (x-markitect-heading-text) - Content field instructions (x-markitect-content-instructions) - Outline structure representation (x-markitect-outline-mode/depth) - Backward compatibility with existing schemas - Validation rules for all new features - CLI integration in schema-ingest command 📁 Files Added: - markitect/metaschema.py - Validation logic and MetaschemaValidator - markitect/schemas/markitect-metaschema.json - Metaschema definition - Enhanced markitect/cli.py - Automatic metaschema validation 🧪 Testing: - 15 comprehensive tests (100% passing) - RED-GREEN-REFACTOR cycle validated - CLI integration tested and working - Backward compatibility verified 📋 Acceptance Criteria Met: ✅ Schema metaschema supports heading text capture ✅ Schema metaschema supports content field instructions ✅ Schema metaschema supports outline structure representation ✅ Schema metaschema is backward compatible with existing schemas ✅ Schema metaschema includes validation rules for new features ✅ Documentation explains the metaschema structure and usage 🔗 Foundation for Future Issues: - Issue #51: Outline mode schema generation - Issue #52: Heading text capture in schemas - Issue #54: Content instruction capabilities - Issue #55: Schema-based draft generation 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-01 02:39:29 +02:00
{
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "https://markitect.io/schemas/markitect-metaschema.json",
"type": "object",
"title": "MarkiTect Extended JSON Schema Metaschema",
"description": "Metaschema for MarkiTect JSON schemas that extends standard JSON Schema with MarkiTect-specific features for document structure analysis and generation",
"allOf": [
{
"$ref": "http://json-schema.org/draft-07/schema#"
},
{
"properties": {
"x-markitect-heading-text": {
"type": "string",
"description": "Preserve actual heading text from source document for validation and template generation"
},
"x-markitect-content-instructions": {
"type": "string",
"description": "Instructions for content authors about what should go in this section"
},
"x-markitect-outline-mode": {
"type": "boolean",
"description": "Indicates if this schema was generated in outline mode, focusing on structural hierarchy"
},
"x-markitect-outline-depth": {
"type": "integer",
"minimum": 1,
"description": "Maximum heading depth captured in outline mode"
},
"x-markitect-instruction-type": {
"type": "string",
"enum": ["description", "example", "constraint", "template"],
"description": "Type of content instruction provided"
},
"x-markitect-generated-from": {
"type": "string",
"description": "Source file or document this schema was generated from"
},
"x-markitect-generation-mode": {
"type": "string",
"enum": ["outline", "full"],
"description": "Mode used to generate this schema"
feat: implement Phase 1 - Enhanced Schema Format with Classifications Complete Phase 1 of Schema Evolution Workplan implementing flexible content control and section classification system. ## New Features ### 1. x-markitect-sections Extension - Five classification levels: required, recommended, optional, discouraged, improper - Per-section content constraints (paragraphs, code blocks, lists) - Position hints for section ordering - Custom error/warning messages - Alternative section names support - Content instructions for authors ### 2. x-markitect-content-control Extension - Required/discouraged/forbidden pattern matching - Content quality metrics (word count, readability target, sentence count) - Content instruction arrays - Link validation configuration ### 3. Metaschema Validation - Updated markitect-metaschema.json with complete validation rules - Enhanced metaschema.py with validation methods for both extensions - Comprehensive validation of all extension properties - Clear error messages for invalid schemas ### 4. Documentation & Examples - Complete specification in docs/specifications/schema-extensions-spec.md - Enhanced manpage schema demonstrating all 5 classification levels - API documentation schema showing alternative patterns - Detailed usage examples and validation behavior ## Implementation Details **Files Modified:** - markitect/schemas/markitect-metaschema.json: Added extension definitions - markitect/metaschema.py: Added _validate_sections() and _validate_content_control() **Files Created:** - docs/specifications/schema-extensions-spec.md: Complete specification (v1.0) - examples/manpages/enhanced-manpage-schema.json: Demonstrates all classifications - examples/manpages/api-documentation-schema.json: Shows API doc patterns ## Validation Behavior **Classification Levels:** - required: Missing = ERROR (validation fails) - recommended: Missing = WARNING (validation succeeds with warnings) - optional: No validation impact - discouraged: Present = WARNING (validation succeeds with warnings) - improper: Present = ERROR (validation fails) ## Next Steps Phase 2: Schema Refinement Tools (schema-analyze, schema-refine, schema-compose) Phase 3: Enhanced Validation Engine (classification-aware validation, quality metrics) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-01-04 21:02:51 +01:00
},
"x-markitect-sections": {
"type": "object",
"description": "Section classification and content control for document sections",
"patternProperties": {
"^[A-Z][A-Z0-9_ ]*$": {
"type": "object",
"description": "Section definition with classification and constraints",
"properties": {
"classification": {
"type": "string",
"enum": ["required", "recommended", "optional", "discouraged", "improper"],
"description": "Classification level determining validation behavior"
},
"heading_level": {
"type": "integer",
"minimum": 1,
"maximum": 6,
"description": "Expected heading level (H1-H6) for this section"
},
"position": {
"type": "string",
"enum": ["after_title", "before_section_name", "after_section_name", "anywhere"],
"description": "Where this section should appear in the document"
},
"content_instruction": {
"type": "string",
"description": "Human-readable instruction for section content"
},
"min_paragraphs": {
"type": "integer",
"minimum": 0,
"description": "Minimum number of paragraphs in this section"
},
"max_paragraphs": {
"type": "integer",
"minimum": 0,
"description": "Maximum number of paragraphs in this section"
},
"min_code_blocks": {
"type": "integer",
"minimum": 0,
"description": "Minimum number of code blocks in this section"
},
"max_code_blocks": {
"type": "integer",
"minimum": 0,
"description": "Maximum number of code blocks in this section"
},
"min_lists": {
"type": "integer",
"minimum": 0,
"description": "Minimum number of lists in this section"
},
"max_lists": {
"type": "integer",
"minimum": 0,
"description": "Maximum number of lists in this section"
},
"warning_if_missing": {
"type": "string",
"description": "Custom warning message for missing recommended sections"
},
"error_message": {
"type": "string",
"description": "Custom error message for required/improper section violations"
},
"alternatives": {
"type": "array",
"items": {"type": "string"},
"description": "Alternative section names that satisfy the requirement"
}
},
"required": ["classification"]
}
}
},
"x-markitect-content-control": {
"type": "object",
"description": "Content validation rules including patterns and quality metrics",
"patternProperties": {
"^[a-z][a-z0-9_]*$": {
"type": "object",
"description": "Content control rules for a specific section",
"properties": {
"required_patterns": {
"type": "array",
"items": {"type": "string"},
"description": "Regex patterns that must appear in section content"
},
"discouraged_patterns": {
"type": "array",
"items": {"type": "string"},
"description": "Regex patterns that should not appear in content (warning)"
},
"forbidden_patterns": {
"type": "array",
"items": {"type": "string"},
"description": "Regex patterns that must not appear in content (error)"
},
"content_quality": {
"type": "object",
"description": "Quality metrics for section content",
"properties": {
"min_words": {
"type": "integer",
"minimum": 0,
"description": "Minimum word count"
},
"max_words": {
"type": "integer",
"minimum": 0,
"description": "Maximum word count"
},
"readability_target": {
"type": "string",
"enum": ["simple", "general", "technical", "advanced"],
"description": "Target readability level"
},
"min_sentences": {
"type": "integer",
"minimum": 0,
"description": "Minimum sentence count"
},
"max_sentences": {
"type": "integer",
"minimum": 0,
"description": "Maximum sentence count"
}
}
},
"content_instructions": {
"type": "array",
"items": {"type": "string"},
"description": "Array of human-readable content creation instructions"
},
"link_validation": {
"type": "object",
"description": "Link checking configuration",
"properties": {
"check_internal": {
"type": "boolean",
"description": "Validate internal document links"
},
"check_external": {
"type": "boolean",
"description": "Validate external URLs"
},
"allow_fragments": {
"type": "boolean",
"description": "Allow fragment-only links like #section"
}
}
}
}
}
}
feat: Complete Issue #50 - Define metaschema for JSON schema structure Implement comprehensive MarkiTect metaschema that extends standard JSON Schema with MarkiTect-specific features for document analysis and generation. 🎯 TDD8 Implementation Complete: - ISSUE: Analyzed existing schema system and requirements - TEST: 15 comprehensive tests covering all features - RED: Verified tests fail before implementation - GREEN: Implemented metaschema JSON and validation logic - REFACTOR: Clean, extensible validator architecture - DOCUMENT: Updated CLI help and comprehensive documentation - REFINE: 100% test success rate and CLI integration - PUBLISH: Ready for production use ✅ Key Features Implemented: - Heading text capture support (x-markitect-heading-text) - Content field instructions (x-markitect-content-instructions) - Outline structure representation (x-markitect-outline-mode/depth) - Backward compatibility with existing schemas - Validation rules for all new features - CLI integration in schema-ingest command 📁 Files Added: - markitect/metaschema.py - Validation logic and MetaschemaValidator - markitect/schemas/markitect-metaschema.json - Metaschema definition - Enhanced markitect/cli.py - Automatic metaschema validation 🧪 Testing: - 15 comprehensive tests (100% passing) - RED-GREEN-REFACTOR cycle validated - CLI integration tested and working - Backward compatibility verified 📋 Acceptance Criteria Met: ✅ Schema metaschema supports heading text capture ✅ Schema metaschema supports content field instructions ✅ Schema metaschema supports outline structure representation ✅ Schema metaschema is backward compatible with existing schemas ✅ Schema metaschema includes validation rules for new features ✅ Documentation explains the metaschema structure and usage 🔗 Foundation for Future Issues: - Issue #51: Outline mode schema generation - Issue #52: Heading text capture in schemas - Issue #54: Content instruction capabilities - Issue #55: Schema-based draft generation 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-01 02:39:29 +02:00
}
},
"patternProperties": {
"^x-markitect-": {
"description": "MarkiTect extension properties"
}
}
}
]
}