Files
WoW-Hybrid-gateway/ops/published_client_assets.py
2026-11-23 03:28:32 +02:00

1607 lines
108 KiB
Python

"""Retain an already validated private CASC publication in a fresh public package."""
import hashlib
import json
from pathlib import Path
def digest(path):
p = Path(path)
if p.is_symlink() or not p.is_file():
raise ValueError('Regular publication input required')
return hashlib.sha256(p.read_bytes()).hexdigest()
def read(path):
p = Path(path)
if p.is_symlink() or not p.is_file():
raise ValueError('Regular publication input required')
return json.loads(p.read_text())
def published_source(source_root):
root = Path(source_root).resolve()
manifest_path = root / 'linux-release.json'
if not manifest_path.exists():
return None
declared = read(manifest_path).get('private_asset_publication')
if declared is None:
return None
return _publication_proof(root, declared)
def _generic_equipment_delta(root, receipt, depth):
"""Consume owning incremental proofs; never reopen asset payloads."""
def require(condition, message):
if not condition:
raise ValueError(message)
def pinned(reference):
require(isinstance(reference, dict) and isinstance(reference.get('path'), str)
and isinstance(reference.get('sha256'), str) and len(reference['sha256']) == 64,
'Pinned equipment publication input required')
require(digest(reference['path']) == reference['sha256'], 'Equipment publication input identity differs')
return read(reference['path'])
parent_ref = receipt.get('parent_publication', {})
require(isinstance(parent_ref, dict), 'Pinned parent publication required')
parent = _publication_proof(root, {
'receipt_path': parent_ref.get('receipt_path'),
'composed_root': receipt.get('old_root'),
'validation_sha256': parent_ref.get('validation_sha256')}, historical=True, depth=depth + 1)
require(parent['receipt_sha256'] == parent_ref.get('receipt_sha256'), 'Parent publication identity differs')
inputs = receipt.get('inputs', {})
require(isinstance(inputs, dict), 'Equipment publication inputs required')
before = pinned(inputs.get('parent_assets')); after = pinned(inputs.get('assets'))
previous_frame = pinned(inputs.get('parent_frames')); frame = pinned(inputs.get('frames'))
sdk = pinned(inputs.get('sdk')); metadata = pinned(inputs.get('metadata')); delta = pinned(inputs.get('delta_plan'))
require(parent['_receipt'].get('framing_manifest_sha256') == inputs['parent_frames']['sha256']
and previous_frame['root']['content_key'] == parent['composed_root']
and previous_frame['asset_manifest_sha256'] == inputs['parent_assets']['sha256'],
'Parent equipment asset lineage differs')
require(after.get('source_parent_manifest_sha256') == inputs['parent_assets']['sha256'],
'Registered equipment parent identity differs')
old = {r['file_data_id']: r for r in before['assets']}
new = {r['file_data_id']: r for r in after['assets']}
require(len(old) == len(before['assets']) == parent['registered_assets']
and len(new) == len(after['assets']) and all(new.get(k) == v for k, v in old.items())
and all(after['registry']['slots'].get(k) == v for k, v in before['registry']['slots'].items())
and after['source_icon_bindings'] == before['source_icon_bindings'],
'Equipment parent records or reservations differ')
ids = sorted(set(new) - set(old))
require(0 < len(ids) <= 4096 and all(type(i) is int and 0 < i < 2**32 for i in ids)
and receipt.get('new_file_data_ids') == ids, 'Equipment delta FileDataID set differs')
framed = frame.get('source_rows', [])
require(len(framed) == len(ids) and {r['asset']['file_data_id'] for r in framed} == set(ids)
and all(r['asset'] == new[r['asset']['file_data_id']] for r in framed)
and frame['asset_manifest_sha256'] == inputs['assets']['sha256']
and frame['parent_root'] == parent['composed_root']
and frame['root']['content_key'] == receipt.get('composed_root')
and frame['old_asset_count'] == len(old) and frame['registered_asset_count'] == len(new)
and frame['new_asset_count'] == len(ids), 'Equipment frame lineage differs')
require(frame['warrior_ui_content_key'] == previous_frame['warrior_ui_content_key']
and frame['source_icon_bindings_preserved'] == parent['source_icon_bindings']
and frame['encoding_audit']['all_original_content_key_encoding_bindings_preserved'] is True
and frame['download_audit']['original_entry_bytes_preserved'] is True
and frame['download_audit']['original_tag_bits_preserved'] is True
and frame['tvfs_child_audit']['old_cft_vfs_and_spec_prefixes_preserved'] is True,
'Equipment parent framing retention differs')
require(sdk.get('schema_version') == 1 and sdk.get('kind') == 'native-sdk-selected-fileid-readback-v1'
and sdk.get('passed') is True and sdk.get('status') == 'PASS_NATIVE_SDK_FILEID_BODY_READBACK'
and sdk.get('effective_root') == frame['root']['content_key']
and sdk.get('parent_root') == parent['composed_root']
and sdk.get('product') == 'wow_classic_beta' and sdk.get('build') == 70334
and type(sdk.get('body_reads')) is int and sdk['body_reads'] == len(ids)
and sdk.get('native_render_acceptance') is False and sdk.get('game_launched') is False,
'Equipment SDK boundary differs')
observed = sdk.get('rows', [])
require(len(observed) == len(ids) and {r['requested_file_data_id'] for r in observed} == set(ids),
'Equipment SDK FileDataID set differs')
for row in observed:
asset = new[row['requested_file_data_id']]
require(row.get('status') == 'PASS' and row.get('expected_content_key') == asset['content_key']
and row.get('observed_body_MD5') == asset['content_key']
and type(row.get('expected_size')) is int and type(row.get('observed_size')) is int
and row['expected_size'] == row['observed_size'] == asset['bytes'],
'Equipment SDK content identity differs')
return _finish_asset_delta(parent, inputs, old, new, ids, frame, metadata, delta)
def _reviewed_map_replacement_records(base, target, name_child, changes, native_join, assets):
"""Check the closed existing-map class, retaining every unrelated row."""
def require(ok, message):
if not ok:
raise ValueError(message)
def index(package):
rows = package['rows']
result = {(int(r['table_hash'], 0) if isinstance(r['table_hash'], str) else r['table_hash'], r['id']): r for r in rows}
require(len(result) == len(rows), 'Reviewed Map metadata key collision')
return result
old = index(base); final = index(target); named = index(name_child); table = 0xBD84CD62
approved = {0, 1, 30, 33, 36, 47, 90, 129, 169, 189, 209, 249, 269,
289, 309, 329, 469, 489, 509, 529, 531, 533}
require(len(old) == 84225 and len(named) == 84226 and len(final) == 84246,
'Reviewed Map package row arithmetic differs')
require(set(named) - set(old) == {(table, 35)} and set(old) <= set(named)
and all(named[k] == v for k, v in old.items())
and final.get((table, 35)) == named[(table, 35)],
'Accepted Map35 name-only child differs')
require(set(final) - set(old) == {(table, i) for i in approved - {1, 169}} | {(table, 35)}
and set(old) <= set(final), 'Approved twenty-one Map appends differ')
allowed = {(table, 1): {'WdtFileDataID'},
(table, 169): {'WdtFileDataID', 'LoadingScreenID'}}
for key, row in old.items():
if key not in allowed:
require(final[key] == row, 'Unrelated existing metadata row changed')
else:
before = row['record']; after = final[key]['record']
require(set(before) == set(after)
and {k for k in before if before[k] != after[k]} == allowed[key],
'Unreviewed existing Map field changed')
selected = {r['MapID']: r for r in changes}
require(set(selected) == approved and len(changes) == 22, 'Reviewed Map composition class differs')
native = {r['MapID']: r for r in native_join['rows']}
by_id = assets if isinstance(assets, dict) else {r['file_data_id']: r for r in assets}
for ident, row in selected.items():
key = (table, ident); before = row['before']; after = row['after']
expected_before = old[key]['record'] if key in old else native[ident]['original_native_Map_record']
expected_fields = {'WdtFileDataID'} | ({'LoadingScreenID'} if ident == 169 else set())
require(native[ident]['same_id_directory'] is True and before == expected_before
and set(before) == set(after)
and {k for k in before if before[k] != after[k]} == expected_fields
and final[key] == row['entry'] and final[key]['record'] == after
and after['ID'] == ident, 'Frozen original Map pointer-only relationship differs')
asset = by_id.get(after['WdtFileDataID'], {})
directory = after['Directory'].lower()
member = 'world/maps/' + directory + '/' + directory + '.wdt'
require(asset.get('kind') == 'terrain-wdt' and member in asset.get('source_paths', []),
'Reviewed Map WDT resource identity differs')
require(final[(table, 169)]['record']['LoadingScreenID'] == 501
and final[(table, 269)]['record']['LoadingScreenID'] == 4
and any(r.get('table_name') == 'LoadingScreens' and r['id'] == 501 for r in base['rows'])
and native[169]['loading']['source_LoadingScreens_ID'] == 501,
'Explicit Source loading-screen relationship differs')
def _reviewed_metadata_pinner():
"""Reuse one pinned-input cache for a reviewed metadata cohort."""
def require(ok, message):
if not ok:
raise ValueError(message)
loaded = {}
def pinned(ref, binary=False):
require(isinstance(ref, dict) and isinstance(ref.get('path'), str)
and isinstance(ref.get('sha256'), str) and len(ref['sha256']) == 64,
'Pinned reviewed Map input required')
key = (ref['path'], ref['sha256'], binary)
if key not in loaded:
path = Path(ref['path'])
require(path.is_file() and not path.is_symlink(), 'Regular reviewed Map input required')
raw = path.read_bytes()
require(hashlib.sha256(raw).hexdigest() == ref['sha256'], 'Reviewed Map input identity differs')
loaded[key] = raw if binary else json.loads(raw)
return loaded[key]
return pinned
def _reviewed_openworld_area_records(base, target, changes, areas, assets):
"""Only the reviewed two WDT fields and 313 owned Area appends may differ."""
def require(ok, message):
if not ok:
raise ValueError(message)
def key(row):
return (int(row['table_hash'], 0), row['id'])
old = {key(r): r for r in base['rows']}
final = {key(r): r for r in target['rows']}
require(len(old) == len(base['rows']) == 84246
and len(final) == len(target['rows']) == 84559,
'Open-world metadata row/key arithmetic differs')
require(areas.get('status') == 'PASS_OUTDOOR319_PROFILE_ROWS_AND_INDEPENDENT_ENCODER_ROUNDTRIP'
and areas.get('total') == 319 and areas.get('Map0_1_ready_rows') == 313
and areas.get('exploration_state_unprojected') is True
and areas.get('runtime_verified') is False,
'Accepted outdoor Area profile boundary differs')
selected = [r for r in areas['rows'] if r['original_Map0_1_binding_ready']]
approved = {(0x7253EB43, r['id']): r for r in selected}
require(len(selected) == len(approved) == 313
and not set(approved) & set(old)
and set(final) - set(old) == set(approved),
'Owned Area append namespace differs')
allowed = {(0xBD84CD62, 0): 8554294, (0xBD84CD62, 1): 8554295}
selected_maps = {r['MapID']: r for r in changes}
require(len(changes) == 2 and set(selected_maps) == {0, 1},
'Reviewed open-world Map cohort differs')
by_id = assets if isinstance(assets, dict) else {r['file_data_id']: r for r in assets}
for index, row in enumerate(base['rows']):
ident = key(row); current = target['rows'][index]
require(key(current) == ident, 'Existing metadata row order/identity changed')
if ident not in allowed:
require(current == row, 'Unrelated existing metadata or Area row changed')
continue
before = row['record']; after = current['record']; change = selected_maps[ident[1]]
require(set(before) == set(after)
and {f for f in before if before[f] != after[f]} == {'WdtFileDataID'}
and after['WdtFileDataID'] == allowed[ident]
and change['before'] == before and change['after'] == after
and change['entry'] == current,
'Unreviewed open-world Map field or pointer changed')
asset = by_id.get(after['WdtFileDataID'], {})
directory = after['Directory'].lower()
require(asset.get('kind') == 'terrain-wdt'
and 'world/maps/' + directory + '/' + directory + '.wdt' in asset.get('source_paths', []),
'Open-world Map WDT resource identity differs')
fields = ('table_name', 'table_hash', 'id', 'record_status', 'record', 'wire_hex', 'sha256')
for ident, row in approved.items():
require(final[ident] == {f: row[f] for f in fields}
and row['table_name'] == 'AreaTable' and row['record']['ContinentID'] in (0, 1),
'Accepted owned Area record differs')
return dict(base=base, target=target, changes=changes, areas=areas, assets=assets)
def _reviewed_openworld_area_metadata(metadata, expected_parent_sha256, assets):
def require(ok, message):
if not ok:
raise ValueError(message)
lineage = metadata.get('input_identity', {})
require(metadata.get('kind') == 'reviewed-map0-1-wdt-and-owned-area313-appends-v1'
and metadata.get('prefix_exact') is False
and metadata.get('base_rows') == 84246 and metadata.get('rows') == 84559
and metadata.get('new_rows') == 313
and set(lineage) == {'base_package', 'package'}
and lineage['base_package'].get('sha256') == expected_parent_sha256,
'Reviewed open-world metadata parent identity differs')
pinned = _reviewed_metadata_pinner()
refs = metadata.get('reviewed_openworld_Area313', {})
compiled = pinned(refs.get('compiled_boundary'))
plan = pinned(refs.get('compiled_plan')); build = pinned(refs.get('compiled_build'))
composition = pinned(refs.get('composition_boundary'))
header = refs.get('header'); pinned(header, binary=True)
require(compiled.get('status') == 'PASS_COMPILED315_MAP2_AREA313_ADVERTISEMENT_HOTFIX_DIRECT_LOOKUP'
and compiled.get('metadata_rows') == 84559
and compiled.get('changed_Map_rows') == 2 and compiled.get('new_Area_rows') == 313
and compiled.get('exact_hotfix_bodies') == 315 and compiled.get('exact_direct_lookups') == 315
and build.get('status') == 'PASS' and build.get('sha256') == compiled.get('codec_sha256')
and build.get('codec') == compiled.get('codec') and plan.get('metadata_rows') == 84559
and plan.get('new_metadata_header_sha256') == header['sha256']
and plan.get('new_metadata_package_sha256') == lineage['package']['sha256']
and composition.get('status') == 'PASS_84246_PLUS_MAP2_WDT_AND_AREA313_COMPOSITION_NAMESPACE_FK_HEADER_BOUNDARY'
and composition.get('new313_parent_FKs_closed') is True
and composition.get('prefix_exact') is False
and composition.get('parent_package') == lineage['base_package']
and composition.get('header') == header and composition.get('package') == lineage['package'],
'Compiled open-world Map/Area/header relationship differs')
return _reviewed_openworld_area_records(
pinned(lineage['base_package']), pinned(lineage['package']),
pinned(refs.get('changed_Map_rows')), pinned(refs.get('Area319_component')), assets)
def _reviewed_openworld_pointer_records(base, target, changes, assets, *, reviewed_cohort=None):
"""Replace WDT pointers only in an explicitly reviewed same-count cohort."""
def require(ok, message):
if not ok:
raise ValueError(message)
def key(row):
return (int(row['table_hash'], 0), row['id'])
require(len(base['rows']) == len(target['rows']) == 84559,
'Same-count continent metadata cohort differs')
old = {key(r): r for r in base['rows']}
final = {key(r): r for r in target['rows']}
require(len(old) == len(final) == 84559 and set(old) == set(final),
'Same-count continent metadata namespace differs')
expected = {0, 1}
if reviewed_cohort is not None:
require(reviewed_cohort in {'alpha-m2-map10-v1', 'blackrock3-map0-v1',
'current-map1-obj6-v1'},
'Unreviewed same-count Map pointer cohort')
expected = ({0} if reviewed_cohort == 'blackrock3-map0-v1'
else {1} if reviewed_cohort == 'current-map1-obj6-v1'
else {0, 1, 30, 33, 90, 169, 209, 249, 309, 329})
selected = {r['MapID']: r for r in changes}
require(len(changes) == len(selected) == len(expected) and set(selected) == expected,
'Same-count continent Map replacement cohort differs')
allowed = {(0xBD84CD62, mid) for mid in selected}
by_id = assets if isinstance(assets, dict) else {r['file_data_id']: r for r in assets}
for index, before_entry in enumerate(base['rows']):
after_entry = target['rows'][index]; ident = key(before_entry)
require(key(after_entry) == ident, 'Same-count metadata row order changed')
if ident not in allowed:
require(after_entry == before_entry, 'Unrelated installed metadata row changed')
continue
before = before_entry['record']; after = after_entry['record']; change = selected[ident[1]]
mutable = {'record', 'wire_hex', 'sha256'}
require(set(before_entry) == set(after_entry)
and {k: v for k, v in before_entry.items() if k not in mutable}
== {k: v for k, v in after_entry.items() if k not in mutable}
and after_entry.get('table_name') == 'Map'
and set(before) == set(after)
and {field for field in before if before[field] != after[field]} == {'WdtFileDataID'}
and change['before'] == before and change['after'] == after
and change['entry'] == after_entry,
'Unreviewed same-count continent Map field changed')
fdi = after['WdtFileDataID']; asset = by_id.get(fdi, {})
directory = after['Directory'].lower()
require(type(fdi) is int and 0 < fdi <= 0xffffffff
and asset.get('kind') == 'terrain-wdt'
and 'world/maps/' + directory + '/' + directory + '.wdt' in asset.get('source_paths', []),
'Same-count continent WDT resource identity differs')
return dict(base=base, target=target, changes=changes, assets=assets)
def _reviewed_current_map1_item_append_metadata(metadata, expected_parent_sha256, assets):
"""Consume the accepted installed-Map1 correction and finite owned item appends."""
def require(ok, message):
if not ok:
raise ValueError(message)
lineage = metadata.get('input_identity', {})
require(metadata.get('kind') == 'reviewed-current-map1-obj6-with-qualified-item-appends-v1'
and metadata.get('prefix_exact') is False
and metadata.get('base_rows') == 84559
and type(metadata.get('new_rows')) is int
and 0 <= metadata['new_rows'] <= 4096
and metadata.get('rows') == 84559 + metadata['new_rows']
and set(lineage) == {'base_package', 'package'}
and lineage['base_package'].get('sha256') == expected_parent_sha256,
'Current Map1/item metadata parent identity differs')
pinned = _reviewed_metadata_pinner()
refs = metadata.get('reviewed_current_Map1', {})
boundary = pinned(refs.get('current_boundary'))
map6_ref = refs.get('map6_package')
require(boundary.get('status') == 'PASS_CURRENT84559_ONLY_MAP1_WDT_DELTA_MAP0_RETAINED'
and boundary.get('rows') == 84559
and boundary.get('current_installed_package', {}).get('sha256') == expected_parent_sha256
and boundary.get('produced_package') == map6_ref
and boundary.get('changed_relative_current_Map_IDs') == [1]
and boundary.get('Map0_current_record_and_wire_retained_via_same_producer_and_prior_owner') is True
and boundary.get('all_other_current_records_exact_via_prior_owner') is True
and boundary.get('new_or_removed_records') == 0
and boundary.get('asset_count') == len(assets),
'Owning current Map1-only boundary differs')
base = pinned(lineage['base_package'])
map6 = pinned(map6_ref)
changes = pinned(refs.get('changed_Map_rows'))
_reviewed_openworld_pointer_records(base, map6, changes, assets,
reviewed_cohort='current-map1-obj6-v1')
target = pinned(lineage['package'])
count = metadata['new_rows']
require(len(target.get('rows', [])) == metadata['rows']
and target['rows'][:84559] == map6['rows'],
'Qualified item append changed an existing Map6 metadata record')
if count:
authority = pinned(refs.get('item_append_authority'))
appended = authority.get('appended_rows')
if isinstance(appended, dict):
appended = pinned(appended)
require(authority.get('kind') == 'qualified-item-catalogue-append-authority-v1'
and authority.get('status') == 'PASS_QUALIFIED_ITEM_CATALOGUE_APPENDS'
and authority.get('base_package', {}).get('sha256') == map6_ref.get('sha256')
and Path(authority.get('base_package', {}).get('path', '')).resolve() == Path(map6_ref.get('path', '')).resolve()
and authority.get('package') == lineage['package']
and authority.get('base_rows') == 84559
and authority.get('new_rows') == count
and authority.get('rows') == metadata['rows']
and isinstance(appended, list) and len(appended) == count
and target['rows'][84559:] == appended,
'Finite qualified item append authority differs')
tables = {}
for row in base['rows']:
name = row.get('table_name')
if name in {'Item', 'ItemSparse'}:
tables.setdefault(name, set()).add(int(row['table_hash'], 0))
require(set(tables) == {'Item', 'ItemSparse'}
and all(len(values) == 1 for values in tables.values()),
'Installed item table identities are ambiguous')
old_ids = {(int(row['table_hash'], 0), row['id']) for row in map6['rows']}
new_ids = {(int(row['table_hash'], 0), row['id']) for row in appended}
require(len(new_ids) == count and not old_ids & new_ids
and all(row.get('table_name') in tables
and int(row['table_hash'], 0) in tables[row['table_name']]
for row in appended),
'Qualified item append namespace differs')
else:
require(lineage['package'] == map6_ref and refs.get('item_append_authority') is None,
'Unexpected authority or target in Map1-only publication')
compiled = pinned(refs.get('compiled_boundary'))
build = pinned(refs.get('compiled_build'))
plan = pinned(refs.get('compiled_plan'))
header = refs.get('header')
require(compiled.get('status') == f"PASS_COMPILED_SAME{metadata['rows']}_MAP2_ADVERTISEMENT_HOTFIX_DIRECT_LOOKUP"
and compiled.get('metadata_rows') == metadata['rows']
and compiled.get('exact_hotfix_bodies') == compiled.get('exact_direct_lookups') == count + 2
and (not count or compiled.get('exact_compiled_appended_item_bodies') == count)
and build.get('status') == 'PASS'
and build.get('metadata_rows') == metadata['rows']
and build.get('sha256') == compiled.get('codec_sha256')
and Path(build.get('codec', '')).resolve() == Path(compiled.get('codec', '')).resolve()
and build.get('coherent_header_sha256') == header.get('sha256')
and plan.get('metadata_rows') == metadata['rows']
and plan.get('new_metadata_package') == lineage['package']
and plan.get('new_metadata_header') == header,
'Compiled current Map1/item/header relationship differs')
return dict(base=base, target=target, changes=changes, assets=assets)
def _reviewed_openworld_pointer_metadata(metadata, expected_parent_sha256, assets):
def require(ok, message):
if not ok:
raise ValueError(message)
lineage = metadata.get('input_identity', {})
map10 = metadata.get('kind') == 'reviewed-map10-wdt-pointer-replacements-v1'
map0 = metadata.get('kind') == 'reviewed-blackrock3-map0-wdt-pointer-replacement-v1'
count = 1 if map0 else (10 if map10 else 2)
require(metadata.get('kind') in {'reviewed-map0-1-wdt-pointer-replacements-v1',
'reviewed-map10-wdt-pointer-replacements-v1',
'reviewed-blackrock3-map0-wdt-pointer-replacement-v1'}
and metadata.get('prefix_exact') is False
and metadata.get('base_rows') == metadata.get('rows') == 84559
and metadata.get('new_rows') == 0
and set(lineage) == {'base_package', 'package'}
and lineage['base_package'].get('sha256') == expected_parent_sha256,
'Same-count continent metadata parent identity differs')
pinned = _reviewed_metadata_pinner()
refs = metadata.get('reviewed_Map0_pointer' if map0 else
('reviewed_Map10_pointers' if map10 else 'reviewed_Map0_1_pointers'), {})
composition = pinned(refs.get('composition_boundary'))
compiled = pinned(refs.get('compiled_boundary'))
plan = pinned(refs.get('compiled_plan')); build = pinned(refs.get('compiled_build'))
header = refs.get('header'); pinned(header, binary=True)
require(composition.get('status') == f'PASS_SAME84559_MAP{count}_WDT_POINTER_COMPOSITION_HEADER_BOUNDARY'
and composition.get('parent_package') == lineage['base_package']
and composition.get('package') == lineage['package'] and composition.get('header') == header
and composition.get(f'other{84559-count}_rows_exact') is True
and composition.get('prefix_exact') is False
and compiled.get('status') == f'PASS_COMPILED_SAME84559_MAP{count}_ADVERTISEMENT_HOTFIX_DIRECT_LOOKUP'
and compiled.get('metadata_rows') == 84559 and compiled.get('changed_Map_rows') == count
and compiled.get('exact_hotfix_bodies') == compiled.get('exact_direct_lookups') == count
and build.get('status') == 'PASS' and build.get('sha256') == compiled.get('codec_sha256')
and build.get('codec') == compiled.get('codec') and plan.get('metadata_rows') == 84559
and plan.get('new_metadata_header_sha256') == header['sha256']
and plan.get('new_metadata_package_sha256') == lineage['package']['sha256'],
'Compiled same-count continent Map/header relationship differs')
base = pinned(lineage['base_package'])
target = pinned(lineage['package'])
changes = pinned(refs.get('changed_Map_rows'))
if map10 or map0:
qualified = pinned(refs.get('qualified_cohort'))
expected = {0} if map0 else {0, 1, 30, 33, 90, 169, 209, 249, 309, 329}
selected = {r['MapID']: r for r in qualified.get('rows', [])}
require(qualified.get('status') == 'PASS_ACTUAL_INSTALLED84559_MAP_SELECTOR_COHORT_QUALIFIED'
and qualified.get('parent_package') == lineage['base_package']
and set(qualified.get('qualified_affected_Map_IDs', [])) == expected
and len(selected) == len(qualified.get('rows', [])) == count
and set(selected) == expected
and len(changes) == count and {change['MapID'] for change in changes} == expected
and all(change['before'] == selected[change['MapID']]['original_Map_record']
and change['before']['WdtFileDataID']
== selected[change['MapID']]['current_WDT_file_data_id']
for change in changes),
'Reviewed installed Map definition cohort differs')
return _reviewed_openworld_pointer_records(base, target, changes, assets,
reviewed_cohort='blackrock3-map0-v1' if map0 else ('alpha-m2-map10-v1' if map10 else None))
def _reviewed_map_replacement_metadata(metadata, expected_parent_sha256, assets):
"""Consume the owning composition and compiled lookup proof, without rebuilding."""
if metadata.get('kind') == 'reviewed-current-map1-obj6-with-qualified-item-appends-v1':
return _reviewed_current_map1_item_append_metadata(metadata, expected_parent_sha256, assets)
if metadata.get('kind') == 'reviewed-map0-1-wdt-and-owned-area313-appends-v1':
return _reviewed_openworld_area_metadata(metadata, expected_parent_sha256, assets)
if metadata.get('kind') in {'reviewed-map0-1-wdt-pointer-replacements-v1',
'reviewed-map10-wdt-pointer-replacements-v1',
'reviewed-blackrock3-map0-wdt-pointer-replacement-v1'}:
return _reviewed_openworld_pointer_metadata(metadata, expected_parent_sha256, assets)
def require(ok, message):
if not ok:
raise ValueError(message)
lineage = metadata.get('input_identity', {})
require(metadata.get('kind') == 'reviewed-existing-map-pointer-replacements-v1'
and metadata.get('prefix_exact') is False and set(lineage) == {'base_package', 'package'}
and lineage['base_package'].get('sha256') == expected_parent_sha256,
'Reviewed Map metadata parent identity differs')
pinned = _reviewed_metadata_pinner()
refs = metadata.get('reviewed_Map_replacements', {})
compiled = pinned(refs.get('compiled_boundary'))
plan = pinned(refs.get('compiled_plan')); build = pinned(refs.get('compiled_build'))
composition = pinned(refs.get('composition_boundary'))
header = refs.get('header'); pinned(header, binary=True)
require(compiled.get('status') == 'PASS_COMPILED23_MAP_ROWS_ADVERTISEMENT_HOTFIX_DIRECT_LOOKUP'
and compiled.get('metadata_rows') == 84246 and compiled.get('changed_Map_rows') == 23
and compiled.get('exact_hotfix_bodies') == 23 and compiled.get('exact_direct_lookups') == 23
and compiled.get('Map35_name_included') is True and compiled.get('Map169_loading501_included') is True
and build.get('status') == 'PASS' and build.get('sha256') == compiled.get('codec_sha256')
and build.get('codec') == compiled.get('codec')
and plan.get('metadata_rows') == 84246
and plan.get('new_metadata_header_sha256') == header['sha256']
and plan.get('new_metadata_package_sha256') == lineage['package']['sha256']
and composition.get('status') == 'PASS_COMBINED57_METADATA_COMPOSITION_NEW22_LOOKUP'
and composition.get('header_sha256') == header['sha256']
and composition.get('package_sha256') == lineage['package']['sha256'],
'Compiled reviewed Map/header relationship differs')
name = pinned(refs.get('name_child_boundary'))
require(name.get('status') == 'PASS_PRIVATE_OPTIONAL_MAP35_NAME_ONLY_CHILD84226'
and name.get('parent') == lineage['base_package']
and name.get('base_rows') == 84225 and name.get('rows') == 84226
and name.get('all_other25_native_fields_and_ID_preserved') is True
and composition.get('parent_sha256') == name['package']['sha256'],
'Accepted Map35 child lineage differs')
inputs = dict(base=pinned(lineage['base_package']), target=pinned(lineage['package']),
name_child=pinned(name['package']), changes=pinned(refs.get('changed_rows')),
native_join=pinned(refs.get('native_relationships')), assets=assets)
_reviewed_map_replacement_records(**inputs)
return inputs
def _finish_asset_delta(parent, inputs, old, new, ids, frame, metadata, delta):
def require(condition, message):
if not condition:
raise ValueError(message)
require(delta.get('new_file_data_ids') == ids and delta.get('required_parent_ROOT') == parent['composed_root']
and delta.get('new_ROOT') == frame['root']['content_key']
and delta.get('parent_asset_count') == len(old) and delta.get('new_asset_count') == len(new)
and delta.get('new_source_payloads') == len(ids), 'Equipment delivery delta differs')
require(isinstance(metadata.get('status'), str) and metadata['status'].startswith('PASS_')
and metadata.get('unique_record_ids') is True
and metadata.get('push_identity_and_pages_exact') is True,
'Equipment metadata owning boundary is not complete')
lineage = metadata.get('input_identity', {})
require(isinstance(lineage, dict) and set(lineage) == {'base_package', 'package'},
'Equipment metadata lineage required')
if metadata.get('prefix_exact') is True:
for key in ('base_package', 'package'):
ref = lineage[key]
require(isinstance(ref, dict) and isinstance(ref.get('path'), str)
and digest(ref['path']) == ref.get('sha256'), 'Equipment metadata input identity differs')
else:
_reviewed_map_replacement_metadata(metadata, parent['_receipt'].get('metadata_package_sha256'), new)
count = metadata.get('new_rows')
require(type(count) is int and 0 <= count <= 4096 and type(metadata.get('base_rows')) is int
and type(metadata.get('rows')) is int and metadata['base_rows'] + count == metadata['rows'],
'Equipment metadata delta arithmetic differs')
expected = dict(schema_version=4, applied=True, parent_registered_assets=len(old), registered_assets=len(new),
source_icon_bindings=parent['source_icon_bindings'], new_assets=len(ids), new_file_data_ids=ids,
old_root=parent['composed_root'], framing_manifest_sha256=inputs['frames']['sha256'],
metadata_base_package_sha256=lineage['base_package']['sha256'], metadata_package_sha256=lineage['package']['sha256'])
validation = dict(schema_version=4, kind='reused-completed-generic-equipment-delta-validation-v4', passed=True,
changed_assets=len(ids), staged_native_SDK_FileID_bodies_exact=len(ids), metadata_rows_added=count,
warrior_ui_preserved=True, all_parent_records_and_aliases_preserved=True, native_render_acceptance_verified=False,
new_physical_delta_files_copied_and_hash_exact=len(delta['files']))
return expected, validation
def _generic_asset_lineage(root, receipt, depth):
"""Consume completed private storage batches behind one actual publication.
Intermediate stores are never represented as installed clients. Their
original owning SDK receipts cover only their new IDs; no payload is read.
"""
def require(condition, message):
if not condition:
raise ValueError(message)
loaded = {}
def pinned(reference):
require(isinstance(reference, dict) and isinstance(reference.get('path'), str)
and isinstance(reference.get('sha256'), str) and len(reference['sha256']) == 64,
'Pinned storage lineage input required')
key = (reference['path'], reference['sha256'])
if key not in loaded:
require(digest(reference['path']) == reference['sha256'], 'Storage lineage input identity differs')
loaded[key] = read(reference['path'])
return loaded[key]
reference = receipt.get('parent_publication', {})
parent = _publication_proof(root, dict(receipt_path=reference.get('receipt_path'),
composed_root=receipt.get('old_root'),
validation_sha256=reference.get('validation_sha256')),
historical=True, depth=depth + 1)
require(parent['receipt_sha256'] == reference.get('receipt_sha256'), 'Parent publication identity differs')
inputs = receipt.get('inputs', {})
before = pinned(inputs.get('parent_assets')); after = pinned(inputs.get('assets'))
previous = pinned(inputs.get('parent_frames')); final = pinned(inputs.get('frames'))
require(parent['_receipt'].get('framing_manifest_sha256') == inputs['parent_frames']['sha256']
and previous['root']['content_key'] == parent['composed_root']
and previous['asset_manifest_sha256'] == inputs['parent_assets']['sha256'],
'Published storage lineage anchor differs')
old = {row['file_data_id']: row for row in before['assets']}
new = {row['file_data_id']: row for row in after['assets']}
require(len(old) == len(before['assets']) == parent['registered_assets']
and len(new) == len(after['assets']) and all(new.get(k) == v for k, v in old.items())
and all(after['registry']['slots'].get(k) == v for k, v in before['registry']['slots'].items())
and after['source_icon_bindings'] == before['source_icon_bindings'],
'Cumulative parent records or reservations differ')
ids = sorted(set(new) - set(old))
steps = inputs.get('storage_steps')
# Match the existing shared allocator's catalogue bound; a complete model
# family may add more than4096 MD21/SKIN names in one accepted storage step.
step_asset_limit = 32768
require(isinstance(steps, list) and 0 < len(steps) <= 32 and 0 < len(ids) <= step_asset_limit * len(steps)
and all(type(i) is int and 0 < i < 2**32 for i in ids)
and receipt.get('new_file_data_ids') == ids, 'Cumulative storage delta differs')
sdk_statuses = {
'PASS_NATIVE_SDK_FILEID_BODY_READBACK', 'PASS_NATIVE_SDK_NEW88_BODY_READBACK',
'PASS_NATIVE_SDK_SELECTOR_SAFE52_ALIASES_AND5_WMO_ROOTS',
'PASS_NATIVE_SDK_SELECTOR_SAFE180_LOCAL_ALIASES_AND28_NEW_TEXTURES',
'PASS_NATIVE_SDK_MODEL_TEXTURE35_LOCAL_ALIASES_AND52_NEW_TEXTURES',
'PASS_NATIVE_SDK_MODEL_TEXTURE161_LOCAL_ALIASES379_NEW_AND_ONE_NATIVE',
'PASS_NATIVE_SDK_STATIC277_MODEL1108_SKIN',
}
seen = set(); count = len(old); current_root = parent['composed_root']
for step in steps:
frame = pinned(step.get('frames')); sdk = pinned(step.get('sdk'))
rows = frame.get('source_rows', [])
introduced = {row['asset']['file_data_id'] for row in rows}
require(0 < len(introduced) <= step_asset_limit and len(introduced) == len(rows)
and not (introduced & seen) and introduced <= set(ids)
and all(row['asset'] == new[row['asset']['file_data_id']] for row in rows),
'Storage step owned records differ')
require(frame.get('parent_root') == current_root and frame.get('old_asset_count') == count
and frame.get('new_asset_count') == len(introduced)
and frame.get('registered_asset_count') == count + len(introduced)
and frame.get('all_old_asset_records_exact') is True
and frame.get('all_old_registry_records_exact') is True,
'Storage frame parent sequence differs')
require(frame['warrior_ui_content_key'] == previous['warrior_ui_content_key']
and frame['native_aliases_preserved'] == previous['native_aliases_preserved']
and frame['source_icon_bindings_preserved'] == parent['source_icon_bindings']
and frame['encoding_audit']['all_original_content_key_encoding_bindings_preserved'] is True
and frame['download_audit']['original_entry_bytes_preserved'] is True
and frame['download_audit']['original_tag_bits_preserved'] is True
and frame['tvfs_child_audit']['old_cft_vfs_and_spec_prefixes_preserved'] is True,
'Storage step parent framing retention differs')
require(sdk.get('status') in sdk_statuses and sdk.get('passed', True) is True
and not sdk.get('failures', []),
'Completed owning SDK storage proof required')
if 'effective_root' in sdk:
require(sdk['effective_root'] == frame['root']['content_key'], 'SDK storage ROOT differs')
if 'parent_root' in sdk:
require(sdk['parent_root'] == current_root, 'SDK parent ROOT differs')
if 'effective_root' not in sdk:
handoff = pinned(step.get('owning_handoff'))
def same_reference(label, reference):
path = Path(label)
actual = Path(reference['path'])
return (path == actual if path.is_absolute() else
'..' not in path.parts and actual.as_posix().endswith('/' + path.as_posix()))
require(isinstance(handoff.get('status'), str) and handoff['status'].startswith('PASS_')
and same_reference(handoff['framing_manifest'], step['frames'])
and same_reference(handoff['native_SDK'], step['sdk']),
'Owning SDK/framing completion relationship differs')
if 'framing_manifest_sha256' in handoff:
require(handoff['framing_manifest_sha256'] == step['frames']['sha256'],
'Owning frame completion identity differs')
observed = sdk.get('rows', [])
observed_ids = [row.get('requested_file_data_id', row.get('file_data_id')) for row in observed]
require(len(observed_ids) == len(introduced) and set(observed_ids) == introduced,
'SDK step FileDataID coverage differs')
for row, ident in zip(observed, observed_ids):
asset = new[ident]
require(row.get('status') in ('PASS', 'PASS_NATIVE_SDK_NUMERIC_BODY_CKEY_SHA_SIZE'),
'SDK body read did not pass')
if 'requested_file_data_id' in row:
require(row['expected_content_key'] == row['observed_body_MD5'] == asset['content_key']
and row['expected_size'] == row['observed_size'] == asset['bytes'],
'SDK recorded body identity differs')
else:
require(row.get('content_key') == asset['content_key'] and row.get('bytes') == asset['bytes'],
'SDK owning body identity differs')
if 'sha256' in row:
require(row['sha256'] == asset['sha256'], 'SDK recorded SHA identity differs')
seen.update(introduced); count += len(introduced)
current_root = frame['root']['content_key']; previous = frame
require(seen == set(ids) and count == len(new) and current_root == receipt.get('composed_root')
and steps[-1]['frames'] == inputs['frames']
and final['asset_manifest_sha256'] == inputs['assets']['sha256'],
'Cumulative final storage identity differs')
metadata = pinned(inputs.get('metadata')); delta = pinned(inputs.get('delta_plan'))
expected, validation = _finish_asset_delta(parent, inputs, old, new, ids, final, metadata, delta)
expected['storage_steps'] = len(steps)
validation.update(kind='reused-completed-storage-lineage-validation-v4', storage_steps=len(steps),
intermediate_clients_activated=0, owning_SDK_proofs_reused=len(steps))
return expected, validation
def _reviewed_original_ui_replacement(receipt):
"""Consume the exact two reviewed Glue replacements, without parent replay.
The working32337 publication is a frozen owning certificate. Only its two
original UI CKeys may change; registered assets and metadata stay exact.
This returns required publication fields, never performs activation.
"""
def require(condition, message):
if not condition:
raise ValueError(message)
loaded = {}
def pinned(ref):
require(isinstance(ref, dict) and isinstance(ref.get('path'), str)
and isinstance(ref.get('sha256'), str) and len(ref['sha256']) == 64,
'Pinned original UI publication input required')
key = (ref['path'], ref['sha256'])
if key not in loaded:
require(digest(ref['path']) == ref['sha256'], 'Original UI input identity differs')
loaded[key] = read(ref['path'])
return loaded[key]
single = receipt.get('kind') == 'closed-private-evidence-chained-original-UI-single-publication-v4'
general = single or receipt.get('kind') == 'closed-private-evidence-chained-original-UI-publication-v3'
chained = general or receipt.get('kind') == 'closed-private-chained-original-UI-replacement-publication-v2'
parent_ref = receipt.get('parent_publication', {})
parent_sha = (parent_ref.get('sha256') if general else
'ae6a2ec03e9b01ffb319753f7d7b07cc49b294d9cf01035ccdff94092dd367ed' if chained
else 'a33a066130380e0416956552efceeb21800a30ad41363b3facc038f5c2ac6cd2')
require(parent_ref.get('sha256') == parent_sha, 'Exact accepted32337 original UI parent required')
parent = pinned(parent_ref)
parent_root = (parent.get('composed_root') if general else
'7fa89b8aef66012a9553abd30738bd0e' if chained
else '53ba5f55e21184752b7019126809e9f0')
package_sha = (parent.get('metadata_package_sha256') if general else
'7963d29e005d09462b2c20bdf6950e90fd4a339f8a716e117cdc82c22367b030')
registered = parent.get('registered_assets') if general else 32337
icons = parent.get('source_icon_bindings') if general else 841
require(parent.get('applied') is True and parent.get('composed_root') == parent_root
and type(registered) is int and registered > 0 and parent.get('registered_assets') == registered
and type(icons) is int and icons >= 0 and parent.get('source_icon_bindings') == icons
and isinstance(parent_root, str) and len(parent_root) == 32
and isinstance(package_sha, str) and len(package_sha) == 64
and parent.get('metadata_package_sha256') == package_sha, 'Accepted UI parent scope differs')
inputs = receipt.get('inputs', {})
if general:
require(parent.get('kind') in ('closed-private-original-UI-replacement-publication-v1',
'closed-private-chained-original-UI-replacement-publication-v2',
'closed-private-evidence-chained-original-UI-publication-v3')
or (single and parent.get('kind') == 'closed-private-original-art-create-composite-publication-v1'),
'Reviewed original UI parent publication required')
require(isinstance(parent.get('target'), str) and receipt.get('target') == parent.get('target'),
'Original UI parent and child targets differ')
parent_validation = pinned(inputs.get('parent_validation'))
require(inputs['parent_validation']['sha256'] == parent.get('changed_validation_sha256')
and parent_validation.get('passed') is True
and parent_validation.get('kind') in ('reviewed-original-UI-two-replacement-validation-v1',
'reviewed-chained-original-UI-two-replacement-validation-v2',
'reviewed-evidence-chained-original-UI-two-replacement-validation-v3',
'reviewed-original-art-create-composite-validation-v1')
and parent_validation.get('composed_root') == parent_root
and parent_validation.get('staged_native_SDK_FileID_bodies_exact') == 2
and parent_validation.get('parent_index_preimages') == 16
and parent_validation.get('derived_mapping_Data_relative') is True
and parent_validation.get('all_parent_records_and_aliases_preserved') is True,
'Accepted UI parent validation differs')
composite_parent = parent.get('kind') == 'closed-private-original-art-create-composite-publication-v1'
parent_inputs = parent.get('inputs', {})
parent_cow = pinned(parent_inputs.get('ui_cow' if composite_parent else 'COW'))
parent_frames = pinned(parent_inputs.get('ui_frames')) if composite_parent else None
parent_config = parent_cow.get('new_build_config')
require(isinstance(parent_config, str) and len(parent_config) == 32
and parent_cow.get('logical_parent_root') == (parent_frames.get('parent_root') if composite_parent else parent.get('old_root'))
and parent_cow.get('new_framing_manifest') == parent_inputs.get('ui_frames' if composite_parent else 'frames', {}).get('path')
and (not composite_parent or parent_frames.get('root', {}).get('content_key') == parent_root),
'Accepted UI parent build configuration required')
elif chained:
readiness = pinned(inputs.get('installed_parent_readiness'))
require(readiness.get('status') == 'PASS_INSTALLED_SOURCE_REALM_UI_PAIR'
and readiness.get('installed') is True and readiness.get('composed_root') == parent_root
and readiness.get('publication') == parent_ref, 'Installed original UI parent readiness differs')
previous = pinned(inputs.get('parent_frames')); frame = pinned(inputs.get('frames'))
owner = pinned(inputs.get('UI_owner')); pair = pinned(inputs.get('UI_pair'))
native = pinned(inputs.get('native_UI_metadata')); sdk = pinned(inputs.get('SDK'))
cow = pinned(inputs.get('COW')); delta = pinned(inputs.get('delta_plan'))
rollback = pinned(inputs.get('rollback_plan'))
require(inputs['parent_frames']['sha256'] == parent['framing_manifest_sha256']
and previous['root']['content_key'] == parent_root
and receipt.get('old_root') == parent_root, 'Original UI framing parent differs')
expected_ui = {
5613302: ('interface/addons/blizzard_gluexml/mainline/realmlist.lua',
'a8f5e7c00c6ee3a78a4f7bb0a451c047',
'1486be22772e638b4a302083def941c9514a651287420bad1b3f43d35922c084',
'57c8c91fca2dac7c8d3865d0bfb9344e44619365a8ee832ec8d4c56c9072450a'),
5612385: ('interface/addons/blizzard_glueparent/mainline/glueparent.lua',
'5c83e8c02211095851be3f22fadf13ae',
'3f7d06f7801f8a8eb47f700d735ca083ed920004b106bdb1d888b10706d4c986',
'6c39eaf76c25d2d6ac2b37cbbee7e9c79871b15d4b73bb609b4fec00fdb1f093'),
}
if chained and not general:
expected_ui = {
5612385: ('interface/addons/blizzard_glueparent/mainline/glueparent.lua',
'0d4f7ea95f80892c01835b498122d142', None,
'5f6b8c008f071a547906beb252dc9aea4d06ef6b6d7716e1fdaecf9066aa013b'),
8209459: ('interface/addons/blizzard_charactercreate/camelot/blizzard_charactercreate.lua',
'0ab151cc2745b232fcfdcd9dc11512b3', None,
'a360826025f2fb01fdc61314163cad37dcc86224584f98176499e41319928ee7'),
}
def keyed(rows, field):
count = 1 if single else 2
require(isinstance(rows, list) and len(rows) == count and all(isinstance(r, dict) for r in rows),
'Exact original UI record count required')
result = {r.get(field): r for r in rows}
require(len(result) == count, 'Duplicate original UI identity')
return result
native_rows = keyed(native.get('rows'), 'file_data_id')
staged = keyed(frame.get('native_UI_rows'), 'file_data_id')
transforms = keyed(pair, 'source_reference')
consumers = {5612385: ('interface/addons/blizzard_glueparent/mainline/glueparent.lua', 'glue'),
8209459: ('interface/addons/blizzard_charactercreate/camelot/blizzard_charactercreate.lua', 'create'),
5613302: ('interface/addons/blizzard_gluexml/mainline/realmlist.lua', 'realm'),
6099272: ('interface/addons/blizzard_staticpopup/staticpopup.lua', 'popup')}
if chained:
observed_by_consumer = keyed(sdk.get('rows'), 'consumer')
if general:
require(set(native_rows) <= set(consumers), 'Off-scope original UI identity')
require(set(observed_by_consumer) == {consumers[i][1] for i in native_rows},
'Unexpected chained UI SDK consumer')
expected_ui = {}
for ident, n in native_rows.items():
path, consumer = consumers[ident]
transform = transforms.get(path, {})
candidate_sha = transform.get('candidate', {}).get('sha256')
old_ckey = n.get('nativeInfo_CKey')
require(n.get('path') == path and isinstance(old_ckey, str) and len(old_ckey) == 32
and isinstance(candidate_sha, str) and len(candidate_sha) == 64,
'Pinned original UI generation identity required')
expected_ui[ident] = (path, old_ckey, None, candidate_sha)
observed = {i: observed_by_consumer[consumers[i][1]] for i in native_rows}
else:
require(set(observed_by_consumer) == {'glue', 'create'}, 'Unexpected chained UI SDK consumer')
observed = {5612385: observed_by_consumer['glue'], 8209459: observed_by_consumer['create']}
else:
observed = keyed(sdk.get('rows'), 'file_data_id')
require(set(native_rows) == set(staged) == set(observed) == set(expected_ui), 'Off-scope UI FileDataID')
popup_only = single and set(native_rows) == {6099272}
require(not (general and composite_parent) or popup_only, 'Composite parent only supports reviewed 1016 popup')
require(owner.get('status') == ('PASS_1016_KEY_BEHAVIOR' if popup_only else 'PASS_OFFLINE_ORIGINAL_CONSUMERS_SOURCE_FACTORY_AND_NATIVE_FALLBACK')
and frame.get('owner') == inputs['UI_owner'] and frame.get('source_pair') == inputs['UI_pair']
and frame.get('native_metadata') == inputs['native_UI_metadata'], 'Owning original UI contracts differ')
require(frame.get('kind') == ('exact-reviewed-race-login-single-file-CASC-stage-v2' if popup_only else
'exact-reviewed-race-login-two-file-CASC-stage-v1' if chained
else 'exact-reviewed-original-Glue-two-file-CASC-stage-v1')
and frame.get('status') == 'PASS_FRAMED_PRIVATE' and frame.get('parent_root') == parent_root
and frame.get('registered_asset_count') == registered and frame.get('new_asset_count') == 0
and frame.get('reviewed_ui_payload_count') == (1 if single else 2), 'Original UI storage scope differs')
changes = keyed(frame.get('root_audit', {}).get('changes'), 'file_data_id')
require(set(changes) == set(expected_ui) and frame['root_audit'].get('all_other_root_bytes_identical') is True
and frame['root_audit'].get('root_names_ids_groups_order_preserved') is True,
'Unrelated original ROOT change')
for ident, (path, old_ckey, original_sha, candidate_sha) in expected_ui.items():
n, s, o, change = native_rows[ident], staged[ident], observed[ident], changes[ident]
transform = transforms.get(path, {})
require(n.get('path') == s.get('source_reference') == path
and n.get('nativeInfo_CKey') == s.get('nativeInfo_CKey') == change.get('old_content_key') == old_ckey,
'Original UI native identity differs')
if chained:
consumer = consumers[ident][1]
require(n.get('nativeInfo_EKey') == s.get('nativeInfo_EKey')
and transform.get('consumer') == consumer == o.get('consumer')
and owner.get('candidates', {}).get(consumer, {}).get('sha256') == candidate_sha
and transform.get('candidate', {}).get('sha256') == candidate_sha
== s.get('candidate', {}).get('sha256') == o.get('sha256')
and s['frame']['content_key'] == change.get('new_content_key')
and o.get('bytes') == s['frame']['decoded_size'], 'Chained UI body identity differs')
else:
require(n.get('full_info_available') is True and o.get('source_reference') == path,
'Original UI native information differs')
require(transform.get('original', {}).get('sha256') == original_sha
and transform.get('candidate', {}).get('sha256') == candidate_sha == s.get('candidate', {}).get('sha256') == o.get('sha256')
and transform.get('global_native_APIs_overridden') is False
and transform.get('original_controls_and_style_preserved') is True
and transform.get('new_original_UI_assets') is False, 'Unreviewed original UI transform')
require(o.get('status') == 'PASS' and o.get('content_key') == s['frame']['content_key'] == change.get('new_content_key')
and o.get('bytes') == s['frame']['decoded_size'], 'Original UI SDK body identity differs')
if chained:
require(native.get('status') == 'PASS_METADATA_ONLY'
and sdk.get('status') == ('PASS_ONE_CHANGED_UI_EXACT_NATIVE_SDK_READBACK' if single else 'PASS_TWO_CHANGED_UI_EXACT_NATIVE_SDK_READBACK')
and sdk.get('parent_root') == parent_root and sdk.get('other_root_bytes_preserved') is True
and sdk.get('candidate_root') == frame['root']['content_key'] == receipt.get('composed_root'),
'Exact chained UI SDK proof required')
else:
require(native.get('status') == 'PASS_METADATA_ONLY'
and sdk.get('status') == 'PASS_NATIVE_SDK_EXACT_TWO_ORIGINAL_UI_BODIES'
and sdk.get('passed') is True and sdk.get('body_reads') == 2 and not sdk.get('failures')
and sdk.get('effective_root') == frame['root']['content_key'] == receipt.get('composed_root'),
'Exact changed-two UI SDK proof required')
require(frame['download_audit'].get('original_entry_bytes_preserved') is True
and frame['download_audit'].get('original_tag_bits_preserved') is True
and frame['encoding_audit'].get('all_original_content_key_encoding_bindings_preserved') is True
and frame['tvfs_child_audit'].get('new_paths') == (1 if single else 2)
and frame['tvfs_child_audit'].get('old_cft_vfs_and_spec_prefixes_preserved') is True,
'Parent UI storage bindings changed')
require(cow.get('logical_parent_root') == parent_root
and cow.get('original_build_config') == (parent_config if general else
'87484fdad383454a9d3cb19eb3e702dc' if chained
else '278de2afa85eda830d91dfd653c9ff7a')
and cow.get('new_framing_manifest') == inputs['frames']['path']
and cow.get('reviewed_original_UI_overrides') == [r['file_data_id'] for r in frame['native_UI_rows']],
'Original UI COW relationship differs')
require(delta.get('required_parent_ROOT') == parent_root and delta.get('new_ROOT') == frame['root']['content_key']
and delta.get('new_build_config') == cow.get('new_build_config')
and delta.get('parent_asset_count') == delta.get('new_asset_count') == registered
and delta.get('new_file_data_ids') == [] and delta.get('replaced_native_UI_file_data_ids') == sorted(expected_ui),
'Original UI physical delta differs')
config = cow['new_build_config']
if general:
generations = cow.get('new_index_generations')
segments = cow.get('created_segments')
hexchars = set('0123456789abcdef')
require(isinstance(config, str) and len(config) == 32 and set(config) <= hexchars
and isinstance(generations, list) and 1 <= len(generations) <= 16
and all(isinstance(row, dict) and isinstance(row.get('new_file'), str)
and len(row['new_file']) == 14 and row['new_file'].endswith('.idx')
and set(row['new_file'][:-4]) <= hexchars for row in generations)
and len({row['new_file'] for row in generations}) == len(generations)
and isinstance(segments, list) and segments
and all(type(n) is int and 0 <= n <= 999 for n in segments)
and len(set(segments)) == len(segments), 'Unsafe UI candidate generation path')
physical = {'.build.info', 'Data/config/' + config[:2] + '/' + config[2:4] + '/' + config}
physical.update('Data/data/' + r['new_file'] for r in cow['new_index_generations'])
physical.update(f'Data/data/data.{n:03d}' for n in cow['created_segments'])
files = delta.get('files')
require(isinstance(files, list) and len(files) == len(physical)
and {r.get('relative') for r in files} == physical
and all(type(r.get('bytes')) is int and r['bytes'] > 0
and isinstance(r.get('sha256'), str) and len(r['sha256']) == 64
and r.get('action') == ('ATOMIC_BUILD_INFO_LAST' if r['relative'] == '.build.info' else 'COPY_NEW_NO_OVERWRITE')
for r in files), 'Off-scope original UI physical file')
indices = rollback.get('parent_index_files')
require(isinstance(indices, list) and len(indices) == 16 and indices == cow.get('parent_index_files')
and {r.get('bucket') for r in indices} == set(range(16))
and rollback.get('parent_root') == parent_root
and rollback.get('candidate_root') == frame['root']['content_key']
and rollback.get('parent_build_info', {}).get('sha256') == parent['published_build_info_sha256']
and rollback.get('restore_parent_indices_before_candidate_deletion') is True
and rollback.get('derived_mapping_relative_namespace') == 'client/Data'
and rollback.get('derived_mapping_relatives') == ['data/shmem', 'ecache/shmem', 'wow_classic_beta/shmem']
and rollback.get('restore_stale_derived_maps') is False, 'Corrected original UI rollback contract required')
if general:
require(all(isinstance(r.get('file'), str) and len(r['file']) == 14
and r['file'].endswith('.idx') and set(r['file'][:-4]) <= set('0123456789abcdef')
and r.get('relative') == 'Data/data/' + r['file'] for r in indices),
'Unsafe UI parent index path')
expected = dict(schema_version=5, applied=True, registered_assets=registered, parent_registered_assets=registered,
source_icon_bindings=icons, new_assets=0, new_file_data_ids=[],
replaced_native_UI_file_data_ids=sorted(expected_ui), old_root=parent_root,
framing_manifest_sha256=inputs['frames']['sha256'], metadata_package_sha256=package_sha)
validation = dict(schema_version=5, kind=('reviewed-evidence-chained-original-UI-single-replacement-validation-v4' if single else 'reviewed-evidence-chained-original-UI-two-replacement-validation-v3' if general else
'reviewed-chained-original-UI-two-replacement-validation-v2' if chained
else 'reviewed-original-UI-two-replacement-validation-v1'), passed=True,
changed_assets=(1 if single else 2), staged_native_SDK_FileID_bodies_exact=(1 if single else 2), new_assets=0,
parent_index_preimages=16, derived_mapping_Data_relative=True,
metadata_rows_added=0, all_parent_records_and_aliases_preserved=True,
native_UI_runtime_acceptance_verified=False,
new_physical_delta_files_copied_and_hash_exact=len(delta['files']))
return expected, validation
def _reviewed_art_create_composite(root, receipt, depth):
"""Validate one privately staged original icon plus its original Create UI reference.
The intermediate asset COW remains private; only the final child is published.
"""
def require(ok, message):
if not ok:
raise ValueError(message)
def pinned(ref):
require(isinstance(ref, dict) and isinstance(ref.get('path'), str)
and isinstance(ref.get('sha256'), str) and len(ref['sha256']) == 64,
'Pinned composite input required')
require(digest(ref['path']) == ref['sha256'], 'Composite input identity differs')
return read(ref['path'])
parent_ref = receipt.get('parent_publication', {})
parent = _publication_proof(root, {'receipt_path':parent_ref.get('receipt_path'),
'composed_root':receipt.get('old_root'), 'validation_sha256':parent_ref.get('validation_sha256')},
historical=True, depth=depth+1)
require(parent['receipt_sha256'] == parent_ref.get('receipt_sha256'), 'Composite parent receipt differs')
inputs = receipt.get('inputs', {})
ancestry = pinned(inputs.get('registry_ancestry'))
before = pinned(inputs.get('parent_assets'))
after = pinned(inputs.get('assets'))
art = pinned(inputs.get('art_frames'))
art_cow = pinned(inputs.get('art_cow'))
art_sdk = pinned(inputs.get('art_sdk'))
ui = pinned(inputs.get('ui_frames'))
ui_cow = pinned(inputs.get('ui_cow'))
ui_sdk = pinned(inputs.get('ui_sdk'))
qualification = pinned(inputs.get('ui_qualification'))
frontend = pinned(inputs.get('ui_frontend'))
delta = pinned(inputs.get('delta_plan'))
rollback = pinned(inputs.get('rollback_plan'))
require(ancestry.get('status') == 'PASS_PINNED_R2_UI_FRAME_ANCESTRY_TO_32337_REGISTRY'
and ancestry.get('root') == parent['composed_root']
and ancestry.get('asset_manifest_sha256') == inputs['parent_assets']['sha256'],
'Pinned UI ancestry does not anchor asset registry')
chain = ancestry.get('chain')
require(isinstance(chain, list) and len(chain) == ancestry.get('ui_only_ancestors', 0)+1
and chain[0].get('publication_sha256') == parent['receipt_sha256'],
'Incomplete composite UI ancestry')
for index, item in enumerate(chain):
pub_path, frame_path = item.get('publication_path'), item.get('frame_path')
require(digest(pub_path) == item.get('publication_sha256') and digest(frame_path) == item.get('frame_sha256'),
'Composite ancestor identity differs')
pub, frame = read(pub_path), read(frame_path)
require(pub.get('composed_root') == item.get('root') == frame.get('root', {}).get('content_key')
and pub.get('inputs', {}).get('frames', {}).get('sha256') == item.get('frame_sha256'),
'Composite ancestor frame differs')
if index+1 < len(chain):
audit = frame.get('root_audit', {})
changes = audit.get('changes', [])
require(audit.get('all_other_root_bytes_identical') is True and changes
and all(v.get('file_data_id') in (5612385, 5613302, 8209459) for v in changes)
and frame.get('registered_asset_count') == parent['registered_assets']
and frame.get('new_asset_count') == 0
and pub.get('parent_publication', {}).get('sha256') == chain[index+1].get('publication_sha256')
and pub.get('inputs', {}).get('parent_frames', {}).get('sha256') == chain[index+1].get('frame_sha256'),
'Composite UI ancestor is not a preserved-assets transition')
else:
require(frame.get('asset_manifest_sha256') == inputs['parent_assets']['sha256'],
'Composite ancestor asset manifest differs')
old = {v['file_data_id']:v for v in before.get('assets', [])}
new = {v['file_data_id']:v for v in after.get('assets', [])}
ids = sorted(set(new)-set(old))
require(len(old) == len(before['assets']) == parent['registered_assets']
and len(new) == len(after['assets']) == len(old)+1 and ids == [8560810]
and all(new.get(k) == v for k,v in old.items())
and all(after['registry']['slots'].get(k) == v for k,v in before['registry']['slots'].items())
and after.get('source_icon_bindings') == before.get('source_icon_bindings'),
'Composite registry does not preserve parent assets')
icon = new[8560810]
require(icon.get('kind') == 'texture' and icon.get('native_group_control') == 143079
and after['registry']['slots'].get(icon.get('path')) == 8560810
and art.get('parent_root') == parent['composed_root']
and art.get('new_filedataid') == 8560810 and art.get('new_asset_count') == 1
and art.get('registered_asset_count') == len(new)
and art['icon_frame']['content_key'] == icon['content_key']
and art.get('root_audit', {}).get('original_id_and_content_key_prefixes_bit_identical') is True
and art.get('root_audit', {}).get('original_group_order_preserved') is True
and art.get('encoding_audit', {}).get('all_original_content_key_encoding_bindings_preserved') is True
and art.get('tvfs_child_audit', {}).get('old_cft_vfs_and_spec_prefixes_preserved') is True,
'Composite art stage does not preserve native assets')
require(art_cow.get('logical_parent_root') == parent['composed_root']
and art_cow.get('current_registered_asset_count') == len(new)
and art_cow.get('new_FileDataIDs') == 1
and art_sdk.get('status') == 'PASS_NEW_FDI_EXACT_NATIVE_SDK_READBACK'
and art_sdk.get('file_data_id') == 8560810 and art_sdk.get('content_key') == icon['content_key']
and art_sdk.get('sha256') == icon['sha256'] and art_sdk.get('size') == icon['bytes']
and art_sdk.get('candidate_root') == art['root']['content_key'], 'Art owning SDK boundary differs')
changes = ui.get('root_audit', {}).get('changes', [])
ui_rows = ui.get('native_UI_rows', [])
require(ui.get('parent_root') == art['root']['content_key']
and ui.get('registered_asset_count') == len(new) and ui.get('new_asset_count') == 0
and ui.get('root_audit', {}).get('all_other_root_bytes_identical') is True
and len(changes) == len(ui_rows) == 1 and changes[0].get('file_data_id') == 8209459
and ui_rows[0].get('file_data_id') == 8209459
and changes[0].get('new_content_key') == ui_rows[0]['frame']['content_key']
and ui_cow.get('logical_parent_root') == art['root']['content_key']
and ui_cow.get('reviewed_original_UI_overrides') == [8209459]
and ui_cow.get('new_FileDataIDs') == 0, 'Composite Create UI scope differs')
jobs = frontend.get('jobs', [])
outputs = jobs[0].get('outputs', []) if len(jobs) == 1 else []
require(qualification.get('status') == 'PASS_FOCUSED_PRIVATE_UNINSTALLED'
and qualification.get('portraits', {}).get('Furbolg') == 8560810
and qualification.get('candidate_sha256') == ui_rows[0]['candidate']['sha256']
and frontend.get('kind') == 'classic-to-forever-stage-v1' and frontend.get('installed') is False
and len(outputs) == 1 and outputs[0].get('sha256') == qualification['candidate_sha256']
and jobs[0].get('id') == 'create-menu' and jobs[0].get('native_accepted') is False,
'Composite Create source qualification differs')
observed = {v['file_data_id']:v for v in ui_sdk.get('rows', [])}
require(ui_sdk.get('status') == 'PASS_FINAL_CREATE_AND_NEW_FURBOLG_FDI_SDK_EXACT'
and ui_sdk.get('candidate_root') == ui['root']['content_key']
and ui_sdk.get('glue_unchanged') is True and set(observed) == {8209459,8560810}
and observed[8560810].get('content_key') == icon['content_key']
and observed[8560810].get('sha256') == icon['sha256']
and observed[8209459].get('content_key') == ui_rows[0]['frame']['content_key']
and observed[8209459].get('sha256') == qualification['candidate_sha256'],
'Composite final SDK boundary differs')
require(delta.get('required_parent_ROOT') == parent['composed_root']
and delta.get('intermediate_art_ROOT') == art['root']['content_key']
and delta.get('new_ROOT') == ui['root']['content_key'] == receipt.get('composed_root')
and delta.get('new_file_data_ids') == [8560810]
and delta.get('replaced_native_UI_file_data_ids') == [8209459]
and delta.get('parent_asset_count') == len(old) and delta.get('new_asset_count') == len(new),
'Composite physical delta scope differs')
indices = rollback.get('parent_index_files')
require(isinstance(indices, list) and len(indices) == 16 and indices == art_cow.get('parent_index_files')
and {r.get('bucket') for r in indices} == set(range(16))
and rollback.get('parent_root') == parent['composed_root']
and rollback.get('candidate_root') == receipt.get('composed_root')
and rollback.get('parent_build_info', {}).get('sha256') == parent['build_info_sha256']
and rollback.get('restore_parent_indices_before_candidate_deletion') is True
and rollback.get('derived_mapping_relative_namespace') == 'client/Data'
and rollback.get('derived_mapping_relatives') == ['data/shmem', 'ecache/shmem', 'wow_classic_beta/shmem']
and rollback.get('restore_stale_derived_maps') is False, 'Composite rollback contract differs')
files = delta.get('files')
def stage_relatives(cow):
config = cow.get('new_build_config')
hexchars = set('0123456789abcdef')
require(isinstance(config, str) and len(config) == 32 and set(config) <= hexchars,
'Invalid composite build configuration')
generations = cow.get('new_index_generations', [])
segments = cow.get('created_segments', [])
require(isinstance(generations, list) and generations and isinstance(segments, list) and segments
and all(isinstance(v.get('new_file'), str) and len(v['new_file']) == 14
and v['new_file'].endswith('.idx') and set(v['new_file'][:-4]) <= hexchars for v in generations)
and all(type(v) is int and 0 <= v <= 999 for v in segments), 'Invalid composite index or segment')
return ({f'Data/config/{config[:2]}/{config[2:4]}/{config}'}
| {'Data/data/' + v['new_file'] for v in generations}
| {f'Data/data/data.{v:03d}' for v in segments})
art_files, ui_files = stage_relatives(art_cow), stage_relatives(ui_cow)
require(isinstance(files, list) and files and len({v.get('relative') for v in files}) == len(files)
and files[-1].get('relative') == '.build.info'
and files[-1].get('action') == 'ATOMIC_BUILD_INFO_LAST'
and not (art_files & ui_files)
and {v.get('relative') for v in files} == art_files | ui_files | {'.build.info'}
and all(v.get('action') == 'COPY_NEW_NO_OVERWRITE' for v in files[:-1])
and all(type(v.get('bytes')) is int and v['bytes'] > 0
and isinstance(v.get('sha256'), str) and len(v['sha256']) == 64 for v in files),
'Composite physical file ordering differs')
art_store, ui_store = Path(inputs['art_cow']['path']).parent, Path(inputs['ui_cow']['path']).parent
require(all(Path(v['source']) == (art_store if v['relative'] in art_files else ui_store) / v['relative']
for v in files), 'Composite physical file source differs')
expected = dict(schema_version=5, applied=True, registered_assets=len(new), parent_registered_assets=len(old),
source_icon_bindings=parent['source_icon_bindings'], new_assets=1,
new_file_data_ids=[8560810], replaced_native_UI_file_data_ids=[8209459],
old_root=parent['composed_root'], framing_manifest_sha256=inputs['ui_frames']['sha256'],
metadata_package_sha256=parent['_receipt']['metadata_package_sha256'])
validation = dict(schema_version=5, kind='reviewed-original-art-create-composite-validation-v1', passed=True,
changed_assets=1, staged_native_SDK_FileID_bodies_exact=2, new_assets=1,
parent_index_preimages=16, derived_mapping_Data_relative=True,
metadata_rows_added=0, all_parent_records_and_aliases_preserved=True,
native_UI_runtime_acceptance_verified=False,
new_physical_delta_files_copied_and_hash_exact=len(files))
return expected, validation
def _reviewed_mixed_journal_lineage(root, receipt):
"""Validate saved applied clone journals as one explicitly limited publication."""
def require(ok, message):
if not ok:
raise ValueError(message)
def pin(ref):
require(isinstance(ref, dict) and isinstance(ref.get('path'), str)
and isinstance(ref.get('sha256'), str) and len(ref['sha256']) == 64,
'Pinned lineage evidence required')
require(digest(ref['path']) == ref['sha256'], 'Lineage evidence changed')
return read(ref['path'])
data=receipt['inputs']; anchor=pin(data['parent_receipt']); parent_validation=pin(data['parent_validation'])
require(anchor.get('applied') is True and parent_validation.get('passed') is True
and anchor.get('changed_validation_sha256') == data['parent_validation']['sha256']
and anchor.get('composed_root') == receipt.get('old_root')
and anchor.get('registered_assets') == 32338 and anchor.get('source_icon_bindings') == 841,
'Actual previously published anchor required')
steps=data['steps']; require(isinstance(steps,list) and len(steps)==9,'Nine recorded mixed steps required')
current=anchor['composed_root']; expected={}
for step in steps:
spec=pin(step['spec']);plan=pin(step['plan']);journal=pin(step['journal']);sdk=pin(step['sdk'])
require(spec.get('parent_root')==current and plan.get('spec_sha256')==step['spec']['sha256']
and plan.get('sdk_sha256')==step['sdk']['sha256']
and journal.get('plan_sha256')==step['plan']['sha256']
and journal.get('phase')=='APPLIED_EXPERIMENTAL'
and Path(spec.get('client_root','')).resolve()==root/'runtime/native-client'
and len(spec.get('parent_index_preimages',[]))==len(journal.get('indices',[]))==16,
'Mixed transition or genuine journal differs')
require([(x['relative'],x['sha256']) for x in journal['indices']]
==[(x['relative'],x['sha256']) for x in spec['parent_index_preimages']]
and [(x['relative'],x['sha256']) for x in journal['created']]
==[(x['relative'],x['sha256']) for x in spec['physical_files'][:-1]],
'Mixed journal indices or copied delta differs')
require(sdk.get('status','').startswith(('PASS_','PRIVATE_')),'Saved SDK evidence missing')
selected=sdk.get('fdids',sdk.get('selected_fdids',{}))
if isinstance(selected,dict):
expected.update({str(k):v for k,v in selected.items() if isinstance(v,str) and len(v)==32})
if sdk.get('native_icon_file_data_id') and sdk.get('source_content_key'):
expected[str(sdk['native_icon_file_data_id'])]=sdk['source_content_key']
current=spec['candidate_root']
spec=pin(data['final_spec']);plan=pin(data['final_plan']);journal=pin(data['final_journal'])
intermediate=pin(data['intermediate_sdk']);final=pin(data['final_sdk']);closure=pin(data['closure'])
require(spec['parent_root']==current and spec['candidate_root']==receipt['composed_root']
and plan['spec_sha256']==data['final_spec']['sha256']
and journal['plan_sha256']==data['final_plan']['sha256']
and journal['phase']=='APPLIED_EXPERIMENTAL'
and Path(spec['client_root']).resolve()==root/'runtime/native-client'
and len(spec['parent_index_preimages'])==len(journal['indices'])==16
and [(x['relative'],x['sha256']) for x in journal['indices']]
==[(x['relative'],x['sha256']) for x in spec['parent_index_preimages']]
and [(x['relative'],x['sha256']) for x in journal['created']]
==[(x['relative'],x['sha256']) for x in spec['physical_files'][:-1]]
and journal.get('build_sha256')==spec['physical_files'][-1]['sha256']
and journal.get('release_sha256')==data['applied_release']['sha256']
and digest(data['applied_release']['path'])==data['applied_release']['sha256'],
'Final actual CASC installation differs')
for row in intermediate+final:
require(row.get('known') is True and row.get('full_info_available') is True,'Final selector evidence incomplete')
expected[str(row['file_data_id'])]=row['content_key']
lookup=pin(data['final_lookup']);actual={str(row['file_data_id']):row.get('content_key') for row in lookup}
require(len(expected)==22 and len(actual)==22 and actual==expected
and closure.get('status')=='PASS_FINAL_FDI_CLOSURE' and closure.get('matched')==22
and closure.get('expected')==22 and closure.get('mismatches')=={},'Final FDI scope differs')
frame=pin(data['final_frame'])
require(frame['root']['content_key']==receipt['composed_root']
and frame.get('registered_asset_count')==32351
and frame.get('all_old_tvfs_paths_and_spans_preserved') is True,
'Final registered content frame differs')
wanted={'schema_version':1,'applied':True,'registered_assets':32351,'source_icon_bindings':841,
'published_build_info_sha256':spec['physical_files'][-1]['sha256']}
validation={'schema_version':1,'kind':'reviewed-mixed-journal-lineage-validation-v1','passed':True,
'historical_journal_steps':9,'final_parent_index_preimages':16,
'final_fdi_bindings_checked':22,'native_acceptance_verified':False,
'catalogue_wide_runtime_acceptance_verified':False}
return wanted,validation
def _reviewed_icon_ui_descendant(root, receipt, depth):
"""Consume one actually installed icon batch and its UI-only descendant."""
def require(ok, message):
if not ok:
raise ValueError(message)
parent_ref=receipt.get('parent_publication',{})
parent_path=Path(parent_ref.get('receipt_path','')).resolve()
runtime=next((p for p in Path(root).resolve().parents
if p.name=='runtime' and parent_path.is_relative_to(p)),None)
require(runtime is not None,'Shared owned publication runtime required')
def pinned(ref, *, parse=True):
require(isinstance(ref,dict) and isinstance(ref.get('path'),str) and
isinstance(ref.get('sha256'),str) and len(ref['sha256'])==64,
'Pinned icon/UI publication evidence required')
path=Path(ref['path']).resolve()
require(path.is_relative_to(runtime.resolve()) and digest(path)==ref['sha256'],
'Icon/UI publication evidence changed')
return read(path) if parse else None
parent=_publication_proof(root,dict(receipt_path=parent_ref.get('receipt_path'),
composed_root=receipt.get('old_root'),validation_sha256=parent_ref.get('validation_sha256')),
historical=True,depth=depth+1)
require(parent['receipt_sha256']==parent_ref.get('receipt_sha256') and
parent['registered_assets']==32351 and parent['source_icon_bindings']==841,
'Exact prior applied icon/UI parent required')
inputs=receipt.get('inputs',{})
icon=pinned(inputs.get('icon_cow'));icon_frame=pinned(inputs.get('icon_frame'))
ui=pinned(inputs.get('ui_cow'));ui_frame=pinned(inputs.get('ui_frame'))
coverage=pinned(inputs.get('combined_sdk'));icon_sdk=pinned(inputs.get('icon_sdk'))
ui_sdk=pinned(inputs.get('ui_sdk'));pinned(inputs.get('ui_readback'),parse=False)
icon_root=icon_frame.get('root',{}).get('content_key');combined=receipt.get('composed_root')
require(icon_frame.get('parent_root')==receipt.get('old_root') and
icon_frame.get('registered_asset_count')==34534 and icon_frame.get('new_asset_count')==2183 and
len(icon_frame.get('source_rows',[]))==2183 and
icon.get('logical_parent_root')==receipt.get('old_root') and
icon.get('current_registered_asset_count')==34534 and icon.get('new_FileDataIDs')==2183 and
icon.get('parent_index_preimages_preserved_independently_of_native_pruning') is True and
icon.get('derived_mapping_relative_namespace')=='client/Data' and len(icon.get('parent_index_files',[]))==16,
'Icon ROOT, saved framing or parent index scope differs')
changes=ui_frame.get('root_audit',{}).get('changes',[])
require(ui_frame.get('parent_root')==icon_root and ui_frame.get('root',{}).get('content_key')==combined and
ui_frame.get('root_audit',{}).get('all_other_root_bytes_identical') is True and
len(changes)==1 and changes[0].get('file_data_id')==8209459 and
ui.get('logical_parent_root')==icon_root and ui.get('original_build_config')==icon.get('new_build_config') and
ui.get('new_FileDataIDs')==0 and ui.get('current_registered_asset_count')==34534 and
ui.get('parent_index_preimages_preserved_independently_of_native_pruning') is True and
ui.get('derived_mapping_relative_namespace')=='client/Data' and len(ui.get('parent_index_files',[]))==16,
'One-FDI UI child or icon-parent rollback proof differs')
require(icon_sdk.get('status')=='PASS_2188_ICON_AND_TWO_UI_FDI_CKEYS' and
icon_sdk.get('candidate_root')==icon_root and icon_sdk.get('icons')==2188 and
icon_sdk.get('mismatches')==[] and
coverage.get('status')=='PASS_COMBINED_ICON_AND_UI_SDK_COVERAGE' and
coverage.get('icon_parent_root')==icon_root and coverage.get('candidate_root')==combined and
coverage.get('icon_sdk_sha256')==inputs['icon_sdk']['sha256'] and
coverage.get('ui_sdk_selector_sha256')==inputs['ui_sdk']['sha256'] and
coverage.get('ui_sdk_strict_readback_sha256')==inputs['ui_readback']['sha256'] and
coverage.get('file_data_id')==8209459 and
isinstance(ui_sdk,list) and len(ui_sdk)==1 and ui_sdk[0].get('known') is True and
ui_sdk[0].get('content_key')==coverage.get('content_key')==changes[0].get('new_content_key'),
'Combined icon and UI SDK evidence differs')
spec=pinned(inputs.get('action_spec'));plan=pinned(inputs.get('action_plan'));journal=pinned(inputs.get('action_journal'))
pinned(inputs.get('applied_release'),parse=False)
physical=spec.get('physical_files',[]);indices=spec.get('parent_index_preimages',[])
require(spec.get('target_root')==str(root) and spec.get('client_root')==str(root/'runtime/native-client') and
spec.get('parent_root')==receipt.get('old_root') and spec.get('intermediate_root')==icon_root and
spec.get('candidate_root')==combined and spec.get('candidate_build_config')==ui.get('new_build_config') and
len(physical)==25 and physical[-1].get('relative')=='.build.info' and
physical[-1].get('action')=='ATOMIC_BUILD_INFO_LAST' and
all(r.get('action')=='COPY_NEW_NO_OVERWRITE' for r in physical[:-1]) and len(indices)==16 and
plan.get('spec_sha256')==inputs['action_spec']['sha256'] and
journal.get('plan_sha256')==inputs['action_plan']['sha256'] and journal.get('phase')=='APPLIED_EXPERIMENTAL' and
[(x['relative'],x['sha256']) for x in journal.get('indices',[])]==[(x['relative'],x['sha256']) for x in indices] and
[(x['relative'],x['sha256']) for x in journal.get('created',[])]==[(x['relative'],x['sha256']) for x in physical[:-1]] and
journal.get('build_sha256')==physical[-1].get('sha256')==receipt.get('published_build_info_sha256') and
journal.get('release_sha256')==inputs['applied_release']['sha256'],
'Actual cold adoption journal or index-first rollback scope differs')
def physical_paths(cow):
key=cow['new_build_config']
require(isinstance(key,str) and len(key)==32 and all(c in '0123456789abcdef' for c in key),
'Unsafe build configuration identity')
paths={'Data/config/'+key[:2]+'/'+key[2:4]+'/'+key}
for row in cow['new_index_generations']:
name=row['new_file'];require(isinstance(name,str) and len(name)==14 and name.endswith('.idx') and
all(c in '0123456789abcdef' for c in name[:-4]),'Unsafe new index path')
paths.add('Data/data/'+name)
for segment in cow['created_segments']:
require(type(segment)is int and 0<=segment<=999,'Unsafe new segment')
paths.add('Data/data/data.%03d'%segment)
return paths
require({r['relative'] for r in physical}==physical_paths(icon)|physical_paths(ui)|{'.build.info'},
'Cold adoption includes files outside the exact two COW deltas')
final_meta=pinned(inputs.get('metadata_handoff'));nonwire_meta=pinned(inputs.get('nonwire_metadata_handoff'))
wire_meta=pinned(inputs.get('wire_metadata_handoff'));codec=pinned(inputs.get('codec_build'))
boundary=pinned(inputs.get('codec_boundary'));actual=pinned(inputs.get('installed_dependency'))
require(final_meta.get('status')=='PRIVATE_PRIOR_ICON_EVIDENCE_PINNED_WIRE_ROWS_UNCHANGED' and
final_meta.get('source_package_sha256')==nonwire_meta.get('package_sha256') and
nonwire_meta.get('wire_header_identical') is True and
nonwire_meta.get('source_package_sha256')==wire_meta.get('package_sha256') and
final_meta.get('header_sha256')==nonwire_meta.get('header_sha256')==wire_meta.get('header_sha256')==codec.get('metadata_header_sha256') and
final_meta.get('codec_sha256')==codec.get('codec_sha256')==boundary.get('codec_sha256') and
boundary.get('status')=='PASS_21335_CHANGED_ITEM_AND_NINE_RETAINED_DB_REPLIES_CORE_WIRE_CODEC_ABI' and
boundary.get('metadata_package_sha256')==wire_meta.get('package_sha256') and
boundary.get('changed_item_replies')==21335 and boundary.get('retained_definition_and_link_replies')==9 and
boundary.get('root')==combined and final_meta.get('combined_root')==combined and
actual.get('status')=='PASS_ACTUAL_INSTALLED_ICON_DEPENDENCY' and
actual.get('target')==str(root/'runtime/native-client') and
actual.get('metadata_package_sha256')==final_meta.get('package_sha256') and
actual.get('codec_sha256')==codec.get('codec_sha256') and actual.get('root_md5')==combined and
actual.get('items')==21335 and actual.get('textures')==2188 and
actual.get('prior_items')==841 and actual.get('prior_fdis')==459 and
actual.get('installed_root_dependency_verified') is True and actual.get('engine_rendering_verified') is False,
'Actual item dependency or metadata/codec wire lineage differs')
installed=read(root/'linux-release.json')
require(installed.get('runtime_file_sha256',{}).get('build/forever-schema/libforever_codec.so')==codec['codec_sha256'],
'Installed launcher codec pin differs')
expected=dict(schema_version=1,applied=True,registered_assets=34534,source_icon_bindings=22176,
old_root=receipt['old_root'],published_build_info_sha256=journal['build_sha256'])
validation=dict(schema_version=1,kind='reviewed-applied-icon-ui-descendant-validation-v1',passed=True,
new_item_icon_bindings=21335,retained_item_icon_bindings=841,
icon_fdis_checked=2188,retained_icon_fdis_checked=459,
parent_index_preimages=16,derived_mapping_Data_relative=True,
native_render_acceptance_verified=False,gameplay_acceptance_verified=False)
return expected,validation
def _publication_proof(root, declared, *, historical=False, depth=0):
"""Consume the same owning proof before a coordinator updates release pins."""
if depth > 32:
raise ValueError('Publication parent lineage bound exceeded')
if not isinstance(declared, dict) or not isinstance(declared.get('receipt_path'), str):
raise ValueError('Published client asset receipt is required')
path = Path(declared['receipt_path'])
receipt = read(path)
profiles = {
'closed-private-qa-material-publication-v1': (
{'schema_version': 1, 'applied': True, 'registered_assets': 6805,
'source_icon_bindings': 841, 'new_assets': 32},
{'passed': True, 'changed_assets': 32, 'fdid_resolutions_exact': 32,
'strict_ckey_payloads_exact': 32, 'warrior_ui_preserved': True,
'all_parent_records_and_aliases_preserved': True}),
'closed-private-material-delta-publication-v2': (
{'schema_version': 2, 'applied': True, 'registered_assets': 7866,
'source_icon_bindings': 841, 'new_assets': 1061},
{'schema_version': 2, 'kind': 'reused-completed-material-delta-validation-v2',
'passed': True, 'changed_assets': 1061,
'registered_root_and_payloads_exact': 1061,
'staged_CASC_representatives': 4,
'staged_CASC_representatives_byte_exact': 4,
'warrior_ui_preserved': True,
'all_parent_records_and_aliases_preserved': True,
'native_render_acceptance_verified': False}),
'closed-private-equipment-delta-publication-v3': (
{'schema_version': 3, 'applied': True, 'parent_registered_assets': 7866,
'registered_assets': 7871, 'source_icon_bindings': 841, 'new_assets': 5,
'old_root': 'edf3875d93cc173bb39d3bee42598e98'},
{'schema_version': 3, 'kind': 'reused-completed-equipment-delta-validation-v3',
'passed': True, 'changed_assets': 5,
'staged_native_SDK_FileID_bodies_exact': 5, 'metadata_rows_added': 7,
'warrior_ui_preserved': True,
'all_parent_records_and_aliases_preserved': True,
'native_render_acceptance_verified': False}),
}
selected = (_reviewed_icon_ui_descendant(root, receipt, depth)
if receipt.get('kind') == 'closed-private-applied-icon-ui-descendant-publication-v1'
else _reviewed_mixed_journal_lineage(root, receipt)
if receipt.get('kind') == 'closed-private-journaled-mixed-lineage-publication-v1'
else _reviewed_original_ui_replacement(receipt)
if receipt.get('kind') in ('closed-private-original-UI-replacement-publication-v1',
'closed-private-chained-original-UI-replacement-publication-v2',
'closed-private-evidence-chained-original-UI-publication-v3',
'closed-private-evidence-chained-original-UI-single-publication-v4')
else _reviewed_art_create_composite(root, receipt, depth)
if receipt.get('kind') == 'closed-private-original-art-create-composite-publication-v1'
else _generic_asset_lineage(root, receipt, depth)
if receipt.get('kind') == 'closed-private-asset-lineage-publication-v4'
else _generic_equipment_delta(root, receipt, depth) if receipt.get('kind') == 'closed-private-equipment-delta-publication-v4' else profiles.get(receipt.get('kind')))
if selected is None:
raise ValueError('Unreviewed published client receipt')
expected, expected_validation = selected
if any(type(receipt.get(k)) is not type(v) or receipt.get(k) != v for k, v in expected.items()):
raise ValueError('Unreviewed published client receipt')
if (Path(receipt.get('target', '')).resolve() != root / 'runtime/native-client'
or receipt.get('composed_root') != declared.get('composed_root')
or receipt.get('changed_validation_sha256') != declared.get('validation_sha256')):
raise ValueError('Publication differs from source manifest')
validation_path = path.parent / 'changed-validation.json'
if digest(validation_path) != receipt['changed_validation_sha256']:
raise ValueError('Changed-asset validation identity differs')
validation = read(validation_path)
expected = expected_validation
if (any(type(validation.get(k)) is not type(v) or validation.get(k) != v for k, v in expected.items())
or validation.get('composed_root') != receipt['composed_root']):
raise ValueError('Published asset boundary is not validated')
if not historical and digest(root / 'runtime/native-client/.build.info') != receipt.get('published_build_info_sha256'):
raise ValueError('Published client build identity changed')
result = {'receipt_sha256': digest(path), 'validation_sha256': digest(validation_path),
'composed_root': receipt['composed_root'], 'registered_assets': receipt['registered_assets'],
'source_icon_bindings': receipt['source_icon_bindings'], 'build_info_sha256': receipt['published_build_info_sha256']}
if historical:
result['_receipt'] = receipt
return result
def reviewed_compacted_client(source_root, receipt_path, *, source_publication=None):
"""Consume an owning fresh-compaction check; never mutate source/publication.
Compaction changes physical metadata/config/index placement, not any current
FDI, CKey, appearance or definition. It is not an additive-asset publication.
This build-time input is not required after the standalone folder is staged.
"""
root=Path(source_root).resolve()
proof=published_source(root)if source_publication is None else source_publication
if proof is None:raise ValueError('Reviewed published current source required')
path=Path(receipt_path);receipt=read(path)
if (receipt.get('kind')!='fresh-current-root-compact-casc-delivery-v1'
or receipt.get('status')!='PASS_FRESH_CURRENT_ROOT_COMPACT_CASC_DELIVERY'
or receipt.get('source_publication')!=proof
or receipt.get('composed_root')!=proof['composed_root']
or receipt.get('registered_assets')!=proof['registered_assets']):
raise ValueError('Compaction changes current logical publication')
ref=receipt.get('owning_validation',{})
if not isinstance(ref.get('path'),str)or digest(ref['path'])!=ref.get('sha256'):
raise ValueError('Pinned owning compact-output validation required')
validation=read(ref['path'])
if (validation.get('status')!='PASS_COMPACT_CURRENT_ROOT_STORAGE_AND_REFERENCES'
or validation.get('source_publication')!=proof
or any(validation.get(k)!=receipt.get(k)for k in
('composed_root','registered_assets','new_build_config','base_files','generated_files'))):
raise ValueError('Owning compact-output identity differs')
required=('logical_ROOT_byte_identical','current_registered_bindings_preserved',
'original_baseline_content_preserved','original_native_fill_content_preserved',
'historical_overlay_metadata_omitted','current_root_index_reference_closure',
'all_original_TVFS_paths_and_spans_preserved')
if any(validation.get(k)is not True for k in required):
raise ValueError('Complete original/current compact-store closure required')
client=root/'runtime/native-client';files=[];seen=set()
base=receipt.get('base_files');generated=receipt.get('generated_files')
if not isinstance(base,list)or not base or not isinstance(generated,list)or not generated:
raise ValueError('Explicit compact baseline and generated file lists required')
for row,kind in [(r,'base')for r in base]+[(r,'generated')for r in generated]:
relative=row.get('relative');rel=Path(relative or '')
if (not isinstance(relative,str)or rel.is_absolute()or '..'in rel.parts or relative in seen
or type(row.get('bytes'))is not int or row['bytes']<=0):
raise ValueError('Unique bounded compact file identity required')
if kind=='base':
if len(rel.parts)!=3 or rel.parts[:2]!=('Data','data'):
raise ValueError('Baseline reuse limited to immutable Data/data files')
expected=client/rel
if Path(row['source']).resolve()!=expected.resolve():
raise ValueError('Baseline must use local published source, not VM/base copies')
source=expected
else:
source=Path(row['source'])
allowed=(relative=='.build.info'or
len(rel.parts)==3 and rel.parts[:2]==('Data','data')or
len(rel.parts)==5 and rel.parts[:2]==('Data','config'))
if not allowed:raise ValueError('Unrelated compact file override rejected')
if not source.is_absolute():raise ValueError('Absolute owning generated file required')
if source.is_symlink()or not source.is_file()or source.stat().st_size!=row['bytes']:
raise ValueError('Qualified compact source file extent changed')
seen.add(relative);files.append(dict(row,source=str(source)))
info=[r for r in files if r['relative']=='.build.info']
if len(info)!=1 or digest(info[0]['source'])!=receipt.get('build_info_sha256'):
raise ValueError('Actual compact build identity differs')
build=receipt.get('new_build_config')
if not isinstance(build,str)or len(build)!=32 or any(c not in'0123456789abcdef'for c in build):
raise ValueError('Exact compact build key required')
return dict(receipt,base_files=[r for r in files if r['relative'].startswith('Data/data/')and r['relative']in{v['relative']for v in base}],
generated_files=[r for r in files if r['relative']in{v['relative']for v in generated}],
owning_validation_sha256=ref['sha256'])
def retained_bar_package(source_root, client_target, *, declared_publication=None, compacted_content=None):
"""No asset payload reads or CASC edits; consume the owning boundary proof."""
proof = (published_source(source_root) if declared_publication is None else
_publication_proof(Path(source_root).resolve(), declared_publication))
if proof is None:
return None
from warrior_action_bar_ui import FID, SOURCE_SHA, PATCH_SHA
target = Path(client_target)
expected_build_info=proof['build_info_sha256']
if compacted_content is not None:
if compacted_content.get('source_publication')!=proof:raise ValueError('Compacted source publication changed')
expected_build_info=compacted_content['build_info_sha256']
if digest(target / '.build.info') != expected_build_info:
raise ValueError('Copied publication identity differs')
lines = (target / '.build.info').read_text().splitlines()
headers = [x.split('!')[0] for x in lines[0].split('|')]
active = [dict(zip(headers, x.split('|'))) for x in lines[1:] if x.strip()]
active = [x for x in active if x.get('Active') == '1']
if len(active) != 1 or active[0].get('Version') != '1.60.1.70334':
raise ValueError('Published client active build differs')
report = {'kind': 'retained-published-controller-and-item-assets-v1', 'file_data_id': FID,
'source_sha256': SOURCE_SHA, 'patched_source_sha256': PATCH_SHA,
'original_branch_only': True, 'registered_asset_count': proof['registered_assets'],
'source_icon_bindings': proof['source_icon_bindings'],
'all_old_tvfs_paths_and_spans_preserved': True,
'root_audit': {'new_content_key': proof['composed_root']}, 'owning_publication': proof,
'native_engine_acceptance_verified': False, 'new_build_config': active[0]['Build Key']}
path = target / 'warrior-action-bar-casc.json'
path.write_text(json.dumps(report, indent=2) + '\n')
if compacted_content is not None:
if active[0]['Build Key']!=compacted_content['new_build_config']:raise ValueError('Compacted active build differs')
report['physical_archive_spans_repacked']=True
report['compacted_storage_validation_sha256']=compacted_content['owning_validation_sha256']
report['files'] = {'runtime/native-client/.build.info': expected_build_info,
'runtime/native-client/warrior-action-bar-casc.json': digest(path)}
return report
def ui_load_entries(toc):
"""Read the ordinary Lua modules from the maintained addon's manifest."""
import re
entries = [line.strip() for line in toc.decode('utf-8').splitlines()
if line.strip() and not line.lstrip().startswith('#')]
if (not entries or len(entries) != len(set(entries))
or any(not re.fullmatch(r'[A-Za-z0-9_]+\.lua', entry) for entry in entries)):
raise ValueError('Native UI manifest requires distinct local Lua filenames')
return entries
def discard_copied_packaged_addons(client_target, *, addon_names=None, ui_toc=None):
"""Regenerate only our declared addons in a fresh release copy, never its source."""
root = Path(client_target)
diagnostic_core = {'GatewayDiagnostics.toc', 'GatewayDiagnostics.lua', 'SessionObserver.lua'}
diagnostic_legacy = {'TurtleTalents.lua', 'TurtleTalentProvider.lua', 'TurtleData.lua',
'SourceWeaponDamage.lua', 'SourceWeaponDamageData.lua'}
diagnostic_native = {'EquipmentVisibility.lua', 'NativeModelProbe.lua'}
ui_previous = {'WoWHybridUI.toc', 'NativeNameplates.lua',
'NativeProfessionsBook.lua', 'NativeCharacterStats.lua',
'NativeProfessionBorderData.lua', 'NativeProfessionIcons.lua'}
ui_current = ui_previous | {'NativeEquipmentVisibility.lua'}
ui_talents = {'TurtleData.lua', 'TurtleTalentProvider.lua', 'TurtleTalents.lua'}
folders = {
# Legacy duplicate of the profession files already loaded by WoWHybridUI.
'WoWHybridProfessionIcons': {'WoWHybridProfessionIcons.toc', 'NativeProfessionBorderData.lua', 'NativeProfessionIcons.lua'},
# The reporter and diagnostic addon remain available in private test copies.
'WoWHybridIssueReporter': {'WoWHybridIssueReporter.toc', 'IssueReporter.lua'},
'GatewayDiagnostics': (diagnostic_core | diagnostic_native,
diagnostic_core | diagnostic_legacy,
diagnostic_core | diagnostic_legacy | diagnostic_native),
# Only the fresh release copy is cleaned before the canonical UI addon
# is staged. The source installation and its preferences stay intact.
'WoWHybridUI': (ui_previous, ui_current,
ui_previous | ui_talents, ui_current | ui_talents),
'WoWHybridWarriorStance': {'WoWHybridWarriorStance.toc', 'SourcePolicies.lua', 'WarriorStance.lua'},
}
if ui_toc is not None:
canonical = {'WoWHybridUI.toc', *ui_load_entries(ui_toc)}
folders['WoWHybridUI'] += (canonical, canonical | ui_talents)
if addon_names is not None:
if (not isinstance(addon_names, (tuple, list)) or
any(not isinstance(name, str) for name in addon_names) or
len(addon_names) != len(set(addon_names)) or
any(name not in folders for name in addon_names)):
raise ValueError('Known distinct packaged addon names required')
folders = {name: folders[name] for name in addon_names}
base = root / '_classic_beta_/Interface/AddOns'
for p in [root, root/'_classic_beta_', root/'_classic_beta_/Interface', base]:
if p.is_symlink():
raise ValueError('Copied addon parent is a symlink')
# Validate every owned folder before changing any one of them.
present = []
for folder, names in folders.items():
path = base / folder
if not path.exists() and not path.is_symlink():
continue
if path.is_symlink() or not path.is_dir():
raise ValueError('Copied owned addon directory is not regular')
files = list(path.iterdir())
allowed = names if isinstance(names, tuple) else (names,)
if any(p.is_symlink() or not p.is_file() for p in files):
raise ValueError('Copied addon has undeclared files')
found = {p.name for p in files}
if found not in allowed:
# A previous native UI may predate additions to the maintained manifest.
if not (folder == 'WoWHybridUI' and ui_toc is not None and
'WoWHybridUI.toc' in found and found <= canonical | ui_talents):
raise ValueError('Copied addon has undeclared files')
prior = {'WoWHybridUI.toc', *ui_load_entries((path/'WoWHybridUI.toc').read_bytes())}
if found not in (prior, prior | ui_talents):
raise ValueError('Copied addon has undeclared files')
present.append((path, files))
for folder, files in present:
for path in files:
path.unlink()
folder.rmdir()