Files
WoW-Hybrid-gateway/ops/native_model_probe.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

408 lines
29 KiB
Python

#!/usr/bin/env python3
"""Quick original-engine asset lookup/load test in the local native client.
Does not convert models, install files, remap item IDs, or change equipment.
Path registration and explicit native FileDataID loading are separate checks.
An accepted load request does not establish complete particle rendering.
"""
import argparse
import json
from pathlib import Path
import re
import secrets
import time
from client_session import Session
from console_report import parse
from native_engine_character_test import Controller, ROOT, local_listeners
from native_test_guard import (require_authenticated_turtle_realm, require_local_turtle_ports,
require_native_world_observation, require_native_gameplay_policy)
def owned_published_model_bindings(root,entries):
"""Reuse the applied owned registry once for a bounded model batch."""
if not isinstance(entries,list) or not 1<=len(entries)<=32:
raise ValueError('Bounded owned model identities required')
seen=set()
for row in entries:
if (not isinstance(row,dict) or set(row)!={'path','file_data_id'}
or not isinstance(row['path'],str)
or re.fullmatch(r'wowhybrid/source-equipment/[0-9a-f]{64}\.m2',row['path']) is None
or type(row['file_data_id'])is not int or not 0<row['file_data_id']<=0x7fffffff
or row['file_data_id']in seen):
raise ValueError('Owned model requires distinct exact paths and numeric FileDataIDs')
seen.add(row['file_data_id'])
import published_client_assets as publication
from item_package_preflight import read_public_json
proof=publication.published_source(root)
if proof is None:raise ValueError('Owned model requires an applied publication proof')
release,_=read_public_json(Path(root)/'linux-release.json')
receipt_path=release.get('private_asset_publication',{}).get('receipt_path')
if not isinstance(receipt_path,str):raise ValueError('Owned model publication receipt unavailable')
receipt,receipt_identity=read_public_json(Path(receipt_path))
if receipt_identity!=proof['receipt_sha256']:
raise ValueError('Owned model publication receipt changed')
reference=receipt.get('inputs',{}).get('assets',{})
if not isinstance(reference.get('path'),str) or not isinstance(reference.get('sha256'),str):
raise ValueError('Owned model registered manifest unavailable')
manifest,identity=read_public_json(Path(reference['path']))
if identity!=reference['sha256']:
raise ValueError('Owned model registered manifest changed')
assets=manifest.get('assets')
if not isinstance(assets,list) or len(assets)!=proof['registered_assets']:
raise ValueError('Owned model registered asset count differs')
indexed={}
for row in assets:
if isinstance(row,dict):indexed.setdefault(row.get('file_data_id'),[]).append(row)
bindings=[]
for entry in entries:
path,file_data_id=entry['path'],entry['file_data_id'];matches=indexed.get(file_data_id,[])
if (len(matches)!=1 or matches[0].get('path')!=path or matches[0].get('kind')!='model'
or not isinstance(matches[0].get('content_key'),str)
or re.fullmatch('[0-9a-f]{32}',matches[0]['content_key']) is None):
raise ValueError('Owned model path/type/FileDataID binding differs')
bindings.append(dict(file_data_id=file_data_id,path=path,kind='model',content_key=matches[0]['content_key'],
registered_manifest_sha256=identity,publication_root=proof['composed_root'],
community_listfile_or_named_lookup_claimed=False))
return bindings
def owned_published_model_binding(root,path,file_data_id):
"""Single requests consume the same applied owned registry as batches."""
return owned_published_model_bindings(root,[dict(path=path,file_data_id=file_data_id)])[0]
def batch_model_dependencies(profile,entries):
"""Typed SFID/TXID scope from the pinned existing constructor fixture."""
rows=profile.get('models')
if not isinstance(rows,list):raise ValueError('Pinned model dependency rows required')
by_id={}
for row in rows:
if isinstance(row,dict):by_id.setdefault(row.get('model_file_data_id'),[]).append(row)
result={}
for entry in entries:
matches=by_id.get(entry['file_data_id'],[])
if len(matches)!=1 or matches[0].get('registered_path')!=entry['path']:
raise ValueError('Model dependency identity differs')
row=matches[0];skins,textures=row.get('SFID'),row.get('TXID')
if (not isinstance(skins,list)or len(skins)!=4 or not isinstance(textures,list)or len(textures)!=1
or any(type(i)is not int or not 0<i<=0x7fffffff for i in skins+textures)
or len(set(skins))!=4):raise ValueError('Reviewed four-skin/one-texture dependency scope required')
result[entry['file_data_id']]={entry['file_data_id'],*skins,*textures}
return result
def require_model_probe_native_world(controller,session,account):
"""Existing source/native World plus policy authorizes this local UI probe.
The read-only observation proof is combined with the existing owned input
policy; it is not used alone to authorize an action. Known non-World UI
rejects, while an unknown zone label cannot override consumed self-create.
"""
require_authenticated_turtle_realm(account)
state=session.state(world_first=True)
pipe=controller.rpc('inspect-engine-pipe',unit_fields_only=True)
engine=controller.rpc('inspect-engine-session')
require_native_world_observation(pipe,engine,state)
policy=controller.rpc('inspect-native-channel-policy')
require_native_gameplay_policy(policy)
if policy.get('owner_matches') is not True:
raise RuntimeError('Model probe native input owner differs')
return dict(readiness='live-local-source-and-native-consumed-self-create',ui_state=state,
native_gameplay_policy_enabled=True,owner_matches=True,zone_OCR_wait_repeated=False)
def model_stream_failures(text,file_ids):
"""Export only typed loader failures, never arbitrary private log lines.
A model actor can return IsLoaded=true and the requested ID while showing
the error cube. Actual gx/AsyncFile errors therefore remain separate from
accepted API calls and require a negative rendering verdict.
"""
if not isinstance(text,str)or len(text)>1048576:raise ValueError('Bounded model diagnostic text required')
if not isinstance(file_ids,set)or not 1<=len(file_ids)<=32 or any(type(i)is not int or not 0<i<=0x7fffffff for i in file_ids):
raise ValueError('Explicit bounded model IDs required')
found=set()
for line in text.splitlines():
match=re.search(r'\bFileData ID ([0-9]{1,10})\b',line)
if match is None or int(match[1])not in file_ids:continue
if "Can't find file in build manifest"in line:
found.add((int(match[1]),'manifest-lookup','file-absent-from-build-manifest'))
elif 'Streaming failed'in line and '[Invalid file handle]'in line:
found.add((int(match[1]),'stream-open','invalid-file-handle'))
return [dict(file_data_id=i,stage=stage,reason=reason)for i,stage,reason in sorted(found)]
def commands(path,run,file_data_id=None):
owned_source=isinstance(path,str) and re.fullmatch(r'wowhybrid/source-equipment/[0-9a-f]{64}\.m2',path) is not None
if owned_source and file_data_id is None:
raise ValueError('Owned Source model probe requires its registered numeric FileDataID')
if (not isinstance(path, str) or len(path) > 128 or (not re.fullmatch('(?:Interface/AddOns|Item/ObjectComponents|Spells|Creature)/[A-Za-z0-9_/-]+\\.m2', path) and (not owned_source)) or ('//' in path) or ('/..' in path) or (not re.fullmatch('[0-9a-f]{8}', run))):
raise ValueError('Bounded local model path/run required')
if file_data_id is not None and (type(file_data_id)is not int or not 0<file_data_id<=0x7fffffff):
raise ValueError('Bounded positive model FileDataID required')
prefix='GatewayDiagnosticsSaved.nativeModelProbe'
requested=''if file_data_id is None else f',requestedFileID={file_data_id}'
rows=[
f'/run {prefix}={{run="{run}",path="{path}",overrideArchive=GetCVar("overrideArchive"){requested}}}',
f'/run local r={prefix};local ok,id=pcall(GetFileIDFromPath,r.path);r.lookupOK=ok;r.pathFileID=(ok and type(id)=="number" and id>0) and id or nil;r.fileID=r.pathFileID or r.requestedFileID',
'/run GWSourceModelProbe=CreateFrame("PlayerModel",nil,UIParent);GWSourceModelProbe:SetSize(500,500);GWSourceModelProbe:SetPoint("CENTER");GWSourceModelProbe:SetFrameStrata("DIALOG");GWSourceModelProbe:Show()',
f'/run local r={prefix};if type(r.fileID)=="number" and r.fileID>0 then r.loadAccepted=pcall(GWSourceModelProbe.SetModel,GWSourceModelProbe,r.fileID);r.loadedFileID=GWSourceModelProbe:GetModelFileID() end',
]
if any(len(row)>255 for row in rows):raise ValueError('Actual macro edit limit exceeded before UI input')
return rows
def lookup_commands(path,run):
"""Capture the original API result without filtering signed handles.
No model load or data publication. A negative process-local handle is an
observation, never a portable FileDataID or evidence of model support.
"""
init=commands(path,run)[0];prefix='GatewayDiagnosticsSaved.nativeModelProbe'
return [init,f'/run local r={prefix};local ok,v=pcall(GetFileIDFromPath,r.path);r.lookupOK=ok;r.lookupType=type(v);if ok then r.lookupValue=v end']
def batch_commands(entries,run):
"""Preflight all inputs before interaction; one saved result per real request."""
if not isinstance(entries,list)or not 1<=len(entries)<=32:raise ValueError('Bounded model batch required')
seen=set();phases=[]
for row in entries:
if not isinstance(row,dict)or set(row)!={'path','file_data_id'}or row['file_data_id']in seen:raise ValueError('Distinct explicit model identities required')
rows=commands(row['path'],run,row['file_data_id']);seen.add(row['file_data_id'])
rows.insert(0,'/run if GWSourceModelProbe then GWSourceModelProbe:Hide();GWSourceModelProbe:ClearModel()end')
rows.append('/run local b=GatewayDiagnosticsSaved.nativeModelBatch;b.models[#b.models+1]=GatewayDiagnosticsSaved.nativeModelProbe')
if any(len(r)>255 for r in rows):raise ValueError('Model batch macro bound')
phases.append(rows)
return phases
def owned_batch_commands(entries,run):
"""Reuse the proven numeric PlayerModel API without retyping invariants."""
batch_commands(entries,run) # Keep the existing path/ID/run/edit-bound preflight.
prefix='GatewayDiagnosticsSaved.nativeModelBatch'
initialization=f'/run {prefix}={{run="{run}",models={{}},overrideArchive=GetCVar("overrideArchive")}}'
frame=commands(entries[0]['path'],run,entries[0]['file_data_id'])[2]
phases=[]
for row in entries:
path,identity=row['path'],row['file_data_id']
request=f'/run local b={prefix};local f=GWSourceModelProbe;local r={{run=b.run,fileID={identity},requestedFileID={identity},overrideArchive=b.overrideArchive}};b.pending=r;f:ClearModel();r.loadAccepted=pcall(f.SetModel,f,r.fileID)'
complete=f'/run local b={prefix};local r=b.pending;r.path="{path}";r.loadedFileID=GWSourceModelProbe:GetModelFileID();b.models[#b.models+1]=r'
phases.append([request,complete])
if any(len(text)>255 for text in [initialization,frame]+[text for phase in phases for text in phase]):
raise ValueError('Actual macro edit limit exceeded before UI input')
return initialization,frame,phases
def grid_completion_marker(session,group):
"""Read the opt-in addon's callback marker; never submit another model."""
import client_ui as ui
from Xlib import X
from PIL import Image
if ui.focus_id(session.d)!=session.win.id:
raise RuntimeError('Focus changed during grid readiness; cohort preserved without replay')
raw=session.win.get_image(20,20,1,1,X.ZPixmap,0xffffffff)
color=Image.frombytes('RGB',(1,1),raw.data,'raw','BGRX').getpixel((0,0))
if ui.focus_id(session.d)!=session.win.id:
raise RuntimeError('Focus changed during grid marker capture')
colors=[(0,255,0),(0,0,255),(255,0,255),(0,255,255),(255,255,0),(255,255,255)]
expected=colors[(group-1)%len(colors)]
return all(actual>=220 if wanted else actual<=30 for actual,wanted in zip(color,expected))
def run_batch(entries,output,*,native_world_readiness=False,resource_profile=None,resource_profile_sha256=None,grid_size=1):
"""Share one identity source, authenticated session and final UI reload."""
from item_icon_preflight import listfile_index
from octo_client_data import canonical_sha256
if grid_size not in (1,4):raise ValueError('Existing single view or bounded four-frame grid required')
started=time.monotonic();run=secrets.token_hex(4);phases=batch_commands(entries,run)
ids={r['file_data_id']for r in entries}
owned=[bool(re.fullmatch(r'wowhybrid/source-equipment/[0-9a-f]{64}\.m2',r['path']))for r in entries]
listing=None;bindings=None;dependency_ids={i:{i}for i in ids};profile_identity=None;owned_setup=None;owned_initialization=None
if any(owned):
if not all(owned):raise ValueError('Do not mix owned and community model namespaces')
bindings=owned_published_model_bindings(ROOT,entries)
if resource_profile is None or re.fullmatch('[0-9a-f]{64}',resource_profile_sha256 or '')is None:
raise ValueError('Owned batches require the pinned existing dependency profile')
from item_package_preflight import read_public_json
profile,profile_identity=read_public_json(Path(resource_profile))
if profile_identity!=resource_profile_sha256:raise ValueError('Model dependency profile changed')
dependency_ids=batch_model_dependencies(profile,entries)
owned_initialization,owned_setup,phases=owned_batch_commands(entries,run)
else:
if resource_profile is not None or resource_profile_sha256 is not None:raise ValueError('Owned dependency profile does not authorize community paths')
with (ROOT.parent/'listfiles/community-listfile.csv').open('rb')as stream:names,listing=listfile_index(stream,ids)
if any(names.get(r['file_data_id'])!=[r['path'].lower()]for r in entries):raise ValueError('Batch model identities differ from native listfile')
if grid_size==4 and not bindings:raise ValueError('Grid is restricted to applied owned numeric models')
require_local_turtle_ports(local_listeners());pid=int((ROOT/'runtime/native-client.pid').read_text());c=Controller(pid)
account=c.rpc('inspect-wire-account');require_authenticated_turtle_realm(account)
output.parent.mkdir(parents=True,exist_ok=True)
planned=[output.with_name(output.stem+'-group'+str(i+1).zfill(2)+'.png')for i in range((len(entries)+3)//4)]if grid_size==4 else[output.with_name(output.stem+'-'+str(row['file_data_id'])+'.png')for row in entries]
if any(p.exists()for p in planned):raise RuntimeError('Preserve existing model frames; no batch input sent')
pending=dict(kind='original-native-model-batch-pending',pid=pid,run=run,entries=entries,completed_frames=0,external_gateway_running=False,command_mode='owned-four-frame-deferred-grid'if grid_size==4 else'owned-reusable-frame-two-separated-macros'if bindings else'community-original-six-macros')
output.write_text(json.dumps(pending,indent=2)+'\n');output.chmod(0o600)
log_offsets={ROOT/'runtime/native-client/_classic_beta_/Logs'/name:0 for name in('gx.log','AsyncFile.log')}
log_identities={}
for path in log_offsets:
if path.exists():
st=path.stat();log_offsets[path]=st.st_size;log_identities[path]=st.st_ino
frames=[];frame_bindings=[]
with Session(pid)as s:
readiness=require_model_probe_native_world(c,s,account)if native_world_readiness else None
if not native_world_readiness:s.wait_world()
if grid_size==4:
s.macro('/run assert(GWNativeModelProbe and GWNativeModelProbe.version==1,"Grid addon unavailable");GWNativeModelProbe:Begin("'+run+'",4)')
for start in range(0,len(entries),4):
cohort=entries[start:start+4];group=start//4+1;identities=[r['file_data_id']for r in cohort]
pending.update(current_cohort_ids=identities,current_group=group,cohort_result='Uncertain until callback marker and snapshot')
output.write_text(json.dumps(pending,indent=2)+'\n')
# One dispatch; no per-model input and no constructor retry.
s.macro('/run GWNativeModelProbe:Show({'+','.join(map(str,identities))+'},'+str(group)+')')
c.wait(lambda:grid_completion_marker(s,group),8)
frame=planned[group-1];s.shot(frame);frames.append(str(frame))
frame_bindings.extend(dict(file_data_id=r['file_data_id'],group=group,slot=i+1,frame=str(frame),native_callback_id_and_loadAccepted_matched=True)for i,r in enumerate(cohort))
pending.update(completed_frames=len(frames),captured_models=len(frame_bindings),frames=frames,frame_bindings=frame_bindings,current_cohort_ids=[],cohort_result='Native callback matched all requested IDs; frame captured; persistence pending')
output.write_text(json.dumps(pending,indent=2)+'\n')
s.macro('/run GWNativeModelProbe:Finish()')
else:
s.macro(owned_initialization if bindings else'/run GatewayDiagnosticsSaved.nativeModelBatch={run="'+run+'",models={}}')
if owned_setup:s.macro(owned_setup)
try:
for row,macros in zip(entries,phases):
for index,macro in enumerate(macros):
pending.update(current_model_file_data_id=row['file_data_id'],current_macro_index=index,constructor_outcome='Unresolved until saved native tuple')
output.write_text(json.dumps(pending,indent=2)+'\n');s.macro(macro)
frame=output.with_name(output.stem+'-'+str(row['file_data_id'])+'.png')
if frame.exists():raise RuntimeError('Preserve existing model frame')
s.shot(frame);frames.append(str(frame))
pending.update(completed_frames=len(frames),frames=frames,current_model_file_data_id=None,current_macro_index=None);output.write_text(json.dumps(pending,indent=2)+'\n')
finally:
s.macro('/run if GWSourceModelProbe then GWSourceModelProbe:Hide();GWSourceModelProbe:ClearModel();GWSourceModelProbe=nil end')
s.macro('/run ReloadUI()')
saved=ROOT/'runtime/native-client/_classic_beta_/WTF/Account/SavedVariables/GatewayDiagnostics.lua'
def sample():
try:
value=parse(saved.read_text()).get('nativeModelBatch',{})
return value if value.get('run')==run else None
except (OSError,ValueError):return None
result=c.wait(sample,10)
if native_world_readiness:after_reload_readiness=require_model_probe_native_world(c,s,account)
else:s.wait_world(15);after_reload_readiness=None
rows=result.get('models');rows=list(rows.values())if isinstance(rows,dict)else rows
if not isinstance(rows,list)or len(rows)!=len(entries):raise RuntimeError('Model batch results incomplete; preserve frames, no automatic replay')
observed={row.get('requestedFileID'):row for row in rows if isinstance(row,dict)}
if len(observed)!=len(entries)or set(observed)!=ids:raise RuntimeError('Model batch identities incomplete/duplicate; no replay')
errors=[];log_coverage=[];all_ids=sorted(set().union(*dependency_ids.values()))
for path,offset in log_offsets.items():
if not path.exists():
log_coverage.append(dict(name=path.name,status='missing',complete=False));continue
st=path.stat();end=st.st_size
if path in log_identities and st.st_ino!=log_identities[path]:
log_coverage.append(dict(name=path.name,status='rotated',complete=False));continue
if end<offset:
log_coverage.append(dict(name=path.name,status='truncated',complete=False));continue
with path.open('rb')as stream:stream.seek(offset);data=stream.read(min(1048576,end-offset))
text=data.decode(errors='replace');log_coverage.append(dict(name=path.name,offset=offset,end=end,read_bytes=len(data),complete=len(data)==end-offset))
for index in range(0,len(all_ids),32):errors+=model_stream_failures(text,set(all_ids[index:index+32]))
if grid_size==4:
groups=result.get('groups',[]);groups=list(groups.values())if isinstance(groups,dict)else groups
if (not isinstance(groups,list)or len(groups)!=(len(entries)+3)//4 or any(g.get('ready')is not True for g in groups)):
raise RuntimeError('Grid callback results incomplete; preserve exact cohorts, no replay')
models=[]
for entry in entries:
row=observed[entry['file_data_id']]
if row.get('run')!=run or row.get('requestedFileID')!=entry['file_data_id']or row.get('overrideArchive')!='0':raise RuntimeError('Original model request identity/archive differs')
accepted=row.get('loadAccepted')is True and row.get('loadedFileID')==entry['file_data_id']
models.append(dict(file_data_id=entry['file_data_id'],original_model_load_accepted=accepted,original_loaded_file_id=row.get('loadedFileID'),evidence_sha256=canonical_sha256(row),stream_dependency_ids=sorted(dependency_ids[entry['file_data_id']]),stream_failures=[e for e in errors if e['file_data_id']in dependency_ids[entry['file_data_id']]]))
report=dict(kind='original-native-model-resource-acceptance',pid=pid,local_only=True,external_gateway_running=False,override_archive='0',
client_files_or_character_changed=False,models=models,result=result,frames=frames,stream_failures=errors,command_mode=pending['command_mode'],grid_size=grid_size,frame_bindings=frame_bindings,
model_rendering_verified=False,item_appearance_verified=False,full_particle_rendering_verified=False,
target_listfile_sha256=listing['sha256']if listing else None,owned_registered_model_bindings=bindings,model_dependency_profile_sha256=profile_identity,native_world_readiness=readiness,after_reload_native_world_readiness=after_reload_readiness,stream_log_coverage=log_coverage,elapsed_seconds=round(time.monotonic()-started,3),
limits=['Original model request/returned identity only; no complete visual/particle/asset equivalence claim.','One session and one final UI reload; no item, spell, progression or data changes.'])
output.write_text(json.dumps(report,indent=2)+'\n');output.chmod(0o600)
print(json.dumps(dict(models=len(models),accepted=sum(r['original_model_load_accepted']for r in models),stream_failures=len(errors),ui_reloads=1,elapsed_seconds=report['elapsed_seconds'],output=str(output))))
return 0 if all(r['original_model_load_accepted']for r in models)and not errors and all(r['complete']for r in log_coverage)else 2
def actor_path_commands(path,control_path,control_id,preview_item,run,*,numeric_control=False):
"""Known-native control gates a documented original actor path request."""
init=commands(path,run)[0];commands(control_path,run,control_id)
if type(preview_item)is not int or not 0<preview_item<2**31:raise ValueError('Bounded preview item required')
if type(numeric_control)is not bool:raise ValueError('Explicit control mode required')
prefix='GatewayDiagnosticsSaved.nativeModelProbe'
control=f'SetModelByFileID,GWPathActor,{control_id}'if numeric_control else f'SetModelByPath,GWPathActor,"{control_path}"'
rows=[init,f'/run DressUpItemLink("item:{preview_item}");GWPathActor=DressUpFrame.ModelScene:GetPlayerActor()',
f'/run local r={prefix};r.controlOK,r.controlAccepted=pcall(GWPathActor.{control})',
f'/run local r={prefix};r.controlLoaded=GWPathActor:IsLoaded();r.controlFileID=GWPathActor:GetModelFileID()',
f'/run local r={prefix};if r.controlOK and r.controlAccepted and r.controlLoaded and r.controlFileID=={control_id} then r.attempted=true;r.sourceOK,r.sourceAccepted=pcall(GWPathActor.SetModelByPath,GWPathActor,r.path) end',
f'/run local r={prefix};if r.attempted then r.sourceLoaded=GWPathActor:IsLoaded();r.sourceFileID=GWPathActor:GetModelFileID() end']
if any(len(r)>255 or any(c in r for c in '`~')for r in rows):raise ValueError('Actor path diagnostic macro bound')
return rows
def main():
p=argparse.ArgumentParser(description=__doc__)
selection=p.add_mutually_exclusive_group(required=True)
selection.add_argument('--model-path')
selection.add_argument('--model-list',type=Path,help='Batch JSON path/file_data_id pairs; one listfile scan, session and final UI reload')
p.add_argument('--file-data-id',type=int,help='Explicit target listfile-bound ID when the original path lookup is unavailable')
p.add_argument('--lookup-only',action='store_true',help='Record raw signed path lookup; no model widget or load request')
p.add_argument('--native-world-readiness',action='store_true',help='Reuse live consumed-self-create and owned input-policy proof; do not wait on outlined zone OCR')
p.add_argument('--grid-size',type=int,choices=[1,4],default=1,help='Opt-in four-frame addon queue; owned batch only')
p.add_argument('--model-resource-profile',type=Path,help='Existing pinned typed model/SFID/TXID dependency ledger; batch only')
p.add_argument('--model-resource-profile-sha256',help='Owning dependency-ledger pin; batch only')
p.add_argument('--output',type=Path,required=True)
a=p.parse_args();output=a.output.resolve()
if not output.is_relative_to(ROOT/'runtime') or output.exists() or output.with_suffix('.png').exists():p.error('Use a new runtime evidence path')
if a.model_list:
if a.file_data_id is not None or a.lookup_only:p.error('Batch models retain distinct explicit resource requests')
from item_package_preflight import read_public_json
return run_batch(read_public_json(a.model_list,65536)[0],output,native_world_readiness=a.native_world_readiness,resource_profile=a.model_resource_profile,resource_profile_sha256=a.model_resource_profile_sha256,grid_size=a.grid_size)
if a.grid_size!=1:p.error('Grid is batch-only')
if a.model_resource_profile is not None or a.model_resource_profile_sha256 is not None:p.error('Dependency profile is batch-only')
if a.lookup_only and a.file_data_id is not None:p.error('Lookup-only does not take a fallback FileDataID')
started=time.monotonic();run=secrets.token_hex(4);macros=lookup_commands(a.model_path,run)if a.lookup_only else commands(a.model_path,run,a.file_data_id)
listing=None;owned_binding=None
if a.file_data_id is not None and re.fullmatch(r'wowhybrid/source-equipment/[0-9a-f]{64}\.m2',a.model_path):
owned_binding=owned_published_model_binding(ROOT,a.model_path,a.file_data_id)
elif a.file_data_id is not None:
from item_icon_preflight import listfile_index
with (ROOT.parent/'listfiles/community-listfile.csv').open('rb')as stream:
names,listing=listfile_index(stream,{a.file_data_id})
if names.get(a.file_data_id)!=[a.model_path.lower()]:
raise ValueError('Explicit model FileDataID/path differs from target listfile')
require_local_turtle_ports(local_listeners())
pid=int((ROOT/'runtime/native-client.pid').read_text());c=Controller(pid)
account=c.rpc('inspect-wire-account');require_authenticated_turtle_realm(account)
output.parent.mkdir(parents=True,exist_ok=True)
saved=ROOT/'runtime/native-client/_classic_beta_/WTF/Account/SavedVariables/GatewayDiagnostics.lua'
def sample():
try:
result=parse(saved.read_text()).get('nativeModelProbe',{})
return result if result.get('run')==run else None
except (OSError,ValueError):return None
with Session(pid)as s:
readiness=require_model_probe_native_world(c,s,account) if a.native_world_readiness else None
if not a.native_world_readiness:s.wait_world()
for macro in macros:s.macro(macro)
s.shot(output.with_suffix('.png'))
s.macro('/run ReloadUI()')
result=c.wait(sample,10)
registered=type(result.get('pathFileID'))is int and result['pathFileID']>0
has_target_id=type(result.get('fileID'))is int and result['fileID']>0
report=dict(kind='original-native-model-load-probe',pid=pid,external_gateway_running=False,
result=result,registered=registered,load_request_accepted=result.get('loadAccepted',False),
status='RAW_PATH_LOOKUP_CAPTURED'if a.lookup_only else'MODEL_LOAD_REQUEST_ACCEPTED_VISUAL_REVIEW_REQUIRED' if result.get('loadAccepted') else
'FILE_DATA_REGISTRATION_MISSING' if not has_target_id else 'MODEL_LOAD_REJECTED',
model_rendering_verified=False,item_appearance_verified=False,
client_files_modified=False,character_modified=False,elapsed_seconds=round(time.monotonic()-started,3),
explicit_file_data_id=a.file_data_id,
lookup_only=a.lookup_only,
target_listfile_sha256=listing['sha256']if listing is not None else None,
owned_registered_model_binding=owned_binding,native_world_readiness=readiness)
output.parent.mkdir(parents=True,exist_ok=True);output.write_text(json.dumps(report,indent=2)+'\n')
print(json.dumps(dict(status=report['status'],fileID=result.get('fileID'),output=str(output))))
if __name__=='__main__':raise SystemExit(main()or 0)