Files
WoW-Hybrid-gateway/tests/classic_to_forever_test.py
praxisandClaude Fable 5.2 7f2139d8d0 Offline test fixtures
883 files, from working commit b1a079a.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-19 01:32:48 +02:00

1010 lines
70 KiB
Python

#!/usr/bin/env python3
"""Focused orchestration batch: real converters, immutable pins and scoped proof."""
from pathlib import Path
import copy
import io
import json
import shutil
import sys
import tempfile
import unittest
from unittest.mock import patch
ROOT = Path(__file__).resolve().parents[1]
sys.path.insert(0, str(ROOT / 'ops'))
sys.path.insert(0, str(ROOT / 'tests'))
import classic_to_forever as tool
from m2_equipment_convert_test import fixture as model_fixture
from PIL import Image
class BatchTest(unittest.TestCase):
def setUp(self):
self.root = Path(tempfile.mkdtemp(prefix='fixture-', dir=ROOT / 'runtime/continuation-20261028/classic-to-forever'))
self.addCleanup(shutil.rmtree, self.root)
self.evidence = self.write('original-consumer.json', {'status': 'PASS_FIXTURE', 'original': 'bounded synthetic API contract'})
self.model = self.write('source.m2', model_fixture())
image = Image.new('P', (8, 8)); image.putpalette([0, 0, 0] * 256)
stream = io.BytesIO(); image.save(stream, format='BLP')
self.icon = self.write('source-icon.blp', stream.getvalue())
self.native = self.write('native.m2', b'preserved native model')
self.other = self.write('native-icon.blp', b'preserved icon until explicit exception')
archives = {'patch-4.mpq': {'bytes': 10, 'mtime_ns': 20}, 'patch-5.mpq': {'bytes': 30, 'mtime_ns': 40}}
self.snapshot = self.write('snapshot.json', {
'kind': 'classic-to-forever-source-snapshot-v1', 'archives': archives,
'inputs': {'model': dict(self.model, archive_owners=['patch-4.mpq']),
'icon': dict(self.icon, archive_owners=['patch-5.mpq'])}})
self.inventory = self.write('inventory.json', {'kind': 'classic-to-forever-patch-inventory-v1', 'archives': archives})
self.natives = self.write('native-assets.json', {'assets': {'existing-model': self.native, 'same-model': self.model, 'existing-icon': self.other}})
self.backend_receipt = self.write('backend-rea.json', {'status': 'PASS_SYNTHETIC_M2_CONTRACT', 'operation': 'm2-convert'})
self.req = {'kind': tool.KIND, 'source_snapshot': self.snapshot, 'patch_inventory': self.inventory,
'native_assets': self.natives, 'rea_contracts': {}, 'jobs': []}
self.add_model('model-convert')
self.add_model('native-preserve', 'existing-model')
self.add_model('identical-reuse', 'same-model')
self.add_icon('icon-convert')
self.req['jobs'].append({'id': 'unsupported-mail', 'scope': 'mail', 'adapter': 'mail', 'source_inputs': ['model']})
def write(self, name, value):
raw = value if isinstance(value, bytes) else tool.encoded(value)
path = self.root / name; path.parent.mkdir(parents=True, exist_ok=True); path.write_bytes(raw)
return {'path': str(path), 'sha256': tool.digest(raw), 'bytes': len(raw)}
def add_model(self, ident, native=None):
key = ident + '-rea'
native_bindings = {native: self.model['sha256'] if native == 'same-model' else self.native['sha256']} if native else {}
rea = {'kind': 'classic-to-forever-rea-contract-v1', 'status': 'QUALIFIED_FIXTURE', 'scope': 'models', 'adapter': 'map-batch',
'source_bindings': {'model': self.model['sha256']}, 'native_bindings': native_bindings,
'evidence': [dict(self.evidence, role='original-loader')], 'acceptance_criteria': ['animation'],
'backend_operations': ['m2-convert'], 'backend_receipts': [self.backend_receipt], 'asset_addition_qualified': True}
self.req['rea_contracts'][key] = self.write(key + '.json', rea)
backend = {'kind': 'map-conversion-batch-v1', 'payloads': {'m': self.model},
'contracts': {'m2': {'operation': 'm2-convert', 'api': 'convert_equipment', 'admission': 'private-candidate',
'receipt': self.backend_receipt, 'accepted_status': 'PASS_SYNTHETIC_M2_CONTRACT',
'scope': {'source_sha256': self.model['sha256']}, 'provenance': [self.evidence]}},
'jobs': [{'id': 'model', 'kind': 'm2', 'source': 'm', 'contracts': {'m2-convert': 'm2'}}]}
self.req['jobs'].append({'id': ident, 'scope': 'models', 'adapter': 'map-batch', 'source_inputs': ['model'],
'native_inputs': [native] if native else [], 'rea_contract': key,
'parameters': {'batch': backend}})
def add_icon(self, ident):
key = ident + '-rea'
rea = {'kind': 'classic-to-forever-rea-contract-v1', 'status': 'QUALIFIED_FIXTURE', 'scope': 'icons', 'adapter': 'icon-stage',
'source_bindings': {'icon': self.icon['sha256']}, 'native_bindings': {'existing-icon': self.other['sha256']},
'evidence': [dict(self.evidence, role='original-loader')], 'acceptance_criteria': ['source-selection']}
self.req['rea_contracts'][key] = self.write(key + '.json', rea)
self.req['jobs'].append({'id': ident, 'scope': 'icons', 'adapter': 'icon-stage', 'asset_role': 'item-icon',
'source_inputs': ['icon'], 'native_inputs': ['existing-icon'], 'rea_contract': key})
def stage(self, suffix='stage'):
return tool.convert(self.req, self.root / suffix)
def test_real_backend_multifamily_native_policy_and_offline_acceptance(self):
source_before = Path(self.model['path']).read_bytes()
native_before = Path(self.native['path']).read_bytes()
result = self.stage()
rows = {r['id']: r for r in result['jobs']}
self.assertEqual(rows['model-convert']['status'], 'CONVERTED_PRIVATE')
self.assertTrue(rows['model-convert']['outputs'])
model_output = next(x for x in rows['model-convert']['outputs'] if x['role'] == 'model')
self.assertNotEqual(model_output['sha256'], self.model['sha256'])
self.assertFalse(rows['model-convert']['content_complete'])
self.assertEqual(rows['native-preserve']['status'], 'PRESERVED_NATIVE')
self.assertFalse(rows['native-preserve']['source_content_resolved'])
self.assertEqual(rows['identical-reuse']['status'], 'REUSED')
self.assertEqual(rows['icon-convert']['outputs'][0]['sha256'], self.icon['sha256'])
self.assertEqual(rows['icon-convert']['outputs'][0]['role'], 'source-icon')
self.assertEqual(rows['unsupported-mail']['status'], 'HELD')
self.assertEqual(Path(self.model['path']).read_bytes(), source_before)
self.assertEqual(Path(self.native['path']).read_bytes(), native_before)
self.assertFalse(result['native_accepted'])
self.assertTrue(all(not r['native_accepted'] for r in result['jobs']))
def test_changed_archive_only_invalidates_owned_and_unknown_member_jobs(self):
inventory = json.loads(Path(self.inventory['path']).read_text())
inventory['archives']['patch-5.mpq']['bytes'] += 5
self.req['patch_inventory'] = self.write('changed-inventory.json', inventory)
result, _ = tool.plan(self.req)
rows = {r['id']: r for r in result['jobs']}
self.assertEqual(rows['model-convert']['status'], 'PLANNED')
self.assertEqual(rows['icon-convert']['status'], 'HELD')
capture = json.loads(Path(self.snapshot['path']).read_text()); del capture['inputs']['model']['archive_owners']
self.req['source_snapshot'] = self.write('unknown-owner.json', capture)
result, _ = tool.plan(self.req)
self.assertEqual(result['jobs'][0]['status'], 'HELD')
self.assertIn('owner/delta', result['jobs'][0]['reason'])
def test_pinned_previous_stage_skips_unchanged_backend_and_new_inventory_independent(self):
first = self.stage()
self.req['previous_stage'] = self.write('previous-stage.json', first)
inventory = json.loads(Path(self.inventory['path']).read_text())
inventory['archives']['patch-5.mpq']['mtime_ns'] += 1
self.req['patch_inventory'] = self.write('new-patch-inventory.json', inventory)
with patch('map_conversion_batch.convert_batch', side_effect=AssertionError('unchanged converter rerun')):
second = self.stage('stage-two')
rows = {r['id']: r for r in second['jobs']}
self.assertEqual(rows['model-convert']['status'], 'REUSED_PREVIOUS')
self.assertEqual(rows['icon-convert']['status'], 'HELD')
# A changed staged body invalidates only its job, without a catalogue hash sweep.
model_output = first['jobs'][0]['outputs'][0]
Path(model_output['path']).write_bytes(b'changed')
report, _ = tool.plan(self.req)
self.assertEqual(report['jobs'][0]['status'], 'HELD')
self.assertEqual(report['jobs'][1]['status'], 'PLANNED')
def test_scoped_acceptance_and_bound_observation_payload(self):
stage = self.stage(); ref = self.write('stage-ref.json', stage); job = stage['jobs'][0]
outputs = sorted(x['sha256'] for x in job['outputs'])
criteria = {}
for criterion in job['acceptance_criteria']:
body = {'kind': 'classic-to-forever-native-observation-v1', 'status': 'PASS', 'scope': job['scope'],
'criterion': criterion, 'fingerprint': job['fingerprint'], 'output_sha256': outputs}
proof = self.write('observation-' + criterion + '.json', body)
criteria[criterion] = dict(proof, kind='native-observation', scope=job['scope'], criterion=criterion)
receipt = {'kind': 'classic-to-forever-native-acceptance-v1', 'status': 'PASS', 'stage': 'native',
'job_id': job['id'], 'scope': job['scope'], 'adapter': job['adapter'], 'fingerprint': job['fingerprint'],
'stage_sha256': ref['sha256'], 'source_bindings': job['source_bindings'], 'output_sha256': outputs, 'criteria': criteria}
wrong = dict(receipt, scope='spells')
rejected = tool.acceptance_report(ref, [self.write('wrong-scope.json', wrong)])
self.assertFalse(rejected['jobs'][0]['native_accepted'])
self.assertIn('scope/adapter', rejected['jobs'][0]['rejected_receipts'][0])
accepted = tool.acceptance_report(ref, [self.write('bound-receipt.json', receipt)])
self.assertTrue(accepted['jobs'][0]['native_accepted'])
self.assertFalse(accepted['native_accepted'])
bad = copy.deepcopy(receipt)
first = next(iter(criteria))
bad['criteria'][first] = dict(self.evidence, kind='native-observation', scope='models', criterion=first)
invalid = tool.acceptance_report(ref, [self.write('arbitrary-pass.json', bad)])
self.assertFalse(invalid['jobs'][0]['native_accepted'])
def test_batch_deduplicates_shared_model_sources_and_pin_changes(self):
self.add_model('second-model-convert')
result = self.stage()
rows = {r['id']: r for r in result['jobs']}
self.assertEqual(rows['second-model-convert']['status'], 'CONVERTED_PRIVATE')
backend = json.loads(Path(rows['model-convert']['backend_report']['path']).read_text())
self.assertEqual(backend['unique_operations_executed'], 1)
self.assertEqual(backend['unique_input_files_read'], 2)
original = tool.plan(self.req)[0]['jobs'][0]['fingerprint']
with patch.object(tool, 'producer_pins', return_value={'changed-backend': 'f' * 64}):
changed = tool.plan(self.req)[0]['jobs'][0]['fingerprint']
self.assertNotEqual(original, changed)
def test_changed_higher_priority_archive_needs_selection_delta(self):
inventory = json.loads(Path(self.inventory['path']).read_text())
inventory['archives']['patch-5.mpq']['bytes'] += 5
inventory['archive_priorities'] = {'patch-4.mpq': 68, 'patch-5.mpq': 69}
self.req['patch_inventory'] = self.write('higher-priority-inventory.json', inventory)
rows = tool.plan(self.req)[0]['jobs']
self.assertEqual(rows[0]['status'], 'HELD')
self.assertIn('higher-priority', rows[0]['reason'])
def test_implicit_native_association_cannot_be_bypassed(self):
catalogue = json.loads(Path(self.natives['path']).read_text())
catalogue['source_to_native'] = {'model': ['existing-model']}
self.req['native_assets'] = self.write('associated-native.json', catalogue)
report, _ = tool.plan(self.req)
self.assertEqual(report['jobs'][0]['status'], 'HELD')
self.assertIn('native input bindings', report['jobs'][0]['reason'])
# A new asset needs the owning native-lookup/addition admission.
self.req['native_assets'] = self.natives
key = self.req['jobs'][0]['rea_contract']
contract = json.loads(Path(self.req['rea_contracts'][key]['path']).read_text())
del contract['asset_addition_qualified']
self.req['rea_contracts'][key] = self.write('no-lookup-admission.json', contract)
report, _ = tool.plan(self.req)
self.assertEqual(report['jobs'][0]['status'], 'HELD')
self.assertIn('native lookup/addition', report['jobs'][0]['reason'])
def test_native_terrain_data_patch_is_planned_without_replacing_native_assets(self):
from map_conversion_batch_test import adt_fixture
import map_asset_preflight
source = self.write('terrain.adt', adt_fixture())
native = self.write('native-terrain.adt', adt_fixture(native=True))
snapshot = json.loads(Path(self.snapshot['path']).read_text())
snapshot['inputs']['terrain'] = dict(source, archive_owners=['patch-4.mpq'])
self.req['source_snapshot'] = self.write('terrain-source-snapshot.json', snapshot)
self.req['native_assets'] = self.write('terrain-native-assets.json', {'assets': {'terrain-native': native}})
profile = self.write('terrain-profile.json', map_asset_preflight.NATIVE_NEAR_TERRAIN_PROFILE_V1)
rea = {'kind': 'classic-to-forever-rea-contract-v1', 'status': 'QUALIFIED_FIXTURE', 'scope': 'maps', 'adapter': 'map-batch',
'source_bindings': {'terrain': source['sha256']}, 'native_bindings': {'terrain-native': native['sha256']},
'evidence': [dict(self.evidence, role='original-loader')], 'acceptance_criteria': ['geometry'],
'backend_operations': ['native-patch'], 'backend_receipts': [profile]}
self.req['rea_contracts']['terrain'] = self.write('terrain-rea.json', rea)
batch = {'kind': 'map-conversion-batch-v1', 'payloads': {'source': source, 'native': native},
'contracts': {'native': {'operation': 'native-patch', 'admission': 'private-candidate',
'api': 'adt_near_terrain_profile_candidate', 'receipt': profile,
'accepted_kind': map_asset_preflight.NATIVE_NEAR_TERRAIN_PROFILE_V1['kind'],
'provenance': [self.evidence]}},
'jobs': [{'id': 'patch', 'kind': 'adt', 'map_id': 1, 'tile': [2, 3], 'source': 'source', 'native': 'native',
'native_file_data_id': 12345, 'contracts': {'native-patch': 'native'}}]}
self.req['jobs'] = [{'id': 'terrain-patch', 'scope': 'maps', 'adapter': 'map-batch', 'change_kind': 'data-behavior',
'source_inputs': ['terrain'], 'native_inputs': ['terrain-native'], 'rea_contract': 'terrain',
'parameters': {'batch': batch}}]
report = tool.plan_batch(self.req)
self.assertEqual(report['jobs'][0]['decision'], 'CONVERT')
self.assertEqual(report['jobs'][0]['status'], 'PLANNED')
self.assertEqual(report['source_payload_bytes_read'], 0)
def test_wdl_frontend_admits_only_map_scope_and_pins_producer(self):
# The owning WDL batch test already covers actual conversion and content.
job = {'scope': 'maps', 'adapter': 'map-batch', 'parameters': {'batch': {
'kind': 'map-conversion-batch-v1', 'payloads': {'source': self.model},
'contracts': {'wdl': {'operation': 'wdl-native-profile', 'receipt': self.backend_receipt,
'provenance': [self.evidence]}},
'jobs': [{'id': 'wdl', 'kind': 'wdl', 'source': 'source'}]}}}
contract = {'backend_operations': ['wdl-native-profile'], 'backend_receipts': [self.backend_receipt],
'evidence': [self.evidence]}
pins = tool.Pins(self.root)
result = tool.backend_request(job, self.req, {'source': self.model}, {}, pins, contract)
self.assertEqual(result['jobs'][0]['kind'], 'wdl')
self.assertIn('map_asset_preflight.py', tool.producer_pins('map-batch', job['parameters']))
job['scope'] = 'models'
with self.assertRaisesRegex(ValueError, 'model scope'):
tool.backend_request(job, self.req, {'source': self.model}, {}, pins, contract)
def test_item_property_catalogue_pins_transitive_producers(self):
pins = tool.producer_pins('classic-data', {'batch': {'jobs': [
{'operation': 'items.property-catalogue-assessment'}]}})
self.assertIn('classic_data_adapters.py', pins)
self.assertIn('item_property_catalogue.py', pins)
self.assertIn('item_effect_compat.py', pins)
def test_item_metadata_composer_pins_change_with_shared_helpers(self):
original_read = Path.read_bytes
helpers = {
'items.catalog-metadata-batch': ('item_batch_stage.py', 'item_sparse_compat.py',
'item_basic_compat.py'),
'items.intrinsic-armor-batch': ('item_batch_stage.py', 'item_sparse_compat.py'),
}
for operation, names in helpers.items():
params = {'batch': {'jobs': [{'operation': operation}]}}
baseline = tool.producer_pins('classic-data', params)
for name in names:
def changed_read(path):
data = original_read(path)
return data + b'\n# changed shared helper' if path.name == name else data
with self.subTest(operation=operation, helper=name):
with patch.object(Path, 'read_bytes', changed_read):
changed = tool.producer_pins('classic-data', params)
self.assertIn(name, baseline)
self.assertNotEqual(baseline[name], changed[name])
def test_item_set_composer_pins_change_with_shared_helpers(self):
original_read = Path.read_bytes
helpers = {
'items.sets': ('item_sparse_compat.py',),
'items.set-relationships': ('item_sparse_compat.py', 'item_set_compat.py'),
}
for operation, names in helpers.items():
params = {'batch': {'jobs': [{'operation': operation}]}}
baseline = tool.producer_pins('classic-data', params)
for name in names:
def changed_read(path):
data = original_read(path)
return data + b'\n# changed shared helper' if path.name == name else data
with self.subTest(operation=operation, helper=name):
with patch.object(Path, 'read_bytes', changed_read):
changed = tool.producer_pins('classic-data', params)
self.assertIn(name, baseline)
self.assertNotEqual(baseline[name], changed[name])
def test_spell_package_composer_pins_change_with_shared_helpers(self):
original_read = Path.read_bytes
helpers = {
'spells.package-passive': ('item_sparse_compat.py', 'spell_passive_compat.py'),
'spells.package-crafting': ('item_sparse_compat.py', 'spell_passive_compat.py',
'spell_crafting_compat.py'),
'spells.package-proc': ('item_sparse_compat.py', 'spell_passive_compat.py',
'spell_item_proc_compat.py', 'spell_restore_compat.py',
'spell_item_food_regen_compat.py'),
}
for operation, names in helpers.items():
params = {'batch': {'jobs': [{'operation': operation}]}}
baseline = tool.producer_pins('classic-data', params)
for name in names:
def changed_read(path):
data = original_read(path)
return data + b'\n# changed shared helper' if path.name == name else data
with self.subTest(operation=operation, helper=name):
with patch.object(Path, 'read_bytes', changed_read):
changed = tool.producer_pins('classic-data', params)
self.assertIn(name, baseline)
self.assertNotEqual(baseline[name], changed[name])
def test_race_and_appearance_wrappers_pin_actual_producers(self):
original_read = Path.read_bytes
helpers = {
'races.creation-rows': ('source_race_class_creation.py',),
'races.starting-outfits': ('source_starting_outfit_compat.py',),
'equipment.native-appearance-links': ('item_appearance_preflight.py',
'item_sparse_compat.py', 'turtle_data.py'),
'equipment.missing-native-links': ('item_sparse_compat.py', 'turtle_data.py'),
'equipment.compose-native-links': ('item_sparse_compat.py',),
}
for operation, names in helpers.items():
params = {'batch': {'jobs': [{'operation': operation}]}}
baseline = tool.producer_pins('classic-data', params)
for name in names:
def changed_read(path):
data = original_read(path)
return data + b'\n# changed producer' if path.name == name else data
with self.subTest(operation=operation, helper=name):
with patch.object(Path, 'read_bytes', changed_read):
changed = tool.producer_pins('classic-data', params)
self.assertIn(name, baseline)
self.assertNotEqual(baseline[name], changed[name])
def test_warrior_package_pins_change_with_actual_producers(self):
params = {'batch': {'jobs': [{'operation': 'spells.package-warrior'}]}}
baseline = tool.producer_pins('classic-data', params)
original_read = Path.read_bytes
for name in ('content_package_stage.py', 'item_sparse_compat.py',
'spell_passive_compat.py', 'spell_shield_slam_compat.py',
'spell_active_warrior_compat.py'):
def changed_read(path):
data = original_read(path)
return data + b'\n# changed producer' if path.name == name else data
with self.subTest(helper=name):
with patch.object(Path, 'read_bytes', changed_read):
changed = tool.producer_pins('classic-data', params)
self.assertIn(name, baseline)
self.assertNotEqual(baseline[name], changed[name])
def test_aura_family_merge_pins_owning_profile(self):
pins = tool.producer_pins('classic-data', {'batch': {'jobs': [
{'operation': 'auras.source-family-merge'}]}})
self.assertIn('aura_source_family_profile.py', pins)
def test_wdt_frontend_admits_qualified_map_patch_only(self):
# The owning WDT batch has checked the real two-map composition.
job = {'scope': 'maps', 'adapter': 'map-batch', 'change_kind': 'data-behavior', 'parameters': {'batch': {
'kind': 'map-conversion-batch-v1', 'payloads': {'source': self.model, 'native': self.native},
'contracts': {'wdt': {'operation': 'wdt-original529-links', 'receipt': self.backend_receipt,
'provenance': [self.evidence]}},
'jobs': [{'id': 'wdt', 'kind': 'wdt', 'source': 'source', 'native': 'native',
'requires_native_patch': True}]}}}
contract = {'backend_operations': ['wdt-original529-links'], 'backend_receipts': [self.backend_receipt],
'evidence': [self.evidence]}
pins = tool.Pins(self.root)
result = tool.backend_request(job, self.req, {'source': self.model}, {'native': self.native}, pins, contract)
self.assertEqual(result['jobs'][0]['kind'], 'wdt')
self.assertIn('map_asset_preflight.py', tool.producer_pins('map-batch', job['parameters']))
job['scope'] = 'models'
with self.assertRaisesRegex(ValueError, 'model scope'):
tool.backend_request(job, self.req, {'source': self.model}, {'native': self.native}, pins, contract)
def test_saved_map_family_refs_are_resolved_for_backend(self):
# Saved-family bodies are validated by their owning backend, not re-converted here.
relative = dict(self.evidence, path=Path(self.evidence['path']).name)
spec = {'operation': 'wdt-original529-links', 'receipt': self.backend_receipt,
'provenance': [self.evidence], 'source_scope': relative,
'map_audits': {'0': relative, '1': relative},
'reuse_saved': {'family_receipt': relative, 'scope_receipt': relative, 'preflight_receipt': relative,
'supplemental_receipt': relative,
'candidates': {'0': relative, '1': relative},
'binding_receipts': {'textures': relative, 'wmo_roots': relative, 'wmo_groups': relative},
'current_source_receipts': {'selection': relative, 'inventory': relative,
'archive_order': relative}}}
job = {'scope': 'maps', 'adapter': 'map-batch', 'parameters': {'batch': {
'kind': 'map-conversion-batch-v1', 'payloads': {'source': self.model},
'contracts': {'wdt': spec}, 'jobs': [{'id': 'wdt', 'kind': 'wdt', 'source': 'source'}]}}}
contract = {'backend_operations': ['wdt-original529-links'], 'backend_receipts': [self.backend_receipt],
'evidence': [self.evidence]}
result = tool.backend_request(job, self.req, {'source': self.model}, {}, tool.Pins(self.root), contract)
actual = result['contracts']['wdt']
for ref in (actual['source_scope'], *actual['map_audits'].values(),
actual['reuse_saved']['family_receipt'], actual['reuse_saved']['scope_receipt'],
actual['reuse_saved']['preflight_receipt'], actual['reuse_saved']['supplemental_receipt'],
*actual['reuse_saved']['candidates'].values(),
*actual['reuse_saved']['binding_receipts'].values(),
*actual['reuse_saved']['current_source_receipts'].values()):
self.assertTrue(Path(ref['path']).is_absolute())
self.assertEqual(ref['sha256'], self.evidence['sha256'])
def test_saved_map_component_reuse_rejects_changed_artifacts(self):
directory = self.root / 'saved-map-output'; directory.mkdir()
jobs, rows, candidates, tokens = [], [], {}, {}
for i in range(37):
ident = f'tile-{i}:tex0'; name = f'{i}.adt'; path = directory / name
path.write_bytes(bytes([i])); token = tool.artifact_token(path)
sha = tool.digest(path.read_bytes())
jobs.append({'id': ident, 'map_id': 1, 'tile': [i, 2], 'options': {'roles': ['tex0']}})
candidates[ident] = {'sha256': sha, 'bytes': 1}; tokens[name] = token
rows.append({'id': ident, 'map_id': 1, 'tile': [i, 2], 'operation': 'source-adt-split',
'status': 'REUSED', 'reused_qualified_output': True, 'installed': False,
'runtime_verified': False, 'outputs': [{'file': name, 'role': 'tex0',
'sha256': sha, 'bytes': 1}]})
digest = 'a' * 64
docs = {'handoff': {'status': 'PASS_EXISTING_MAP_CONVERTER_SAVED_TEX_REUSE',
'validated_output_artifact_tokens': tokens},
'manifest': {'jobs': jobs, 'contracts': {'saved': {'reuse_saved': {'candidates': candidates}}}},
'report': {'kind': 'map-conversion-batch-report-v1', 'action': 'convert', 'manifest_sha256': digest,
'requested': 37, 'resolved': 37, 'held': 0, 'candidate_content_complete': False,
'installed': False, 'runtime_verified': False, 'rows': rows}}
class Pins:
def json(self, ref): return docs[ref['key']]
spec = {'operation': 'saved-source78-tex-components', 'handoff': {'key': 'handoff'},
'manifest': {'key': 'manifest', 'sha256': digest},
'report': {'key': 'report', 'path': str(directory / 'report.json')}}
row = {'_system_spec': spec}
status, outputs, audit = tool.execute_system_stage(row, self.root / 'saved-map-stage', Pins())
self.assertEqual(status, 'MAP_COMPONENTS_REUSED')
self.assertEqual(len(outputs), 37)
self.assertFalse(audit['backend_reexecuted'])
(directory / '0.adt').write_bytes(b'changed')
with self.assertRaisesRegex(ValueError, 'changed since validation'):
tool.execute_system_stage(row, self.root / 'saved-map-drift-stage', Pins())
def test_scope_binding_dependencies_and_fresh_output(self):
job = self.req['jobs'][0]; job['scope'] = 'maps'
report, _ = tool.plan(self.req)
self.assertEqual(report['jobs'][0]['status'], 'HELD')
self.assertIn('scope/adapter', report['jobs'][0]['reason'])
job['scope'] = 'models'
job['dependencies'] = ['unsupported-mail']
report, _ = tool.plan(self.req)
self.assertEqual(next(r for r in report['jobs'] if r['id'] == job['id'])['status'], 'HELD')
with self.assertRaisesRegex(ValueError, 'fresh owned'):
tool.convert(self.req, self.root)
self.assertEqual(len(tool.registry()['scopes']), 24)
class NewAdapterBoundary(unittest.TestCase):
write = BatchTest.write
add_model = BatchTest.add_model
add_icon = BatchTest.add_icon
stage = BatchTest.stage
def setUp(self):
BatchTest.setUp(self)
self.req['jobs'] = []
self.inputs = json.loads(Path(self.snapshot['path']).read_text())['inputs']
self.native_inputs = json.loads(Path(self.natives['path']).read_text())['assets']
def source_input(self, name, value):
ref = self.write(name, value)
self.inputs[name] = dict(ref, archive_owners=['patch-4.mpq'])
return ref
def flush(self):
snapshot = json.loads(Path(self.snapshot['path']).read_text())
snapshot['inputs'] = self.inputs
self.req['source_snapshot'] = self.write('new-adapter-snapshot.json', snapshot)
self.req['native_assets'] = self.write('new-adapter-native.json', {'assets': self.native_inputs})
def job(self, name, scope, adapter, sources, natives, parameters, extras=None):
doc = {'kind': 'classic-to-forever-rea-contract-v1', 'status': 'QUALIFIED_FIXTURE', 'scope': scope, 'adapter': adapter,
'source_bindings': {k: self.inputs[k]['sha256'] for k in sources},
'native_bindings': {k: self.native_inputs[k]['sha256'] for k in natives},
'evidence': [dict(self.evidence, role='original-loader')], 'acceptance_criteria': ['scoped-native-behavior']}
doc.update(extras or {})
self.req['rea_contracts'][name] = self.write(name + '-contract.json', doc)
row = {'id': name, 'scope': scope, 'adapter': adapter, 'source_inputs': sources, 'native_inputs': natives,
'rea_contract': name, 'change_kind': 'data-behavior', 'parameters': parameters}
self.req['jobs'].append(row)
return row
def test_registered_item_icon_stage_and_input_change_invalidation(self):
# The producer's real shared-texture and original native consumer checks are already owned.
from item_icon_native_assets_test import Icons
fixture = Icons(methodName='test_shared_icon_deduplication_and_prior_positive_references_preserved')
fixture.setUp(); self.addCleanup(fixture.doCleanups)
def ref(path):
path = Path(path).resolve(); body = path.read_bytes()
return {'path': str(path), 'sha256': tool.digest(body), 'bytes': len(body)}
source_paths = {'catalogue_manifest': fixture.cat/'manifest.json',
'artwork_manifest': fixture.art/'manifest.json', 'item_icons': fixture.art/'item-icons.json'}
native_paths = {'package': fixture.w/'package.json', 'baseline_manifest': fixture.base/'manifest.json',
'native_root': fixture.w/'native-root.bin'}
for key, path in source_paths.items(): self.inputs[key] = dict(ref(path), archive_owners=['patch-4.mpq'])
for key, path in native_paths.items(): self.native_inputs[key] = ref(path)
loader = ref(ROOT/'docs/evidence/data/octo-builtin-archive-selection.json')
consumer = ref(ROOT/'docs/evidence/content-data/native-item-icon-assets-20261021/acceptance.json')
params = {'operation': 'registered-zero-item-icons', **{key:key for key in (*source_paths, *native_paths)}}
evidence = [dict(loader, role='original-loader'), dict(consumer, role='owning-rea-receipt')]
for name in ('icons', 'icons-again'):
job = self.job(name, 'icons', 'registered-item-icon-stage', list(source_paths), list(native_paths),
params, {'evidence': evidence})
job['asset_role'] = 'item-icon'
self.flush()
result = tool.convert_batch(self.req, self.root/'registered-icons')
self.assertEqual([r['status'] for r in result['jobs']], ['ICON_REGISTERED_PRIVATE', 'REUSED'])
self.assertFalse(result['jobs'][0]['native_accepted'])
self.assertEqual(result['jobs'][0]['stage_audit']['selected_items'], 2)
manifest = json.loads((self.root/'registered-icons'/'icons'/'manifest.json').read_text())
self.assertEqual({row['item_id'] for row in manifest['source_icon_bindings']}, {1000, 1001})
self.assertTrue(any(row['file_data_id'] == fixture.prior['file_data_id'] for row in manifest['assets']))
original_jobs = self.req['jobs']; self.req['jobs'] = []
positive_params = dict(params, operation='registered-source-item-icons-replace')
positive = self.job('icons-positive', 'icons', 'registered-item-icon-stage', list(source_paths), list(native_paths),
positive_params, {'evidence': evidence})
positive['asset_role'] = 'item-icon'
staged_positive = tool.convert_batch(self.req, self.root/'registered-icons-positive')['jobs'][0]
self.assertEqual(staged_positive['status'], 'ICON_REGISTERED_PRIVATE')
self.assertTrue(staged_positive['stage_audit']['positive_replacement_requested'])
self.assertEqual(staged_positive['stage_audit']['positive_replacement_candidates'], 1)
self.assertFalse(staged_positive['native_accepted'])
positive_manifest = json.loads((self.root/'registered-icons-positive'/'icons-positive'/'manifest.json').read_text())
self.assertEqual(next(r for r in positive_manifest['source_icon_bindings'] if r['item_id'] == 1002)['old_icon_file_data_id'], 134400)
self.req['jobs'] = original_jobs
previous = ref(self.root/'registered-icons'/'stage.json'); self.req['previous_stage'] = previous
self.assertEqual(tool.plan_batch(self.req)['jobs'][0]['decision'], 'REUSE_PREVIOUS')
fixture.texture.write_bytes(fixture.raw+b'x')
self.assertEqual(tool.plan_batch(self.req)['jobs'][0]['decision'], 'CONVERT')
self.req.pop('previous_stage'); self.req['jobs'] = []
self.native_inputs['native_root'] = dict(self.native_inputs['native_root'], sha256='0'*64)
bad = self.job('bad-root', 'icons', 'registered-item-icon-stage', list(source_paths), list(native_paths),
params, {'evidence': evidence})
bad['asset_role'] = 'item-icon'; self.flush()
held = tool.convert_batch(self.req, self.root/'wrong-native-root')['jobs'][0]
self.assertEqual(held['status'], 'HELD')
self.assertIn('Pinned registered icon stage inputs differ', held['reason'])
def test_saved_emerald_wdt_frontend_uses_pinned_registry_without_reading_it(self):
# The owning Map169 test has already checked the real 25-MiB registry.
saved = json.loads((ROOT / 'runtime/continuation-20261029/outdoor-coverage-join/emerald-wdt-reuse-handoff.private.json').read_text())
for key, name in saved['inputs_in_order'].items():
path = ROOT / name
if key == 'active_registry':
digest, size = saved['active_registry_sha256_from_owning_handoff'], saved['active_registry_bytes']
else:
raw = path.read_bytes(); digest, size = tool.digest(raw), len(raw)
self.native_inputs[key] = {'path': str(path), 'sha256': digest, 'bytes': size}
keys = ('handoff', 'role_audit', 'active_registry', 'outdoor_coverage')
row = self.job('emerald', 'maps', 'saved-emerald-wdt-stage', [], list(keys),
{'operation': 'saved-emerald-wdt-assessment', **{k: k for k in keys}})
doc = json.loads(Path(self.req['rea_contracts']['emerald']['path']).read_text())
doc['evidence'].append(dict(self.native_inputs['handoff'], role='owning-rea-receipt'))
self.req['rea_contracts']['emerald'] = self.write('emerald-qualified-contract.json', doc)
self.flush()
result = tool.plan_batch(self.req)['jobs'][0]
self.assertEqual(result['status'], 'PLANNED'); self.assertFalse(result['runtime_candidate'])
self.assertFalse(result['native_accepted'])
self.assertIn('map_conversion_batch.py', tool.producer_pins('saved-emerald-wdt-stage', row['parameters']))
row['parameters']['operation'] = 'unqualified-map-write'
self.assertEqual(tool.plan_batch(self.req)['jobs'][0]['status'], 'HELD')
def test_saved_area_frontend_stages_only_an_assessment(self):
# The owning Area319 test has already checked the real saved relationships.
directory = ROOT / 'runtime/continuation-20261026/Root-named-openworld-area-status'
names = {'assessment': 'Area319-profile-and-metadata84559-handoff.json',
'manifest': 'full-outdoor319-AreaTable-definition-parent-manifest.json',
'component': 'Area319-observed-native-profile-component.json'}
for key, name in names.items():
path = directory / name; raw = path.read_bytes()
self.native_inputs[key] = {'path': str(path), 'sha256': tool.digest(raw), 'bytes': len(raw)}
row = self.job('area', 'maps', 'saved-area-profile-stage', [], list(names),
{'operation': 'saved-outdoor-area-assessment', **{k: k for k in names}})
doc = json.loads(Path(self.req['rea_contracts']['area']['path']).read_text())
doc['evidence'].append(dict(self.native_inputs['assessment'], role='owning-rea-receipt'))
self.req['rea_contracts']['area'] = self.write('area-qualified-contract.json', doc)
self.flush()
with patch('map_asset_preflight.reuse_saved_outdoor_area_profiles',
return_value={'previously_composed': 313, 'uncomposed_held': 6}):
result = tool.convert_batch(self.req, self.root / 'area-output')['jobs'][0]
self.assertEqual(result['status'], 'AREA_ASSESSMENT_STAGED')
self.assertFalse(result['runtime_candidate']); self.assertFalse(result['native_accepted'])
row['parameters']['operation'] = 'unqualified-area-write'
self.assertEqual(tool.plan_batch(self.req)['jobs'][0]['status'], 'HELD')
def test_saved_taxi_frontend_stages_only_an_assessment(self):
# The owning taxi test has already checked the real headers/cohorts.
path = ROOT / 'docs/evidence/content-data/map-taxi-relationship-closure-20261023/assessment.json'
raw = path.read_bytes()
assessment = {'path': str(path), 'sha256': tool.digest(raw), 'bytes': len(raw)}
self.inputs['assessment'] = dict(assessment, archive_owners=['patch-4.mpq'])
for key in ('profile', 'resolved', 'held'):
self.source_input(key, {'fixture': key})
for key in ('paths_header', 'nodes_header'):
self.source_input(key, key.encode())
keys = ('assessment', 'profile', 'resolved', 'held', 'paths_header', 'nodes_header')
row = self.job('taxi', 'travel', 'saved-taxi-stage', list(keys), [],
{'operation': 'saved-static-taxi-assessment', **{k: k for k in keys}})
original = self.req['rea_contracts']['taxi']
doc = json.loads(Path(original['path']).read_text())
doc['evidence'].append(dict(assessment, role='owning-rea-receipt'))
self.req['rea_contracts']['taxi'] = self.write('taxi-qualified-contract.json', doc)
self.flush()
with patch('taxi_profile.reuse_saved_routes', return_value={'resolved_static_endpoint_relations': 252,
'held_endpoint_relations': 107}):
result = tool.convert_batch(self.req, self.root / 'taxi-output')['jobs'][0]
self.assertEqual(result['status'], 'TAXI_ASSESSMENT_STAGED')
self.assertFalse(result['runtime_candidate'])
self.assertFalse(result['native_accepted'])
current_dir = ROOT / 'runtime/continuation-20261029/worldmap-flightmap-reuse'
for key, name in (('current_freshness', 'current-taxi-source-freshness.private.json'),
('current_added', 'current-added-taxi-paths.private.json')):
path = current_dir / name; raw = path.read_bytes()
self.inputs[key] = {'path': str(path), 'sha256': tool.digest(raw), 'bytes': len(raw),
'archive_owners': ['patch-4.mpq']}
row['source_inputs'].append(key); row['parameters'][key] = key
doc['source_bindings'] = {k: self.inputs[k]['sha256'] for k in row['source_inputs']}
self.req['rea_contracts']['taxi'] = self.write('taxi-current-qualified-contract.json', doc)
self.flush()
with patch('taxi_profile.reuse_saved_routes', return_value={'resolved_static_endpoint_relations': 252,
'held_endpoint_relations': 111}) as saved:
current = tool.convert_batch(self.req, self.root / 'taxi-current-output')['jobs'][0]
self.assertEqual(current['status'], 'TAXI_ASSESSMENT_STAGED')
self.assertEqual(set(saved.call_args.kwargs), {'current_freshness', 'current_added'})
del row['parameters']['current_added']
self.assertEqual(tool.plan_batch(self.req)['jobs'][0]['status'], 'HELD')
row['parameters']['current_added'] = 'current_added'
row['parameters']['operation'] = 'unqualified-taxi-write'
self.assertEqual(tool.plan_batch(self.req)['jobs'][0]['status'], 'HELD')
def test_catalogue_assessment_is_not_a_runtime_candidate(self):
source = self.source_input('catalogue.json', {'items': []})
nested = {'kind': 'classic-data-batch-v1', 'inputs': {'source': source},
'contracts': {'assessment': {'receipt': self.evidence, 'provenance': [self.evidence],
'operations': ['items.property-catalogue-assessment']}},
'jobs': [{'id': 'assessment', 'operation': 'items.property-catalogue-assessment', 'contract': 'assessment'}]}
self.job('assessment', 'items', 'classic-data', ['catalogue.json'], [], {'batch': nested},
{'backend_operations': ['items.property-catalogue-assessment'], 'backend_receipts': [self.evidence]})
self.flush()
row = tool.plan_batch(self.req)['jobs'][0]
self.assertEqual(row['status'], 'PLANNED')
self.assertFalse(row['runtime_candidate'])
self.assertFalse(row['native_accepted'])
def test_source_only_texture_staging_cannot_claim_native_acceptance(self):
prepared = self.job('source-only', 'textures', 'blp-stage', ['icon'], [], {},
{'source_only_staging': True})
prepared['change_kind'] = 'source-preparation'
unqualified = self.job('unqualified-source', 'textures', 'blp-stage', ['icon'], [], {})
unqualified['change_kind'] = 'source-preparation'
self.flush()
stage = tool.convert(self.req, self.root / 'source-only-textures')
rows = {row['id']: row for row in stage['jobs']}
row = rows['source-only']
self.assertEqual(row['status'], 'CONVERTED_PRIVATE')
self.assertTrue(row['source_only_staging'])
self.assertFalse(row['runtime_candidate'])
self.assertEqual(row['outputs'][0]['role'], 'source-texture')
self.assertNotIn('file_data_id', row['outputs'][0])
self.assertEqual(rows['unqualified-source']['status'], 'HELD')
receipt = self.write('misleading-source-only-pass.json',
{'job_id': 'source-only', 'kind': 'classic-to-forever-native-acceptance-v1'})
assessment = tool.acceptance_report(self.write('source-only-stage.json', stage), [receipt])
result = next(item for item in assessment['jobs'] if item['id'] == 'source-only')
self.assertFalse(result['native_accepted'])
self.assertIn('cannot be native behavior accepted', result['rejected_receipts'][0])
def test_one_batch_real_data_observations_and_public_protocol_stage(self):
from item_basic_compat_test import source, icon
import item_basic_compat as basic
from octo_travel_capture_test import raw as travel_raw
from octo_social_capture_test import SocialCapture
from octo_guild_bank_capture_test import RAW as bank_raw
proto = source(); icon_row = icon(proto)
native = dict(basic.convert(proto, icon_evidence=icon_row), Material=1)
src = self.source_input('item-proto.json', proto)
native_ref = self.write('native-item.json', native); self.native_inputs['native-item'] = native_ref
contract = {'receipt': self.evidence, 'accepted_status': 'PASS_FIXTURE', 'provenance': [self.evidence],
'operations': ['items.basic'], 'policy': 'qualified-data-only-native-assets-preserved-v1'}
child = {'id': 'basic', 'operation': 'items.basic', 'contract': 'basic',
'args': [{'$input': 'proto'}, {'$input': 'native'}], 'kwargs': {'icon_evidence': icon_row, 'source_authoritative': True},
'source_inputs': ['proto'], 'native_inputs': ['native'], 'override_policy': 'qualified-same-identity',
'old_rows': [{'input': 'native', 'sha256': tool.digest(tool.encoded(native))}]}
nested = {'kind': 'classic-data-batch-v1', 'inputs': {'proto': src, 'native': native_ref},
'contracts': {'basic': contract}, 'jobs': [child, dict(child, id='basic-again')]}
self.job('item-fields', 'items', 'classic-data', ['item-proto.json'], ['native-item'], {'batch': nested},
{'backend_operations': ['items.basic'], 'backend_receipts': [self.evidence]})
for name, scope, operation, body in [('travel', 'travel', 'travel-observation', travel_raw()),
('social', 'social', 'social-observation', SocialCapture().raw()),
('bank', 'bank', 'guild-bank-observation', bank_raw)]:
self.source_input(name + '.lua', body.encode())
self.job(name, scope, 'observation-stage', [name + '.lua'], [], {'operation': operation})
self.source_input('version.bin', b'v' * 20); self.source_input('addons.bin', b'\0' * 4)
self.job('profile', 'protocol', 'public-profile-stage', ['version.bin', 'addons.bin'], [],
{'version': 'version.bin', 'addons': 'addons.bin', 'destination': 'octo'})
self.flush()
stage = self.stage('new-stage'); rows = {r['id']: r for r in stage['jobs']}
(ROOT / 'runtime/continuation-20261028/classic-to-forever/new-stage-fixture-diagnostics.private.json').write_bytes(tool.encoded(stage))
self.assertEqual(rows['item-fields']['status'], 'CONVERTED_PRIVATE')
item_result = json.loads(Path(rows['item-fields']['outputs'][0]['path']).read_text())
self.assertEqual(item_result['record']['Material'], 0)
self.assertEqual(json.loads(Path(native_ref['path']).read_text())['Material'], 1)
backend = json.loads(Path(rows['item-fields']['backend_report']['path']).read_text())
self.assertEqual(backend['unique_producer_calls'], 1)
self.assertEqual(rows['travel']['status'], 'OBSERVATION_STAGED')
self.assertEqual(rows['bank']['status'], 'OBSERVATION_STAGED')
self.assertEqual(rows['social']['status'], 'OBSERVATION_STAGED')
summary = json.loads(Path(rows['social']['outputs'][0]['path']).read_text())
self.assertNotIn('private', json.dumps(summary))
self.assertEqual(rows['profile']['status'], 'PUBLIC_PROFILE_STAGED')
self.assertFalse(rows['profile']['stage_audit']['authentication_performed'])
self.assertTrue(all(not row['native_accepted'] for row in rows.values()))
ref = self.write('new-stage-receipt.json', stage)
# A native-looking PASS cannot promote an evidence-only stage to runtime behavior.
job = rows['social']
receipt = self.write('misleading-evidence-pass.json', {'job_id': 'social', 'kind': 'classic-to-forever-native-acceptance-v1'})
accepted = tool.acceptance_report(ref, [receipt])
rejection = next(r for r in accepted['jobs'] if r['id'] == 'social')
self.assertFalse(rejection['native_accepted'])
self.assertIn('cannot be native behavior accepted', rejection['rejected_receipts'][0])
def test_data_scope_and_original_provenance_cannot_be_crossed(self):
src = self.source_input('source.json', {'value': 1})
native = self.write('native.json', {'value': 1}); self.native_inputs['native'] = native
batch = {'kind': 'classic-data-batch-v1', 'inputs': {'source': src, 'native': native}, 'contracts': {},
'jobs': [{'id': 'wrong', 'operation': 'spells.visual'}]}
self.job('wrong-scope', 'items', 'classic-data', ['source.json'], ['native'], {'batch': batch})
self.flush(); rows = tool.plan_batch(self.req)['jobs']
self.assertEqual(rows[0]['status'], 'HELD')
self.assertIn('outer scope', rows[0]['reason'])
def test_fixed_casc_declarations_and_specific_real_blocks(self):
assets = self.source_input('registered/manifest.json', {'assets': []})
root = self.source_input('registered/root.bin', b'fixture-root')
reuse = self.source_input('reuse/report.json', {'asset_manifest_sha256': assets['sha256']})
names = ['target-encoding.bin', 'target-download.bin', 'native-tvfs-default.bin', 'native-vfs-root.bin',
'download-native-controls.json', 'tvfs-default-identity.json']
context = {}
for name in names:
key = 'context/' + name; self.source_input(key, b'fixture-native-metadata'); context[name] = key
sources = ['registered/manifest.json', 'registered/root.bin', 'reuse/report.json'] + list(context.values())
parameters = {'asset_manifest': sources[0], 'root_payload': sources[1], 'reuse_report': sources[2], 'native_context': context}
row = self.job('framing', 'build', 'casc-frame-stage', sources, [], parameters)
self.flush(); plan = tool.plan_batch(self.req)
self.assertEqual(plan['jobs'][0]['status'], 'PLANNED')
self.assertFalse(plan['jobs'][0]['runtime_candidate'])
row['parameters']['native_context'].pop(names[0])
plan = tool.plan_batch(self.req)
self.assertEqual(plan['jobs'][0]['status'], 'HELD')
self.assertIn('complete fixed native metadata context', plan['jobs'][0]['reason'])
registry = tool.registry()['scopes']
for scope in ('combat', 'mail', 'auction', 'auth', 'runtime', 'talents', 'quests', 'npc'):
self.assertEqual(registry[scope]['status'], 'HELD_NO_QUALIFIED_PRODUCER')
self.assertTrue(registry[scope]['remaining_behavior_block'])
def test_enchantment_visual_candidates_reuse_existing_producer(self):
from item_enchantment_visual_profile_test import EnchantVisualTest
fixture = EnchantVisualTest(methodName='test_native_visual_identity_without_copying_extra_native_effects')
fixture.setUp()
self.addCleanup(fixture.tearDown)
table = fixture.table()
view = {'fields': 24, 'rows': {str(row[0]): list(row) for row in table.rows},
'strings': {'1': table.string(1)}}
self.req['jobs'] = []
owner = self.write('enchant-owning-review.json', json.loads((ROOT /
'docs/evidence/content-data/enchantment-visuals-20261019/report.json').read_text()))
self.evidence = owner
source = self.source_input('enchant-source.json', view)
native = self.write('enchant-native.json', fixture.native)
visuals = self.write('enchant-visuals.json', fixture.visuals)
proof = self.write('enchant-namespace.json', json.loads(Path(owner['path']).read_text())['namespace'])
self.native_inputs.update({'enchant-native': native, 'enchant-visuals': visuals, 'enchant-proof': proof})
nested = {'kind': 'classic-data-batch-v1',
'inputs': {'source': source, 'native': native, 'visuals': visuals, 'proof': proof},
'contracts': {'enchant': {'policy': 'qualified-data-only-native-assets-preserved-v1',
'receipt': owner, 'accepted_kind': 'native-equipped-enchantment-visual-batch',
'provenance': [owner], 'operations': ['equipment.enchantment-visual-candidates']}},
'jobs': [{'id': 'enchant', 'operation': 'equipment.enchantment-visual-candidates',
'contract': 'enchant',
'args': [[{'$input': 'source', 'as': 'dbc'}], {'$input': 'native'},
{'$input': 'visuals'}, {'$input': 'proof'}],
'source_inputs': ['source'], 'native_inputs': ['native', 'visuals', 'proof'],
'override_policy': 'preserve-existing'}]}
self.job('enchant-adapter', 'equipment', 'classic-data', ['enchant-source.json'],
['enchant-native', 'enchant-visuals', 'enchant-proof'], {'batch': nested},
{'backend_operations': ['equipment.enchantment-visual-candidates'], 'backend_receipts': [owner]})
self.flush()
row = tool.convert_batch(self.req, self.root / 'enchant-unified')['jobs'][0]
self.assertEqual(row['status'], 'CONVERTED_PRIVATE', row.get('reason'))
output = json.loads(Path(row['outputs'][0]['path']).read_text())
self.assertEqual(len(output['definitions']), 1)
self.assertFalse(output['installed'])
self.assertFalse(output['model_assets_verified'])
self.assertFalse(output['gameplay_verified'])
self.assertFalse(row['native_accepted'])
def test_reputation_faction_producer_stages_without_race_aliases(self):
import faction_compat as faction
from faction_compat_test import FactionCompatTest
self.req['jobs'] = []
original = self.write('reputation-original-witness.json', json.loads(
(ROOT / 'docs/evidence/gameplay/reputation-standing-roundtrip.json').read_text()))
fixture_proof = self.write('faction-fixture-proof.json', {'status': 'PASS_FACTION_FIXTURE'})
source = self.source_input('faction-source.json', faction.source_rows(FactionCompatTest().raw()))
native = self.write('faction-native.json', [{'ID': 72, 'ReputationIndex': 75}])
registry = self.write('faction-registry.json', {'version': 1, 'indices': {}})
schema = self.write('faction-schema.json', faction.fields(faction.DBD, faction.LAYOUT, 21))
self.native_inputs.update({'faction-native': native, 'faction-registry': registry, 'faction-schema': schema})
nested = {'kind': 'classic-data-batch-v1',
'inputs': {'source': source, 'native': native, 'registry': registry, 'schema': schema},
'contracts': {'faction': {'policy': 'qualified-data-only-native-assets-preserved-v1',
'receipt': fixture_proof, 'accepted_status': 'PASS_FACTION_FIXTURE',
'provenance': [original], 'operations': ['reputation.factions']}},
'jobs': [{'id': 'factions', 'operation': 'reputation.factions', 'contract': 'faction',
'args': [{'$input': key} for key in ('source', 'native', 'registry', 'schema')],
'source_inputs': ['source'], 'native_inputs': ['native', 'registry', 'schema'],
'override_policy': 'qualified-same-identity',
'old_rows': [{'input': 'native', 'sha256': native['sha256'], 'encoding': 'input-bytes'}]}]}
self.job('faction-adapter', 'reputation', 'classic-data', ['faction-source.json'],
['faction-native', 'faction-registry', 'faction-schema'], {'batch': nested},
{'evidence': [dict(original, role='owning-rea-receipt')],
'backend_operations': ['reputation.factions'], 'backend_receipts': [fixture_proof]})
self.flush()
row = tool.convert_batch(self.req, self.root / 'faction-unified')['jobs'][0]
self.assertEqual(row['status'], 'CONVERTED_PRIVATE', row.get('reason'))
output = json.loads(Path(row['outputs'][0]['path']).read_text())
self.assertEqual([r['id'] for r in output['records']], [1007])
self.assertFalse(output['race_aliases_applied'])
self.assertFalse(output['installed'])
self.assertFalse(row['native_accepted'])
def test_aura_visual_candidates_use_existing_native_links_in_frontend(self):
base = ROOT / 'docs/evidence/data/aura-profile/visuals'
load = lambda name: json.loads((base / name).read_text())
self.req['jobs'] = []
self.evidence = self.write('visual-original-native-api.json', load('native-api-capabilities.json'))
owner = self.write('visual-owning-review.json', load('profile-package-links.json'))
source = self.source_input('visual-source.json', load('tortoise.json'))
native = self.write('visual-native-links.json', load('forever-links.json'))
self.native_inputs['visual-native'] = native
nested = {'kind': 'classic-data-batch-v1', 'inputs': {'source': source, 'native': native},
'contracts': {'visual': {'policy': 'qualified-data-only-native-assets-preserved-v1',
'receipt': owner, 'accepted_kind': 'source-owned-package-visual-profile-extension',
'provenance': [self.evidence], 'operations': ['auras.visual-link-candidates']}},
'jobs': [{'id': 'visual-links', 'operation': 'auras.visual-link-candidates',
'contract': 'visual', 'args': [{'$input': 'source'}, {'$input': 'native'}],
'source_inputs': ['source'], 'native_inputs': ['native'],
'override_policy': 'preserve-existing'}]}
self.job('visual-adapter', 'auras', 'classic-data', ['visual-source.json'], ['visual-native'],
{'batch': nested}, {'backend_operations': ['auras.visual-link-candidates'],
'backend_receipts': [owner]})
self.flush()
row = tool.convert_batch(self.req, self.root / 'visual-unified')['jobs'][0]
self.assertEqual(row['status'], 'CONVERTED_PRIVATE', row.get('reason'))
output = json.loads(Path(row['outputs'][0]['path']).read_text())
self.assertEqual(output['definitions'], load('profile.json')['definitions'])
self.assertEqual(len(output['definitions']), 7)
self.assertTrue(any('renderer behavior' in limit for limit in output['limits']))
self.assertFalse(row['native_accepted'])
def test_disarm_family_uses_existing_original_review_in_frontend(self):
base = ROOT / 'docs/evidence/data/aura-profile/disarm-family-20261022'
load = lambda name: json.loads((base / name).read_text())
self.req['jobs'] = []
self.evidence = self.write('disarm-owner.json', load('report.json'))
source = self.source_input('disarm-source.json', load('source.json'))
native_refs = {}
for key, name in (('profile', 'retained-baseline.json'),
('native', 'native-effective-projection.json'),
('namespace', 'namespace.json'), ('review', 'review.json')):
native_refs[key] = self.write('disarm-' + key + '.json', load(name))
self.native_inputs['disarm-' + key] = native_refs[key]
arg = lambda name, pointer='': {'$input': name, 'pointer': pointer}
nested = {'kind': 'classic-data-batch-v1',
'inputs': {'source': source, **native_refs},
'contracts': {'disarm': {'policy': 'qualified-data-only-native-assets-preserved-v1',
'receipt': self.evidence, 'accepted_kind': 'offline-source-native-disarm-admission-proposal',
'provenance': [self.evidence], 'operations': ['auras.disarm-family-merge']}},
'jobs': [{'id': 'disarm-family', 'operation': 'auras.disarm-family-merge', 'contract': 'disarm',
'args': [arg('profile'), arg('source'), arg('native')],
'kwargs': {'enum_proof': arg('namespace', '/enum_proof'),
'native_parent_ids': arg('review', '/native_parent_ids')},
'source_inputs': ['source'], 'native_inputs': ['profile', 'native', 'namespace', 'review'],
'override_policy': 'preserve-existing'}]}
self.job('disarm-adapter', 'auras', 'classic-data', ['disarm-source.json'],
['disarm-' + k for k in native_refs], {'batch': nested},
{'backend_operations': ['auras.disarm-family-merge'], 'backend_receipts': [self.evidence]})
self.flush()
stage = tool.convert_batch(self.req, self.root / 'disarm-unified')
row = stage['jobs'][0]
self.assertEqual(row['status'], 'CONVERTED_PRIVATE', row.get('reason'))
output = json.loads(Path(row['outputs'][0]['path']).read_text())
self.assertEqual(output['merge']['retained'], 1537)
self.assertEqual(len(output['merge']['added']), 15)
self.assertEqual(len(output['profile']['definitions']), 1552)
self.assertEqual(output['merge']['conflicts'], [])
self.assertFalse(output['installed'])
self.assertFalse(output['native_accepted'])
class OriginalRealmUIBoundary(unittest.TestCase):
def test_qualified_pair_and_rejection_of_unqualified_operation(self):
self.assertIn('optional_login_diagnostic', tool.registry()['adapters']['source-realm-ui'])
# The owning original-Lua test passed; this checks the converter boundary.
base = ROOT / 'runtime/continuation-20261029/source-realm-original-ui-adapter'
directory = Path(tempfile.mkdtemp(prefix='converter-boundary-', dir=base))
self.addCleanup(shutil.rmtree, directory)
def ref(path):
raw = Path(path).read_bytes()
return {'path': str(Path(path).resolve()), 'sha256': tool.digest(raw), 'bytes': len(raw)}
def doc(name, value):
path = directory / name; path.write_bytes(tool.encoded(value)); return ref(path)
realm = ref(ROOT / 'runtime/native-login-ui/interface/addons/blizzard_gluexml/mainline/realmlist.lua')
glue = ref(ROOT / 'runtime/native-login-ui/interface/addons/blizzard_glueparent/mainline/glueparent.lua')
qualification = ref(base / 'owning-focused-check.private.json')
snapshot = doc('snapshot.json', {'kind': 'classic-to-forever-source-snapshot-v1', 'inputs': {}, 'archives': {}})
inventory = doc('inventory.json', {'kind': 'classic-to-forever-patch-inventory-v1', 'archives': {}})
native = doc('native.json', {'assets': {'realm': realm, 'glue': glue}})
contract = doc('rea.json', {'kind': 'classic-to-forever-rea-contract-v1', 'status': 'QUALIFIED_ORIGINAL_UI',
'scope': 'ui', 'adapter': 'source-realm-ui', 'source_bindings': {},
'native_bindings': {'realm': realm['sha256'], 'glue': glue['sha256']},
'evidence': [dict(qualification, role='owning-rea-receipt')], 'acceptance_criteria': ['original-realm-choice']})
request = {'kind': tool.KIND, 'source_snapshot': snapshot, 'patch_inventory': inventory, 'native_assets': native,
'rea_contracts': {'realm': contract}, 'jobs': [{'id': 'realm', 'scope': 'ui', 'adapter': 'source-realm-ui',
'source_inputs': [], 'native_inputs': ['realm', 'glue'], 'rea_contract': 'realm', 'change_kind': 'data-behavior',
'parameters': {'operation': 'source-pending-realm-choice', 'realm_list_lua': 'realm',
'glue_parent_lua': 'glue', 'qualification': qualification}}]}
self.assertEqual(tool.plan_batch(request)['jobs'][0]['status'], 'PLANNED')
row = tool.convert_batch(request, directory / 'staged')['jobs'][0]
self.assertEqual(row['status'], 'UI_PATCH_STAGED')
owning = json.loads(Path(qualification['path']).read_text())['candidates']
self.assertEqual([o['sha256'] for o in row['outputs']],
[owning['realm-list']['sha256'], owning['glue-parent']['sha256']])
self.assertFalse(row['installed']); self.assertFalse(row['native_accepted'])
request['jobs'][0]['parameters']['login_diagnostic'] = None
self.assertEqual(tool.plan_batch(request)['jobs'][0]['status'], 'HELD')
diagnostic = ref(ROOT / 'runtime/continuation-20261029/new-login-front-prototype/diagnostic-handoff.private.json')
request['jobs'][0]['parameters']['login_diagnostic'] = {'qualification': diagnostic}
self.assertEqual(tool.plan_batch(request)['jobs'][0]['status'], 'HELD')
diagnostic_contract = json.loads(Path(contract['path']).read_text())
diagnostic_contract['evidence'].append(dict(diagnostic, role='owning-rea-receipt'))
request['rea_contracts']['realm'] = doc('diagnostic-rea.json', diagnostic_contract)
row = tool.convert_batch(request, directory / 'diagnostic-staged')['jobs'][0]
self.assertEqual(row['status'], 'UI_PATCH_STAGED', row.get('reason'))
handoff = json.loads(Path(diagnostic['path']).read_text())
self.assertEqual([o['sha256'] for o in row['outputs']],
[owning['realm-list']['sha256'], handoff['files']['runtime/continuation-20261029/new-login-front-prototype/glueparent-diagnostic.private.lua']])
self.assertTrue(row['stage_audit']['login_diagnostic_enabled'])
self.assertFalse(row['installed']); self.assertFalse(row['native_accepted'])
del request['jobs'][0]['parameters']['login_diagnostic']
request['jobs'][0]['parameters']['operation'] = 'arbitrary-ui-patch'
self.assertEqual(tool.plan_batch(request)['jobs'][0]['status'], 'HELD')
request['jobs'][0]['parameters']['operation'] = 'source-pending-realm-choice'
request['jobs'][0]['parameters']['glue_parent_lua'] = 'realm'
self.assertEqual(tool.plan_batch(request)['jobs'][0]['status'], 'HELD')
class OriginalCreationUIBoundary(unittest.TestCase):
def test_qualified_original_ui_registration_plan_and_exact_staged_candidate(self):
# This is a new frontend boundary; the owning Lua behavior/syntax tests
# already passed and are deliberately not rerun here.
base = ROOT / 'runtime/continuation-20261028/classic-to-forever'
directory = Path(tempfile.mkdtemp(prefix='creation-ui-boundary-', dir=base))
self.addCleanup(shutil.rmtree, directory)
def reference(path):
raw = Path(path).read_bytes()
return {'path': str(Path(path).resolve()), 'sha256': tool.digest(raw), 'bytes': len(raw)}
def document(name, value):
path = directory / name; path.write_bytes(tool.encoded(value)); return reference(path)
original = reference(ROOT / 'runtime/single-name-creation-20261022/original-ui/interface/addons/blizzard_charactercreate/camelot/blizzard_charactercreate.lua')
qualification = reference(ROOT / 'docs/evidence/gameplay/distinct-race-creation-menu-20261028/assessment.json')
snapshot = document('snapshot.json', {'kind': 'classic-to-forever-source-snapshot-v1', 'inputs': {}, 'archives': {}})
inventory = document('inventory.json', {'kind': 'classic-to-forever-patch-inventory-v1', 'archives': {}})
native = document('native.json', {'assets': {'original-create-lua': original}})
contract = document('rea.json', {'kind': 'classic-to-forever-rea-contract-v1', 'status': 'QUALIFIED_ORIGINAL_UI',
'scope': 'ui', 'adapter': 'creation-menu-ui', 'source_bindings': {}, 'native_bindings': {'original-create-lua': original['sha256']},
'evidence': [dict(qualification, role='owning-rea-receipt')], 'acceptance_criteria': ['original-create-menu-policy']})
request = {'kind': tool.KIND, 'source_snapshot': snapshot, 'patch_inventory': inventory, 'native_assets': native,
'rea_contracts': {'create-menu': contract}, 'jobs': [{'id': 'create-menu', 'scope': 'ui', 'adapter': 'creation-menu-ui',
'source_inputs': [], 'native_inputs': ['original-create-lua'], 'rea_contract': 'create-menu', 'change_kind': 'data-behavior',
'parameters': {'operation': 'disable-extra-elves', 'native_lua': 'original-create-lua', 'qualification': qualification}}]}
plan = tool.plan_batch(request)
self.assertEqual(plan['jobs'][0]['status'], 'PLANNED')
self.assertEqual(tool.registry()['scopes']['ui']['adapter'], 'creation-menu-ui')
staged = tool.convert_batch(request, directory / 'staged')
row = staged['jobs'][0]
self.assertEqual(row['status'], 'UI_PATCH_STAGED')
owning = json.loads(Path(qualification['path']).read_text())
self.assertEqual(row['outputs'][0]['sha256'], owning['candidate_sha256'])
self.assertFalse(row['stage_audit']['native_race9_10_admission_changed'])
self.assertFalse(row['native_accepted'])
request['jobs'][0]['parameters']['operation'] = 'arbitrary-ui-patch'
held = tool.plan_batch(request)
self.assertEqual(held['jobs'][0]['status'], 'HELD')
self.assertIn('only the qualified', held['jobs'][0]['reason'])
(base / 'creation-ui-boundary-report.private.json').write_bytes(tool.encoded({'status': 'PASS_NEW_UI_FRONTEND_BOUNDARY',
'original_pin': original, 'qualification_pin': qualification, 'plan_status': plan['jobs'][0]['status'],
'staged_candidate_sha256': row['outputs'][0]['sha256'], 'owning_candidate_sha256': owning['candidate_sha256'],
'native_verified': False, 'race_admission_modified': False, 'wrong_operation_status': held['jobs'][0]['status']}))
if __name__ == '__main__':
unittest.main()