883 files, from working commit b1a079a. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
139 lines
8.8 KiB
Python
139 lines
8.8 KiB
Python
#!/usr/bin/env python3
|
|
"""Retained static-family container relationships; no conversion or Game use."""
|
|
import argparse
|
|
import copy
|
|
import hashlib
|
|
import json
|
|
from pathlib import Path
|
|
import struct
|
|
import sys
|
|
from unittest.mock import patch
|
|
|
|
sys.path.insert(0,str(Path(__file__).resolve().parents[1]/'ops'))
|
|
import casc_asset_package as c
|
|
from item_appearance_preflight import model_dependency_chunks
|
|
from item_model_assets import stage_registered,_validated_model_texture_references
|
|
|
|
def check(job):
|
|
load=lambda p:json.loads(Path(p).read_text())
|
|
pin=lambda p:hashlib.sha256(Path(p).read_bytes()).hexdigest()
|
|
parameters=load(job/'stage-parameters.json');audit=load(job/'fixture-input-audit.json')
|
|
baseline=load(parameters['baseline_manifest']);old={r['path']:r for r in baseline['assets']}
|
|
outputs=set(audit['conversion_output_files'])
|
|
forbidden=set(audit['forbidden_existing_texture_files'])|{str(Path(p).resolve())for p in audit['Source_body_paths']}
|
|
references=load(parameters['validated_model_texture_bindings'])
|
|
sdk=load(references['native_availability_receipt']);forbidden.add(str(Path(sdk['direct_native']['body']).resolve()))
|
|
original_read=Path.read_bytes;original_container=c.model_container
|
|
reads={};containers=[];root_memory=[None]
|
|
def read(path):
|
|
key=str(path.resolve());assert key not in forbidden,'Existing texture or Source model body was read'
|
|
raw=original_read(path)
|
|
if key in outputs:reads[key]=reads.get(key,0)+1
|
|
if path.resolve()==Path(parameters['native_root']).resolve():root_memory[0]=raw
|
|
return raw
|
|
def container(body,skins,textures):
|
|
result=original_container(body,skins,textures)
|
|
dependencies=model_dependency_chunks(result)
|
|
assert dependencies['skin_file_ids']==skins and dependencies['texture_file_ids']==textures
|
|
assert len(skins)==4 and len(textures)==1 and all(type(x)is int and x>0 for x in skins+textures)
|
|
assert not dependencies['skin_path_fallback_unreviewed']
|
|
tag,size=struct.unpack_from('<4sI',result);assert tag==b'MD21' and size==len(body)
|
|
expected=bytearray(body);count,offset=struct.unpack_from('<II',body,80)
|
|
assert count==1
|
|
for index in range(count):struct.pack_into('<II',expected,offset+index*16+8,0,0)
|
|
actual=result[8:8+size]
|
|
assert actual==expected,'Container changed bytes outside the declared fixed filename references'
|
|
assert struct.unpack_from('<I',body,16)[0]==struct.unpack_from('<I',actual,16)[0]==0
|
|
containers.append(dict(SFID=skins,TXID=textures,body_bytes_preserved_except_filename_references=True,
|
|
source_flag0_preserved=True))
|
|
return result
|
|
arguments={k:Path(v)if k in ('source_manifest','conversion_manifest','baseline_manifest','native_root','output',
|
|
'retained_conversion_manifest','validated_model_texture_bindings')else v for k,v in parameters.items()}
|
|
with patch.object(Path,'read_bytes',read),patch.object(c,'model_container',container):
|
|
result=stage_registered(**arguments)
|
|
assert len(containers)==277 and len(reads)==1385 and all(n==1 for n in reads.values())
|
|
after={r['path']:r for r in result['assets']};assert all(after[p]==r for p,r in old.items())
|
|
added=[r for p,r in after.items()if p not in old]
|
|
assert len(result['assets'])==11356 and len(added)==1385 and not result['excluded']
|
|
assert sum(r['kind']=='model'for r in added)==277 and sum(r['kind']=='skin'for r in added)==1108
|
|
assert sum(7786005 in r['TXID']for r in containers)==1
|
|
# New relationship refusals exercise the production proof reader only.
|
|
# The successful family staging/conversion is not repeated.
|
|
canonical_path=Path(references['canonical_manifest']);canonical=load(canonical_path)
|
|
selected=set(references['Source_paths'])
|
|
owned=next(r for r in canonical['aliases']if r['source_path']in selected and r.get('registered_path'))
|
|
native=next(r for r in canonical['aliases']if r['source_path']in selected and r.get('registered_path')is None)
|
|
refusal_dir=job/'typed-binding-refusals';refusal_dir.mkdir()
|
|
refusals=[]
|
|
def refuse(name,document,*,canonical_document=None,wrong_pin=False):
|
|
doc=copy.deepcopy(document)
|
|
if canonical_document is not None:
|
|
cp=refusal_dir/(name+'-canonical.json');cp.write_text(json.dumps(canonical_document))
|
|
doc['canonical_manifest']=str(cp);doc['canonical_manifest_sha256']=pin(cp)
|
|
path=refusal_dir/(name+'.json');path.write_text(json.dumps(doc))
|
|
try:_validated_model_texture_references(path,'0'*64 if wrong_pin else pin(path),baseline,
|
|
parameters['frozen_parent_manifest_sha256'],root_memory[0])
|
|
except ValueError as error:refusals.append(dict(case=name,reason=str(error)))
|
|
else:raise AssertionError('Accepted invalid model texture reference: '+name)
|
|
refuse('changed-binding-pin',references,wrong_pin=True)
|
|
bad=copy.deepcopy(references);bad['parent_manifest_sha256']='0'*64
|
|
refuse('wrong-frozen-parent',bad)
|
|
bad=copy.deepcopy(references);bad['Source_paths']=[owned['source_path']]
|
|
changed=copy.deepcopy(canonical)
|
|
next(r for r in changed['aliases']if r['source_path']==owned['source_path'])['file_data_id']+=1
|
|
refuse('owned-ID-mismatch',bad,canonical_document=changed)
|
|
bad=copy.deepcopy(references);bad['Source_paths']=[native['source_path']]
|
|
changed=copy.deepcopy(canonical)
|
|
next(r for r in changed['aliases']if r['source_path']==native['source_path'])['file_data_id']=127513
|
|
refuse('ambiguous-native-variant',bad,canonical_document=changed)
|
|
bad=copy.deepcopy(references);bad['Source_paths']=[native['source_path']];bad['native_availability_receipt_sha256']='0'*64
|
|
refuse('changed-availability-pin',bad)
|
|
bad=copy.deepcopy(references);bad['Source_paths']=[native['source_path']];bad.pop('native_availability_receipt')
|
|
refuse('missing-native-availability',bad)
|
|
manifest=Path(parameters['output'])/'manifest.json'
|
|
report=dict(status='PASS_COMPLETE277_RETAINED_MODEL_NUMERIC_RELATIONSHIPS',family_models=277,SKINs=1108,
|
|
parent_assets=9971,candidate_assets=11356,added_textures=0,Native_texture7786005_copies_imported=0,
|
|
typed_binding_refusals=refusals,container_relationships=containers,
|
|
all_Sourceflag0_and_accepted_geometry_tracks_preserved=True,retained_output_files_read_once=1385,
|
|
Source_model_body_reads=0,existing_texture_body_reads=0,old_conversions_repeated=False,
|
|
old_texture_SDK_checks_repeated=False,Native_SDK_or_Game_queries=0,
|
|
Native_constructor_and_renderer_acceptance='PENDING_ONE_REPRESENTATIVE',
|
|
candidate_manifest=str(manifest),candidate_manifest_sha256=pin(manifest))
|
|
(job/'completed-static277-numeric-family-check.json').write_text(json.dumps(report,indent=2)+'\n')
|
|
return report
|
|
|
|
def probe_check(job):
|
|
"""Only the newly added owned-path command guard; do not stage again."""
|
|
from native_model_probe import commands
|
|
accepted=json.loads((job/'completed-static277-numeric-family-check.json').read_text())
|
|
assert accepted['status']=='PASS_COMPLETE277_RETAINED_MODEL_NUMERIC_RELATIONSHIPS'
|
|
manifest=json.loads(Path(accepted['candidate_manifest']).read_text())
|
|
asset=next(r for r in manifest['assets']if r['kind']=='model'and r['path'].startswith('wowhybrid/source-equipment/'))
|
|
rows=commands(asset['path'],'27700001',file_data_id=asset['file_data_id'])
|
|
assert rows and all(len(row)<=255 for row in rows)
|
|
assert 'SetModel'in ''.join(rows)and str(asset['file_data_id'])in ''.join(rows)
|
|
refusals=[]
|
|
for name,path,run,ident in [
|
|
('owned-path-without-numeric-ID',asset['path'],'27700001',None),
|
|
('traversal','wowhybrid/source-equipment/../'+('a'*64)+'.m2','27700001',asset['file_data_id']),
|
|
('non-SHA-owned-model','wowhybrid/source-equipment/unknown.m2','27700001',asset['file_data_id']),
|
|
('invalid-run',asset['path'],'not-a-bounded-label',asset['file_data_id']),
|
|
('invalid-numeric-ID',asset['path'],'27700001',True)]:
|
|
try:commands(path,run,file_data_id=ident)
|
|
except ValueError:refusals.append(name)
|
|
else:raise AssertionError('Unbounded probe command accepted: '+name)
|
|
report=dict(status='PASS_OWNED_SHA_MODEL_NUMERIC_PROBE_PREPARATION',
|
|
actual_original_consumer='PlayerModel:SetModel',command_rows=len(rows),refusals=refusals,
|
|
family_staging_repeated=False,Game_actions=False,Native_constructor_or_render_acceptance=False)
|
|
(job/'owned-numeric-probe-command-focused-check.json').write_text(json.dumps(report,indent=2)+'\n')
|
|
return report
|
|
|
|
|
|
if __name__=='__main__':
|
|
parser=argparse.ArgumentParser(description=__doc__);parser.add_argument('--job',type=Path,required=True)
|
|
parser.add_argument('--probe-only',action='store_true')
|
|
args=parser.parse_args()
|
|
if args.probe_only:probe_check(args.job)
|
|
else:check(args.job)
|
|
print('PASS: affected offline model fixture boundary; renderer acceptance pending.')
|