367 files, from working commit b1a079a. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
107 lines
7.5 KiB
Python
107 lines
7.5 KiB
Python
#!/usr/bin/env python3
|
|
"""Read-only source-icon acceptance through the real local Forever UI APIs.
|
|
|
|
Requires an installed provider, native authenticated world, stopped gateway.
|
|
No items, equipment, progression, database or character state are modified.
|
|
"""
|
|
import argparse,json,re,secrets,time
|
|
from pathlib import Path
|
|
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
|
|
from item_package_preflight import bounded_digest
|
|
import client_ui as ui
|
|
|
|
def indexed_entries(value):
|
|
"""SavedVariables parser returns lists for dense numeric Lua tables."""
|
|
if isinstance(value,list):return [(i+1,r)for i,r in enumerate(value)if r is not None]
|
|
if isinstance(value,dict):return [(i,r)for i,r in value.items()if r is not None]
|
|
raise ValueError('Unsupported numeric diagnostic table')
|
|
|
|
def owned_samples(data,mapping):
|
|
samples=[]
|
|
for scope in ('equipment','bags'):
|
|
entries=indexed_entries(data.get(scope,{}))
|
|
if scope=='bags':entries=[(str(b)+':'+str(slot),row)for b,slots in entries for slot,row in indexed_entries(slots)]
|
|
for slot,row in entries:
|
|
if str(row['id'])in mapping:samples.append(dict(scope=scope,slot=slot,**row))
|
|
return samples
|
|
|
|
|
|
def main():
|
|
p=argparse.ArgumentParser(description=__doc__)
|
|
p.add_argument('--installation',type=Path,required=True);p.add_argument('--output',type=Path,required=True)
|
|
p.add_argument('--collect-existing-run',help='Collect a completed same-session screenshot/probe after a reporting failure; no UI replay')
|
|
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()and not a.collect_existing_run):p.error('Fresh runtime evidence required')
|
|
install=json.loads(a.installation.read_bytes());target=ROOT/'runtime/native-client/_classic_beta_/Interface/AddOns/WoWHybridContent'
|
|
if install.get('kind')!='source-item-artwork-provider-installation'or install.get('target')!=str(target)or not install.get('installed'):raise ValueError('Owned source icon provider installation required')
|
|
for name,digest in install['files'].items():
|
|
if name not in ('SourceItemIcons.lua','SourceItemIconData.lua','WoWHybridContent.toc')or bounded_digest(target/name)!=digest:raise ValueError('Installed source provider changed')
|
|
require_local_turtle_ports(local_listeners());pid=int((ROOT/'runtime/native-client.pid').read_text());c=Controller(pid)
|
|
require_authenticated_turtle_realm(c.rpc('inspect-wire-account'))
|
|
pipe=c.rpc('inspect-engine-pipe')
|
|
if pipe['error']or pipe['closed']or not pipe['world_auth']or not pipe['world']['self_create']:raise RuntimeError('Native world required')
|
|
run=a.collect_existing_run or secrets.token_hex(4)
|
|
if not re.fullmatch('[0-9a-f]{8}',run):raise ValueError('Probe run identity bound')
|
|
selected=[118,1710,13446,47248,47254,58242,21994,21996,55252,13529,17782]
|
|
commands=['/run GatewayDiagnosticsSaved.sourceArtwork={run="'+run+'",loaded=not not GWSourceItemIcons,items={},equipment={},bags={}}']
|
|
for offset in range(0,len(selected),6):
|
|
ids=' '.join(map(str,selected[offset:offset+6]))
|
|
commands.append('/run local s=GatewayDiagnosticsSaved.sourceArtwork;for id in ("'+ids+'"):gmatch("%d+") do id=tonumber(id);s.items[id]={icon=C_Item.GetItemIconByID(id),resolved=GWSourceItemIcons and GWSourceItemIcons.TextureForItem(id)} end')
|
|
commands.extend([
|
|
'/run for i=1,19 do local id=GetInventoryItemID("player",i);if id then GatewayDiagnosticsSaved.sourceArtwork.equipment[i]={id=id,icon=GetInventoryItemTexture("player",i)} end end',
|
|
'/run for b=0,4 do local a={};GatewayDiagnosticsSaved.sourceArtwork.bags[b]=a;for s=1,C_Container.GetContainerNumSlots(b) do local i=C_Container.GetContainerItemInfo(b,s);if i then a[s]={id=i.itemID,icon=i.iconFileID} end end end',
|
|
])
|
|
if any(len(command)>255 for command in commands):raise ValueError('Macro edit bound')
|
|
started=time.monotonic();old=ui.KEY_DELAY
|
|
saved=ROOT/'runtime/native-client/_classic_beta_/WTF/Account/SavedVariables/GatewayDiagnostics.lua'
|
|
def observed():
|
|
try:
|
|
data=parse(saved.read_text()).get('sourceArtwork',{})
|
|
return data if data.get('run')==run else None
|
|
except (OSError,ValueError):return None
|
|
try:
|
|
if a.collect_existing_run:
|
|
if not output.with_suffix('.png').is_file()or not output.with_name(output.stem+'-equipment.png').is_file():raise ValueError('Completed existing screenshot evidence required')
|
|
data=observed()
|
|
if not data:raise ValueError('Completed diagnostic run not found; do not replay automatically')
|
|
else:
|
|
with Session(pid)as s:
|
|
s.wait_world();ui.KEY_DELAY=.03 # The faster8ms long-macro trial failed readiness; retain reliable input timing.
|
|
for index,command in enumerate(commands,1):
|
|
s.macro(command);print('Completed read-only artwork probe',index,'/',len(commands),flush=True)
|
|
ui.key(s.d,'b')
|
|
s.shot(output.with_suffix('.png'))
|
|
ui.key(s.d,'c')
|
|
s.shot(output.with_name(output.stem+'-equipment.png'))
|
|
s.macro('/run local a=GWSourceItemIcons;if a then GatewayDiagnosticsSaved.sourceArtwork.stats={version=a.version,resolved=a.resolvedPaths,unavailable=a.unavailablePaths,substitutions=a.substitutions,samples=a.samples} end')
|
|
s.macro('/run GatewayDiagnosticsSaved.sourceArtwork.secureAPIs={item=issecurevariable(C_Item,"GetItemInfo"),bag=issecurevariable(C_Container,"GetContainerItemInfo"),equipment=issecurevariable("GetInventoryItemTexture")}')
|
|
ui.key(s.d,'c');ui.key(s.d,'b')
|
|
s.macro('/reload')
|
|
data=c.wait(observed,15);s.wait_world()
|
|
finally:ui.KEY_DELAY=old
|
|
mapping=json.loads((Path(install['stage'])/'item-icons.json').read_bytes())['items']
|
|
samples=owned_samples(data,mapping)
|
|
rendered=data.get('stats',{}).get('samples',{})
|
|
rendered_good=bool(rendered)and all(type(r.get('displayed'))in(int,float)and r['displayed']<-1 and r['displayed']==r['expected']for _,r in indexed_entries(rendered))
|
|
apis_secure=data.get('secureAPIs')==dict(item=True,bag=True,equipment=True)
|
|
valid=data.get('loaded')is True and data.get('stats',{}).get('version')==2 and data.get('stats',{}).get('unavailable')==0 and samples and rendered_good and apis_secure
|
|
report=dict(kind='actual-native-source-artwork-acceptance',pid=pid,external_gateway_running=False,local_only=True,
|
|
installation_sha256=bounded_digest(a.installation),observed=data,owned_icon_samples=samples,
|
|
original_ui_texture_post_hooks_verified=bool(valid),original_item_apis_secure=apis_secure,
|
|
elapsed_seconds=None if a.collect_existing_run else round(time.monotonic()-started,3),
|
|
collected_existing_completed_run=bool(a.collect_existing_run),
|
|
character_or_database_modified=False,engine_db2_definitions_modified=False,
|
|
visual_review_required=True,all_items_gameplay_verified=False,
|
|
limits=['Original UI texture post-hooks only; item definitions/stats/models are independent.',
|
|
'Only sampled owned icons and selected public item APIs checked; no claim all26k items function.'])
|
|
output.write_text(json.dumps(report,indent=2)+'\n')
|
|
print('Native source artwork API acceptance:',bool(valid),'owned samples:',len(samples),'evidence:',output)
|
|
return 0 if valid else 2
|
|
|
|
|
|
if __name__=='__main__':raise SystemExit(main())
|