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

79 lines
5.8 KiB
Python

#!/usr/bin/env python3
"""Read-only item previews through the original70334 dressing-room interface.
No equipment changes, grants, server writes, API replacements or custom model
frames. API acceptance and screenshots require visual review; neither proves
source asset parity or gameplay. Local authenticated native sessions only.
"""
import argparse,json,secrets,time
from pathlib import Path
from client_session import Session
from console_report import parse
from native_engine_character_test import ROOT,Controller,local_listeners
from native_test_guard import (require_authenticated_turtle_realm,require_local_turtle_ports,
require_native_world_observation,require_native_gameplay_policy)
from native_item_metadata_test import persist_probe
def commands(ident,run,*,actor_model_fields=False):
if type(ident)is not int or not 0<ident<2**31 or len(run)!=8 or any(c not in'0123456789abcdef'for c in run):raise ValueError('Bounded original item identity and diagnostic nonce required')
# Exact built-in DressUpItemLink path verified in the70334 CASC Lua.
rows = [
f'/run local n,l,q,v=C_Item.GetItemInfo({ident});GatewayDiagnosticsSaved.itemRender.samples[{ident}]={{name=n,quality=q,level=v}}',
f'/run local r=GatewayDiagnosticsSaved.itemRender.samples[{ident}];r.callOK,r.accepted=pcall(DressUpItemLink,"item:{ident}")',
f'/run GameTooltip:SetOwner(UIParent,"ANCHOR_NONE");GameTooltip:ClearAllPoints();GameTooltip:SetPoint("RIGHT",UIParent,"RIGHT",-80,0);GameTooltip:SetHyperlink("item:{ident}")',
# Reposition after SetHyperlink: the original comparison manager can
# change the initial anchor while populating equipped comparisons.
# Keep long equipped-item comparisons away from the original chat
# edit box used by the guarded controller for the next command.
'/run GameTooltip:ClearAllPoints();GameTooltip:SetPoint("TOPRIGHT",UIParent,"TOPRIGHT",-80,-40)',
f'/run local r=GatewayDiagnosticsSaved.itemRender.samples[{ident}];local n,l,q,v=C_Item.GetItemInfo({ident});r.name=n;r.quality=q;r.level=v',
'/run local a=DressUpFrame.ModelScene:GetPlayerActor();GWPreviewSlots=a and a:GetItemTransmogInfoList()',
f'/run local t={{}};for i,v in ipairs(GWPreviewSlots or {{}}) do if not issecretvalue(v.appearanceID) then t[i]=v.appearanceID end end;GatewayDiagnosticsSaved.itemRender.samples[{ident}].slots=t;GWPreviewSlots=nil',
]
if actor_model_fields:
rows.append(f'/run local a=DressUpFrame.ModelScene:GetPlayerActor();local r=GatewayDiagnosticsSaved.itemRender.samples[{ident}];if a then r.actorLoaded=a:IsLoaded();r.actorFileID=a:GetModelFileID() end')
return rows
def require_owned_native_world(c):
"""Reuse the native self-create and channel-policy proof, without an OCR zone gate."""
require_authenticated_turtle_realm(c.rpc('inspect-wire-account'))
require_native_world_observation(c.rpc('inspect-engine-pipe'),c.rpc('inspect-engine-session'),'loading-or-unknown')
policy=c.rpc('inspect-native-channel-policy')
require_native_gameplay_policy(policy)
if policy.get('owner_matches') is not True:raise RuntimeError('Native input owner differs')
def main():
p=argparse.ArgumentParser(description=__doc__);p.add_argument('--items',type=int,nargs='+',required=True);p.add_argument('--output',type=Path,required=True);p.add_argument('--actor-model-fields',action='store_true',help='Capture the original actor loaded state and body file ID once per preview');a=p.parse_args()
out=a.output.resolve()
if not out.is_relative_to(ROOT/'runtime')or out.exists()or not 1<=len(a.items)<=12 or len(set(a.items))!=len(a.items):p.error('Fresh runtime directory and1..12 distinct source item IDs required')
run=secrets.token_hex(4);rows={i:commands(i,run,actor_model_fields=a.actor_model_fields)for i in a.items}
if any(len(c)>255 or '`'in c or '~'in c for cs in rows.values()for c in cs):raise ValueError('Macro edit bounds')
require_local_turtle_ports(local_listeners());c=Controller(int((ROOT/'runtime/native-client.pid').read_text()));require_owned_native_world(c)
saved=ROOT/'runtime/native-client/_classic_beta_/WTF/Account/SavedVariables/GatewayDiagnostics.lua'
out.mkdir(mode=0o700);started=time.monotonic();report=dict(kind='actual-native-original-item-previews',pid=c.pid,local_only=True,external_gateway_running=False,run=run,items=a.items,screenshots=[],character_modified=False,models_visually_verified=False,source_asset_parity_verified=False)
try:
with Session(c.pid)as s:
s.macro('/run GatewayDiagnosticsSaved.itemRender={run="'+run+'",samples={}}')
for ident,cs in rows.items():
for command in cs:s.macro(command)
s.shot(out/(str(ident)+'.png'));report['screenshots'].append(str(ident)+'.png')
print('Captured original item preview',ident,flush=True)
s.macro('/run GameTooltip:Hide();if DressUpFrame then DressUpFrame:Hide() end')
def observed():
try:
data=parse(saved.read_text()).get('itemRender',{})
return data if data.get('run')==run else None
except(OSError,ValueError):return None
report['results'],report['reload_acknowledgement_warning']=persist_probe(s,c,observed,world_ready=lambda:require_owned_native_world(c))
pipe=c.rpc('inspect-engine-pipe');report.update(pipe_error=pipe['error'],pipe_closed=pipe['closed'])
except Exception as error:
report['failure']=type(error).__name__+': '+str(error)
raise
finally:
report['elapsed_seconds']=round(time.monotonic()-started,3)
(out/'result.json').write_text(json.dumps(report,indent=2)+'\n')
print('Original UI previews captured; visual/source parity review still required:',out)
if __name__=='__main__':main()