883 files, from working commit b1a079a. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
74 lines
5.1 KiB
Python
74 lines
5.1 KiB
Python
"""Reuse the actual qualified WDL/WDT families without rerunning conversion."""
|
|
import copy
|
|
import hashlib
|
|
import json
|
|
from pathlib import Path
|
|
import shutil
|
|
import sys
|
|
import tempfile
|
|
import unittest
|
|
from unittest import mock
|
|
|
|
ROOT = Path(__file__).resolve().parents[1]
|
|
sys.path.insert(0, str(ROOT / 'ops'))
|
|
import map_conversion_batch as batch
|
|
|
|
|
|
class SavedMapFamiliesBoundary(unittest.TestCase):
|
|
def test_one_batch_reuses_qualified_families_and_holds_missing_candidate(self):
|
|
def ref(path):
|
|
path = Path(path).resolve(); body = path.read_bytes()
|
|
return {'path': str(path), 'sha256': hashlib.sha256(body).hexdigest(), 'bytes': len(body)}
|
|
wdl_assessment_path = ROOT / 'docs/evidence/content-data/wdl-native-presentation-profile-20261026/assessment.json'
|
|
wdl_assessment = json.loads(wdl_assessment_path.read_text())
|
|
wdl_family_path = ROOT / wdl_assessment['full_output_and_binding_receipt']
|
|
wdl_family = json.loads(wdl_family_path.read_text())
|
|
wdt_assessment_path = ROOT / 'docs/evidence/content-data/openworld-original529-presentation-20261026/assessment.json'
|
|
wdt_assessment = json.loads(wdt_assessment_path.read_text())
|
|
wdt_family_path = ROOT / 'runtime/continuation-20261026/openworld-MAIN-activation-contract/final-finite-outdoor-WDT2/final-WDT2-handoff.json'
|
|
wdt_family = json.loads(wdt_family_path.read_text())
|
|
payloads, jobs, wdl_candidates = {}, [], {}
|
|
for row in wdl_family['outputs']:
|
|
source = row['Source_sha256']; payloads[source] = ref(row['Source_file'])
|
|
wdl_candidates[source] = ref(ROOT / row['output'])
|
|
for i, row in enumerate(wdl_family['rows']):
|
|
jobs.append({'id': 'wdl-' + str(i), 'kind': 'wdl', 'source': row['payload_SHA256'],
|
|
'contracts': {'wdl-native-profile': 'wdl'}, 'options': {'native_profile': wdl_assessment['policy']}})
|
|
wdl_contract = {'operation': 'wdl-native-profile', 'admission': 'private-candidate',
|
|
'receipt': ref(wdl_assessment_path), 'accepted_status': wdl_assessment['status'],
|
|
'api': 'wdl_source_height_native_profile_candidate', 'provenance': [ref(ROOT / wdl_assessment['original_REA_witness'])],
|
|
'reuse_saved': {'family_receipt': ref(wdl_family_path), 'candidates': wdl_candidates}}
|
|
wdt_audits, wdt_candidates = {}, {}
|
|
source_shas = {0: '751bc4610b35bc51ad573b91dd8f6658f095732e5bfde67e09eb25901d793c80',
|
|
1: '69e64853f43142f02aacc1a796c16e9a51bab656e1c9078c05e5752419a1d5ca'}
|
|
for row in wdt_family['rows']:
|
|
mid = row['MapID']; source_key = 'source-wdt' + str(mid); native_key = 'native-wdt' + str(mid)
|
|
payloads[source_key] = ref(ROOT / 'runtime/all-source-map-inventory-20261019/payloads' / (source_shas[mid] + '.wdt'))
|
|
payloads[native_key] = ref(row['baseline_file']); wdt_audits[str(mid)] = ref(row['audit']); wdt_candidates[str(mid)] = ref(row['file'])
|
|
jobs.append({'id': 'wdt-' + str(mid), 'kind': 'wdt', 'map_id': mid, 'source': source_key, 'native': native_key,
|
|
'requires_native_patch': True, 'native_file_data_id': row['control'], 'source_reference': row['source_reference'],
|
|
'contracts': {'wdt-original529-links': 'wdt'}})
|
|
wdt_contract = {'operation': 'wdt-original529-links', 'admission': 'private-candidate',
|
|
'api': 'wdt_native_component_links_candidate', 'receipt': ref(wdt_family_path),
|
|
'accepted_status': wdt_family['status'], 'source_scope': ref(ROOT / wdt_family['input_scope']),
|
|
'map_audits': wdt_audits, 'provenance': [ref(wdt_assessment_path), ref(wdt_assessment['REA']['exact_529_seed'])],
|
|
'reuse_saved': {'candidates': wdt_candidates}}
|
|
broken = copy.deepcopy(wdl_contract); missing_sha = jobs[0]['source']; broken['reuse_saved']['candidates'].pop(missing_sha)
|
|
bad_job = copy.deepcopy(jobs[0]); bad_job['id'] = 'missing-candidate'; bad_job['contracts']['wdl-native-profile'] = 'broken'
|
|
jobs.append(bad_job)
|
|
request = {'kind': 'map-conversion-batch-v1', 'payloads': payloads,
|
|
'contracts': {'wdl': wdl_contract, 'wdt': wdt_contract, 'broken': broken}, 'jobs': jobs}
|
|
directory = Path(tempfile.mkdtemp(prefix='saved-map-families-', dir=ROOT / 'runtime/continuation-20261029'))
|
|
self.addCleanup(shutil.rmtree, directory)
|
|
with mock.patch.object(batch, 'invoke', side_effect=AssertionError('qualified candidates must not be reconverted')):
|
|
result = batch.convert_batch(request, directory / 'staged', base_directory=ROOT)
|
|
self.assertEqual([r['status'] for r in result['rows']], ['REUSED'] * 13 + ['HELD'],
|
|
[r.get('reason') for r in result['rows']])
|
|
self.assertTrue(all(r.get('reused_qualified_output') and not r['runtime_verified'] for r in result['rows'][:13]))
|
|
self.assertEqual([r['outputs'][0]['sha256'] for r in result['rows'][11:13]], [r['sha256'] for r in wdt_family['rows']])
|
|
self.assertFalse(result['candidate_content_complete'])
|
|
|
|
|
|
if __name__ == '__main__':
|
|
unittest.main()
|