#!/usr/bin/env python3 """Record the tested v2 deliverables without rewriting their fixed build anchor.""" from datetime import datetime, timezone import hashlib import json from pathlib import Path ROOT = Path(__file__).resolve().parents[2] OUT = ROOT / 'tests/results/pdfium-intent-context' PARENT = ROOT / 'tests/results/pdfium-intent-build/record.json' PARENT_SHA = '47b4dc2efbf8e671f904610b3047400dbd3ceb0fa10d6bd53fb04f3727943e7e' ANCHOR_SHA = '80af72b06d5c9a6a3ab8b9311373e6a23e8df28668ce575e1124350e69aa160b' def sha(path): with path.open('rb') as stream: return hashlib.file_digest(stream, 'sha256').hexdigest() def relative(path): return str(path.relative_to(ROOT)) def reference(path): return {'path': relative(path), 'sha256': sha(path)} def main(): current = ROOT / 'docs/validation-record.json' destination = OUT / 'integration-record.json' assert not destination.exists(), 'Integration records are immutable.' assert sha(current) == sha(PARENT) == PARENT_SHA assert sha(OUT / 'record.json') == ANCHOR_SHA parent = json.loads(PARENT.read_text()) anchor = json.loads((OUT / 'record.json').read_text()) required = { 'archCandidate': OUT / 'arch/report.json', 'ubuntuCandidate': OUT / 'ubuntu/report.json', 'archNewBuild': OUT / 'arch-integration/report.json', 'ubuntuNewBuildAndPackage': OUT / 'ubuntu-package/report.json', 'sdkFreeUbuntu': OUT / 'ubuntu-package/clean-vm/report.json', 'performance': OUT / 'performance/report.json', 'renderReview': OUT / 'render-review/report.json', } reports = {key: json.loads(path.read_text()) for key, path in required.items()} for key, data in reports.items(): assert data.get('candidateTestsPass', data.get('success')) is True, key assert reports['renderReview']['humanApproved'] is False arch = reports['archNewBuild'] for name, digest in arch['binaries'].items(): assert sha(ROOT / 'build-context' / name) == digest, name library = ROOT / '.deps/pdfium-context/lib/libpdfium.so' assert sha(library) == anchor['pdfiumRenderingIntentCandidate']['librarySha256'] assert sha(ROOT / '.deps/pdfium/lib/libpdfium.so') == '08f6ea53a64f6fbb9f5ba8d9c02e0051987c6a9175f3fb5ba25f219174731aaa' source_paths = {ROOT / name for name in parent['sourceSha256']} source_paths.update(ROOT / name for name in parent['validationToolsSha256']) for folder in ('tools', 'cmake', 'tests/cmyk_lut'): source_paths.update(path for path in (ROOT / folder).rglob('*') if path.is_file() and '__pycache__' not in path.parts) required_sources = tuple(ROOT / name for name in ( 'CMakeLists.txt', 'tests/test_stage_pdfium_candidate.py', 'tests/test_pdfium_candidate_integration.py', 'tests/ubuntu_vm/context_package.py', 'tests/ubuntu_vm/package_smoke.py', 'tests/ubuntu_vm/clean_package.py', 'tests/compare_pdf_extended.py', 'tests/generate_render_review.py')) for path in required_sources: assert path.is_file(), relative(path) source_paths.update(required_sources) sources = {relative(path): sha(path) for path in sorted(source_paths) if path.is_file()} changed = [{'path': name, 'previousSha256': digest, 'currentSha256': sources[name]} for name, digest in {**parent['sourceSha256'], **parent['validationToolsSha256']}.items() if name in sources and sources[name] != digest] evidence = {} for folder in (OUT, ROOT / 'tests/results/pdfium-intent-transparency', ROOT / 'tests/results/pdfium-intent-ubuntu'): for path in sorted(folder.rglob('*')): if path.is_file() and path != destination and '__pycache__' not in path.parts: evidence[relative(path)] = sha(path) record = { 'schemaVersion': 7, 'recordedAtUtc': datetime.now(timezone.utc).isoformat(), 'goalComplete': False, 'scope': 'Linux v2 candidate integrated into dedicated Arch and Ubuntu builds and a local validation deb. Earlier evidence is retained by immutable parent references. Target Windows/physical/human/release gates remain incomplete.', 'previousValidation': reference(PARENT), 'candidateBuildAnchor': reference(OUT / 'record.json'), 'pdfiumRenderingIntentCandidate': anchor['pdfiumRenderingIntentCandidate'], 'candidateIntegration': { 'selectedLibrary': reference(library), 'originalProviderPreserved': True, 'buildInfo': reference(ROOT / '.deps/pdfium-context/BUILDINFO.json'), 'reviewedLock': reference(ROOT / 'cmake/pdfium-candidate-v2.lock.json'), 'archExecutable': 'build-context/docview', 'archInstalledExecutable': 'build-context/install/bin/docview', 'ubuntuPackageRecord': reference(required['ubuntuNewBuildAndPackage']), }, 'executables': arch['binaries'], 'validationReports': {key: reference(path) for key, path in required.items()}, 'oracleCorrection': reference(ROOT / 'tests/fixtures/pdf/rendering-intents-context/manifest.json'), 'historicalOracleLimitation': 'The v1 shading-pattern-inherit expectations selected paint-time RI incorrectly. Its numerical pass is preserved as historical evidence, not pattern conformance. Revision 2 keeps the original PDF/profile bytes and corrects eight rows.', 'referenceCmm': reference(ROOT / 'tests/results/pdfium-intent-ubuntu/reference-cmm/verification.json'), 'remainingAcceptance': [ 'Windows 11 native build, sandbox/pipe/IME execution and distribution tests', 'Target-OS physical GPU/display/input, reference hardware and long-duration acceptance', 'Human approval of G-RENDER reference images and documented comparison differences', 'Final public distribution/license decision and complete corresponding-source/notice assessment', ], 'sourceSha256': sources, 'changedSincePreviousRecord': changed, 'documentationSha256': {name: sha(ROOT / name) for name in ( 'README.md', 'docs/PDFIUM-CANDIDATE.md', 'docs/VALIDATION.md', 'docs/ACCEPTANCE-AUDIT.md', 'docs/UBUNTU-PACKAGE.md', 'tests/PDF-VALIDATION.md')}, 'evidenceSha256': evidence, } encoded = json.dumps(record, indent=2) + '\n' destination.write_text(encoded) current.write_text(encoded) print(json.dumps({'schemaVersion': 7, 'sha256': sha(current), 'evidenceFiles': len(evidence), 'sourceFiles': len(sources), 'goalComplete': False})) if __name__ == '__main__': main()