883 files, from working commit b1a079a. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
57 lines
3.4 KiB
Python
57 lines
3.4 KiB
Python
"""Exercise the saved original529 WDT family at the new batch boundary."""
|
|
import hashlib
|
|
import copy
|
|
import json
|
|
from pathlib import Path
|
|
import shutil
|
|
import sys
|
|
import tempfile
|
|
import unittest
|
|
|
|
ROOT = Path(__file__).resolve().parents[1]
|
|
sys.path.insert(0, str(ROOT / 'ops'))
|
|
import map_conversion_batch as batch
|
|
|
|
|
|
class WdtBatchBoundary(unittest.TestCase):
|
|
def test_saved_map0_map1_family_and_native_identity_guard(self):
|
|
evidence = ROOT / 'docs/evidence/content-data/openworld-original529-presentation-20261026/assessment.json'
|
|
assessment = json.loads(evidence.read_text())
|
|
family_path = ROOT / 'runtime/continuation-20261026/openworld-MAIN-activation-contract/final-finite-outdoor-WDT2/final-WDT2-handoff.json'
|
|
family = json.loads(family_path.read_text())
|
|
def ref(path):
|
|
path = Path(path).resolve(); body = path.read_bytes()
|
|
return {'path': str(path), 'sha256': hashlib.sha256(body).hexdigest(), 'bytes': len(body)}
|
|
source_shas = {0: '751bc4610b35bc51ad573b91dd8f6658f095732e5bfde67e09eb25901d793c80',
|
|
1: '69e64853f43142f02aacc1a796c16e9a51bab656e1c9078c05e5752419a1d5ca'}
|
|
source_dir = ROOT / 'runtime/all-source-map-inventory-20261019/payloads'
|
|
payloads, jobs, audits = {}, [], {}
|
|
for row in family['rows']:
|
|
mid = row['MapID']; native = ref(row['baseline_file'])
|
|
source = ref(source_dir / (source_shas[mid] + '.wdt'))
|
|
self.assertEqual(source['sha256'], source_shas[mid]); self.assertEqual(native['sha256'], row['baseline_sha256'])
|
|
payloads['source' + str(mid)] = source; payloads['native' + str(mid)] = native
|
|
audits[str(mid)] = ref(row['audit'])
|
|
jobs.append({'id': 'map' + str(mid), 'kind': 'wdt', 'map_id': mid,
|
|
'source': 'source' + str(mid), 'native': 'native' + str(mid), 'requires_native_patch': True,
|
|
'native_file_data_id': row['control'], 'source_reference': row['source_reference'],
|
|
'contracts': {'wdt-original529-links': 'wdt'}})
|
|
contract = {'operation': 'wdt-original529-links', 'admission': 'private-candidate',
|
|
'api': 'wdt_native_component_links_candidate', 'receipt': ref(family_path),
|
|
'accepted_status': family['status'], 'source_scope': ref(ROOT / family['input_scope']),
|
|
'map_audits': audits, 'provenance': [ref(evidence), ref(assessment['REA']['exact_529_seed'])]}
|
|
wrong_control = copy.deepcopy(jobs[0]); wrong_control['id'] = 'wrong-control'; wrong_control['native_file_data_id'] += 1
|
|
jobs.append(wrong_control)
|
|
request = {'kind': 'map-conversion-batch-v1', 'payloads': payloads, 'contracts': {'wdt': contract}, 'jobs': jobs}
|
|
directory = Path(tempfile.mkdtemp(prefix='wdt-map-boundary-', dir=ROOT / 'runtime/continuation-20261029'))
|
|
self.addCleanup(shutil.rmtree, directory)
|
|
result = batch.convert_batch(request, directory / 'staged', base_directory=ROOT)
|
|
self.assertEqual([x['status'] for x in result['rows']], ['CONVERTED', 'CONVERTED', 'HELD'],
|
|
[x.get('reason') for x in result['rows']])
|
|
self.assertEqual([x['outputs'][0]['sha256'] for x in result['rows'][:2]], [x['sha256'] for x in family['rows']])
|
|
self.assertTrue(all(not x['runtime_verified'] for x in result['rows']))
|
|
|
|
|
|
if __name__ == '__main__':
|
|
unittest.main()
|