"""Run with Python 3; no dependencies. Paths resolve relative to this script.""" import hashlib import json import re from pathlib import Path root = Path(__file__).resolve().parent workspace = root.parent article = (root / 'article.md').read_text(encoding='utf-8') meta = json.loads((root / 'metadata.json').read_text(encoding='utf-8')) assert set(meta) == {'headline', 'excerpt', 'search_description'} assert all(isinstance(value, str) and value.strip() for value in meta.values()) assert article.splitlines()[0] == '# ' + meta['headline'] body = article.split('\n', 1)[1] prose = re.sub(r'\[inputs/[^\]]+\]', '', body) paragraphs = re.sub(r'^#+ .*$', '', prose, flags=re.M) counts = { 'article_words_excluding_headline_including_citations': len(body.split()), 'article_words_excluding_headline_and_citations_including_subheadings': len(prose.split()), 'article_paragraph_words_excluding_all_headings_and_citations': len(paragraphs.split()), 'headline_characters': len(meta['headline']), 'excerpt_words': len(meta['excerpt'].split()), 'search_description_characters': len(meta['search_description']) } for key in counts: if key.startswith('article_'): assert 600 <= counts[key] <= 800, (key, counts[key]) assert 50 <= counts['headline_characters'] <= 70 assert counts['excerpt_words'] <= 45 assert 140 <= counts['search_description_characters'] <= 160 citations = re.findall(r'(inputs/[\w.-]+) — ([^;\]]+)', article) assert citations for path, sections in citations: source = (workspace / path).read_text(encoding='utf-8') for section in sections.split(', '): assert re.search(r'^#+ ' + re.escape(section) + r'\s*$', source, re.M), (path, section) assert 29 * 3 == 87 assert 87 + 12 == 99 assert 50 - 20 == 30 assert (50 - 20) / 50 * 100 == 60 archive = root / 'original-submission' manifest = json.loads((archive / 'sha256.json').read_text(encoding='utf-8')) for name, expected in manifest.items(): assert hashlib.sha256((archive / name).read_bytes()).hexdigest() == expected, name for name in ['article.md', 'metadata.json', 'editor-notes.md']: assert (root / name).read_text(encoding='utf-8').strip() result = { 'counts': counts, 'citation_groups_checked': len(citations), 'archived_original_files_verified': len(manifest), 'status': 'PASS', 'checks': ['UTF-8 deliverable readability', 'JSON parsing, keys and string values', 'headline matches article', 'length constraints under three word-count conventions', 'cited files and section headings exist', 'price and percentage arithmetic', 'archived original SHA-256 integrity'], 'limits': 'No product tests or rendered-layout checks; citation matching checks existence, not evidentiary support.' } (root / 'check-results.json').write_text(json.dumps(result, indent=2) + '\n', encoding='utf-8') print(json.dumps(result, indent=2))