feat: complete schema-evolution topic with ADR schema and markdown support
This commit closes the schema-evolution topic (260105) by adding the final deliverable (ADR schema) and fixing markdown schema support across commands. **ADR Schema Created**: - Comprehensive Architecture Decision Record validation schema - 12 section classifications (7 required, 2 recommended, 2 optional, 3 improper/discouraged) - Content pattern validation for ADR formatting rules (status dates, decision statements, rationale structure) - Quality metrics for completeness (word counts, sentence counts) - Follows title case naming convention (Status, Context, Decision, etc.) **Markdown Schema Support Fixed**: - Fixed `markitect validate` command to support .md schemas - Added load_schema_from_path() for both .json and .md files - Updated structural and semantic validation to use schema dict - Fixed `markitect generate-stub` command to support .md schemas - Uses load_schema_from_path() instead of direct JSON loading - Created DocumentWrapper class in semantic_validator.py - Extracts headings from AST tokens (heading_open, inline) - Provides get_headings_by_level() interface expected by validators - Enables section validation to work with real documents **Topic Closure**: - Updated SCHEMA_EVOLUTION_WORKPLAN.md with completion summary - Phases 1-3: 100% complete (via Schema-of-Schemas and Semantic Validation) - Phase 4: Deferred as future enhancement (15-20 sessions) - Phase 5: 70% complete (docs done, CI/CD templates deferred) - Created DONE.md with comprehensive task checklist - Generated ADR template stub (examples/templates/adr-template.md) - Moved topic from roadmap/ to history/260105-schema-evolution/ **Files Changed**: - markitect/cli.py: Added markdown schema support to validate and generate-stub - markitect/semantic_validator.py: Added DocumentWrapper class for AST parsing - markitect/schemas/adr-schema-v1.0.md: New ADR validation schema (560 lines) - examples/templates/adr-template.md: Generated ADR template stub - history/260105-schema-evolution/: Moved completed topic to history **Status**: Schema evolution topic successfully closed with ADR schema as final deliverable. All schema commands now support markdown schemas. Section validation working correctly. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1559,16 +1559,20 @@ def validate(config, file_path, schema, schema_json, quiet, detailed_errors, err
|
||||
click.echo("Error: Specify exactly one schema source (--schema or --schema-json)", err=True)
|
||||
sys.exit(1)
|
||||
|
||||
# Load schema dict (supports .json and .md)
|
||||
schema_dict = None
|
||||
if schema:
|
||||
from .semantic_validator import load_schema_from_path
|
||||
schema_dict = load_schema_from_path(schema)
|
||||
schema_source = f"schema file: {schema}"
|
||||
elif schema_json:
|
||||
schema_dict = json.loads(schema_json)
|
||||
schema_source = "provided JSON schema"
|
||||
|
||||
# Perform validation (with or without detailed errors)
|
||||
if detailed_errors:
|
||||
# Use detailed error reporting for Issue #8
|
||||
if schema:
|
||||
error_collector = validator.validate_file_with_errors_file(file_path, schema)
|
||||
schema_source = f"schema file: {schema}"
|
||||
else:
|
||||
error_collector = validator.validate_file_with_errors_string(file_path, schema_json)
|
||||
schema_source = "provided JSON schema"
|
||||
|
||||
error_collector = validator.validate_file_with_errors(file_path, schema_dict)
|
||||
is_valid = not error_collector.has_errors()
|
||||
|
||||
# Output detailed errors
|
||||
@@ -1589,12 +1593,7 @@ def validate(config, file_path, schema, schema_json, quiet, detailed_errors, err
|
||||
|
||||
else:
|
||||
# Use simple boolean validation (original Issue #7 functionality)
|
||||
if schema:
|
||||
is_valid = validator.validate_file_against_schema_file(file_path, schema)
|
||||
schema_source = f"schema file: {schema}"
|
||||
else:
|
||||
is_valid = validator.validate_file_against_schema_string(file_path, schema_json)
|
||||
schema_source = "provided JSON schema"
|
||||
is_valid = validator.validate_file_against_schema(file_path, schema_dict)
|
||||
|
||||
# Output results
|
||||
if quiet:
|
||||
@@ -1613,12 +1612,9 @@ def validate(config, file_path, schema, schema_json, quiet, detailed_errors, err
|
||||
|
||||
# Semantic validation (if enabled and schema has x-markitect extensions)
|
||||
semantic_report = None
|
||||
if semantic and schema:
|
||||
if semantic and schema_dict:
|
||||
try:
|
||||
from .semantic_validator import SemanticValidator, load_schema_from_path
|
||||
|
||||
# Load schema (supports .md and .json)
|
||||
schema_dict = load_schema_from_path(schema)
|
||||
from .semantic_validator import SemanticValidator
|
||||
|
||||
# Check if schema has x-markitect extensions
|
||||
has_extensions = ('x-markitect-sections' in schema_dict or
|
||||
@@ -2550,10 +2546,9 @@ def generate_stub(config, schema_file, output, style, title):
|
||||
generator = StubGenerator()
|
||||
associated_files = AssociatedFilesManager()
|
||||
|
||||
# Load schema and generate stub content
|
||||
import json
|
||||
with open(schema_file, 'r') as f:
|
||||
schema = json.load(f)
|
||||
# Load schema (supports .json and .md)
|
||||
from .semantic_validator import load_schema_from_path
|
||||
schema = load_schema_from_path(schema_file)
|
||||
|
||||
stub_content = generator.generate_stub_from_schema(
|
||||
schema, placeholder_style=style, title=title, schema_file_path=schema_file
|
||||
|
||||
Reference in New Issue
Block a user