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

94 lines
7.1 KiB
Python

#!/usr/bin/env python3
"""Export only reviewed public content validation records from native Hotfix.log.
Never export arbitrary log lines, command history, keys or authentication data.
DB2 validation is not proof of complete tooltip/gameplay equivalence.
"""
import argparse,json,re,time
from pathlib import Path
from item_sparse_compat import MAX_PACKAGE_ROWS
ROOT=Path(__file__).resolve().parents[1]
ITEM_TABLES=('Item','ItemSparse','ItemEffect','ItemXItemEffect','ItemArmorShield')
# Same pinned70334 hashes as the source-passive component. New table families
# require explicit review; arbitrary log lines/table names remain excluded.
SPELL_TABLES={'Spell':0xe111669e,'SpellName':0x46c66698,'SpellMisc':0xc603ee28,
'SpellEffect':0xf04238a5,'SpellEquippedItems':0xe44abbd4,'SkillLineAbility':0xff4446f6,
'SpellClassOptions':0x288eab81,'SpellLevels':0x1ddec5e6,
'SpellAuraOptions':0xf42fc065,'SpellXSpellVisual':0x27b7a01a,'SpellCategories':0xdbe7f829,
'SpellVisual':0xf72496d9,'SpellVisualEvent':0xcc284d0f,
'SpellVisualKit':0xf483eadb,'SpellVisualKitEffect':0x4666ed42,
'SpellVisualKitModelAttach':0xf07194c3,
'SpellReagents':0xab66c99f,'SpellTotems':0xa50f8a31,
'SpellCastingRequirements':0x61025756,'SpellInterrupts':0x668fae03}
FACTION_TABLES={'Faction':0x06f624d7}
ENCHANTMENT_TABLES={'SpellItemEnchantment':0xe05ac589}
SET_TABLES={'ItemSet':0x8e741a98,'ItemSetSpell':0x8645bb79}
APPEARANCE_TABLES={'ItemModifiedAppearance':0xe491ac55,'ItemAppearance':0x42261b89,
'ItemDisplayInfo':0x986f8cd0,'ModelFileData':0xa161e42c,'TextureFileData':0x1a473014,
'ItemDisplayInfoMaterialRes':0xf35af3db,'ComponentModelFileData':0xbe6aed26}
CONTENT_TABLES=SPELL_TABLES|FACTION_TABLES|SET_TABLES|APPEARANCE_TABLES|ENCHANTMENT_TABLES
ROW=re.compile(r'^\d{2}/\d{2} \d{2}:\d{2}:\d{2}\.\d{3}\s+(\d+) Table ('+'|'.join(ITEM_TABLES+tuple(CONTENT_TABLES))+r') RecID (\d+) (VALIDATION_RESULT_[A-Z_]+)\s*$')
def summarize(text,package):
if len(text.encode())>16777216:raise ValueError('Bound native hotfix log to16MiB')
expected={(r.get('table_name','ItemSparse'),int(r['id'])) for r in package['rows']};push=int(package['push_id'])
removed={(r.get('table_name','ItemSparse'),int(r['id'])) for r in package['rows'] if r.get('record_status','valid')=='removed'}
if any(r.get('record_status','valid')not in('valid','removed')for r in package['rows']):raise ValueError('Unreviewed expected record status')
valid=expected-removed
if any(table not in ITEM_TABLES and table not in CONTENT_TABLES for table,ident in expected):raise ValueError('Unreviewed validation table')
for row in package['rows']:
if row.get('table_name')=='Item':
try:table=int(row['table_hash'],16)
except (KeyError,TypeError,ValueError):raise ValueError('Reviewed Item basic table hash required') from None
if table!=0x50238ec2:raise ValueError('Reviewed Item basic table hash required')
elif row.get('table_name') in CONTENT_TABLES:
family='faction'if row['table_name']in FACTION_TABLES else'item-set'if row['table_name']in SET_TABLES else'appearance'if row['table_name']in APPEARANCE_TABLES else'spell'
try:table=int(row['table_hash'],16)
except (KeyError,TypeError,ValueError):raise ValueError('Reviewed '+family+' table hash required') from None
if table!=CONTENT_TABLES[row['table_name']]:raise ValueError('Reviewed '+family+' table hash required')
if (not 0<push<=0x7fffffff or not 1<=len(expected)<=MAX_PACKAGE_ROWS
or (len(expected)>4096 and 'pushes'not in package)):raise ValueError('Invalid item package identity/bound')
# Full packages carry content-derived page ownership. Never accept an
# old push's same-ID validation as evidence for the installed revision.
if len(expected)>4096 or 'pushes'in package:
from item_sparse_compat import package_pages
pages=package_pages(package['rows'])
if package.get('pushes')!=pages:raise ValueError('Package push ownership differs')
else:pages=[dict(push_id=push,first=0,count=len(package['rows']))]
ownership={}
for page in pages:
for row in package['rows'][page['first']:page['first']+page['count']]:
ownership[row.get('table_name','ItemSparse'),int(row['id'])]=page['push_id']
selected={}
for line in text.splitlines():
m=ROW.fullmatch(line)
if not m:continue
found,table,entry,status=m.groups();entry=int(entry)
if int(found)==ownership.get((table,entry)):
selected[table,entry]={'table':table,'id':entry,'status':status}
return {'push_id':push,'push_ids':[p['push_id']for p in pages],'expected_item_ids':sorted(i for t,i in expected if t=='ItemSparse'),'expected_records':[{'table':t,'id':i} for t,i in sorted(expected)],'validation_rows':[selected[i] for i in sorted(selected)],
'expected_removed_records':[{'table':t,'id':i}for t,i in sorted(removed)],
'all_valid_records_validated':valid.issubset(selected)and all(selected[k]['status']=='VALIDATION_RESULT_VALID'for k in valid),
'removal_application_verified':(removed.issubset(selected)and all(selected[k]['status']=='VALIDATION_RESULT_DELETE'for k in removed))if removed else None,
'all_expected_validated':set(selected)==expected and all(selected[k]['status']==('VALIDATION_RESULT_DELETE'if k in removed else 'VALIDATION_RESULT_VALID')for k in expected),
'limits':['Native DB2 validation evidence only; casting/equipping/stats/tooltip equivalence require actual-client and server-state checks.',
'Unmatched log lines and all arbitrary log bodies are excluded.']}
if __name__=='__main__':
p=argparse.ArgumentParser(description=__doc__)
p.add_argument('--log',type=Path,default=ROOT/'runtime/native-client/_classic_beta_/Logs/Hotfix.log')
p.add_argument('--package',type=Path,default=ROOT/'docs/evidence/data/item-sparse-compat/package.json')
p.add_argument('--output',type=Path,default=ROOT/'runtime/item-hotfix-validation.json')
p.add_argument('--wait',type=float,default=0,help='Bounded0..60s polling after world entry; log flush can lag packet delivery');a=p.parse_args()
if not a.output.resolve().is_relative_to(ROOT):p.error('Keep report output in gateway')
if not 0<=a.wait<=60:p.error('Bound polling to0..60seconds')
package=json.loads(a.package.read_text());deadline=time.monotonic()+a.wait
while True:
if a.log.exists() and a.log.stat().st_size>16777216:raise ValueError('Native hotfix log size bound')
report=summarize(a.log.read_text(errors='replace') if a.log.exists() else '',package)
if report['all_expected_validated'] or time.monotonic()>=deadline:break
time.sleep(min(.1,max(0,deadline-time.monotonic())))
a.output.write_text(json.dumps(report,indent=2)+'\n')
print('Native DB2 records validated:',len(report['validation_rows']),'/',len(report['expected_records']),'complete:',report['all_expected_validated'])
raise SystemExit(0 if report['all_expected_validated'] else 2)