"""Build final ledgers from accepted portable cases; never upgrade preservation gaps.""" import json import re from pathlib import Path HERE = Path(__file__).resolve().parent def read(name): return json.loads((HERE / name).read_text(encoding='utf-8')) def cell(value): return str(value).replace('|', '/').replace('\n', ' ') def main(): inventory = read('p9-00/inventory.json') groups = inventory['preservation'] assert len(groups) == len({row['id'] for row in groups}) == 57 # Later reconciliation supersedes historic Phase2 gaps, without rewriting them. p7 = (HERE.parent / 'phase-7/PRESERVATION.md').read_text(encoding='utf-8') remaining = {} for line in p7.splitlines(): if line.startswith('| **PRES-'): cols = [part.strip() for part in line.strip('|').split('|')] remaining[re.search(r'PRES-[A-Z]\d{2}', cols[0]).group()] = cols[3] assert set(remaining) == {row['id'] for row in groups} cases = read('p9-01/ordinary-cases.json') diagnostics = read('p9-05/phase9-cases.json') volume = read('p9-05/volume-cases.json') assert len(cases) == 362 and len(diagnostics) == 18 and len(volume) == 3 assert len({(row['id'], row['project']) for row in cases}) == 362 contracts = [case for lane in ['ai', 'auth', 'rate', 'ingress', 'pdf', 'preferences'] for case in read(f'p9-06/{lane}-cases.json')] assert len(contracts) == 23 assert all(row['status'] == 'expected' and len(row['results']) == 1 and row['results'][0]['status'] == 'passed' and row['results'][0]['retry'] == 0 and not row['results'][0]['errors'] for row in cases + diagnostics + volume + contracts) validation_record = read('validation.json') validation = validation_record['lanes'] offline_commands = { 'python scripts/test-supply-chain.py', 'python scripts/test-ollama-evaluation.py', 'python scripts/test-browser-runtime-retry.py', 'python scripts/test-ingress.py', 'python scripts/supply-chain.py scan-secrets', 'python scripts/supply-chain.py generate-sbom', 'node --test audit-dependencies.test.mjs localSMTPfixture.test.mjs', 'node --test browser-extension/tests/capture-url.test.mjs', } assert len(validation_record['offline']) == len(offline_commands) assert {row['command'] for row in validation_record['offline']} == offline_commands assert all(row['exitCode'] == 0 for row in validation_record['offline']) documents = validation_record['nativeDocuments'] assert len(documents['commands']) == 2 and all(row['exitCode'] == 0 for row in documents['commands']) assert '.artifacts/phase9/ordinary-cta-shard-1.json' in documents['inputs'] assert '.artifacts/phase9/ordinary-cta-shard-1-exit.json' in documents['inputs'] assert len(documents['outputs']) == 2 assert validation['ordinary']['membershipMatchesDiscovery'] for lane in ['ordinary', 'phase9', 'volume', 'ai', 'auth', 'rate', 'ingress', 'pdf', 'preferences']: record = validation[lane] assert not record['fileFailures'] and not record['retries'] assert record['stats']['unexpected'] == record['stats']['flaky'] == record['stats']['skipped'] == 0 assert record['stats']['expected'] == record['cases'] assert sum(validation[lane]['cases'] for lane in ['ai', 'auth', 'rate', 'ingress', 'pdf', 'preferences']) == 23 assert validation['backend']['passed'] == '1084' and validation['backend']['failed'] == '0' assert validation['backend']['total'] == validation['backend']['executed'] == '1084' assert validation['backend']['notExecuted'] == '0' assert validation['frontend']['success'] and validation['frontend']['numPassedTests'] == 919 assert validation['frontend']['numFailedTests'] == validation['frontend']['numPendingTests'] == 0 assert validation['frontend']['numTodoTests'] == validation['frontend']['numFailedTestSuites'] == 0 assert validation['frontend']['numPassedTestSuites'] == 104 assert validation['sidecar']['tests'] == '56' and validation['sidecar']['failures'] == validation['sidecar']['errors'] == '0' assert validation['sidecar']['skipped'] == '0' for lane in [*[f'ordinary-cta-shard-{number}' for number in range(1, 5)], 'admin-grid-green', 'landing-cta-green', 'phase9-cta', 'volume-complete', *[lane + '-cta' for lane in ['ai', 'auth', 'rate', 'ingress', 'pdf', 'preferences']], 'backend', 'frontend-cta', 'sidecar', 'build-cta']: assert validation[lane + 'Process']['exitCode'] == 0 for name, count, pages in [('fidelity-results.json', 16, 36), ('settings-fidelity-results.json', 8, 24)]: corpus = read('p9-05/evidence/' + name) assert corpus['passed'] == corpus['total'] == count assert all(row['pass'] and not row['failures'] for row in corpus['fixtures']) assert sum(row['pdfPages'] for row in corpus['fixtures']) == pages rows = read('p9-02/route-results.json') assert len(rows) == 396 and {row['pattern'] for row in rows} == set(inventory['routes']) header = '# Phase 9 preservation reconciliation\n\nAll57 groups retain **56 PARTIAL / C11 DEFERRED**. Zero groups are promoted to PASS. These statuses retain mandatory human/provider/output obligations and are not57 defect findings. Phase9 adds finite executed evidence and repairs in two existing UI owners; it does not erase previous acceptance records. [Phase7](../phase-7/PRESERVATION.md) supplies the later residual obligations, superseding stale Phase2 gap descriptions (notably repaired P2-D01 and CV revision safety).\n\n' header += 'Exact executed browser cases are in [ordinary-cases](p9-01/ordinary-cases.json); complete backend case results and frontend suite totals are linked from [validation](validation.json). The matches below use explicit IDs in test titles only; zero explicit matches means no direct title mapping, not absent unit/API coverage. A case may cover several groups; do not sum counts as independent tests.\n\n' lines = [header, '| Group / owners | Entry → Phase9 | Direct native title matches | Current residual / closure |', '|---|---|---|---|'] portable = [] for group in groups: identifier = group['id'] matches = [dict(file=c['file'], title=c['title']) for c in cases if identifier in c['title']] residual = re.sub(r'\[([^]]+)\]\([^)]+\)', r'\1', remaining[identifier]) delta = 'Finite full regression retained; human/provider/output qualifications remain.' if identifier in ['PRES-C01', 'PRES-W02', 'PRES-J06']: delta += ' RD21 stale-write safety FAIL; see separate contract issue.' if identifier == 'PRES-C11': delta = 'P5-13 remains withheld; real model/semantic qualification not executed.' if identifier == 'PRES-E01': delta += ' P9-V01/P9-V02 proportional heading and CTA fixes; two native cases retain16-vector geometry proof.' if identifier in ['PRES-A01', 'PRES-E08']: delta += ' P9-L01 installed vendor locale and2new Jest cases.' if identifier == 'PRES-S02': delta += ' Phase8 account-layout order/size/visibility/reset/conflict behaviour preserved.' lines.append(f"| {cell(group['capability'])}; owners: {cell(group['owners'])} | {group['entryStatus']} → {group['entryStatus']} | {len(matches)} | {cell(delta)} {cell(residual)} |") portable.append(dict(id=identifier, capability=group['capability'], owners=group['owners'], entry=group['entryStatus'], phase9=group['entryStatus'], evidence=matches, remaining=residual, delta=delta)) assert sum(row['phase9'] == 'PARTIAL' for row in portable) == 56 assert sum(row['phase9'] == 'DEFERRED' for row in portable) == 1 (HERE / 'PRESERVATION.md').write_text('\n'.join(lines) + '\n', encoding='utf-8') (HERE / 'preservation.json').write_text(json.dumps(portable, ensure_ascii=False, indent=2) + '\n', encoding='utf-8') lines = ['# Final route/workflow QA matrix', '', 'All33 concrete patterns are retained. Each has12 native samples:320/768/1440px × EN/NB × light/dark, with actual applied theme/locale, heading, expected owned read states where applicable and root-overflow assertions. The correspondence review alias deliberately expects409 for unavailable mailbox configuration. Public invalid-token/unpublished states are deliberately identified; they do not prove successful external delivery/publication. Screenshots were inspected within the scope in [visual report](p9-02/README.md).', '', 'Route presence/DOM PASS is separate from workflow acceptance PARTIAL. Consult [ordinary executed cases](p9-01/ordinary-cases.json) and per-group [preservation](PRESERVATION.md) for connected mutation/failure journeys; route screenshots alone are not end-to-end capability proof.', '', '| Route → workflow owners | Feature contracts | Executed route evidence | Known risks / acceptance |', '|---|---|---|---|'] for route, owners in inventory['routes'].items(): samples = [r for r in rows if r['pattern'] == route] assert len(samples) == 12 assert all(r['scrollWidth'] <= r['viewport'] + 1 and r['effectiveTheme'] == r['theme'] for r in samples) related = [g['id'] for g in groups if route != '/' and route in g['entry'] or route == '/' and '`/`' in g['entry']] extra = 'RD06/07 human/device; relevant provider/output gates; PARTIAL workflow qualification' if route in ['/career', '/jobs/:id', '/applications/:id', '/jobs']: extra += '; RD21 unsafe concurrent saves FAIL' lines.append(f"| `{route}` → {cell(', '.join(owners))} | {', '.join(related) or 'Shared shell/nearest contracts; no invented group'} |12/12 applied-state/overflow samples; [rows](p9-02/route-results.json) | {extra} |") (HERE / 'QA_MATRIX.md').write_text('\n'.join(lines) + '\n', encoding='utf-8') print('Reconciled33 routes and57 unchanged preservation dispositions') if __name__ == '__main__': main()