from pathlib import Path import csv, hashlib, json, re root = Path('.') text = (root/'output/handoff.md').read_text(encoding='utf-8') words = len(text.split()) assert words < 900, words with (root/'output/requirements.csv').open(encoding='utf-8', newline='') as f: reader = csv.DictReader(f) fields = ['id','current_requirement','owner','status','source'] assert reader.fieldnames == fields rows = list(reader) assert len(rows) == 16 assert len({r['id'] for r in rows}) == len(rows) for row in rows: assert set(row) == set(fields) assert all(isinstance(v, str) and v.strip() for v in row.values()) archive = (root/'inputs/archive.md').read_text(encoding='utf-8') changes = (root/'inputs/approved-changes.md').read_text(encoding='utf-8') archive_ids = set(re.findall(r'^## ([A-Z]+-\d+) ', archive, re.M)) change_ids = set(re.findall(r'^(CR-\d+) approved', changes, re.M)) combined = text + '\n' + '\n'.join(r['source'] for r in rows) for record in set(re.findall(r'\b(?:DEC|TEST|MAIL|EMAIL|TICKET|NOTE)-\d+\b', combined)): assert record in archive_ids, record for record in set(re.findall(r'\bCR-\d+\b', combined)): assert record in change_ids, record # Validate every member of abbreviated NOTE citation ranges, not only endpoints. for start, end in re.findall(r'NOTE-(\d+)–NOTE-(\d+)', combined): for i in range(int(start), int(end)+1): assert f'NOTE-{i:03}' in archive_ids for row in rows: for citation in row['source'].split('; '): path, record = citation.split(' ', 1) assert path in ['inputs/archive.md', 'inputs/approved-changes.md'] assert (root/path).is_file() valid_ids = archive_ids if path.endswith('archive.md') else change_ids for rec in re.findall(r'[A-Z]+-\d+', record): assert rec in valid_ids assert 12 + 4 == 16 snapshot = root/'output/original_submission' manifest = json.loads((snapshot/'sha256.json').read_text()) for name, digest in manifest.items(): assert hashlib.sha256((snapshot/name).read_bytes()).hexdigest() == digest, name print(f'PASS: handoff {words} whitespace-delimited words (<900); CSV {len(rows)} rows, exact header, unique IDs, nonempty fields and correct row width.') print('PASS: cited source files and record IDs exist; all members of NOTE ranges checked; a17 CSV total 12+4=16.') print('PASS: all three original-submission files match preserved SHA-256 manifest.') print('LIMIT: structural checks do not prove source entailment; conclusions require the separate evidence review. No product tests run.')