Files
WoW-Hybrid-gateway/ops/classic_to_forever.py
praxisandClaude Fable 5.2 8a24c445b0 Content pipeline and operator tools
367 files, from working commit b1a079a.

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

1951 lines
141 KiB
Python

#!/usr/bin/env python3
"""One staging-only Classic -> Forever batch entry point.
REA contracts, snapshots and catalogues are immutable JSON references. Planning
joins their metadata once; only changed conversion jobs read original payloads.
Existing native assets are preserved. Source icons are the sole replacement
exception. Conversion receipts describe private candidates, never client fixes.
"""
from pathlib import Path
import argparse
import copy
import errno
import hashlib
import json
import os
import re
import sys
KIND = 'classic-to-forever-v1'
SHA = re.compile(r'[0-9a-f]{64}')
ID = re.compile(r'[A-Za-z0-9_.-]{1,100}')
SCOPES = {
'maps': ('map-batch', ['geometry', 'terrain-materials', 'placements', 'dependencies', 'world-transition']),
'travel': (None, ['route-definition', 'transport-lifecycle', 'arrival']),
'models': ('map-batch', ['geometry', 'materials', 'attachments', 'animation', 'dependencies']),
'textures': ('blp-stage', ['decode', 'material-binding', 'native-loader']),
'icons': ('icon-stage', ['decode', 'source-selection', 'icon-binding', 'native-loader']),
'items': (None, ['catalogue-fields', 'green-properties', 'set-relationships', 'tooltips']),
'equipment': (None, ['appearance-selector', 'race-sex-attachment', 'materials']),
'races': (None, ['race-sex-selector', 'character-create-select', 'world-appearance']),
'spells': (None, ['definition', 'cast-result', 'cooldown', 'tooltip']),
'talents': (None, ['catalogue', 'allocation', 'inspection', 'native-events']),
'auras': (None, ['update-fields', 'lifecycle', 'buff-debuff-ui']),
'reputation': (None, ['faction-definitions', 'standing-updates', 'native-listeners']),
'combat': (None, ['request-admission', 'server-result', 'state-synchronization']),
'quests': (None, ['catalogue', 'request-response', 'progress', 'rewards']),
'npc': (None, ['gossip-order', 'dialogue', 'interaction-lifecycle']),
'ui': (None, ['original-control-contract', 'native-events', 'interaction']),
'social': (None, ['recipient-resolution', 'packet-framing', 'delivery', 'native-events']),
'bank': (None, ['open-close', 'slot-mapping', 'transaction-completion']),
'mail': (None, ['open-close', 'payload', 'item-transaction']),
'auction': (None, ['open-close', 'query-response', 'transaction']),
'auth': (None, ['login-lifecycle', 'reconnect', 'account-switch']),
'protocol': (None, ['dispatch', 'payload-framing', 'field-semantics', 'listeners']),
'runtime': (None, ['process-lifecycle', 'session-ownership', 'exit']),
'build': (None, ['coherent-registered-root', 'metadata-bindings', 'storage-closure']),
'package': (None, ['retained-assets', 'portable-launch', 'cold-adoption', 'native-start']),
}
ADAPTERS = {
'map-batch': {'api': 'map_conversion_batch.convert_batch', 'scopes': ['maps', 'models'],
'stage': 'private-conversion', 'native_receipt': 'classic-to-forever-native-acceptance-v1'},
'icon-stage': {'api': 'octo_icon_assets.decode_blp', 'scopes': ['icons'],
'stage': 'private-artwork', 'native_receipt': 'classic-to-forever-native-acceptance-v1'},
'blp-stage': {'api': 'octo_icon_assets.decode_blp', 'scopes': ['textures'],
'stage': 'private-texture', 'native_receipt': 'classic-to-forever-native-acceptance-v1'},
}
# These entries describe executable *stages*, not completed game features.
for _scope in ('items', 'equipment', 'races', 'spells', 'auras', 'reputation', 'talents', 'quests', 'npc', 'ui'):
SCOPES[_scope] = ('classic-data', SCOPES[_scope][1])
for _scope in ('travel', 'social', 'bank'):
SCOPES[_scope] = ('observation-stage', SCOPES[_scope][1])
for _scope in ('protocol', 'package'):
SCOPES[_scope] = ('public-profile-stage', SCOPES[_scope][1])
SCOPES['build'] = ('casc-frame-stage', SCOPES['build'][1])
ADAPTERS.update({
'classic-data': {'api': 'classic_data_adapters.convert_batch',
'scopes': ['items', 'equipment', 'races', 'spells', 'auras', 'reputation', 'talents', 'quests', 'npc', 'ui'],
'stage': 'qualified-definition-or-association-only', 'runtime_candidate': True,
'native_receipt': 'classic-to-forever-native-acceptance-v1'},
'observation-stage': {'api': 'octo_travel_capture.extract_saved|octo_social_capture.extract|octo_guild_bank_capture.extract',
'scopes': ['travel', 'social', 'bank'], 'stage': 'rea-observation-only', 'runtime_candidate': False,
'native_receipt': 'classic-to-forever-native-acceptance-v1'},
'public-profile-stage': {'api': 'package_octo_protocol.package_protocol',
'scopes': ['protocol', 'package'], 'stage': 'public-protocol-files-only', 'runtime_candidate': False,
'native_receipt': 'classic-to-forever-native-acceptance-v1'},
'casc-frame-stage': {'api': 'casc_asset_package.stage_framed_native_assets',
'scopes': ['build'], 'stage': 'offline-casc-framing-only', 'runtime_candidate': False,
'native_receipt': 'classic-to-forever-native-acceptance-v1'},
})
ADAPTERS['saved-taxi-stage'] = {'api': 'taxi_profile.reuse_saved_routes', 'scopes': ['travel'],
'stage': 'saved-static-taxi-assessment-only', 'runtime_candidate': False,
'native_receipt': 'classic-to-forever-native-acceptance-v1'}
ADAPTERS['saved-area-profile-stage'] = {'api': 'map_asset_preflight.reuse_saved_outdoor_area_profiles',
'scopes': ['maps'], 'stage': 'saved-outdoor-area-assessment-only', 'runtime_candidate': False,
'native_receipt': 'classic-to-forever-native-acceptance-v1'}
ADAPTERS['saved-emerald-wdt-stage'] = {'api': 'map_conversion_batch.reuse_saved_emerald_wdt',
'scopes': ['maps'], 'stage': 'saved-emerald-wdt-assessment-only', 'runtime_candidate': False,
'native_receipt': 'classic-to-forever-native-acceptance-v1'}
ADAPTERS['saved-map-components-stage'] = {'api': 'qualified saved map-conversion-batch report',
'scopes': ['maps'], 'stage': 'saved-private-map-components-only', 'runtime_candidate': False,
'native_receipt': 'classic-to-forever-native-acceptance-v1'}
ADAPTERS['saved-source-map-art-stage'] = {'api': 'map_conversion_batch.reuse_saved_source_worldmap_art',
'scopes': ['maps'], 'stage': 'saved-source-map-art-profile-only', 'runtime_candidate': False,
'native_receipt': 'classic-to-forever-native-acceptance-v1'}
SCOPE_BLOCKS = {
'talents': 'No qualified pure talent-definition/allocation/inspection writer; classic-data reports this operation held.',
'quests': 'No qualified pure quest catalogue/request/progress/reward writer; original server/native relationships remain required.',
'npc': 'No qualified pure dialogue/gossip interaction writer; payload and menu lifecycle semantics remain unresolved.',
'ui': 'No qualified general UI-control/event writer; installing observer code would not implement native behavior.',
'travel': 'Observation extraction only; transport boarding, movement, arrival and transitions need qualified runtime implementation/proofs.',
'social': 'Observation extraction only; delivery/recipient resolution and native event listeners are not implemented by summary extraction.',
'bank': 'Guild-bank addon observations only; ordinary bank slot transactions and completion are separate unresolved runtime behavior.',
'protocol': 'Public version/addon profile files only; opcode semantics, framing and native listeners need qualified gateway changes.',
'package': 'Public protocol files only; complete release composition and portable client/native-start acceptance remain separate.',
'build': 'Registered-CASC framing only; no compilation, physical archive assembly, adoption or native acceptance.',
'combat': 'No pure offline producer can implement request admission/server result/native-state synchronization; qualified gateway dispatch changes required.',
'mail': 'No qualified fixed mail lifecycle/item-transaction producer; generic metadata or social summaries cannot implement mail.',
'auction': 'No qualified fixed auction query/transaction producer; packet framing, catalogue closure and native listeners required.',
'auth': 'No offline adapter for authentication/reconnect/account-switch state machines; public protocol files alone do not implement login.',
'runtime': 'No stage-only producer for live process/session/exit behavior; native/runtime changes and owned-session acceptance required.',
}
SCOPES['ui'] = ('creation-menu-ui', SCOPES['ui'][1])
ADAPTERS['creation-menu-ui'] = {'api': 'single_name_creation_ui.transform', 'scopes': ['ui'],
'stage': 'private-original-creation-menu-only', 'runtime_candidate': True,
'optional_future_placeholders': 'explicit pinned inert native portraits; private staging only',
'native_receipt': 'classic-to-forever-native-acceptance-v1'}
ADAPTERS['source-realm-ui'] = {'api': 'source_realm_ui.transform+transform_glue', 'scopes': ['ui'],
'stage': 'private-original-source-realm-ui-pair-only', 'runtime_candidate': True,
'optional_login_diagnostic': 'explicit pinned qualification; private staging only',
'optional_local_loopback_login': 'explicit profile-5 loopback, build and UI qualifications; private staging only',
'native_receipt': 'classic-to-forever-native-acceptance-v1'}
ADAPTERS['registered-item-icon-stage'] = {'api': 'item_icon_native_assets.stage', 'scopes': ['icons'],
'stage': 'private-registered-source-item-icons-only', 'runtime_candidate': True,
'native_receipt': 'classic-to-forever-native-acceptance-v1'}
SCOPE_BLOCKS['ui'] = 'Qualified original character-create and Source realm UI transforms are staged; general UI behavior and native9/10 admission remain separate.'
REUSABLE_STATES = {'UI_PATCH_STAGED', 'CONVERTED_PRIVATE', 'ICON_REGISTERED_PRIVATE', 'REUSED', 'PRESERVED_NATIVE', 'REUSED_PREVIOUS',
'OBSERVATION_STAGED', 'PUBLIC_PROFILE_STAGED', 'CASC_FRAMED_PRIVATE', 'TAXI_ASSESSMENT_STAGED',
'AREA_ASSESSMENT_STAGED', 'MAP_ASSESSMENT_STAGED', 'MAP_COMPONENTS_REUSED'}
def require(ok, reason):
if not ok:
raise ValueError(reason)
def encoded(value):
return (json.dumps(value, sort_keys=True, indent=2, allow_nan=False) + '\n').encode()
def digest(raw):
return hashlib.sha256(raw).hexdigest()
def good_status(value):
return isinstance(value, str) and value.startswith(('PASS', 'QUALIFIED', 'COMPLETE'))
class Pins:
"""Cache bounded pinned metadata, not unselected source payloads."""
def __init__(self, base):
self.base = Path(base).resolve()
self.cache = {}
self.identities = {}
def path(self, ref):
require(isinstance(ref, dict) and isinstance(ref.get('path'), str), 'pinned path required')
require(isinstance(ref.get('sha256'), str) and SHA.fullmatch(ref['sha256']), 'pinned SHA256 required')
path = Path(ref['path'])
path = path if path.is_absolute() else self.base / path
require(not path.is_symlink() and path.is_file(), 'regular pinned file required')
return path.resolve()
def read(self, ref, maximum=16 * 1024 * 1024):
path = self.path(ref)
st = path.stat()
ident = (st.st_dev, st.st_ino, st.st_size, st.st_mtime_ns)
key = (str(path), ref['sha256'])
if key not in self.cache:
require(0 < st.st_size <= maximum, 'bounded pinned input required')
raw = path.read_bytes()
require(digest(raw) == ref['sha256'], 'pinned input hash differs')
if 'bytes' in ref:
require(ref['bytes'] == len(raw), 'pinned byte extent differs')
self.cache[key] = raw
self.identities[str(path)] = ident
return self.cache[key]
def json(self, ref):
obj = json.loads(self.read(ref))
require(isinstance(obj, dict), 'pinned JSON object required')
return obj
def absolute(self, ref):
return dict(ref, path=str(self.path(ref)))
def stable(self):
for name, before in self.identities.items():
st = Path(name).stat()
require(before == (st.st_dev, st.st_ino, st.st_size, st.st_mtime_ns), 'pinned input changed during batch')
def artifact_token(path):
st = Path(path).stat()
return {'device': st.st_dev, 'inode': st.st_ino, 'bytes': st.st_size, 'mtime_ns': st.st_mtime_ns}
def stage_status_counts(jobs):
states = REUSABLE_STATES | {'HELD'} | {row['status'] for row in jobs}
return {status: sum(row['status'] == status for row in jobs) for status in sorted(states)}
def producer_pins(adapter, parameters):
names = ['classic_to_forever.py']
if adapter == 'map-batch':
names.append('map_conversion_batch.py')
kinds = {j.get('kind') for j in parameters.get('batch', {}).get('jobs', [])}
if kinds & {'adt', 'wmo-root', 'wmo-group', 'wdl', 'wdt'}:
names.append('map_asset_preflight.py')
if 'm2' in kinds:
names += ['m2_equipment_convert.py', 'm2_format_compare.py', 'm2_track_convert.py']
elif adapter == 'creation-menu-ui':
names.append('single_name_creation_ui.py')
elif adapter == 'source-realm-ui':
names.append('source_realm_ui.py')
if parameters.get('operation') != 'local-loopback-no-preflight':
names += ['../compat/glue/source_realm_provider.lua',
'../compat/glue/source_realm_list_adapter.lua', '../compat/glue/source_realm_glue_adapter.lua']
if parameters.get('login_diagnostic') is not None:
names.append('../compat/glue/source_login_diagnostic.lua')
elif adapter == 'registered-item-icon-stage':
names += ['item_icon_native_assets.py', 'item_sparse_compat.py', 'item_package_preflight.py',
'item_batch_stage.py', 'item_basic_compat.py', 'octo_icon_assets.py',
'item_icon_preflight.py', 'octo_client_data.py', 'turtle_data.py',
'casc_asset_package.py', 'casc_tvfs.py']
elif adapter == 'classic-data':
names.append('classic_data_adapters.py')
from classic_data_adapters import ADAPTERS as data_adapters
for child in parameters.get('batch', {}).get('jobs', []):
if child.get('operation') == 'reputation.factions':
names += ['faction_compat.py', 'item_sparse_compat.py']
if child.get('operation') == 'spells.package-warrior':
names += ['content_package_stage.py', 'item_sparse_compat.py',
'spell_passive_compat.py', 'spell_shield_slam_compat.py',
'spell_active_warrior_compat.py']
if child.get('operation') == 'races.creation-rows':
names.append('source_race_class_creation.py')
if child.get('operation') == 'races.starting-outfits':
names.append('source_starting_outfit_compat.py')
if child.get('operation') in ('equipment.native-appearance-links',
'equipment.missing-native-links',
'equipment.compose-native-links'):
names.append('item_sparse_compat.py')
if child.get('operation') in ('equipment.native-appearance-links',
'equipment.missing-native-links'):
names.append('turtle_data.py')
if child.get('operation') == 'equipment.native-appearance-links':
names.append('item_appearance_preflight.py')
if child.get('operation') in ('spells.package-passive', 'spells.package-crafting',
'spells.package-proc'):
names += ['item_sparse_compat.py', 'spell_passive_compat.py']
if child.get('operation') == 'spells.package-crafting':
names.append('spell_crafting_compat.py')
if child.get('operation') == 'spells.package-proc':
names += ['spell_item_proc_compat.py', 'spell_restore_compat.py',
'spell_item_food_regen_compat.py']
if child.get('operation') in ('items.sets', 'items.set-relationships'):
names.append('item_sparse_compat.py')
if child.get('operation') == 'items.set-relationships':
names.append('item_set_compat.py')
if child.get('operation') in ('items.catalog-metadata-batch',
'items.intrinsic-armor-batch'):
# Both composers validate source hashes and encode/package
# sparse records through these shared modules.
names += ['item_batch_stage.py', 'item_sparse_compat.py']
if child.get('operation') == 'items.catalog-metadata-batch':
names.append('item_basic_compat.py')
if child.get('operation') == 'items.property-catalogue-assessment':
names += ['item_property_catalogue.py', 'item_effect_compat.py']
if child.get('operation') == 'auras.source-family-merge':
names.append('aura_source_family_profile.py')
if child.get('operation') == 'auras.disarm-family-merge':
names.append('aura_disarm_profile.py')
if child.get('operation') in data_adapters:
producer = data_adapters[child['operation']][0]
filename = Path(producer.__code__.co_filename)
if filename.parent.resolve() == Path(__file__).resolve().parent:
names.append(filename.name)
elif adapter == 'observation-stage':
names.append({'travel-observation': 'octo_travel_capture.py', 'social-observation': 'octo_social_capture.py',
'guild-bank-observation': 'octo_guild_bank_capture.py'}[parameters.get('operation')])
elif adapter == 'public-profile-stage':
names += ['package_octo_protocol.py', 'engine_login_input_binding.py']
elif adapter == 'casc-frame-stage':
names += ['casc_asset_package.py', 'casc_tvfs.py']
elif adapter == 'saved-taxi-stage':
names.append('taxi_profile.py')
elif adapter == 'saved-area-profile-stage':
names.append('map_asset_preflight.py')
elif adapter in ('saved-emerald-wdt-stage', 'saved-source-map-art-stage'):
names.append('map_conversion_batch.py')
else:
names.append('octo_icon_assets.py')
ops = Path(__file__).resolve().parent
return {name: digest((ops / name).read_bytes()) for name in names}
def registry():
return {'kind': 'classic-to-forever-scope-registry-v1', 'scopes': {
scope: {'adapter': adapter, 'status': ('HELD_NO_QUALIFIED_PRODUCER' if scope in ('talents', 'quests', 'npc') else 'EXECUTABLE_PRIVATE_STAGE') if adapter else 'HELD_NO_QUALIFIED_PRODUCER',
'acceptance_criteria': criteria, 'remaining_behavior_block': SCOPE_BLOCKS.get(scope),
'behavior_implemented': False} for scope, (adapter, criteria) in SCOPES.items()},
'adapters': ADAPTERS, 'asset_policy': 'preserve-native-except-explicit-source-icons',
'installed': False, 'native_accepted': False}
def read_request(request, base_directory=None):
if isinstance(request, dict):
return copy.deepcopy(request), Path(base_directory or Path.cwd()).resolve()
path = Path(request).resolve()
require(path.is_file() and not Path(request).is_symlink() and path.stat().st_size <= 8 * 1024 * 1024,
'bounded request file required')
return json.loads(path.read_bytes()), path.parent
def fresh_output(output):
path = Path(output)
require(not path.exists() and not path.is_symlink(), 'fresh owned output directory required')
resolved = path.resolve()
runtime = (Path(__file__).resolve().parents[1] / 'runtime').resolve()
require(resolved.is_relative_to(runtime), 'staging output must be inside project runtime')
for parent in path.absolute().parents:
require(not parent.is_symlink(), 'output symlink ancestry is forbidden')
resolved.mkdir(parents=True, mode=0o700)
return resolved
def archive_identity(row):
# Archive hashes are optional; a pinned inventory may use captured stat tokens.
return {key: row[key] for key in ('sha256', 'bytes', 'size', 'mtime_ns', 'identity') if key in row}
def normalize_inventory(inventory):
if inventory.get('schema') == 'wow-hybrid.source-snapshot-metadata.v1':
return {'kind': 'classic-to-forever-patch-inventory-v1',
'archives': {r['basename'].casefold(): {'bytes': r['bytes'], 'mtime_ns': r['mtime_ns']}
for r in inventory['files'] if r['basename'].casefold().endswith('.mpq')}}
return inventory
def source_freshness(snapshot, inventory, selected, pins):
"""Changed archive ownership is a dependency, not a global rehash trigger."""
captured = {k.casefold(): v for k, v in snapshot.get('archives', {}).items()}
current = {k.casefold(): v for k, v in inventory.get('archives', {}).items()}
require(isinstance(captured, dict) and isinstance(current, dict), 'keyed archive inventory required')
changed = sorted(k for k in set(captured) | set(current)
if archive_identity(captured.get(k, {})) != archive_identity(current.get(k, {})))
proof = None
if snapshot.get('member_delta_proof'):
proof = pins.json(snapshot['member_delta_proof'])
require(proof.get('kind') == 'classic-to-forever-member-delta-v1' and good_status(proof.get('status')),
'typed member delta proof required')
require(proof.get('current_inventory_sha256') == snapshot.get('_current_inventory_sha256'),
'member delta current inventory binding differs')
rows = {}
for key, payload in selected.items():
owners = payload.get('archive_owners')
if isinstance(owners, list):
require(all(isinstance(x, str) for x in owners), 'archive owner names required')
owners = [x.casefold() for x in owners]
if not changed:
rows[key] = {'status': 'CURRENT_CAPTURE', 'owners': owners or []}
continue
unaffected = proof and proof.get('unchanged_members', {}).get(key) == payload['sha256']
if unaffected:
rows[key] = {'status': 'CURRENT_MEMBER_PROVEN', 'owners': owners or []}
elif not isinstance(owners, list) or not owners:
rows[key] = {'status': 'HELD', 'reason': 'Source archives changed and member owner/delta is unproven'}
elif set(owners) & set(changed):
rows[key] = {'status': 'HELD', 'reason': 'owning Source archive changed; recapture/member delta required'}
else:
priorities = inventory.get('archive_priorities', {})
shadowing = [name for name in changed if name in priorities and owners and
any(priorities[name] >= priorities.get(owner, -1) for owner in owners)]
if shadowing:
rows[key] = {'status': 'HELD', 'reason': 'changed higher-priority archive may override member; selection delta required',
'changed_selection_dependencies': shadowing}
else:
rows[key] = {'status': 'CURRENT_INDEPENDENT_ARCHIVES', 'owners': owners}
return rows, changed
def contract_for(job, request, pins, sources, natives):
key = job.get('rea_contract')
require(key in request.get('rea_contracts', {}), 'REA assessment contract required')
ref = request['rea_contracts'][key]
doc = pins.json(ref)
require(doc.get('kind') == 'classic-to-forever-rea-contract-v1' and good_status(doc.get('status')),
'typed qualified REA contract required')
require(doc.get('scope') == job['scope'] and doc.get('adapter') == job.get('adapter'),
'REA scope/adapter binding differs')
require(doc.get('source_bindings') == {k: v['sha256'] for k, v in sources.items()},
'REA Source input bindings differ')
require(doc.get('native_bindings', {}) == {k: v['sha256'] for k, v in natives.items()},
'REA native input bindings differ')
require(isinstance(doc.get('evidence'), list) and doc['evidence'], 'original-consumer evidence required')
for evidence in doc['evidence']:
require(evidence.get('role') in ('original-handler', 'original-loader', 'original-source', 'owning-rea-receipt'),
'original-consumer evidence role required')
pins.read(evidence)
require(isinstance(doc.get('acceptance_criteria'), list) and doc['acceptance_criteria'],
'adapter REA acceptance criteria required')
return ref, doc
def native_choice(job, sources, natives, contract):
"""Never replace a native asset just because the Source capture is newer."""
if job.get('change_kind') == 'source-preparation':
require(job.get('adapter') == 'blp-stage' and job.get('scope') == 'textures' and not natives and
contract.get('source_only_staging') is True,
'source-only texture preparation requires an explicit private contract and no native association')
return 'CONVERT'
if not natives:
if job['scope'] != 'icons' and job.get('change_kind', 'asset') == 'asset':
require(contract.get('asset_addition_qualified') is True,
'qualified native lookup/addition evidence required before importing absent asset')
return 'CONVERT'
if job['scope'] == 'icons':
require(job.get('asset_role') in ('item-icon', 'spell-icon', 'icon'), 'explicit icon role required')
return 'CONVERT'
if job.get('change_kind', 'asset') == 'data-behavior':
require(job['adapter'] in ('map-batch', 'classic-data', 'observation-stage', 'public-profile-stage', 'casc-frame-stage', 'creation-menu-ui', 'source-realm-ui', 'saved-taxi-stage', 'saved-area-profile-stage', 'saved-emerald-wdt-stage', 'saved-map-components-stage', 'saved-source-map-art-stage') and
(job['adapter'] != 'map-batch' or job['scope'] == 'maps'),
'no supported fixed data/behavior adapter for this scope')
return 'CONVERT'
if sorted(v['sha256'] for v in sources.values()) == sorted(v['sha256'] for v in natives.values()):
return 'REUSE_IDENTICAL'
if contract.get('native_equivalence') is True:
return 'REUSE_REA_EQUIVALENT'
require(not job.get('requires_source_content', False), 'different Source asset needs scoped REA equivalence or added-data adapter')
return 'PRESERVE_NATIVE'
def backend_request(job, request, sources, natives, pins, contract):
nested = copy.deepcopy(job.get('parameters', {}).get('batch'))
require(isinstance(nested, dict) and nested.get('kind') == 'map-conversion-batch-v1', 'fixed map batch request required')
allowed = {v['sha256']: v for v in list(sources.values()) + list(natives.values())}
payloads = nested.get('payloads', {})
require(isinstance(payloads, dict) and payloads, 'backend payload references required')
for key, ref in payloads.items():
require(ref.get('sha256') in allowed, 'undeclared backend payload')
declared = allowed[ref['sha256']]
require(pins.path(ref) == pins.path(declared), 'backend payload path binding differs')
payloads[key] = pins.absolute(declared)
require(set(contract.get('backend_operations', [])), 'explicit backend operation admission required')
for spec in nested.get('contracts', {}).values():
require(spec.get('operation') in contract['backend_operations'], 'backend operation outside REA contract')
require(spec.get('receipt') in contract.get('backend_receipts', []), 'backend receipt not bound by REA contract')
pins.read(spec['receipt'])
spec['receipt'] = pins.absolute(spec['receipt'])
admitted_evidence = {(str(pins.path(e)), e['sha256']) for e in contract['evidence']}
require(spec.get('provenance') and all((str(pins.path(e)), e['sha256']) in admitted_evidence
for e in spec['provenance']), 'backend original provenance is not bound by outer REA contract')
spec['provenance'] = [pins.absolute(e) for e in spec['provenance']]
if 'source_scope' in spec:
spec['source_scope'] = pins.absolute(spec['source_scope'])
if 'map_audits' in spec:
require(isinstance(spec['map_audits'], dict), 'map audit references required')
spec['map_audits'] = {k: pins.absolute(v) for k, v in spec['map_audits'].items()}
if 'reuse_saved' in spec:
saved = spec['reuse_saved']
require(isinstance(saved, dict) and isinstance(saved.get('candidates'), dict),
'pinned saved map candidates required')
if 'family_receipt' in saved:
saved['family_receipt'] = pins.absolute(saved['family_receipt'])
for key in ('scope_receipt', 'preflight_receipt', 'supplemental_receipt'):
if key in saved:
saved[key] = pins.absolute(saved[key])
if 'binding_receipts' in saved:
require(isinstance(saved['binding_receipts'], dict), 'saved map binding receipts required')
saved['binding_receipts'] = {k: pins.absolute(v) for k, v in saved['binding_receipts'].items()}
if 'current_source_receipts' in saved:
current = saved['current_source_receipts']
require(isinstance(current, dict) and set(current) == {'selection', 'inventory', 'archive_order'},
'three current Source selection receipts required')
saved['current_source_receipts'] = {k: pins.absolute(v) for k, v in current.items()}
saved['candidates'] = {k: pins.absolute(v) for k, v in saved['candidates'].items()}
for child in nested.get('jobs', []):
require(child.get('kind') in ('adt', 'm2', 'wmo-group', 'wmo-root', 'wdl', 'wdt'), 'fixed map/model adapter required')
if child.get('native') and job.get('change_kind', 'asset') == 'data-behavior':
require(child['kind'] in ('adt', 'wdt'), 'only qualified ADT or WDT native data patch supported')
if job['scope'] == 'models':
require(child.get('kind') not in ('adt', 'wdl', 'wdt'), 'model scope cannot admit terrain')
else:
require(child.get('kind') in ('adt', 'wdl', 'wdt'), 'map scope cannot admit a model-only job')
return nested
def creation_ui_request(job, sources, natives, pins, contract):
from single_name_creation_ui import SOURCE_SHA256
require(job.get('change_kind') == 'data-behavior' and not sources and len(natives) == 1,
'narrow UI patch requires one exact native Lua input and explicit data-behavior kind')
params = job.get('parameters', {})
require(set(params) in ({'operation', 'native_lua', 'qualification'},
{'operation', 'native_lua', 'qualification', 'future_placeholders'}) and
params['operation'] == 'disable-extra-elves',
'only the qualified disable-extra-elves creation-menu operation is supported')
require(params['native_lua'] in natives, 'declared original native Lua key required')
lua = natives[params['native_lua']]
require(lua['sha256'] == SOURCE_SHA256, 'original native creation Lua pin differs')
qualification = params['qualification']
expected = Path(__file__).resolve().parents[1] / 'docs/evidence/gameplay/distinct-race-creation-menu-20261028/assessment.json'
require(pins.path(qualification) == expected and any(pins.path(e) == expected and e['sha256'] == qualification['sha256']
for e in contract['evidence']), 'owning creation-menu qualification must be pinned original REA evidence')
proof = pins.json(qualification)
require(proof.get('kind') == 'original-creation-menu-disabled-extra-elves-focused-v1' and
proof.get('original_source_sha256') == SOURCE_SHA256 and proof.get('disabled_races') == [27, 29] and
proof.get('original_ui_prepare_pass') is True and proof.get('original_ui_lua_syntax_pass') is True and
proof.get('native_apis_overridden') is False and proof.get('native_race_rows_modified') is False and
proof.get('native_race9_10_availability_changed') is False and SHA.fullmatch(proof.get('candidate_sha256', '')),
'qualified original creation-menu contract differs')
result = {'native_lua': pins.absolute(lua), 'qualification_ref': qualification, 'qualification': proof}
if 'future_placeholders' in params:
ref = params['future_placeholders']
future_path = pins.path(ref)
runtime_root = (Path(__file__).resolve().parents[1] / 'runtime').resolve()
require(future_path.is_relative_to(runtime_root) and
future_path.parent.name.startswith('future-race-create') and
future_path.name == 'qualification.private.json' and
any(pins.path(e) == future_path and e['sha256'] == ref['sha256']
for e in contract['evidence']), 'future-race portrait qualification must be pinned')
future = pins.json(ref)
require(future.get('kind') == 'original-create-disabled-future-portraits-v1' and
future.get('status') == 'PASS_FOCUSED_PRIVATE_UNINSTALLED' and
future.get('original_source_sha256') == SOURCE_SHA256 and
future.get('portraits') in ({'Ogre': 236695, 'Furbolg': 236696},
{'Ogre': 236695, 'Furbolg': 8560810}) and
future.get('default_output_preserved') is True and
future.get('placeholders_selectable') is False and
future.get('native_race_rows_added') is False and
future.get('native_accepted') is False and SHA.fullmatch(future.get('candidate_sha256', '')),
'future-race portrait qualification differs')
asset_path = Path(__file__).resolve().parents[1] / 'runtime/continuation-20261029/future-ogre-race/inert-race-portrait-handoff.private.json'
asset_ref = next((e for e in contract['evidence'] if pins.path(e) == asset_path), None)
require(asset_ref is not None and asset_ref['sha256'] == future.get('asset_handoff_sha256'),
'future-race native portrait evidence must be pinned')
assets = pins.json(asset_ref)
require(assets.get('status') == 'PASS_NATIVE_SDK_STRICT_CONTENT_AND_VISUAL_PREVIEW' and
{p.get('race'): p.get('fdid') for p in assets.get('portraits', [])} ==
{'ogre': 236695, 'furbolg': 236696} and
all(p.get('sdk_opened') is True and p.get('strict_content_read') is True and
p.get('decoded_md5_matches_ckey') is True for p in assets.get('portraits', [])),
'future-race native portrait evidence differs')
if future['portraits']['Furbolg'] == 8560810:
generated_path = Path(__file__).resolve().parents[1] / 'runtime/continuation-20261030/furbolg-generated-portrait/casc-handoff.private.json'
generated_ref = next((e for e in contract['evidence'] if pins.path(e) == generated_path), None)
require(generated_ref is not None and generated_ref['sha256'] == future.get('generated_asset_handoff_sha256'),
'generated furbolg asset evidence must be pinned')
generated = pins.json(generated_ref)
require(generated.get('kind') == 'furbolg-original-icon-private-casc-handoff-v1' and
generated.get('status') == 'PASS_FDI_SDK_READBACK_COW_AND_PARENT_INDEX_ROLLBACK_PREPARED' and
generated.get('file_data_id') == 8560810 and generated.get('added_assets') == 1 and
generated.get('old_assets_preserved') is True and generated.get('client_modified') is False and
generated.get('installed') is False and generated.get('native_rendering_accepted') is False,
'generated furbolg asset evidence differs')
result.update(future_placeholders=future, future_placeholders_ref=ref)
return result
def source_local_login_ui_request(job, sources, natives, pins, contract):
"""Qualify the existing private UI transform for an explicit local build."""
from source_realm_ui import LOCAL_TEST_NOGATE_LUA_SHA256, LOCAL_TEST_NOGATE_XML_SHA256
require(job.get('change_kind') == 'data-behavior' and not sources and len(natives) == 4,
'local test login requires exact Lua, XML, PE wire and engine metadata')
params=job.get('parameters',{})
require(set(params)=={'operation','account_lua','account_xml','wire','engine_metadata',
'qualification','build_qualification','loopback_profile'},
'explicit local test login inputs and qualifications required')
keys=[params[k] for k in ('account_lua','account_xml','wire','engine_metadata')]
require(all(isinstance(k,str) for k in keys) and len(set(keys))==4 and all(k in natives for k in keys),
'four distinct declared native inputs required')
lua,xml,wire,metadata=(natives[k] for k in keys)
require(lua['sha256']==LOCAL_TEST_NOGATE_LUA_SHA256 and xml['sha256']==LOCAL_TEST_NOGATE_XML_SHA256,
'pinned no-gate AccountLogin inputs differ')
profile=params['loopback_profile']
require(isinstance(profile,dict) and set(profile)=={'kind','profile','auth','realm','client_sha256'} and
profile['kind']=='source-local-loopback-test-v1' and type(profile['profile']) is int and profile['profile']==5 and
isinstance(profile['client_sha256'],str) and SHA.fullmatch(profile['client_sha256']),
'explicit build-pinned profile 5 required')
for role in ('auth','realm'):
value=profile[role]
require(isinstance(value,str) and re.fullmatch(r'127\.0\.0\.1:[1-9][0-9]{0,4}',value) is not None and
int(value.rsplit(':',1)[1])<=65535, 'numeric IPv4 loopback endpoint required')
# Verify the build's actual PE wire identity, not just a claimed profile name.
pins.read(wire);meta=pins.json(metadata)
require(meta.get('candidate_only') is True and meta.get('installed') is False and
meta.get('original_sha256')==profile['client_sha256'], 'client build metadata does not match profile')
dependencies=meta.get('auxiliary_dependencies')
require(isinstance(dependencies,list) and sum(isinstance(d,dict) and d.get('file')=='GWNativeWire.dll' and
d.get('sha256')==wire['sha256'] and d.get('source_only_profile')==5 for d in dependencies)==1,
'profile 5 PE wire is not pinned by engine metadata')
def evidence(ref):
require(any(pins.path(e)==pins.path(ref) and e['sha256']==ref['sha256'] for e in contract['evidence']),
'pinned qualification must be included in REA contract evidence')
return pins.json(ref)
qualification=evidence(params['qualification']);build=evidence(params['build_qualification'])
output_sha=qualification.get('candidate_lua_sha256')
require(qualification.get('status')=='PRIVATE_LOCAL_NO_PREFLIGHT_FOCUSED_PASS_NOT_INSTALLED' and
qualification.get('parent_lua_sha256')==lua['sha256'] and qualification.get('parent_xml_sha256')==xml['sha256'] and
qualification.get('candidate_xml_sha256')==xml['sha256'] and qualification.get('installed') is False and
qualification.get('native_accepted') is False and isinstance(output_sha,str) and SHA.fullmatch(output_sha),
'local UI owning qualification differs')
require(build.get('status')=='PROFILE5_FRAME_OWNED_LOOPBACK_PRIVATE_BUILD_FOCUSED_PASS_NOT_INSTALLED' and
build.get('loopback_profile')=={'profile':5,'auth':profile['auth'],'realm':profile['realm']} and
build.get('installed') is False and build.get('native_accepted') is False,
'loopback profile differs from verified build')
overlay=build.get('overlay_plan');require(isinstance(overlay,dict),'qualified build overlay plan required')
plan=overlay.get('destinations',[])
require(isinstance(plan,list) and sum(isinstance(d,dict) and str(d.get('target','')).endswith('/GWNativeWire.dll') and
d.get('candidate_sha256')==wire['sha256'] for d in plan)==1,
'PE wire is not the qualified loopback build')
return {'kind':'local-loopback-no-preflight','lua':pins.absolute(lua),'xml':pins.absolute(xml),
'wire':pins.absolute(wire),'metadata':pins.absolute(metadata),'profile':profile,
'qualification':qualification,'qualification_ref':params['qualification'],
'build_ref':params['build_qualification']}
def source_realm_ui_request(job, sources, natives, pins, contract):
from source_realm_ui import SOURCE_SHA256, GLUE_SHA256
if job.get('parameters',{}).get('operation')=='local-loopback-no-preflight':
return source_local_login_ui_request(job,sources,natives,pins,contract)
require(job.get('change_kind') == 'data-behavior' and not sources and len(natives) == 2,
'Source realm UI requires two exact native Lua inputs and explicit data-behavior kind')
params = job.get('parameters', {})
require(set(params) in ({'operation', 'realm_list_lua', 'glue_parent_lua', 'qualification'},
{'operation', 'realm_list_lua', 'glue_parent_lua', 'qualification', 'login_diagnostic'}) and
params['operation'] == 'source-pending-realm-choice', 'only the qualified Source realm choice operation is supported')
require(params['realm_list_lua'] in natives and params['glue_parent_lua'] in natives and
params['realm_list_lua'] != params['glue_parent_lua'], 'two distinct declared original native Lua keys required')
realm, glue = natives[params['realm_list_lua']], natives[params['glue_parent_lua']]
require(realm['sha256'] == SOURCE_SHA256 and glue['sha256'] == GLUE_SHA256, 'original native realm UI pins differ')
qualification = params['qualification']
expected = Path(__file__).resolve().parents[1] / 'runtime/continuation-20261029/source-realm-original-ui-adapter/owning-focused-check.private.json'
require(pins.path(qualification) == expected and any(pins.path(e) == expected and e['sha256'] == qualification['sha256']
for e in contract['evidence']), 'owning realm UI qualification must be pinned original REA evidence')
proof = pins.json(qualification)
require(proof.get('kind') == 'original-Glue-Source-pending-choice-UI-boundary-v1' and
proof.get('status') == 'PASS_OFFLINE_ORIGINAL_CONSUMERS_SOURCE_FACTORY_AND_NATIVE_FALLBACK' and
proof.get('original_pins', {}).get('realm-list', {}).get('sha256') == SOURCE_SHA256 and
proof.get('original_pins', {}).get('glue-parent', {}).get('sha256') == GLUE_SHA256 and
all(SHA.fullmatch(proof.get('candidates', {}).get(k, {}).get('sha256', ''))
for k in ('realm-list', 'glue-parent')),
'qualified original realm UI contract differs')
diagnostic = params.get('login_diagnostic')
diagnostic_proof = None
require('login_diagnostic' not in params or diagnostic is not None,
'explicit diagnostic qualification required')
if diagnostic is not None:
require(isinstance(diagnostic, dict) and set(diagnostic) == {'qualification'},
'explicit diagnostic qualification required')
diagnostic_ref = diagnostic['qualification']
root = Path(__file__).resolve().parents[1]
expected_diagnostic = root / 'runtime/continuation-20261029/new-login-front-prototype/diagnostic-handoff.private.json'
require(pins.path(diagnostic_ref) == expected_diagnostic and
any(pins.path(e) == expected_diagnostic and e['sha256'] == diagnostic_ref['sha256']
for e in contract['evidence']), 'owning diagnostic qualification must be pinned original REA evidence')
diagnostic_proof = pins.json(diagnostic_ref)
producer = root / 'compat/glue/source_login_diagnostic.lua'
require(diagnostic_proof.get('original_glue_sha256') == GLUE_SHA256 and
diagnostic_proof.get('default_candidate_sha256') == proof['candidates']['glue-parent']['sha256'] and
diagnostic_proof.get('offline_validation', '').startswith('PASS ') and
not diagnostic_proof.get('installed') and not diagnostic_proof.get('native_acceptance') and
diagnostic_proof.get('files', {}).get('compat/glue/source_login_diagnostic.lua') == digest(producer.read_bytes()) and
SHA.fullmatch(diagnostic_proof.get('files', {}).get('runtime/continuation-20261029/new-login-front-prototype/glueparent-diagnostic.private.lua', '')),
'qualified login diagnostic contract differs')
return {'realm': pins.absolute(realm), 'glue': pins.absolute(glue),
'qualification_ref': qualification, 'qualification': proof,
'diagnostic_ref': diagnostic['qualification'] if diagnostic is not None else None,
'diagnostic_proof': diagnostic_proof}
def registered_item_icon_request(job, sources, natives, pins, contract):
"""Bind the existing registered-ROOT item icon stage, without installing it."""
require(job.get('change_kind') == 'data-behavior' and job.get('asset_role') == 'item-icon',
'registered item icons require explicit item-icon data-behavior scope')
params = job.get('parameters', {})
source_roles = ('catalogue_manifest', 'artwork_manifest', 'item_icons')
native_roles = ('package', 'baseline_manifest', 'native_root')
require(set(params) == {'operation', *source_roles, *native_roles} and
params['operation'] in ('registered-zero-item-icons', 'registered-source-item-icons-replace'),
'only registered zero icons or explicit source-backed replacement supported')
require(all(params[k] in sources for k in source_roles) and all(params[k] in natives for k in native_roles),
'declared source and native icon inputs required')
selected = {k: pins.absolute((sources if k in source_roles else natives)[params[k]])
for k in (*source_roles, *native_roles)}
catalog, artwork = Path(selected['catalogue_manifest']['path']), Path(selected['artwork_manifest']['path'])
mapping, baseline = Path(selected['item_icons']['path']), Path(selected['baseline_manifest']['path'])
require(catalog.name == 'manifest.json' and artwork.name == 'manifest.json' and
mapping == artwork.parent / 'item-icons.json', 'catalogue and artwork stage paths differ')
expected = [Path(__file__).resolve().parents[1] / p for p in (
'docs/evidence/data/octo-builtin-archive-selection.json',
'docs/evidence/content-data/native-item-icon-assets-20261021/acceptance.json')]
evidence = {pins.path(e): e for e in contract['evidence']}
require(all(p in evidence for p in expected), 'original Source icon loader and native consumer evidence required')
loader, native = (pins.json(evidence[p]) for p in expected)
require(loader.get('kind') == 'reviewed-source-builtin-archive-search' and loader.get('schema_version') == 1 and
native.get('kind') == 'native-source-item-icon-batch-acceptance' and
native.get('checked_native_item_bindings') == native.get('passed_native_item_bindings') == 839 and
native.get('probe_errors') == native.get('mismatches') == 0 and
native.get('existing_native_positive_item_icon_fields_unchanged') is True,
'original icon consumer qualification differs')
cat = json.loads(pins.read(selected['catalogue_manifest']))
art = json.loads(pins.read(selected['artwork_manifest']))
prior = json.loads(pins.read(selected['baseline_manifest'], 32 * 1024 * 1024))
require(cat.get('kind') == 'source-item-catalogue-conversion' and art.get('kind') == 'source-icon-artwork-batch' and
prior.get('kind') == 'source-equipment-registered-root-stage', 'existing icon stage manifests required')
dependencies = {}
def pin_child(base, name, *, flat=False):
require(isinstance(name, str) and name and (not flat or Path(name).name == name), 'safe icon dependency path required')
path = base / name
require(not path.is_symlink() and path.is_file() and path.resolve().is_relative_to(base.resolve()),
'regular owned icon dependency required')
st = path.stat()
dependencies[str(path.resolve())] = {'device': st.st_dev, 'inode': st.st_ino, 'bytes': st.st_size,
'mtime_ns': st.st_mtime_ns, 'ctime_ns': st.st_ctime_ns}
for reference in selected.values():
path = Path(reference['path']); pin_child(path.parent, path.name, flat=True)
for row in cat.get('files', []):
if row.get('path', '').startswith('items-'):
pin_child(catalog.parent, row['path'], flat=True)
for row in art.get('assets', []):
pin_child(artwork.parent, row['file'])
for row in prior.get('assets', []):
pin_child(baseline.parent, row['file'], flat=True)
pin_child(baseline.parent, 'root.bin', flat=True)
require(dependencies, 'icon input closure required')
return {'selected': selected, 'dependencies': dependencies,
'replace_existing': params['operation'] == 'registered-source-item-icons-replace'}
def data_request(job, sources, natives, pins, contract):
require(job.get('change_kind') == 'data-behavior', 'definition/association patches require explicit data-behavior kind')
nested = copy.deepcopy(job.get('parameters', {}).get('batch'))
require(isinstance(nested, dict) and nested.get('kind') == 'classic-data-batch-v1', 'fixed classic-data batch required')
allowed = {(str(pins.path(v)), v['sha256']) for v in list(sources.values()) + list(natives.values())}
for key, ref in nested.get('inputs', {}).items():
require((str(pins.path(ref)), ref['sha256']) in allowed, 'undeclared classic-data input')
nested['inputs'][key] = pins.absolute(ref)
admitted_evidence = {(str(pins.path(e)), e['sha256']) for e in contract['evidence']}
for spec in nested.get('contracts', {}).values():
require(spec.get('receipt') in contract.get('backend_receipts', []), 'classic-data receipt not bound by outer REA contract')
require(set(spec.get('operations', [])) <= set(contract.get('backend_operations', [])), 'classic-data operation outside outer REA contract')
require(spec.get('provenance') and all((str(pins.path(e)), e['sha256']) in admitted_evidence for e in spec['provenance']),
'classic-data original provenance not bound by outer REA contract')
spec['receipt'] = pins.absolute(spec['receipt'])
spec['provenance'] = [pins.absolute(e) for e in spec['provenance']]
from classic_data_adapters import ADAPTERS as data_adapters, HELD as data_held
for child in nested.get('jobs', []):
operation = child.get('operation', '')
require(operation in data_adapters or operation in data_held, 'unknown fixed classic-data operation')
require(operation.split('.')[0] == job['scope'] or (job['scope'] == 'equipment' and operation == 'items.equipment'),
'classic-data operation differs from outer scope')
require(nested.get('jobs'), 'classic-data jobs required')
return nested
def system_request(job, sources, natives, pins, contract):
require(job.get('change_kind') == 'data-behavior', 'artifact/evidence stages require explicit data-behavior kind')
params = copy.deepcopy(job.get('parameters', {}))
inputs = dict(sources)
for key, value in natives.items():
require(key not in inputs or inputs[key] == value, 'ambiguous artifact input key')
inputs[key] = value
def selected(key):
require(key in inputs, 'declared artifact input key required')
return pins.absolute(inputs[key])
if job['adapter'] == 'saved-source-map-art-stage':
keys = ('area', 'base_inventory', 'overlay', 'overlay_inventory', 'selection',
'primary_stage', 'retry_stage', 'source_contract')
require(set(params) == {'operation', *keys} and params['operation'] == 'saved-source-map-art-profile',
'qualified saved Source map-art inputs required')
refs = {key: selected(params[key]) for key in keys}
root = Path(__file__).resolve().parents[1]
base = root / 'runtime/continuation-20261029/rea-worldmap-original'
expected = {'area': root / 'runtime/rea-system-jobs-20261022/continent-tile-coverage-20261025/source-worldmaparea/decoded.json',
'base_inventory': base / 'source-map-art-inventory.private.json',
'overlay': base / 'source-worldmapoverlay-decoded.private.json',
'overlay_inventory': base / 'source-overlay-art-inventory.private.json',
'selection': base / 'map-art-source-batch/source-selection.private.json',
'primary_stage': base / 'map-art-source-batch/stage-retry/stage-counts-corrected.json',
'retry_stage': base / 'map-art-source-batch/stage-held13/stage.json',
'source_contract': base / 'source-getmapinfo-worldmaparea-static-identity.private.json'}
original_source = expected['source_contract']
original_native = base / 'mapcanvas-original-consumer-handoff.private.json'
evidence = {pins.path(e) for e in contract['evidence']}
require(all(Path(refs[key]['path']) == path for key, path in expected.items()) and
{original_source, original_native} <= evidence,
'saved Source stages and original map UI consumer evidence required')
return dict(operation='saved-source-map-art-profile', **refs)
if job['adapter'] == 'saved-map-components-stage':
if params.get('operation') == 'saved-obj16-retained-roots':
keys = ('identity', 'obj_join', 'split', 'transformed', 'registered', 'active')
require(set(params) == {'operation', *keys}, 'qualified retained ROOT inputs required')
refs = {key: selected(params[key]) for key in keys}
root = Path(__file__).resolve().parents[1]
expected = {
'identity': root / 'runtime/continuation-20261029/converter-worldmap-reuse/obj16-retained-roots-identities.private.json',
'obj_join': root / 'runtime/continuation-20261029/converter-worldmap-reuse/obj16-source-role-join.private.json',
'split': root / 'runtime/rea-system-jobs-20261022/continent-native-split-ADT-20261025/source462-split-candidate-manifest.json',
'transformed': root / 'runtime/continuation-20261026/openworld-Still-River-liquid-contract/Still-containing146-component.json',
'registered': root / 'runtime/continuation-20261026/openworld-Still146-paired-child/Still140-actual-FDI-bindings-and-stage-check.json',
'active': root / 'runtime/continuation-20261028/map-active-projection/registered-final-active32349-private/manifest.json'}
authority = root / 'docs/evidence/content-data/Source-v18-native-split-ADT-20261025/assessment.json'
require(all(Path(refs[key]['path']) == path for key, path in expected.items()) and
any(pins.path(e) == authority for e in contract['evidence']),
'saved ROOT ownership and original terrain evidence required')
return dict(operation=params['operation'], **refs)
if params.get('operation') == 'saved-scene6-wdt-component':
keys = ('family', 'identity', 'projection', 'admission', 'obj_stage', 'placements')
require(set(params) == {'operation', *keys}, 'qualified saved Scene6 inputs required')
refs = {key: selected(params[key]) for key in keys}
root = Path(__file__).resolve().parents[1]
expected = {
'family': root / 'runtime/continuation-20261028/map-selector-prep/completed-Map1-OBJ6/completed-WDT-link-family.json',
'identity': root / 'runtime/continuation-20261029/converter-worldmap-reuse/scene6-wdt-identity.private.json',
'projection': root / 'runtime/continuation-20261028/map-active-projection/final-active32349-logical-handoff.json',
'admission': root / 'runtime/continuation-20261028/map-region-coverage/scene6-source-root-tex-admission.private.json',
'obj_stage': root / 'runtime/continuation-20261029/converter-worldmap-reuse/obj16-unified-reuse/stage/stage.json',
'placements': root / 'runtime/continuation-20261028/map-scene29/closed16-OBJ-component-manifest.json'}
authority = root / 'docs/evidence/content-data/Source-v18-native-split-ADT-20261025/assessment.json'
require(all(Path(refs[key]['path']) == path for key, path in expected.items()) and
any(pins.path(e) == authority for e in contract['evidence']),
'saved Scene6 ownership and original terrain evidence required')
return dict(operation=params['operation'], **refs)
if params.get('operation') == 'saved-obj16-source-role-join':
keys = ('join', 'root_stage', 'tex_stage', 'obj_stage', 'source62_manifest',
'source78_manifest', 'tex_manifest', 'placement_manifest')
expanded = ('family', 'selection', 'retained_root_stage', 'alpha4', 'alpha2', 'tex4', 'tex2')
if set(params) == {'operation', *keys, *expanded}:
keys += expanded
require(set(params) == {'operation', *keys}, 'qualified Source role-join inputs required')
refs = {key: selected(params[key]) for key in keys}
root = Path(__file__).resolve().parents[1]
base = root / 'runtime/continuation-20261029/converter-worldmap-reuse'
expected = {'join':base/'obj16-source-role-join.private.json',
'root_stage':base/'source62-unified-reuse/stage/stage.json',
'tex_stage':base/'source78-unified-reuse/stage/stage.json',
'obj_stage':base/'obj16-unified-reuse/stage/stage.json',
'source62_manifest':base/'source62-private-batch/input-manifest.json',
'source78_manifest':base/'source78-private-batch/input-manifest.json',
'tex_manifest':base/'source78-supplemental-batch/input-manifest.json',
'placement_manifest':root/'runtime/continuation-20261028/map-scene29/closed16-OBJ-component-manifest.json'}
if 'family' in refs:
family = root/'runtime/continuation-20261101/native4-tex-join-private'
expected.update(family=family/'family-join.private.json',
selection=family/'current-original-order-six.private.json',
retained_root_stage=base/'obj16-retained-roots-unified-reuse/stage-retry/stage.json',
alpha4=family/'alpha-focused-check.private.json',
alpha2=family/'retained2/alpha-focused-check.private.json',
tex4=family/'source-flags-alpha8.private.json',
tex2=family/'retained2/source-flags-alpha8.private.json')
authority = root / 'docs/evidence/content-data/Source-v18-native-split-ADT-20261025/assessment.json'
require(all(Path(refs[key]['path']) == path for key, path in expected.items()) and
any(pins.path(e) == authority for e in contract['evidence']),
'saved Source roles and original terrain consumer evidence required')
return dict(operation=params['operation'], **refs)
if params.get('operation') == 'saved-obj16-components':
keys = ('boundary', 'bindings', 'identity', 'checkpoint')
require(set(params) == {'operation', *keys}, 'qualified saved OBJ16 inputs required')
refs = {key: selected(params[key]) for key in keys}
root = Path(__file__).resolve().parents[1]
expected = {
'boundary': root / 'runtime/continuation-20261028/map-cutout-batch/OBJ16-registered-boundary-result.json',
'bindings': root / 'runtime/continuation-20261028/map-cutout-batch/actual-new-OBJ16-bindings.private.json',
'identity': root / 'runtime/continuation-20261029/converter-worldmap-reuse/obj16-identities.private.json',
'checkpoint': root / 'runtime/continuation-20261028/map-scene29/current-checkpoint.json'}
authority = root / 'docs/evidence/content-data/Source-v18-native-split-ADT-20261025/assessment.json'
require(all(Path(refs[key]['path']) == path for key, path in expected.items()) and
any(pins.path(e) == authority for e in contract['evidence']),
'owning saved OBJ batch and original consumer evidence required')
return dict(operation=params['operation'], **refs)
if params.get('operation') == 'saved-wdt-family-components':
keys = ('handoff', 'family', 'identity', 'assessment')
require(set(params) == {'operation', *keys}, 'qualified saved WDT inputs required')
refs = {key: selected(params[key]) for key in keys}
root = Path(__file__).resolve().parents[1]
expected = {
'handoff': root / 'runtime/continuation-20261029/map-conversion-saved-families-handoff.private.json',
'family': root / 'runtime/continuation-20261026/openworld-MAIN-activation-contract/final-finite-outdoor-WDT2/final-WDT2-handoff.json',
'identity': root / 'runtime/continuation-20261029/converter-worldmap-reuse/wdt-family-identities.private.json',
'assessment': root / 'docs/evidence/content-data/openworld-original529-presentation-20261026/assessment.json'}
require(all(Path(refs[key]['path']) == path for key, path in expected.items()),
'owning saved WDT family required')
assessment = pins.json(refs['assessment'])
witness = Path(assessment['REA']['exact_529_seed']).resolve()
evidence = {pins.path(e) for e in contract['evidence']}
require({expected['assessment'], witness} <= evidence, 'original WDT consumer evidence required')
return dict(operation=params['operation'], **refs)
if params.get('operation') == 'saved-wdl-family-components':
keys = ('handoff', 'family', 'identity', 'assessment')
require(set(params) == {'operation', *keys}, 'qualified saved WDL inputs required')
refs = {key: selected(params[key]) for key in keys}
root = Path(__file__).resolve().parents[1]
expected = {
'handoff': root / 'runtime/continuation-20261029/map-conversion-saved-families-handoff.private.json',
'family': root / 'runtime/continuation-20261026/combined57-map-integration/Root-WDL-native-profile/focused-result-and-output-bindings.json',
'identity': root / 'runtime/continuation-20261029/converter-worldmap-reuse/wdl-family-identities.private.json',
'assessment': root / 'docs/evidence/content-data/wdl-native-presentation-profile-20261026/assessment.json'}
require(all(Path(refs[key]['path']) == path for key, path in expected.items()),
'owning saved WDL family required')
assessment = pins.json(refs['assessment'])
witness = (root / assessment['original_REA_witness']).resolve()
evidence = {pins.path(e) for e in contract['evidence']}
require({expected['assessment'], witness} <= evidence, 'original WDL consumer evidence required')
return dict(operation=params['operation'], **refs)
if params.get('operation') in ('saved-source78-existing-components', 'saved-source62-components'):
keys = ('handoff', 'report', 'identity', 'freshness')
require(set(params) == {'operation', *keys}, 'qualified saved map inputs required')
refs = {key: selected(params[key]) for key in keys}
root = Path(__file__).resolve().parents[1]
family = 'source62' if params['operation'] == 'saved-source62-components' else 'source78'
base = root / f'runtime/continuation-20261029/converter-worldmap-reuse/{family}-private-batch'
stage = 'source62-unified-reuse' if family == 'source62' else 'source78-existing-unified-reuse'
expected = {'handoff': base / f'{family}-reuse-handoff.private.json',
'report': base / 'report.json',
'identity': root / f'runtime/continuation-20261029/converter-worldmap-reuse/{stage}/artifact-identity.private.json',
'freshness': root / 'runtime/continuation-20261029/octo-update-freshness/current-openworld-142-selection.private.json'}
authority = root / 'docs/evidence/content-data/Source-v18-native-split-ADT-20261025/assessment.json'
require(all(Path(refs[key]['path']) == path for key, path in expected.items()) and
any(pins.path(e) == authority for e in contract['evidence']),
'owning saved map batch and original consumer evidence required')
return dict(operation=params['operation'], **refs)
keys = ('handoff', 'manifest', 'report')
require(set(params) == {'operation', *keys} and params['operation'] == 'saved-source78-tex-components',
'only the qualified saved Source78 TEX batch is supported')
refs = {key: selected(params[key]) for key in keys}
root = Path(__file__).resolve().parents[1]
base = root / 'runtime/continuation-20261029/converter-worldmap-reuse/source78-supplemental-batch'
expected = {'handoff': base / 'handoff.private.json', 'manifest': base / 'input-manifest.json',
'report': base / 'output/report.json'}
authority = root / 'docs/evidence/content-data/Source-v18-native-split-ADT-20261025/assessment.json'
require(all(Path(refs[key]['path']) == path for key, path in expected.items()) and
any(pins.path(e) == authority for e in contract['evidence']),
'owning saved map batch and original consumer evidence required')
return dict(operation='saved-source78-tex-components', **refs)
if job['adapter'] == 'saved-emerald-wdt-stage':
keys = ('handoff', 'role_audit', 'active_registry', 'outdoor_coverage')
require(set(params) == {'operation', *keys} and params['operation'] == 'saved-emerald-wdt-assessment',
'only the qualified saved Emerald Dream WDT assessment is supported')
refs = {key: selected(params[key]) for key in keys}
root = Path(__file__).resolve().parents[1]
expected = {'handoff': 'runtime/continuation-20261026/all57-terrain-integrated-batch/final-all-native-terrain-WDT-handoff.json',
'role_audit': 'runtime/continuation-20261026/all57-terrain-integrated-batch/final-all-native-terrain-WDTs/map169-role-audit.json',
'active_registry': 'runtime/continuation-20261027/release-base-lowbyte2-child/registered-final-active32337-private/manifest.json',
'outdoor_coverage': 'runtime/continuation-20261026/all-outdoor-area-current-next-coverage/all-outdoor-area-current-next-coverage.json'}
require(all(Path(refs[key]['path']) == root / name for key, name in expected.items()) and any(
pins.path(e) == root / expected['handoff'] and e['sha256'] == refs['handoff']['sha256']
for e in contract['evidence']), 'owning saved Emerald Dream receipts and original evidence required')
return dict(operation='saved-emerald-wdt-assessment', **refs)
if job['adapter'] == 'saved-area-profile-stage':
keys = ('assessment', 'manifest', 'component')
require(set(params) == {'operation', *keys} and params['operation'] == 'saved-outdoor-area-assessment',
'only the qualified saved outdoor area assessment is supported')
refs = {key: selected(params[key]) for key in keys}
directory = Path(__file__).resolve().parents[1] / 'runtime/continuation-20261026/Root-named-openworld-area-status'
expected = {'assessment': 'Area319-profile-and-metadata84559-handoff.json',
'manifest': 'full-outdoor319-AreaTable-definition-parent-manifest.json',
'component': 'Area319-observed-native-profile-component.json'}
require(all(Path(refs[key]['path']) == directory / name for key, name in expected.items()) and any(
pins.path(e) == directory / expected['assessment'] and e['sha256'] == refs['assessment']['sha256']
for e in contract['evidence']), 'owning saved area receipts and assessment evidence required')
return dict(operation='saved-outdoor-area-assessment', **refs)
if job['adapter'] == 'saved-taxi-stage':
keys = ('assessment', 'profile', 'resolved', 'held', 'paths_header', 'nodes_header')
optional = ('current_freshness', 'current_added')
require(set(params) in ({'operation', *keys}, {'operation', *keys, *optional}) and
params['operation'] == 'saved-static-taxi-assessment',
'only the qualified saved static taxi assessment is supported')
refs = {key: selected(params[key]) for key in keys}
expected = Path(__file__).resolve().parents[1] / 'docs/evidence/content-data/map-taxi-relationship-closure-20261023/assessment.json'
require(Path(refs['assessment']['path']) == expected and any(
pins.path(e) == expected and e['sha256'] == refs['assessment']['sha256'] for e in contract['evidence']),
'owning original taxi assessment must be pinned REA evidence')
if 'current_freshness' in params:
directory = Path(__file__).resolve().parents[1] / 'runtime/continuation-20261029/worldmap-flightmap-reuse'
for key, filename in (('current_freshness', 'current-taxi-source-freshness.private.json'),
('current_added', 'current-added-taxi-paths.private.json')):
refs[key] = selected(params[key])
require(Path(refs[key]['path']) == directory / filename, 'exact current taxi receipt required')
return dict(operation='saved-static-taxi-assessment', **refs)
if job['adapter'] == 'observation-stage':
expected = {'travel': 'travel-observation', 'social': 'social-observation', 'bank': 'guild-bank-observation'}[job['scope']]
require(params.get('operation') == expected, 'observation operation differs from scope')
require(len(sources) == 1, 'exactly one pinned official-client observation required')
return dict(operation=expected, input=selected(next(iter(sources))))
if job['adapter'] == 'public-profile-stage':
require(params.get('destination', 'octo') in ('octo', 'praxis'), 'fixed public destination required')
return dict(operation='public-protocol-profile', destination=params.get('destination', 'octo'),
version=selected(params.get('version')), addons=selected(params.get('addons')))
require(job['adapter'] == 'casc-frame-stage', 'unknown fixed artifact adapter')
assets = selected(params.get('asset_manifest')); root = selected(params.get('root_payload'))
reuse = selected(params.get('reuse_report'))
require(Path(root['path']) == Path(assets['path']).parent / 'root.bin', 'registered ROOT must belong to asset manifest directory')
require(Path(reuse['path']).name == 'report.json', 'native reuse report filename required')
names = {'target-encoding.bin', 'target-download.bin', 'native-tvfs-default.bin', 'native-vfs-root.bin',
'download-native-controls.json', 'tvfs-default-identity.json'}
context = params.get('native_context', {})
require(isinstance(context, dict) and set(context) == names, 'complete fixed native metadata context required')
refs = {name: selected(key) for name, key in context.items()}
parents = {str(Path(ref['path']).parent) for ref in refs.values()}
require(len(parents) == 1 and all(Path(refs[name]['path']).name == name for name in names),
'fixed native context filenames in one directory required')
manifest = pins.json(assets)
require(isinstance(manifest.get('assets'), list), 'registered asset manifest required')
retained = selected(params['retained_asset_frames']) if params.get('retained_asset_frames') else None
if retained is None:
for row in manifest['assets']:
require(any(Path(v['path']).resolve() == Path(assets['path']).parent / row['file'] and v['sha256'] == row['sha256']
for v in inputs.values()), 'every new registered body must be a declared pinned input')
else:
retained_doc = pins.json(retained)
require(set(retained_doc) == {row['file'] for row in manifest['assets']}, 'complete retained framing map required')
return dict(operation='native-casc-framing', asset_manifest=assets, native_context=next(iter(parents)),
reuse_directory=str(Path(reuse['path']).parent), retained_asset_frames=retained,
retained_native_content_entries=selected(params['retained_native_content_entries']) if params.get('retained_native_content_entries') else None,
retained_download_controls=selected(params['retained_download_controls']) if params.get('retained_download_controls') else None)
def execute_system_stage(row, output, pins):
spec = row['_system_spec']; operation = spec['operation']
output.mkdir(mode=0o700)
def save(name, value, role):
raw = value if isinstance(value, bytes) else encoded(value)
path = output / name; path.write_bytes(raw)
return {'path': str(path), 'sha256': digest(raw), 'bytes': len(raw), 'role': role}
if operation == 'saved-source-map-art-profile':
from map_conversion_batch import reuse_saved_source_worldmap_art
keys = ('area', 'base_inventory', 'overlay', 'overlay_inventory', 'selection',
'primary_stage', 'retry_stage', 'source_contract')
profile = reuse_saved_source_worldmap_art(*(pins.json(spec[key]) for key in keys))
return 'MAP_ASSESSMENT_STAGED', [save('source-map-art-profile.json', profile, 'saved-source-map-art-profile')], {
'source_base_areas': profile['base_area_count'], 'source_overlays': profile['overlay_count'],
'source_texture_contents': profile['distinct_texture_contents'], 'source_payloads_reread': 0,
'native_ids_assigned': False, 'native_rendering_verified': False, 'publication_performed': False}
if operation == 'saved-obj16-retained-roots':
identity, obj_join, split, transformed, registered = (
pins.json(spec[k]) for k in ('identity', 'obj_join', 'split', 'transformed', 'registered'))
# The retained 32,349-record owner manifest is larger than ordinary
# metadata inputs; this exact, pinned file has a separate 32 MiB cap.
active = json.loads(pins.read(spec['active'], maximum=32 * 1024 * 1024))
require(isinstance(active, dict), 'retained ROOT owner manifest required')
require(identity.get('status') == 'PASS_SIX_DISTINCT_ROOT_OUTPUT_IDENTITY_BOUNDARY' and
identity.get('source_payloads_read') == 0 and identity.get('root_outputs_read') == 6 and
identity.get('installed') is False and identity.get('native_accepted') is False and
obj_join.get('status') == 'PASS_QUALIFIED_SOURCE_ROLE_JOIN' and
obj_join.get('input_obj_components') == 16 and
split.get('status') == 'PRIVATE_PARTIAL_ROLE_CANDIDATES_ALL_HELD' and
transformed.get('status') == 'PASS_CHANGED_EXACT_NIBBLE_GUARD_AND146_PAYLOAD_REUSE' and
transformed.get('installed') is False and
registered.get('status') == 'PASS_STILL140_ROOT_TEX_PAIRED_REGISTRATION_AND_PARENT_PREFIX_BOUNDARY',
'retained ROOT family qualification differs')
def unique(rows, key):
result = {row[key]: row for row in rows}
require(len(result) == len(rows), 'duplicate retained ROOT identity')
return result
objs = unique(obj_join['entries'], 'source_path')
splits = unique(split['results'], 'source_reference')
transforms = unique(transformed['rows'], 'source_reference')
registrations = unique(registered['rows'], 'source_reference')
active_assets = {(row.get('file_data_id'), row.get('sha256')): row for row in active['assets']}
entries = identity.get('entries', []); require(len(entries) == 6, 'six retained ROOTs required')
require(len({row['source_path'] for row in entries}) == 6, 'duplicate retained ROOT Source path')
outputs = []
for item in entries:
name = item['source_path']; obj = objs.get(name, {}); source = splits.get(name, {})
source_root = source.get('files', {}).get('root', {}); transform = transforms.get(name, {})
root = registrations.get(name, {}).get('bindings', {}).get('ROOT', {})
retained = active_assets.get((item['root_fdi'], item['root_sha256']), {})
path = Path(item['root_path'])
require(item['source_sha256'] == obj.get('source_sha256') == source.get('source_sha256_pin_reused') and
item['source_bytes'] == obj.get('source_bytes') and
item['obj_fdi'] == obj.get('roles', {}).get('obj0', {}).get('prior_native_fdi') and
item['split_root_sha256'] == source_root.get('sha256') and
source_root.get('file') == transform.get('input_ROOT') and
item['root_sha256'] == transform.get('sha256') == root.get('sha256') and
item['root_fdi'] == root.get('file_data_id') == retained.get('file_data_id') and
item['root_content_key'] == root.get('content_key') == retained.get('content_key') and
path.name == root.get('file') == retained.get('file') and
path.parent == Path(spec['active']['path']).parent and
path.is_file() and not path.is_symlink() and item['artifact_token'] == artifact_token(path),
'retained ROOT or Source input identity differs')
outputs.append({'path': str(path), 'sha256': item['root_sha256'],
'bytes': item['artifact_token']['bytes'], 'role': 'root',
'source_component': name + ':root', 'prior_native_fdi': item['root_fdi']})
return 'MAP_COMPONENTS_REUSED', outputs, {'source_root_obj_identities': 6, 'source_payloads_reread': 0,
'output_payloads_reread': 0, 'backend_reexecuted': False, 'tex_pairing_verified': False,
'native_wdt_selection_verified': False, 'native_rendering_verified': False,
'publication_performed': False}
if operation == 'saved-scene6-wdt-component':
family, identity, projection, admission, obj_stage, placements = (
pins.json(spec[k]) for k in ('family', 'identity', 'projection', 'admission', 'obj_stage', 'placements'))
require(family.get('status') == 'PASS_ORIGINAL_WDT_MAID_ROOT_TEX_LINK_FAMILY' and
family.get('runtime_verified') is False and family.get('source20_MAP_MAIN_activation') is False and
family.get('new_IDs_allocated') == 0 and
identity.get('status') == 'PASS_ONE_OUTPUT_PIN_BOUNDARY' and
identity.get('family') == spec['family']['path'] and identity.get('source_payloads_read') == 0 and
identity.get('output_payloads_read') == 1 and
projection.get('status') == 'PASS_ACTIVE32349_SCENE6_LOGICAL_ROOT_PROJECTION' and
projection.get('Map_WDT_IDs', {}).get('1') == 8560831 and
projection.get('SourceROOT_TEX_admission', {}).get('sha256') == spec['admission']['sha256'] and
admission.get('status') == 'PASS_REUSED_SIX_CURRENT_SOURCE_ROOT_TEX_AND_NEW_OBJ_INPUT_ADMISSION' and
admission.get('ready') == 6 and admission.get('held') == 10 and
placements.get('status') == 'PASS_CLOSED16_PRIVATE_NUMERIC_OBJ_BATCH_PENDING_ROOT_PAIR_ADMISSION' and
obj_stage.get('installed') is False and obj_stage.get('native_accepted') is False,
'saved Scene6 provenance or scope differs')
rows = family.get('rows', []); require(len(rows) == 1, 'one saved Map1 WDT required')
wdt = rows[0]; path = Path(identity['path'])
require(wdt.get('MapID') == 1 and wdt.get('source_reference') == 'world/maps/kalimdor/kalimdor.wdt' and
str(path) == wdt.get('file') and path.is_file() and not path.is_symlink() and
identity.get('sha256') == wdt.get('sha256') and identity.get('bytes') == wdt.get('bytes') and
identity.get('artifact_token') == artifact_token(path), 'saved Map1 WDT identity differs')
by_source = {r['source_reference']: r for r in placements['rows']}
obj = {}
for job in obj_stage['jobs']:
require(job.get('status') == 'MAP_COMPONENTS_REUSED', 'saved OBJ stage differs')
for item in job.get('outputs', []):
if item.get('role') == 'obj0':
obj[item['source_component'].removesuffix(':obj0')] = item
ready = admission.get('ready_rows', []); changes = wdt.get('changes', [])
require(len(ready) == len(changes) == 6 and len(obj) == 16, 'saved Scene6 role extent differs')
change_by_tile = {tuple(r['tile']): r for r in changes}
require(len(change_by_tile) == 6, 'duplicate Scene6 tile')
for item in ready:
name = item['source_reference']; source = by_source.get(name, {}).get('Source_payload', {})
target = obj.get(name, {}); change = change_by_tile.get(tuple(item['tile']), {})
require(item.get('MapID') == 1 and item.get('Source_input_sha256') == source.get('sha256') and
item.get('current_ROOT_accepted_by_existing_owner') is True and
item.get('current_TEX0_matches_owning_new_output') is True and
item.get('new_OBJ_same_Source_input') is True and change.get('role') == 'OBJ0' and
change.get('new_file_data_id') == target.get('prior_native_fdi'),
'saved Scene6 source or selector relationship differs')
output = {'path': str(path), 'sha256': identity['sha256'], 'bytes': identity['bytes'],
'role': 'wdt', 'map_id': 1, 'prior_native_fdi': 8560831}
return 'MAP_COMPONENTS_REUSED', [output], {'source_triplets': 6, 'source_payloads_reread': 0,
'output_payloads_reread': 0, 'backend_reexecuted': False,
'native_scene_pairing_proved': False, 'native_rendering_verified': False,
'publication_performed': False}
if operation == 'saved-obj16-source-role-join':
join = pins.json(spec['join']); root_stage = pins.json(spec['root_stage'])
tex_stage = pins.json(spec['tex_stage']); obj_stage = pins.json(spec['obj_stage'])
manifests = [pins.json(spec[k]) for k in ('source62_manifest', 'source78_manifest', 'tex_manifest')]
placements = pins.json(spec['placement_manifest'])
require(join.get('status') == 'PASS_QUALIFIED_SOURCE_ROLE_JOIN' and join.get('input_obj_components') == 16 and
join.get('source_payloads_read') == 0 and join.get('output_payloads_read') == 0 and
join.get('installed') is False and join.get('runtime_verified') is False and
placements.get('status') == 'PASS_CLOSED16_PRIVATE_NUMERIC_OBJ_BATCH_PENDING_ROOT_PAIR_ADMISSION',
'Source role-join qualification differs')
allowed = {}
for stage in (root_stage, tex_stage, obj_stage):
require(stage.get('installed') is False and stage.get('native_accepted') is False,
'saved role stage is not private')
for job in stage['jobs']:
require(job.get('status') == 'MAP_COMPONENTS_REUSED', 'saved role stage not reused')
for candidate in job.get('outputs', []):
allowed[(candidate.get('source_component'), candidate.get('role'), candidate.get('path'))] = candidate
source_refs = {}
for manifest in manifests:
for name, ref in manifest['payloads'].items():
source_refs.setdefault(name, set()).add((ref['sha256'], ref['bytes']))
placement_refs = {r['source_reference']:r['Source_payload'] for r in placements['rows']}
entries = join.get('entries', []); require(len(entries) == 16, 'Source role-join count differs')
outputs = []; complete = 0
revalidated = {}
def retained_identity(candidate):
path = Path(candidate['path'])
if path.is_symlink() or not path.is_file():
return False
current = artifact_token(path); old = candidate['artifact_token']
if current == old:
return True
if 'family' not in spec:
return False
# A remount can change st_dev without changing the saved files.
# Revalidate only the affected selected candidates, not the family.
if any(current.get(k) != old.get(k) for k in ('inode', 'bytes', 'mtime_ns')):
return False
if str(path) not in revalidated:
with path.open('rb') as stream:
revalidated[str(path)] = hashlib.file_digest(stream, 'sha256').hexdigest()
return revalidated[str(path)] == candidate['sha256']
for item in entries:
name = item['source_path']; source = placement_refs.get(name, {})
require((item['source_sha256'], item['source_bytes']) == (source.get('sha256'), source.get('bytes')),
'placement Source payload identity differs')
for role, candidate in item['roles'].items():
if 'family' in spec and set(item['roles']) != {'root', 'tex0', 'obj0'}:
continue
key = (name+':'+role, role, candidate['path']); original = allowed.get(key, {})
path = Path(candidate['path'])
require(original == candidate and retained_identity(candidate), 'saved role artifact differs')
if role in ('root', 'tex0'):
require(source_refs.get(name) == {(item['source_sha256'], item['source_bytes'])},
'Source terrain role came from a different payload')
if set(item['roles']) == {'root', 'tex0', 'obj0'}:
complete += 1
for role in ('root', 'tex0', 'obj0'):
candidate = item['roles'][role]
outputs.append({'path':candidate['path'], 'sha256':candidate['sha256'], 'bytes':candidate['bytes'],
'role':role, 'source_component':name+':'+role})
require(complete == join['joined_source_all_three'] == 1, 'qualified Source triplet count differs')
if 'family' in spec:
family = pins.json(spec['family']); selection = pins.json(spec['selection'])
root_stage2 = pins.json(spec['retained_root_stage'])
alpha4, alpha2 = pins.json(spec['alpha4']), pins.json(spec['alpha2'])
tex4, tex2 = pins.json(spec['tex4']), pins.json(spec['tex2'])
require(family.get('status') == 'PRIVATE_SEVEN_OF_SIXTEEN_SOURCE_IDENTITIES' and
family.get('denominator') == 16 and family.get('new_source_role_identity_triplets') == 6 and
family.get('prior_source_role_identity_triplets') == 1 and family.get('held') == 9 and
family.get('installed') is False and family.get('runtime_verified') is False and
family.get('native_wdt_selection_proved') is False and
family.get('native_root_tex_obj_scene_compatible') is False and
family.get('lod_and_liquid_qualified') is False,
'new private Source family qualification differs')
require(alpha4.get('status') == 'PASS_FOUR_FULL64_ALPHA_OUTPUTS_AND_TEXTURE_BINDINGS' and
alpha2.get('status') == 'PASS_FULL64_ALPHA_OUTPUTS_AND_TEXTURE_BINDINGS' and
alpha4.get('tiles') == 4 and alpha2.get('tiles') == 2 and
alpha4.get('alpha_maps', 0) + alpha2.get('alpha_maps', 0) == 3198,
'saved alpha acceptance differs')
require(root_stage2.get('installed') is False and root_stage2.get('native_accepted') is False,
'retained root stage is not private')
roots = {}
for job in root_stage2['jobs']:
require(job.get('status') == 'MAP_COMPONENTS_REUSED', 'retained root stage not reused')
roots.update((o.get('source_component'), o) for o in job.get('outputs', []))
tex = {}
for receipt in (tex4, tex2):
require(receipt.get('status') == 'PRIVATE_CHANGED_ALPHA_PATH_ONLY' and
receipt.get('installed') is False and receipt.get('runtime_verified') is False,
'saved texture candidate is not private')
for item in receipt['results']:
require(item.get('source_sha256') not in tex, 'duplicate saved texture source')
tex[item['source_sha256']] = item
root = Path(__file__).resolve().parents[1]
records = selection.get('records', {}); added = set()
require(len(family.get('new_triplets', [])) == 6 and len(records) == 6,
'new triplet or source selection count differs')
for item in family['new_triplets']:
name = item['source_path']; source = placement_refs.get(name, {}); selected = records.get(name, {})
require(name not in added and name != family.get('prior_triplet_source') and
(item['source_sha256'], item['source_bytes']) == (source.get('sha256'), source.get('bytes')) and
selected.get('state') == 'unchanged' and selected.get('bytes') == item['source_bytes'] and
selected.get('prior_sha256') == selected.get('selected_sha256') == item['source_sha256'],
'new triplet source identity differs')
added.add(name)
for role, candidate in (('root', item['retained_root']), ('obj0', item['obj0'])):
original = roots.get(name+':root') if role == 'root' else allowed.get(
(name+':obj0', 'obj0', candidate['path']))
path = Path(candidate['path'])
require(original == candidate and retained_identity(candidate), 'retained component identity differs')
outputs.append({k:candidate[k] for k in ('path', 'sha256', 'bytes', 'role', 'source_component')})
candidate = item['tex0']; owner = tex.get(item['source_sha256'], {})
path = root / candidate['path']
require(owner.get('status') == 'PRIVATE_SOURCE_FLAGS_ALPHA8' and
(owner.get('file'), owner.get('sha256'), owner.get('bytes')) ==
(candidate['path'], candidate['sha256'], candidate['bytes']) and
not path.is_symlink() and path.is_file() and path.stat().st_size == candidate['bytes'],
'saved texture identity differs')
with path.open('rb') as stream:
revalidated[str(path)] = hashlib.file_digest(stream, 'sha256').hexdigest()
require(revalidated[str(path)] == candidate['sha256'], 'saved texture content differs')
outputs.append({'path':str(path), 'sha256':candidate['sha256'], 'bytes':candidate['bytes'],
'role':'tex0', 'source_component':name+':tex0'})
complete += len(added)
return 'MAP_COMPONENTS_REUSED', outputs, {'placement_components':16, 'source_triplets':complete,
'other_source_role_pairs_held':16-complete, 'source_payloads_reread':0,
'output_payloads_reread':len(revalidated),
'backend_reexecuted':False, 'native_scene_pairing_proved':False, 'native_rendering_verified':False,
'publication_performed':False}
if operation == 'saved-obj16-components':
boundary, bindings, identity, checkpoint = (pins.json(spec[k]) for k in ('boundary', 'bindings', 'identity', 'checkpoint'))
require(boundary.get('status') == 'PASS_OBJ16_ALLOCATION_AND_PARENT_IDENTITY_BOUNDARY' and
boundary.get('new_obj_components') == 16 and
boundary.get('Source_component_to_allocated_ID_bindings_exact') is True and
boundary.get('owning_16043_MDDF_98_MODF_check_reused') is True and
boundary.get('current_client_changed') is False and boundary.get('physical_CASC_published') is False and
identity.get('status') == 'PASS_SIXTEEN_OUTPUT_PIN_BOUNDARY' and
identity.get('bindings') == spec['bindings']['path'] and identity.get('boundary') == spec['boundary']['path'] and
identity.get('checkpoint') == spec['checkpoint']['path'] and
identity.get('source_payloads_read') == 0 and identity.get('output_payloads_read') == 16 and
identity.get('overlapping_existing_source_paths') == 0 and
checkpoint.get('summary', {}).get('whole_OBJ_dependencies_closed') == 16,
'saved OBJ16 family qualification differs')
entries = identity.get('entries', []); originals = bindings.get('rows', [])
require(len(entries) == len(originals) == 16 and len({r['source_path'] for r in originals}) == 16,
'saved OBJ16 count differs')
by_source = {r['source_path']:r for r in originals}; outputs = []
for saved in entries:
item = by_source.get(saved['source_path'], {}); path = Path(saved['path'])
require(path.parent == Path(spec['bindings']['path']).parent / 'registered-OBJ16-private' and
path.name == item.get('file') and not path.is_symlink() and path.is_file() and
saved['artifact_token'] == artifact_token(path) and saved['sha256'] == item.get('sha256') and
saved['content_key'] == item.get('content_key') and saved['bytes'] == item.get('bytes') and
saved['file_data_id'] == item.get('file_data_id'), 'saved OBJ16 output identity or binding differs')
outputs.append({'path':str(path), 'sha256':saved['sha256'], 'bytes':saved['bytes'], 'role':'obj0',
'source_component':saved['source_path']+':obj0', 'prior_native_fdi':saved['file_data_id']})
return 'MAP_COMPONENTS_REUSED', outputs, {'reused_components':16, 'source_payloads_reread':0,
'output_payloads_reread':0, 'backend_reexecuted':False,
'source_root_pairing_complete':False, 'scene_dependency_closure':False,
'native_rendering_verified':False, 'publication_performed':False}
if operation == 'saved-wdt-family-components':
handoff, family, identity = (pins.json(spec[k]) for k in ('handoff', 'family', 'identity'))
require(handoff.get('status') == 'PASS_SINGLE_BATCH_SAVED_WDL_WDT_NO_RECONVERSION' and
handoff.get('installed') is False and handoff.get('runtime_verified') is False and
family.get('status') == 'PASS_FINAL_ORIGINAL529_OUTDOOR_WDT2_COMPONENT_FAMILY' and
identity.get('status') == 'PASS_TWO_OUTPUT_PIN_BOUNDARY' and
identity.get('family_receipt') == spec['family']['path'] and
identity.get('handoff') == spec['handoff']['path'] and
identity.get('source_payloads_read') == 0 and identity.get('output_payloads_read') == 2,
'saved WDT family qualification differs')
entries = identity.get('outputs', {})
require(set(entries) == {'0', '1'} and {r.get('MapID') for r in family.get('rows', [])} == {0, 1},
'saved WDT family count differs')
outputs = []
for item in family['rows']:
mid = item['MapID']; saved = entries[str(mid)]; path = Path(saved['path'])
require(path == Path(item['file']).resolve() and not path.is_symlink() and path.is_file() and
saved['artifact_token'] == artifact_token(path) and saved['sha256'] == item['sha256'] and
saved['native_fdi'] == item['control'] and saved['artifact_token']['bytes'] == item['bytes'],
'saved WDT output identity or binding differs')
outputs.append({'path':str(path), 'sha256':saved['sha256'], 'bytes':item['bytes'],
'role':'wdt', 'map_id':mid, 'prior_native_fdi':item['control']})
return 'MAP_COMPONENTS_REUSED', outputs, {'wdt_maps':[0,1], 'source_payloads_reread':0,
'output_payloads_reread':0, 'backend_reexecuted':False, 'scene_dependency_closure':False,
'native_rendering_verified':False, 'publication_performed':False}
if operation == 'saved-wdl-family-components':
handoff, family, identity, assessment = (pins.json(spec[k]) for k in ('handoff', 'family', 'identity', 'assessment'))
require(handoff.get('status') == 'PASS_SINGLE_BATCH_SAVED_WDL_WDT_NO_RECONVERSION' and
handoff.get('installed') is False and handoff.get('runtime_verified') is False and
identity.get('status') == 'PASS_SEVEN_OUTPUT_PIN_BOUNDARY' and
identity.get('family_receipt') == spec['family']['path'] and
identity.get('handoff') == spec['handoff']['path'] and
identity.get('source_payloads_read') == 0 and identity.get('output_payloads_read') == 7 and
family.get('runtime_verified') is False and family.get('whole_map_graph_closed') is False,
'saved WDL family qualification differs')
entries = identity.get('outputs', {})
require(len(entries) == len(family.get('outputs', [])) == 7 and len(family.get('rows', [])) == 11,
'saved WDL family count differs')
outputs = []
for item in family['outputs']:
key = item['Source_sha256']; saved = entries.get(key, {}); receipt = item['receipt']
path = Path(saved.get('path', ''))
require(path == (Path(__file__).resolve().parents[1] / item['output']).resolve() and
not path.is_symlink() and path.is_file() and saved.get('artifact_token') == artifact_token(path) and
saved.get('content_key') == receipt['content_key'] and
receipt.get('native_profile') == assessment['policy'] and
receipt.get('runtime_verified') is False and receipt.get('publishable') is False,
'saved WDL output identity or profile differs')
outputs.append({'path':str(path), 'sha256':saved['sha256'], 'bytes':saved['artifact_token']['bytes'],
'role':'wdl', 'source_payload_sha256':key})
require({r['payload_SHA256'] for r in family['rows']} == set(entries), 'logical WDL binding differs')
return 'MAP_COMPONENTS_REUSED', outputs, {'logical_wdls':11, 'unique_wdls':7,
'source_payloads_reread':0, 'output_payloads_reread':0, 'backend_reexecuted':False,
'scene_dependency_closure':False, 'native_rendering_verified':False, 'publication_performed':False}
if operation in ('saved-source78-existing-components', 'saved-source62-components'):
handoff, report, identity, fresh = (pins.json(spec[k]) for k in ('handoff', 'report', 'identity', 'freshness'))
source62 = operation == 'saved-source62-components'
family = 'source62' if source62 else 'source78'
expected_roles = {'root': 62, 'tex0': 62, 'obj0': 62} if source62 else {'root': 78, 'tex0': 40, 'obj0': 44}
expected_rows = 62 if source62 else 162
expected_components = sum(expected_roles.values())
require(handoff.get('status') == ('PASS' if source62 else 'PASS_EXPECTED_PARTIAL_ROLES') and
handoff.get('private_only') is True and handoff.get('dependencies_complete') is False and
handoff.get('native_accepted') is False and report.get('kind') == 'map-conversion-batch-report-v1' and
report.get('counts', {}).get('REUSED') == expected_rows and report.get('installed') is False and
report.get('runtime_verified') is False, 'saved map report is not the qualified private batch')
require(identity.get('status') == ('PASS_BOUNDED_186_ROLE_INTEGRATION_BOUNDARY' if source62 else
'PASS_BOUNDED_162_ROLE_INTEGRATION_BOUNDARY') and
identity.get('backend_report') == spec['report']['path'] and
identity.get('backend_handoff') == spec['handoff']['path'] and
identity.get('current_source_selection') == spec['freshness']['path'] and
identity.get('roles') == expected_roles and
identity.get('dependencies_complete') is False and identity.get('installed') is False and
identity.get('native_accepted') is False and
fresh.get('status') == 'COMPLETE_CONDITIONAL_ORIGINAL_ORDER',
'saved map identities or source selection differ')
directory = Path(spec['report']['path']).parent
tokens = identity.get('tokens', {})
outputs, roles, seen = [], {'root': 0, 'tex0': 0, 'obj0': 0}, set()
for item in report.get('rows', []):
if item.get('status') != 'REUSED':
continue
require(item.get('reused_qualified_output') is True and item.get('operation') == 'source-adt-split' and
item.get('installed') is False and item.get('runtime_verified') is False and
len(item.get('outputs', [])) == (3 if source62 else 1) and item.get('id') not in seen,
'saved map component qualification differs')
row_id = item['id']; seen.add(row_id)
source = row_id if source62 else row_id.rsplit(':', 1)[0]
selected = fresh.get('records', {}).get(source, {})
require(selected.get('family') == family and
isinstance(selected.get('prior_sha256'), str) and SHA.fullmatch(selected['prior_sha256']) and
selected['prior_sha256'] == selected.get('current_sha256'),
'saved map current source differs from its owning binding')
item_roles = set()
for part in item['outputs']:
role = part.get('role'); name = part.get('file')
component = row_id + ':' + role if source62 and isinstance(role, str) else row_id
candidate = item.get('contract', {}).get('reuse_saved', {}).get('candidates', {}).get(component, {})
require(role in roles and role not in item_roles and
(source62 or component.endswith(':' + role)) and
isinstance(name, str) and Path(name).name == name and
part.get('sha256') == candidate.get('sha256') and part.get('bytes') == candidate.get('bytes'),
'saved map component differs from its owning binding')
path = directory / name
require(not path.is_symlink() and path.is_file() and tokens.get(name) == artifact_token(path),
'saved map component changed since validation')
outputs.append({'path': str(path), 'sha256': part['sha256'], 'bytes': part['bytes'],
'role': role, 'source_component': component})
roles[role] += 1; item_roles.add(role)
require(not source62 or item_roles == set(roles), 'saved map triplet is incomplete')
require(roles == identity['roles'] and len(outputs) == expected_components, 'saved map component census differs')
return 'MAP_COMPONENTS_REUSED', outputs, {'reused_components': expected_components, 'roles': roles,
'backend_reexecuted': False, 'scene_dependency_closure': False,
'native_rendering_verified': False, 'publication_performed': False}
if operation == 'saved-source78-tex-components':
handoff, manifest, report = (pins.json(spec[k]) for k in ('handoff', 'manifest', 'report'))
require(handoff.get('status') == 'PASS_EXISTING_MAP_CONVERTER_SAVED_TEX_REUSE' and
report.get('kind') == 'map-conversion-batch-report-v1' and report.get('action') == 'convert' and
report.get('manifest_sha256') == spec['manifest']['sha256'] and
report.get('requested') == report.get('resolved') == 37 and report.get('held') == 0 and
report.get('candidate_content_complete') is False and report.get('installed') is False and
report.get('runtime_verified') is False, 'saved map report is not a complete private reuse batch')
jobs = manifest.get('jobs', [])
candidates = manifest.get('contracts', {}).get('saved', {}).get('reuse_saved', {}).get('candidates', {})
expected = {job['id']: job for job in jobs}
rows = report.get('rows', [])
require(len(expected) == len(jobs) == len(rows) == len(candidates) == 37 and
{r.get('id') for r in rows} == set(expected), 'saved map batch identity differs')
directory = Path(spec['report']['path']).parent
tokens = handoff.get('validated_output_artifact_tokens', {})
outputs = []
for item in rows:
job = expected[item['id']]; candidate = candidates[item['id']]
require(item.get('status') == 'REUSED' and item.get('reused_qualified_output') is True and
item.get('operation') == 'source-adt-split' and item.get('installed') is False and
item.get('runtime_verified') is False and job.get('options', {}).get('roles') == ['tex0'] and
item.get('map_id') == job.get('map_id') and item.get('tile') == job.get('tile') and
len(item.get('outputs', [])) == 1, 'saved map component qualification differs')
part = item['outputs'][0]; name = part.get('file')
require(isinstance(name, str) and Path(name).name == name and part.get('role') == 'tex0' and
part.get('sha256') == candidate.get('sha256') and part.get('bytes') == candidate.get('bytes'),
'saved map component differs from its input binding')
path = directory / name
require(not path.is_symlink() and path.is_file() and tokens.get(name) == artifact_token(path),
'saved map component changed since validation')
outputs.append({'path': str(path), 'sha256': part['sha256'], 'bytes': part['bytes'],
'role': 'tex0', 'source_component': item['id']})
return 'MAP_COMPONENTS_REUSED', outputs, {'reused_components': 37, 'backend_reexecuted': False,
'scene_dependency_closure': False, 'native_rendering_verified': False, 'publication_performed': False}
if operation == 'saved-emerald-wdt-assessment':
from map_conversion_batch import reuse_saved_emerald_wdt
values = [pins.json(spec[k]) for k in ('handoff', 'role_audit')]
values.append(json.loads(pins.read(spec['active_registry'], 64 * 1024 * 1024)))
values.append(pins.json(spec['outdoor_coverage']))
report = reuse_saved_emerald_wdt(*values)
return 'MAP_ASSESSMENT_STAGED', [save('emerald-wdt-assessment.json', report, 'saved-emerald-wdt-assessment')], {
'behavior_implemented': False, 'native_selection_or_rendering_verified': False, 'publication_performed': False}
if operation == 'saved-outdoor-area-assessment':
from map_asset_preflight import reuse_saved_outdoor_area_profiles
report = reuse_saved_outdoor_area_profiles(*(pins.json(spec[k]) for k in ('assessment', 'manifest', 'component')))
return 'AREA_ASSESSMENT_STAGED', [save('area-assessment.json', report, 'saved-outdoor-area-assessment')], {
'behavior_implemented': False, 'native_ui_or_rendering_verified': False, 'publication_performed': False}
if operation == 'saved-static-taxi-assessment':
from taxi_profile import reuse_saved_routes
current = ({key: pins.json(spec[key]) for key in ('current_freshness', 'current_added')}
if 'current_freshness' in spec else {})
report = reuse_saved_routes(*(pins.json(spec[k]) for k in ('assessment', 'profile', 'resolved', 'held')),
*(pins.read(spec[k]).decode('utf-8') for k in ('paths_header', 'nodes_header')),
**current)
return 'TAXI_ASSESSMENT_STAGED', [save('taxi-assessment.json', report, 'saved-static-taxi-assessment')], {
'behavior_implemented': False, 'native_server_acceptance_verified': False, 'new_native_records': 0}
if operation.endswith('-observation'):
raw = pins.read(spec['input'], 32 * 1024 * 1024).decode('utf-8')
if operation == 'travel-observation':
from octo_travel_capture import extract_saved, summary
capture, isolated = extract_saved(raw)
outputs = [save('isolated-travel.lua', isolated.encode(), 'official-travel-evidence')]
report = summary(capture)
elif operation == 'social-observation':
from octo_social_capture import extract, summarize
report = summarize(extract(raw)); outputs = []
else:
from octo_guild_bank_capture import extract, summarize
report = summarize(extract(raw)); outputs = []
outputs.append(save('observation-summary.json', report, 'rea-observation-summary'))
return 'OBSERVATION_STAGED', outputs, {'behavior_implemented': False, 'native_server_acceptance_verified': False}
if operation == 'public-protocol-profile':
from package_octo_protocol import package_protocol
fixtures = output / 'public-inputs'; fixtures.mkdir(mode=0o700)
for key, name, low, high in [('version', 'version-hash.bin', 20, 20), ('addons', 'addon-tail.bin', 4, 10000)]:
body = pins.read(spec[key]); require(low <= len(body) <= high, 'bounded public protocol extent required')
(fixtures / name).write_bytes(body)
report = package_protocol(fixtures, output / 'profile', destination=spec['destination'])
outputs = [save('public-profile-stage.json', report, 'public-protocol-profile-stage')]
profile_path = Path(report['profile_path'])
outputs.append({'path': str(profile_path), 'sha256': report['profile_sha256'], 'bytes': profile_path.stat().st_size, 'role': 'public-protocol-profile'})
return 'PUBLIC_PROFILE_STAGED', outputs, {'authentication_performed': False, 'credentials_included': False, 'behavior_implemented': False}
from casc_asset_package import stage_framed_native_assets
kwargs = {key: pins.json(spec[key]) for key in ('retained_asset_frames', 'retained_native_content_entries', 'retained_download_controls') if spec[key]}
if 'retained_download_controls' in kwargs:
kwargs['retained_download_controls'] = {int(k): v for k, v in kwargs['retained_download_controls'].items()}
report = stage_framed_native_assets(spec['asset_manifest']['path'], spec['native_context'], spec['reuse_directory'], output / 'frames', **kwargs)
return 'CASC_FRAMED_PRIVATE', [save('framing-stage.json', report, 'registered-casc-framing-receipt')], {
'installed': False, 'physical_archive_assembled': False, 'compilation_performed': False, 'native_acceptance_verified': False}
def execute_data_batch(rows, target, pins):
results, projected = {}, {}
active = [r for r in rows if r.get('status') == 'PLANNED' and r.get('adapter') == 'classic-data' and r.get('decision') == 'CONVERT']
if not active:
return results, projected
from classic_data_adapters import convert_batch
for row in active:
if row.get('status') != 'PLANNED' or row.get('adapter') != 'classic-data' or row.get('decision') != 'CONVERT':
continue
# Preserve the producer's exact immutable byte-reader namespace. Each
# nested batch already shares its inputs, contracts and producer cache.
directory = target / (row['id'] + '-definition-association-batch')
report = convert_batch(row['_data_backend'], directory, base_directory=pins.base)
results[row['id']] = (directory, report)
projected[row['id']] = report['rows']
return results, projected
def plan(request, *, base_directory=None):
req, base = read_request(request, base_directory)
require(req.get('kind') == KIND, 'classic-to-forever-v1 request required')
pins = Pins(base)
snapshot = pins.json(req.get('source_snapshot'))
require(snapshot.get('kind') == 'classic-to-forever-source-snapshot-v1', 'immutable SourceSnapshot required')
inventory = normalize_inventory(pins.json(req.get('patch_inventory')))
require(inventory.get('kind') == 'classic-to-forever-patch-inventory-v1', 'pinned current patch inventory required')
snapshot['_current_inventory_sha256'] = req['patch_inventory']['sha256']
native = pins.json(req['native_assets']) if req.get('native_assets') else {'assets': {}}
require(isinstance(native.get('assets'), dict), 'keyed native asset catalogue required')
jobs = req.get('jobs')
require(isinstance(jobs, list) and 0 < len(jobs) <= 4096, 'bounded job list required')
require(all(isinstance(j, dict) and ID.fullmatch(j.get('id', '')) for j in jobs), 'safe distinct job IDs required')
require(len({j['id'] for j in jobs}) == len(jobs), 'distinct job IDs required')
source_catalogue = snapshot.get('inputs', {})
require(isinstance(source_catalogue, dict), 'keyed Source payload inventory required')
selected_keys = {key for j in jobs for key in j.get('source_inputs', [])}
require(selected_keys <= source_catalogue.keys(), 'undeclared Source input')
selected = {key: source_catalogue[key] for key in selected_keys}
for ref in selected.values():
pins.path(ref) # Metadata stat only. No unchanged payload reads/hash sweeps.
freshness, changed = source_freshness(snapshot, inventory, selected, pins)
retained_baseline = req.get('retained_baseline')
if retained_baseline:
retained_document = pins.json(retained_baseline)
require(good_status(retained_document.get('status')), 'successful retained-baseline handoff required')
previous = pins.json(req['previous_stage']) if req.get('previous_stage') else {}
require(not previous or previous.get('kind') == 'classic-to-forever-stage-v1', 'typed previous stage required')
prior = {r['id']: r for r in previous.get('jobs', [])}
rows, by_id, pending = [], {}, list(jobs)
while pending:
progressed = False
for job in list(pending):
deps = job.get('dependencies', [])
require(isinstance(deps, list) and all(isinstance(d, str) for d in deps), 'job dependency IDs required')
if not set(deps) <= by_id.keys():
continue
progressed = True
pending.remove(job)
row = {'id': job['id'], 'scope': job.get('scope'), 'adapter': job.get('adapter'),
'status': 'HELD', 'installed': False, 'native_accepted': False, 'dependencies': deps}
try:
require(job.get('scope') in SCOPES, 'unknown scope')
adapter = job.get('adapter')
require(adapter in ADAPTERS and job['scope'] in ADAPTERS[adapter]['scopes'],
SCOPE_BLOCKS.get(job['scope'], 'no supported fixed frontend adapter; existing system needs a scoped adapter'))
require(all(by_id[d]['status'] != 'HELD' for d in deps), 'dependent job held')
sources = {k: source_catalogue[k] for k in job.get('source_inputs', [])}
require(sources or adapter in ('creation-menu-ui', 'source-realm-ui', 'saved-taxi-stage', 'saved-area-profile-stage', 'saved-emerald-wdt-stage', 'saved-map-components-stage', 'saved-source-map-art-stage'),
'selected Source inputs required')
require(all(freshness[k]['status'] != 'HELD' for k in sources),
'; '.join(freshness[k].get('reason', '') for k in sources if freshness[k]['status'] == 'HELD'))
native_keys = set(job.get('native_inputs', []))
for source_key in sources:
associated = native.get('source_to_native', {}).get(source_key, [])
require(isinstance(associated, list), 'native association list required')
native_keys.update(associated)
if source_key in native['assets']:
native_keys.add(source_key)
natives = {k: native['assets'][k] for k in sorted(native_keys)}
for ref in natives.values():
pins.path(ref)
contract_ref, contract = contract_for(job, req, pins, sources, natives)
decision = native_choice(job, sources, natives, contract)
require(job.get('change_kind', 'asset') in ('asset', 'data-behavior', 'source-preparation'), 'explicit change kind required')
if adapter == 'icon-stage':
require(job.get('asset_role') in ('item-icon', 'spell-icon', 'icon'), 'explicit icon role required')
parameters = job.get('parameters', {})
require(isinstance(parameters, dict), 'structured parameters required')
nested = backend_request(job, req, sources, natives, pins, contract) if adapter == 'map-batch' and decision == 'CONVERT' else None
data_nested = data_request(job, sources, natives, pins, contract) if adapter == 'classic-data' and decision == 'CONVERT' else None
system_spec = system_request(job, sources, natives, pins, contract) if adapter in ('observation-stage', 'public-profile-stage', 'casc-frame-stage', 'saved-taxi-stage', 'saved-area-profile-stage', 'saved-emerald-wdt-stage', 'saved-map-components-stage', 'saved-source-map-art-stage') and decision == 'CONVERT' else None
ui_spec = (creation_ui_request(job, sources, natives, pins, contract) if adapter == 'creation-menu-ui' else
source_realm_ui_request(job, sources, natives, pins, contract) if adapter == 'source-realm-ui' else None) if decision == 'CONVERT' else None
icon_spec = registered_item_icon_request(job, sources, natives, pins, contract) if adapter == 'registered-item-icon-stage' and decision == 'CONVERT' else None
fp = digest(encoded({'scope': job['scope'], 'adapter': adapter, 'source': {k: v['sha256'] for k, v in sources.items()},
'native': {k: v['sha256'] for k, v in natives.items()}, 'contract': contract_ref['sha256'],
'parameters': parameters, 'change_kind': job.get('change_kind', 'asset'),
'asset_role': job.get('asset_role'), 'decision': decision,
'icon_dependency_tokens': icon_spec['dependencies'] if icon_spec else None,
'producer_pins': producer_pins(adapter, parameters),
'dependencies': {d: by_id[d]['fingerprint'] for d in deps}}))
row.update(status='PLANNED', fingerprint=fp, decision=decision,
source_bindings={k: v['sha256'] for k, v in sources.items()},
native_bindings={k: v['sha256'] for k, v in natives.items()},
acceptance_criteria=sorted(set(SCOPES[job['scope']][1] + contract['acceptance_criteria'])),
stage=ADAPTERS[adapter]['stage'], source_content_resolved=decision != 'PRESERVE_NATIVE',
source_only_staging=job.get('change_kind') == 'source-preparation',
runtime_candidate=(job.get('change_kind') != 'source-preparation' and ADAPTERS[adapter].get('runtime_candidate', True) and not
(adapter == 'classic-data' and data_nested and all(
child.get('operation') == 'items.property-catalogue-assessment'
for child in data_nested['jobs']))),
remaining_behavior_block=SCOPE_BLOCKS.get(job['scope']))
old = prior.get(job['id'])
if old and old.get('fingerprint') == fp and old.get('status') in REUSABLE_STATES:
require(old.get('outputs') and all(SHA.fullmatch(o.get('sha256', '')) for o in old['outputs']), 'previous output bindings required')
require(all(o.get('artifact_token') == artifact_token(o['path']) for o in old['outputs']),
'previous staged artifact changed; affected job requires conversion')
row.update(decision='REUSE_PREVIOUS', previous_outputs=old['outputs'], previous_stage_sha256=req['previous_stage']['sha256'])
row['_sources'] = sources
row['_natives'] = natives
row['_backend'] = nested
row['_data_backend'] = data_nested
row['_system_spec'] = system_spec
row['_ui_spec'] = ui_spec
row['_icon_spec'] = icon_spec
except (ValueError, KeyError, TypeError, OSError) as error:
row.update(status='HELD', reason=str(error))
rows.append(row)
by_id[job['id']] = row
require(progressed, 'unknown or cyclic job dependency')
pins.stable()
source_paths = {str(pins.path(v)) for v in selected.values()}
payload_reads = [raw for (path, sha), raw in pins.cache.items() if path in source_paths]
return {'kind': 'classic-to-forever-plan-v1', 'request_sha256': digest(encoded(req)),
'source_snapshot': req['source_snapshot'], 'patch_inventory': req['patch_inventory'],
'changed_archives': changed, 'source_freshness': freshness, 'jobs': rows,
'source_payload_files_read': len(payload_reads), 'source_payload_bytes_read': sum(map(len, payload_reads)),
'registry': registry(), 'retained_baseline': retained_baseline,
'counts': {s: sum(r['status'] == s for r in rows) for s in ('PLANNED', 'HELD')},
'installed': False, 'native_accepted': False}, pins
def public(report):
value = copy.deepcopy(report)
for row in value.get('jobs', []):
for key in list(row):
if key.startswith('_'):
del row[key]
return value
def execute_map_batch(rows, target, pins):
combined = {'kind': 'map-conversion-batch-v1', 'payloads': {}, 'contracts': {}, 'jobs': []}
owners = {}
for row in rows:
if row.get('status') != 'PLANNED' or row.get('adapter') != 'map-batch' or row.get('decision') != 'CONVERT':
continue
nested = row['_backend']
prefix = row['id'] + '.'
combined['payloads'].update({prefix + k: v for k, v in nested['payloads'].items()})
combined['contracts'].update({prefix + k: v for k, v in nested.get('contracts', {}).items()})
for child in nested['jobs']:
item = copy.deepcopy(child)
item['id'] = prefix + child['id']
item['source'] = prefix + child['source']
if child.get('native'):
item['native'] = prefix + child['native']
item['contracts'] = {k: prefix + v for k, v in child.get('contracts', {}).items()}
combined['jobs'].append(item)
owners[item['id']] = row['id']
if not combined['jobs']:
return None, {}
from map_conversion_batch import convert_batch
backend_dir = target / 'map-model-batch'
report = convert_batch(combined, backend_dir, base_directory=pins.base)
projected = {}
for child in report['rows']:
projected.setdefault(owners[child['id']], []).append(child)
return (backend_dir, report), projected
def convert(request, output, *, base_directory=None):
report, pins = plan(request, base_directory=base_directory)
target = fresh_output(output)
staged = public(report)
staged['kind'] = 'classic-to-forever-stage-v1'
backend_result, backend_by_job = execute_map_batch(report['jobs'], target, pins)
data_result, data_by_job = execute_data_batch(report['jobs'], target, pins)
icon_stages = {}
for row, outrow in zip(report['jobs'], staged['jobs']):
if row['status'] == 'HELD':
continue
try:
completed = {r['id']: r for r in staged['jobs']}
require(all(completed[d]['status'] != 'HELD' for d in row['dependencies']), 'dependent conversion held')
decision = row['decision']
if decision == 'REUSE_PREVIOUS':
outrow.update(status='REUSED_PREVIOUS', outputs=row['previous_outputs'])
elif decision in ('REUSE_IDENTICAL', 'REUSE_REA_EQUIVALENT', 'PRESERVE_NATIVE'):
outrow.update(status='PRESERVED_NATIVE' if decision == 'PRESERVE_NATIVE' else 'REUSED',
outputs=[dict(pins.absolute(v), role='native-reference', native_key=k) for k, v in row['_natives'].items()])
elif row['adapter'] == 'map-batch':
backend_dir, backend = backend_result
children = backend_by_job.get(row['id'], [])
outrow['backend_report'] = {'path': str(backend_dir / 'report.json'), 'sha256': digest(encoded(backend))}
outrow['backend_rows'] = children
require(children and all(r['status'] != 'HELD' for r in children),
'backend has held rows; no complete candidate admission')
outrow['outputs'] = [dict(o, path=str(backend_dir / o['file'])) for r in children for o in r.get('outputs', [])]
outrow.update(status='CONVERTED_PRIVATE', conversion_scope='backend-requested-operation-only',
content_complete=False, native_accepted=False)
elif row['adapter'] == 'classic-data':
directory, backend = data_result[row['id']]; children = data_by_job.get(row['id'], [])
outrow['backend_rows'] = children
outrow['backend_report'] = {'path': str(directory / 'report.json'), 'sha256': digest((directory / 'report.json').read_bytes())}
require(children and all(r['status'] == 'STAGED' for r in children), 'classic-data backend has held rows')
outrow.update(status='CONVERTED_PRIVATE', outputs=[dict(r['output'], path=str(directory / r['output']['file'])) for r in children],
content_complete=False, native_accepted=False)
if not row['runtime_candidate']:
outrow['conversion_scope'] = 'assessment-only; no runtime artifact generated'
elif row['adapter'] == 'registered-item-icon-stage':
from item_icon_native_assets import stage
if row['fingerprint'] in icon_stages:
outrow.update(status='REUSED', outputs=copy.deepcopy(icon_stages[row['fingerprint']]),
conversion_scope='same qualified icon batch', content_complete=False, native_accepted=False)
else:
spec = row['_icon_spec']['selected']; directory = target / row['id']
produced = stage(Path(spec['package']['path']), Path(spec['catalogue_manifest']['path']).parent,
Path(spec['artwork_manifest']['path']).parent, Path(spec['baseline_manifest']['path']),
Path(spec['native_root']['path']), directory,
expected_inputs={key: value['sha256'] for key, value in spec.items()},
replace_existing=row['_icon_spec']['replace_existing'])
outputs = []
for filename, role in (('manifest.json', 'registered-icon-manifest'), ('root.bin', 'registered-icon-root')):
path = directory / filename; body = path.read_bytes()
outputs.append({'path': str(path), 'sha256': digest(body), 'bytes': len(body), 'role': role})
outputs += [{'path': str(directory / asset['file']), 'sha256': asset['sha256'],
'bytes': asset['bytes'], 'role': 'registered-icon-asset'} for asset in produced['assets']]
icon_stages[row['fingerprint']] = copy.deepcopy(outputs)
outrow.update(status='ICON_REGISTERED_PRIVATE', outputs=outputs, content_complete=False,
native_accepted=False, conversion_scope=('explicit-source-backed-item-icons' if row['_icon_spec']['replace_existing'] else 'published-zero-item-icons-only'),
stage_audit={'prior_assets_preserved': produced.get('prior_assets_preserved'),
'selected_items': len(produced.get('source_icon_bindings', [])),
'held_items': len(produced.get('source_icon_blocked', [])),
'unchanged_items': len(produced.get('source_icon_unchanged', [])),
'positive_replacement_candidates': sum(r.get('old_icon_file_data_id', 0) > 0 for r in produced.get('source_icon_bindings', [])),
'positive_replacement_requested': row['_icon_spec']['replace_existing']})
elif row['adapter'] == 'creation-menu-ui':
from single_name_creation_ui import transform
spec = row['_ui_spec']; future = spec.get('future_placeholders')
body = transform(pins.read(spec['native_lua']), disable_extra_elves=True,
show_future_placeholders=future is not None,
furbolg_portrait_fdid=future['portraits']['Furbolg'] if future else 236696)
expected_ui = future['candidate_sha256'] if future is not None else spec['qualification']['candidate_sha256']
require(digest(body) == expected_ui, 'UI output differs from owning qualified candidate')
directory = target / row['id']; directory.mkdir()
path = directory / 'blizzard_charactercreate.lua'; path.write_bytes(body)
outrow.update(status='UI_PATCH_STAGED', outputs=[{'path': str(path), 'sha256': digest(body), 'bytes': len(body),
'role': 'original-character-create-menu-patch'}], content_complete=False, native_accepted=False,
stage_audit={'disabled_races': [27, 29], 'native_race9_10_admission_changed': False,
'native_apis_overridden': False, 'native_race_rows_modified': False,
'qualification_sha256': spec['qualification_ref']['sha256'],
'future_placeholders': future is not None,
'future_placeholders_selectable': False if future is not None else None})
elif row['adapter'] == 'source-realm-ui':
spec = row['_ui_spec']; directory = target / row['id']; directory.mkdir()
if spec.get('kind')=='local-loopback-no-preflight':
from source_realm_ui import transform_local_test_no_preflight
body,xml=transform_local_test_no_preflight(pins.read(spec['lua']),pins.read(spec['xml']))
require(digest(body)==spec['qualification']['candidate_lua_sha256'] and
digest(xml)==spec['xml']['sha256'], 'local login output differs from owning qualification')
path=directory/'accountlogin.lua';path.write_bytes(body)
outrow.update(status='UI_PATCH_STAGED',
outputs=[{'path':str(path),'sha256':digest(body),'bytes':len(body),'role':'local-test-account-login-patch'}],
content_complete=False,native_accepted=False,
stage_audit={'qualification_sha256':spec['qualification_ref']['sha256'],
'build_qualification_sha256':spec['build_ref']['sha256'],
'loopback_profile':spec['profile'],'wire_sha256':spec['wire']['sha256'],
'engine_metadata_sha256':spec['metadata']['sha256'],
'unchanged_xml_reused':spec['xml'],'local_only_enforced_by_ui':False,
'requires_local_owner_and_endpoint_admission':True,
'source_realm_generation':'HELD','source_activation_installed':False})
else:
from source_realm_ui import transform, transform_glue
outputs = []
for key, filename, producer, native in (
('realm-list', 'realmlist.lua', transform, spec['realm']),
('glue-parent', 'glueparent.lua', transform_glue, spec['glue'])):
options = {'enable_source_pending': True}
if key == 'glue-parent' and spec['diagnostic_proof'] is not None:
options['enable_login_diagnostics'] = True
body = producer(pins.read(native), **options)
expected = (spec['diagnostic_proof']['files']['runtime/continuation-20261029/new-login-front-prototype/glueparent-diagnostic.private.lua']
if key == 'glue-parent' and spec['diagnostic_proof'] is not None
else spec['qualification']['candidates'][key]['sha256'])
require(digest(body) == expected,
'realm UI output differs from owning qualified candidate')
path = directory / filename; path.write_bytes(body)
outputs.append({'path': str(path), 'sha256': digest(body), 'bytes': len(body),
'role': 'original-' + key + '-patch'})
outrow.update(status='UI_PATCH_STAGED', outputs=outputs, content_complete=False, native_accepted=False,
stage_audit={'qualification_sha256': spec['qualification_ref']['sha256'],
'diagnostic_qualification_sha256': spec['diagnostic_ref']['sha256'] if spec['diagnostic_ref'] else None,
'login_diagnostic_enabled': spec['diagnostic_proof'] is not None,
'source_activation_installed': False})
elif row['adapter'] in ('observation-stage', 'public-profile-stage', 'casc-frame-stage', 'saved-taxi-stage', 'saved-area-profile-stage', 'saved-emerald-wdt-stage', 'saved-map-components-stage', 'saved-source-map-art-stage'):
status, outputs, audit = execute_system_stage(row, target / row['id'], pins)
outrow.update(status=status, outputs=outputs, stage_audit=audit, content_complete=False, native_accepted=False)
else:
from octo_icon_assets import decode_blp
outputs = []
held_sources = []
for key, ref in row['_sources'].items():
body = pins.read(ref, 64 * 1024 * 1024)
try:
audit = decode_blp(body)
except (ValueError, OSError) as error:
if not row.get('source_only_staging'):
raise
held_sources.append({'source_input': key, 'reason': str(error)})
continue
filename = digest(body) + '.blp'
destination = target / filename
if not destination.exists():
if row.get('source_only_staging'):
try:
os.link(pins.path(ref), destination)
except OSError as error:
if error.errno not in (errno.EXDEV, errno.EPERM, errno.EOPNOTSUPP):
raise
destination.write_bytes(body)
else:
destination.write_bytes(body)
outputs.append({'path': str(destination), 'sha256': digest(body), 'bytes': len(body),
'source_input': key, 'role': ('source-icon' if row['adapter'] == 'icon-stage' else
'source-texture' if row.get('source_only_staging') else 'added-texture'),
'decode': audit})
status = ('HELD' if not outputs and held_sources else
'PARTIAL_SOURCE_TEXTURES_PRIVATE' if held_sources else 'CONVERTED_PRIVATE')
outrow.update(status=status, outputs=outputs, held_sources=held_sources, content_complete=False)
for artifact in outrow.get('outputs', []):
if decision != 'REUSE_PREVIOUS':
artifact['artifact_token'] = artifact_token(artifact['path'])
except (ValueError, TypeError, KeyError, OSError, NotImplementedError) as error:
outrow.update(status='HELD', reason=str(error))
pins.stable()
staged['counts'] = stage_status_counts(staged['jobs'])
staged['output_directory'] = str(target)
(target / 'stage.json').write_bytes(encoded(staged))
return staged
def acceptance_report(stage_reference, receipts=(), *, base_directory=None):
pins = Pins(base_directory or Path.cwd())
stage = pins.json(stage_reference)
require(stage.get('kind') == 'classic-to-forever-stage-v1', 'typed stage receipt required')
documents = [(ref, pins.json(ref)) for ref in receipts]
rows = []
for job in stage['jobs']:
row = {'id': job['id'], 'scope': job['scope'], 'stage_status': job['status'], 'native_accepted': False,
'missing_criteria': job.get('acceptance_criteria', [])}
errors = []
for ref, receipt in documents:
if receipt.get('job_id') != job['id']:
continue
try:
require(job.get('runtime_candidate', True) is True, 'staged evidence/profile/framing cannot be native behavior accepted')
require(job['status'] != 'HELD' and job.get('source_content_resolved') is True,
'held/unresolved Source job cannot be native accepted')
require(receipt.get('kind') == ADAPTERS[job['adapter']]['native_receipt'], 'typed native acceptance receipt required')
require(receipt.get('stage') == 'native' and receipt.get('status') == 'PASS', 'native PASS stage required')
require(receipt.get('scope') == job['scope'] and receipt.get('adapter') == job['adapter'], 'acceptance scope/adapter differs')
require(receipt.get('fingerprint') == job.get('fingerprint'), 'acceptance input fingerprint differs')
require(receipt.get('stage_sha256') == stage_reference['sha256'], 'acceptance stage binding differs')
require(receipt.get('source_bindings') == job.get('source_bindings'), 'acceptance Source bindings differ')
outputs = sorted(o['sha256'] for o in job.get('outputs', []))
require(receipt.get('output_sha256') == outputs, 'acceptance output bindings differ')
evidence = receipt.get('criteria', {})
require(set(job['acceptance_criteria']) <= set(evidence), 'acceptance criteria missing')
for criterion in job['acceptance_criteria']:
proof = evidence[criterion]
require(proof.get('kind') == 'native-observation' and proof.get('scope') == job['scope'] and
proof.get('criterion') == criterion, 'scoped native criterion evidence required')
observed = pins.json(proof)
require(observed.get('kind') == 'classic-to-forever-native-observation-v1' and
observed.get('status') == 'PASS' and observed.get('scope') == job['scope'] and
observed.get('criterion') == criterion and observed.get('fingerprint') == job['fingerprint'] and
observed.get('output_sha256') == outputs, 'native observation payload binding differs')
row.update(native_accepted=True, missing_criteria=[], receipt=ref)
break
except (ValueError, KeyError, TypeError, OSError) as error:
errors.append(str(error))
if errors:
row['rejected_receipts'] = errors
rows.append(row)
pins.stable()
return {'kind': 'classic-to-forever-acceptance-report-v1', 'stage': stage_reference, 'jobs': rows,
'native_accepted': bool(rows) and all(r['native_accepted'] for r in rows), 'installed': False}
def plan_batch(request, *, base_directory=None):
return public(plan(request, base_directory=base_directory)[0])
def convert_batch(request, output, *, base_directory=None):
return convert(request, output, base_directory=base_directory)
def main(argv=None):
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument('action', choices=('plan', 'convert', 'acceptance-report', 'registry'))
parser.add_argument('request', nargs='?')
parser.add_argument('--output')
parser.add_argument('--receipt', action='append', default=[])
args = parser.parse_args(argv)
try:
if args.action == 'registry':
result = registry()
else:
require(args.request, 'request path required')
if args.action == 'plan':
result = public(plan(args.request)[0])
elif args.action == 'convert':
require(args.output, 'fresh runtime staging directory required')
result = convert(args.request, args.output)
else:
path = Path(args.request).resolve()
stage_ref = {'path': str(path), 'sha256': digest(path.read_bytes())}
receipt_refs = [{'path': str(Path(p).resolve()), 'sha256': digest(Path(p).read_bytes())} for p in args.receipt]
result = acceptance_report(stage_ref, receipt_refs)
if args.output and args.action != 'convert':
target = fresh_output(args.output)
(target / 'report.json').write_bytes(encoded(result))
counts = result.get('counts', {})
print(json.dumps({'kind': result['kind'], 'jobs': len(result.get('jobs', [])), 'counts': counts,
'native_accepted': result.get('native_accepted', False)}, sort_keys=True))
return 0
except (ValueError, KeyError, TypeError, OSError) as error:
print('HELD: ' + str(error), file=sys.stderr)
return 2
if __name__ == '__main__':
raise SystemExit(main())