367 files, from working commit b1a079a. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
352 lines
30 KiB
Python
352 lines
30 KiB
Python
#!/usr/bin/env python3
|
|
"""Explain bounded local item-conversion readiness, without installing a package.
|
|
|
|
Uses actual exported destination definitions and existing checked converter.
|
|
Encodability does not establish armor, spells, visuals or actual-client behavior.
|
|
"""
|
|
import argparse,hashlib,json,math
|
|
from collections import Counter
|
|
from pathlib import Path
|
|
from item_sparse_compat import ROOT,fields,convert,encode,check_db2,requires_stat_budget,stat_budget,bag_family_mask
|
|
from item_template_snapshot import compare_templates
|
|
from turtle_data import inventory_item_snapshot,MAX_INVENTORY_RECORDS
|
|
|
|
MAX_TARGET_ROWS=100000
|
|
MAX_TARGET_BYTES=67108864
|
|
# JSON includes both decoded records and their wire hex. A full source package
|
|
# can exceed the single-table export bound without approaching the independent
|
|
# native wire/page limits in item_sparse_compat. Keep this allowance specific.
|
|
MAX_COMPATIBILITY_PACKAGE_JSON_BYTES=134217728
|
|
# Registry budget; publication divides it into <=4096-row/1MiB pushes.
|
|
# This tool emits no installable record payload.
|
|
from item_sparse_compat import MAX_PACKAGE_ROWS,MAX_PACKAGE_BYTES
|
|
SCALAR_FIELDS=frozenset(('entry','class','subclass','name','description','display_id','quality','buy_count','buy_price','sell_price',
|
|
'inventory_type','allowable_class','allowable_race','item_level','required_level','max_count','stackable','material','bonding','bag_family'))
|
|
ZERO_FIELDS=frozenset(('flags','required_skill','required_skill_rank','required_spell','required_honor_rank','required_city_rank',
|
|
'required_reputation_faction','required_reputation_rank','container_slots','delay','range_mod','ammo_type','block','armor',
|
|
'holy_res','fire_res','nature_res','frost_res','shadow_res','arcane_res','page_text','page_language','page_material','start_quest',
|
|
'lock_id','sheath','random_property','set_id','max_durability','area_bound','map_bound','duration','disenchant_id',
|
|
'food_type','min_money_loot','max_money_loot','wrapped_gift','extra_flags'))|frozenset(
|
|
[f'stat_{key}{slot}' for slot in range(1,11) for key in ('type','value')]+
|
|
[f'dmg_{key}{slot}' for slot in range(1,6) for key in ('min','max','type')])
|
|
SPELL_FIELDS=frozenset(f'{key}_{slot}' for slot in range(1,6) for key in
|
|
('spellid','spelltrigger','spellcharges','spellppmrate','spellcooldown','spellcategory','spellcategorycooldown'))
|
|
SCALAR_SOURCE_FIELDS=SCALAR_FIELDS|ZERO_FIELDS|SPELL_FIELDS|{'script_name','other_team_entry'}
|
|
UNUSED_TEAM_DEFAULT_REVISION='d94947b0db60c33e7248523ad0ba7f58af97fd09'
|
|
SOURCE_COLUMN_RULES={
|
|
'script_name':dict(absent_values=[None,''],source_contract='Field::GetString may return NULL; ScriptMgr::LoadScriptNames seeds empty index0; GetScriptId returns0 for NULL or empty.',
|
|
references=['src/shared/Database/Field.h:48','src/game/ScriptMgr.cpp:1702','src/game/ScriptMgr.cpp:1738','src/game/ObjectMgr.cpp:2341']),
|
|
'other_team_entry':dict(allowed_default=1,only_source_revision=UNUSED_TEAM_DEFAULT_REVISION,
|
|
scope='Candidate selection only: this revision declares/loads the field but has no consuming C/C++ references. Not copied into any native field; nondefault nonzero values remain blocked.',
|
|
references=['sql/base/tw_world_item_template.sql:155','src/game/ObjectMgr.cpp:2340','src/game/Objects/ItemPrototype.h:493'])}
|
|
|
|
def bounded_digest(path,bound=MAX_TARGET_BYTES):
|
|
"""Second observed file pass stays bounded even if an export grows."""
|
|
path=Path(path)
|
|
if path.is_symlink() or not path.is_file() or not 0<path.stat().st_size<=bound:raise ValueError('Missing/linked/oversized public input')
|
|
digest=hashlib.sha256();total=0
|
|
with path.open('rb') as stream:
|
|
while True:
|
|
raw=stream.read(min(65536,bound-total+1))
|
|
if not raw:break
|
|
total+=len(raw)
|
|
if total>bound:raise ValueError('Public input grew beyond byte bound')
|
|
digest.update(raw)
|
|
if not total:raise ValueError('Public input became empty')
|
|
return digest.hexdigest()
|
|
|
|
def read_public_json(path,bound=MAX_TARGET_BYTES):
|
|
"""Bound bytes before decoding; reject ambiguous/nonfinite export JSON."""
|
|
path=Path(path)
|
|
if path.is_symlink() or not path.is_file() or not 0<path.stat().st_size<=bound:raise ValueError('Missing/linked/oversized public input')
|
|
with path.open('rb') as stream:raw=stream.read(bound+1)
|
|
if not 0<len(raw)<=bound:raise ValueError('Public input size changed')
|
|
def unique(pairs):
|
|
result={}
|
|
for key,value in pairs:
|
|
if key in result:raise ValueError('Duplicate public JSON field')
|
|
result[key]=value
|
|
return result
|
|
def finite(text):
|
|
value=float(text)
|
|
if not math.isfinite(value):raise ValueError('Nonfinite public JSON number')
|
|
return value
|
|
result=json.loads(raw,object_pairs_hook=unique,parse_float=finite,
|
|
parse_constant=lambda _:(_ for _ in ()).throw(ValueError('Nonfinite public JSON number')))
|
|
return result,hashlib.sha256(raw).hexdigest()
|
|
|
|
def read_compatibility_package(path):
|
|
return read_public_json(path,MAX_COMPATIBILITY_PACKAGE_JSON_BYTES)
|
|
|
|
def target_index(rows,table):
|
|
"""One index per full accessible target table; no source-ID remapping."""
|
|
if not isinstance(rows,list) or not 1<=len(rows)<=MAX_TARGET_ROWS:raise ValueError('Full target row count bound')
|
|
result={}
|
|
required={'Item':('ClassID','SubclassID','InventoryType'),
|
|
'ItemSparse':('DmgVariance','QualityModifier'),
|
|
'RandPropPoints':('GoodF','SuperiorF','EpicF')}[table]
|
|
def number(value):
|
|
try:return type(value) in (int,float) and math.isfinite(value)
|
|
except OverflowError:return False
|
|
for row in rows:
|
|
if not isinstance(row,dict) or type(row.get('ID')) is not int or not 0<row['ID']<=0xffffffff or row['ID'] in result:raise ValueError('Invalid/duplicate full target identity')
|
|
for key in required:
|
|
value=row.get(key)
|
|
if table=='Item':valid=type(value) is int and 0<=value<=0xffffffff
|
|
elif table=='ItemSparse':valid=number(value)
|
|
else:valid=isinstance(value,list) and len(value)==5 and all(number(v) and v>=0 for v in value)
|
|
if not valid:raise ValueError('Malformed full target field: '+table+'.'+key)
|
|
if 'IconFileDataID' in row and (type(row['IconFileDataID']) is not int or not 0<=row['IconFileDataID']<=0xffffffff):raise ValueError('Malformed full target icon identity')
|
|
result[row['ID']]=row
|
|
return result
|
|
|
|
def sha(path):return hashlib.sha256(path.read_bytes()).hexdigest()
|
|
def indexed(rows,key):
|
|
if not isinstance(rows,list) or len(rows)>4096:raise ValueError('Bounded public data rows required')
|
|
result={}
|
|
for row in rows:
|
|
ident=row.get(key)
|
|
if type(ident) is not int or not 0<ident<=0xffffffff or ident in result:raise ValueError('Invalid/duplicate public data identity')
|
|
result[ident]=row
|
|
return result
|
|
|
|
def classification(item,basics,budgets,natives,schema,covered):
|
|
entry=item['entry'];level=item['item_level'];dependencies=[];row=dict(entry=entry,name=item['name'],source_display_id=item['display_id'],current_package_contains_metadata=entry in covered,native_sparse_accessible=entry in natives,metadata_encodable=False)
|
|
if entry not in basics:dependencies.append('missing accessible same-ID Item basic definition')
|
|
if requires_stat_budget(item) and level not in budgets:dependencies.append('missing accessible RandPropPoints level')
|
|
if not dependencies:
|
|
try:
|
|
converted=convert(item,basics[entry],stat_budget(item,budgets),schema,natives.get(entry));wire=encode(converted,schema)
|
|
row.update(metadata_encodable=True,metadata_wire_bytes=len(wire),metadata_sha256=hashlib.sha256(wire).hexdigest())
|
|
except (ValueError,KeyError,TypeError,OverflowError,IndexError) as e:dependencies.append(type(e).__name__+': '+str(e))
|
|
spells=[dict(slot=i-1,spell=item['spellid_'+str(i)],trigger=item['spelltrigger_'+str(i)]) for i in range(1,6) if item['spellid_'+str(i)]]
|
|
row['source_spell_slots']=spells
|
|
if spells:dependencies.append('validate real spell definitions and ItemEffect/link semantics for this revision')
|
|
if item['armor']:dependencies.append('validate source armor against destination class/slot/quality curve; metadata alone does not convert armor')
|
|
if item['set_id']:dependencies.append('validate actual source item-set definitions, thresholds and spell effects')
|
|
if item['class']==2:dependencies.append('native same-ID damage variance/quality retained; complete legacy damage bands not converted')
|
|
dependencies+=['validate installed Octo display/model/icon/texture mapping','actual-client tooltip/equip/use/effect checks required before acceptance']
|
|
row['remaining_requirements']=dependencies;return row
|
|
|
|
def report(source,basic,points,native,schema,reviewed_source,package):
|
|
indexed(source,'entry');basics=indexed(basic,'ID');budgets=indexed(points,'ID');natives=indexed(native,'ID')
|
|
covered={r['id'] for r in package['rows'] if r.get('table_name')=='ItemSparse'}
|
|
rows=[classification(item,basics,budgets,natives,schema,covered) for item in sorted(source,key=lambda r:r['entry'])]
|
|
diff=compare_templates(reviewed_source,source)
|
|
return dict(kind='offline-local-item-package-preflight',build='1.60.1.70334',source_count=len(source),metadata_encodable_count=sum(r['metadata_encodable'] for r in rows),current_reviewed_metadata_count=sum(r['current_package_contains_metadata'] for r in rows),reviewed_source_diff=diff,rows=rows,client_or_database_modified=False,all_items_compatible=False,limits=['Metadata encoding is not deployment readiness or actual-client verification.','Missing accessible DB2 rows can be in encoded/copy sections; absence from export is not proof that no row exists.','No client schema/build-ID edits, asset installation, item grants, server changes or public Octo contact.'])
|
|
|
|
def batch_report(inventory,basic,points,native,schema,reviewed_source,package):
|
|
"""Classify an already validated snapshot using the existing converter."""
|
|
if (not isinstance(inventory,dict) or inventory.get('kind')!='source-item-dependency-inventory' or
|
|
inventory.get('snapshot_verification',{}).get('content_and_schema_and_ids_verified') is not True):raise ValueError('Require verified completed item inventory')
|
|
records=inventory.get('records')
|
|
if not isinstance(records,list) or not 1<=len(records)<=MAX_INVENTORY_RECORDS:raise ValueError('Batch source record bound')
|
|
source={};blocked=[]
|
|
for record in records:
|
|
item=record.get('raw_fields') if isinstance(record,dict) else None
|
|
if (not isinstance(item,dict) or type(item.get('entry')) is not int or not 0<=item['entry']<=0xffffffff or
|
|
record.get('identity')!=['Item',item['entry']] or item['entry'] in source):raise ValueError('Malformed batch source identity')
|
|
source[item['entry']]=item
|
|
if not item['entry']:blocked.append(dict(entry=0,status='blocked-non-wire-identity'))
|
|
basics=target_index(basic,'Item');budgets=target_index(points,'RandPropPoints');natives=target_index(native,'ItemSparse')
|
|
if not isinstance(reviewed_source,list) or any(not isinstance(row,dict) for row in reviewed_source):raise ValueError('Malformed reviewed source rows')
|
|
reviewed=indexed(reviewed_source,'entry')
|
|
if not isinstance(package,dict) or not isinstance(package.get('rows'),list) or len(package['rows'])>MAX_PACKAGE_ROWS:raise ValueError('Reviewed package record bound')
|
|
covered=set()
|
|
for row in package['rows']:
|
|
if not isinstance(row,dict):raise ValueError('Malformed reviewed package row')
|
|
if row.get('table_name')!='ItemSparse':continue
|
|
ident=row.get('id')
|
|
if type(ident) is not int or not 0<ident<=0x7fffffff or ident in covered:raise ValueError('Invalid/duplicate reviewed item identity')
|
|
covered.add(ident)
|
|
rows=[]
|
|
for entry,item in sorted(source.items()):
|
|
if not entry:continue
|
|
try:row=classification(item,basics,budgets,natives,schema,covered)
|
|
except ZeroDivisionError:
|
|
# A real zero budget is not permission to invent a coefficient.
|
|
# Preserve the ordinary converter's rejection as an explicit class.
|
|
row=dict(entry=entry,name=item['name'],source_display_id=item['display_id'],current_package_contains_metadata=entry in covered,native_sparse_accessible=entry in natives,metadata_encodable=False,
|
|
remaining_requirements=['zero native stat budget cannot represent source stats','validate installed Octo display/model/icon/texture mapping','actual-client tooltip/equip/use/effect checks required before acceptance'])
|
|
if entry>0x7fffffff:
|
|
# The existing package generator and DBReply RecordID use a
|
|
# positive signed32 identity; keep the source row but do not call
|
|
# it encodable merely because its other fields happen to fit.
|
|
row['metadata_encodable']=False;row.pop('metadata_wire_bytes',None);row.pop('metadata_sha256',None)
|
|
row['remaining_requirements'].insert(0,'source item ID outside positive signed hotfix record bounds')
|
|
row['status']='metadata-encodable' if row['metadata_encodable'] else 'blocked-metadata'
|
|
row['dependency_complete']=False;rows.append(row)
|
|
reasons=Counter(reason for row in rows for reason in row['remaining_requirements'])
|
|
present=sorted(reviewed.keys()&source.keys())
|
|
diff=compare_templates([reviewed[i] for i in present],[source[i] for i in present]) if present else None
|
|
return dict(kind='offline-local-item-batch-preflight',schema_version=1,build='1.60.1.70334',stored_source_count=len(source),source_count=len(rows),
|
|
blocked_source_identities=blocked,metadata_encodable_count=sum(row['metadata_encodable'] for row in rows),
|
|
current_reviewed_metadata_count=sum(row['current_package_contains_metadata'] for row in rows),
|
|
target_accessible_rows=dict(Item=len(basics),ItemSparse=len(natives),RandPropPoints=len(budgets)),
|
|
classification_counts=dict(sorted(Counter(row['status'] for row in rows).items())),reason_counts=dict(sorted(reasons.items())),rows=rows,
|
|
reviewed_source_comparison=dict(scope='Only matching reviewed IDs; unrelated source items are not added to this diff',present_ids=present,missing_ids=sorted(reviewed.keys()-source.keys()),diff=diff),
|
|
source_snapshot_identity=inventory['source_identity'],source_snapshot_provenance=inventory.get('snapshot_provenance',{}),source_snapshot_verification=inventory['snapshot_verification'],
|
|
effective_client_tables_selected=False,dependency_complete=False,converted=False,installed=False,engine_loaded=False,client_or_database_modified=False,all_items_compatible=False,
|
|
limits=['Metadata encoding eligibility is not dependency completeness, installation readiness or actual-client acceptance.',
|
|
'Accessible target exports can omit encoded/copy records; absence from export does not establish absence in the engine.',
|
|
'Spell/effect/icon/appearance/item-set dependencies still require effective Octo data and semantic validation.',
|
|
'Local snapshot provenance is retained, not verified against the public Octo database. No SQL, client or network operations.'])
|
|
|
|
def scalar_exclusions(item,basic,covered,source_revision=None):
|
|
"""Exhaustive snapshot-column policy, not a complete engine dependency model."""
|
|
if set(item)!=SCALAR_SOURCE_FIELDS:raise ValueError('Scalar candidate source schema has unreviewed/missing fields')
|
|
reasons=[]
|
|
if item['entry'] in covered:reasons.append('already in reviewed metadata package')
|
|
if item['inventory_type']!=0:reasons.append('equippable or container inventory semantics remain outside scalar candidate')
|
|
if item['class']==2:reasons.append('weapon damage semantics remain outside scalar candidate')
|
|
if type(item['class']) is not int or not 0<=item['class']<=15 or item['class']==8:reasons.append('source class outside reviewed ordinary enum intersection')
|
|
if item['class']==1 and item['subclass']==8:reasons.append('rations/inscription container subclass semantics differ')
|
|
if type(item['material']) is not int or not 0<=item['material']<=8:reasons.append('unreviewed source material')
|
|
if type(item['bonding']) is not int or not 0<=item['bonding']<=4:reasons.append('unreviewed source bonding semantics')
|
|
# ItemSparse already converts named source categories to native masks.
|
|
# Reuse that review for scalar materials; never copy category numbers.
|
|
try:bag_family_mask(item['bag_family'])
|
|
except ValueError:reasons.append('unreviewed source bag family semantics')
|
|
if not basic or type(basic.get('IconFileDataID')) is not int or basic['IconFileDataID']<=0:reasons.append('no accessible same-ID nonzero native icon baseline')
|
|
for key in sorted(ZERO_FIELDS):
|
|
value=item[key]
|
|
if type(value) not in (int,float) or not math.isfinite(value) or value!=0:reasons.append('nonzero/unreviewed source field: '+key)
|
|
for key in sorted(SPELL_FIELDS):
|
|
value=item[key];allowed=(-1,0) if key.startswith(('spellcooldown_','spellcategorycooldown_')) else (0,)
|
|
if type(value) not in (int,float) or not math.isfinite(value) or value not in allowed:reasons.append('nonempty/unreviewed source spell field: '+key)
|
|
# Genuine loader absence: NULL returns0 immediately; empty is the seeded
|
|
# script-name entry at index0. Preserve raw source values/digests unchanged.
|
|
if item['script_name'] not in (None,''):reasons.append('source script dependency')
|
|
# SQL defaults this column to1, but the reviewed revision only declares and
|
|
# loads it. This narrowly pinned candidate policy does not infer an item
|
|
# counterpart or silently map it into native OppositeFactionItemID.
|
|
team=item['other_team_entry']
|
|
if type(team) is not int or team not in (0,1) or (team==1 and source_revision!=UNUSED_TEAM_DEFAULT_REVISION):reasons.append('unreviewed source other_team_entry for this revision')
|
|
return reasons
|
|
|
|
def container_exclusions(item,basic,covered,source_revision=None):
|
|
"""Ordinary stat/spell-free bags use the existing exhaustive field policy.
|
|
|
|
Only three differences are admitted: inventory type18, capacity1..36 and
|
|
source item delay (retained in ItemSparse; no weapon/cast mechanic implied).
|
|
Specialized bag families and magic/stat-bearing bags require further review.
|
|
"""
|
|
if set(item)!=SCALAR_SOURCE_FIELDS:raise ValueError('Container source schema has unreviewed/missing fields')
|
|
if ((item['class'],item['subclass'],item['inventory_type'])!=(1,0,18) or
|
|
type(item['bag_family'])is not int or item['bag_family']!=0 or
|
|
type(item['container_slots']) is not int or not 1<=item['container_slots']<=36 or
|
|
type(item['delay']) is not int or not 0<=item['delay']<=0xffffffff):
|
|
return ['outside-reviewed-ordinary-container-category']
|
|
neutral=dict(item,inventory_type=0,container_slots=0,delay=0)
|
|
return scalar_exclusions(neutral,basic,covered,source_revision)
|
|
|
|
def package_budget(package):
|
|
rows=package.get('rows') if isinstance(package,dict) else None
|
|
if not isinstance(rows,list) or not 1<=len(rows)<=MAX_PACKAGE_ROWS:raise ValueError('Reviewed package row bound')
|
|
# Reuse the native encoder's exact removal policy/provenance checks; empty
|
|
# payloads are legal only for its pinned source-owned relation deletions.
|
|
from item_sparse_compat import package_payloads,load_working_wire_baseline
|
|
package_payloads(rows,wire_baseline=load_working_wire_baseline(package))
|
|
identities=set();covered=set();size=8
|
|
for row in rows:
|
|
# The original Map catalogue has the admitted Eastern Kingdoms ID 0.
|
|
# Other catalogue identities, including Item/ItemSparse, stay positive.
|
|
native_map_zero=isinstance(row,dict)and row.get('table_name')=='Map'and row.get('table_hash')=='0xBD84CD62'and type(row.get('id'))is int and row['id']==0 and isinstance(row.get('record'),dict)and type(row['record'].get('ID'))is int and row['record']['ID']==0
|
|
if not isinstance(row,dict) or type(row.get('id')) is not int or not(0<row['id']<=0x7fffffff or native_map_zero):raise ValueError('Malformed reviewed package identity')
|
|
try:table=int(row['table_hash'],16)
|
|
except (KeyError,TypeError,ValueError):raise ValueError('Malformed reviewed package table') from None
|
|
key=(table,row['id'])
|
|
if not 0<table<=0xffffffff or key in identities:raise ValueError('Ambiguous reviewed package identity')
|
|
identities.add(key);wire=row.get('wire_hex')
|
|
if not isinstance(wire,str) or not 0<=len(wire)<=131070:raise ValueError('Reviewed package record byte bound')
|
|
try:raw=bytes.fromhex(wire)
|
|
except ValueError:raise ValueError('Malformed reviewed package bytes') from None
|
|
if raw.hex()!=wire.lower() or hashlib.sha256(raw).hexdigest()!=row.get('sha256'):raise ValueError('Reviewed package record hash mismatch')
|
|
size+=21+len(raw)
|
|
if row.get('table_name')=='ItemSparse':covered.add(row['id'])
|
|
if size>MAX_PACKAGE_BYTES:raise ValueError('Reviewed package already exceeds native byte bound')
|
|
return covered,size
|
|
|
|
def scalar_candidate(inventory,preflight,basic,points,native,schema,package,input_hashes):
|
|
"""Blocked dry-run ID/digest manifest; deliberately no hotfix row payloads."""
|
|
if (not isinstance(preflight,dict) or preflight.get('kind')!='offline-local-item-batch-preflight' or preflight.get('build')!='1.60.1.70334' or
|
|
preflight.get('schema_version')!=1):raise ValueError('Require existing full batch preflight')
|
|
if any(preflight.get('input_sha256',{}).get(key)!=value for key,value in input_hashes.items()):raise ValueError('Candidate inputs differ from full preflight')
|
|
if inventory.get('snapshot_verification',{}).get('content_and_schema_and_ids_verified') is not True:raise ValueError('Require validated source snapshot')
|
|
if not isinstance(inventory.get('records'),list) or not 1<=len(inventory['records'])<=MAX_INVENTORY_RECORDS:raise ValueError('Candidate source record bound')
|
|
source={}
|
|
for row in inventory['records']:
|
|
item=row['raw_fields'];ident=item['entry']
|
|
if row['identity']!=['Item',ident] or type(ident) is not int or not 0<=ident<=0xffffffff or ident in source:raise ValueError('Malformed candidate source identity')
|
|
if set(item)!=SCALAR_SOURCE_FIELDS:raise ValueError('Scalar candidate source schema has unreviewed/missing fields')
|
|
source[ident]=item
|
|
classifications={}
|
|
if not isinstance(preflight.get('rows'),list) or len(preflight['rows'])>MAX_INVENTORY_RECORDS:raise ValueError('Preflight classification record bound')
|
|
for row in preflight['rows']:
|
|
ident=row.get('entry') if isinstance(row,dict) else None
|
|
if type(ident) is not int or ident<=0 or ident in classifications:raise ValueError('Ambiguous preflight classification identity')
|
|
classifications[ident]=row
|
|
if set(classifications)!=(source.keys()-{0}) or len(source)!=preflight.get('stored_source_count'):raise ValueError('Preflight/source inventory differs')
|
|
basics=target_index(basic,'Item');budgets=target_index(points,'RandPropPoints');natives=target_index(native,'ItemSparse')
|
|
covered,size=package_budget(package);base=size;selected=[];excluded=Counter();eligible=0;deferred=0
|
|
for ident,item in sorted(source.items()):
|
|
if not ident:excluded['blocked non-wire source identity0']+=1;continue
|
|
row=classifications[ident]
|
|
if row.get('metadata_encodable') is not True:excluded['not metadata-encodable in full preflight']+=1;continue
|
|
reasons=scalar_exclusions(item,basics.get(ident),covered,inventory['source_identity'].get('server_source_git_revision'))
|
|
if reasons:
|
|
excluded.update(reasons);continue
|
|
raw=encode(convert(item,basics[ident],stat_budget(item,budgets),schema,natives.get(ident)),schema)
|
|
digest=hashlib.sha256(raw).hexdigest()
|
|
if digest!=row.get('metadata_sha256') or len(raw)!=row.get('metadata_wire_bytes'):raise ValueError('Candidate encoding differs from full preflight')
|
|
eligible+=1
|
|
if len(package['rows'])+len(selected)>=MAX_PACKAGE_ROWS or size+21+len(raw)>MAX_PACKAGE_BYTES:deferred+=1;continue
|
|
size+=21+len(raw)
|
|
source_raw=json.dumps(item,sort_keys=True,separators=(',',':'),ensure_ascii=False,allow_nan=False).encode()
|
|
selected.append(dict(entry=ident,source_record_sha256=hashlib.sha256(source_raw).hexdigest(),metadata_sha256=digest,metadata_wire_bytes=len(raw),source_display_id=item['display_id'],native_icon_file_data_id=basics[ident]['IconFileDataID']))
|
|
return dict(kind='blocked-scalar-item-metadata-candidate',schema_version=1,build='1.60.1.70334',status='BLOCKED_NOT_INSTALLABLE',
|
|
source_count=len(classifications),source_snapshot_identity=inventory['source_identity'],input_sha256=input_hashes,
|
|
policy=dict(version=2,source_columns=sorted(SCALAR_SOURCE_FIELDS),source_scalar_fields=sorted(SCALAR_FIELDS),source_zero_fields=sorted(ZERO_FIELDS),source_spell_slots='All empty; unused cooldown fields may be-1 or0',source_column_rules=SOURCE_COLUMN_RULES,
|
|
source_field_policy_complete_for_snapshot=True,complete_engine_dependency_model=False),
|
|
selected_items=selected,selected_count=len(selected),selector_eligible_count=eligible,deferred_by_budget=deferred,exclusion_reason_counts=dict(sorted(excluded.items())),
|
|
current_package_preserved=dict(rows=len(package['rows']),sha256=input_hashes['package'],neutral_hotfix_bytes=base),
|
|
budget=dict(combined_rows=len(package['rows'])+len(selected),combined_neutral_hotfix_bytes=size,maximum_rows=MAX_PACKAGE_ROWS,maximum_bytes=MAX_PACKAGE_BYTES),
|
|
blockers=['Effective Octo ItemDisplayInfo/icon/appearance equivalence remains unverified for the selected batch.',
|
|
'An existing same-ID native icon is only a baseline, not proof that it represents the authentic Octo definition.',
|
|
'Source field exclusions avoid known effect/quest/world/script dependencies but do not prove full engine compatibility.',
|
|
'Original-writer parity and actual fresh client hotfix/tooltip/inventory acceptance remain required before a reviewed install package.'],
|
|
encoding_checked=True,contains_installable_record_payloads=False,dependency_complete=False,effective_client_tables_selected=False,converted=False,staged=False,installable=False,installed=False,engine_loaded=False,
|
|
limits=['Dry-run ID/digest manifest only: no wire_hex, converted record data or generated header. Not accepted as an ItemSparse source or component profile.',
|
|
'No source ID remapping, package61/header changes, SQL, assets, client or network operations. Local source/public Octo equality is not established.'])
|
|
|
|
if __name__=='__main__':
|
|
p=argparse.ArgumentParser(description=__doc__)
|
|
selection=p.add_mutually_exclusive_group(required=True);selection.add_argument('--source',type=Path);selection.add_argument('--source-snapshot',type=Path)
|
|
for name in ('basic','points','native','reviewed-source','package','output'):p.add_argument('--'+name,type=Path,required=True)
|
|
p.add_argument('--stage-candidate',action='store_true',help='Blocked scalar ID/digest dry run only; emits no installable record payloads')
|
|
p.add_argument('--preflight',type=Path,help='Existing full batch preflight, required with --stage-candidate')
|
|
p.add_argument('--dbd',type=Path,default=Path.home()/'Projects/WoW-Hybrid/tools/WoWDBDefs/definitions/ItemSparse.dbd');p.add_argument('--db2',type=Path,default=Path.home()/'Projects/WoW-Hybrid/servers/trinity-forever/install/bin/dbc/enUS/ItemSparse.db2');a=p.parse_args()
|
|
if not a.output.resolve().is_relative_to(ROOT/'runtime') or a.output.exists():p.error('Preserve existing output; require new runtime report')
|
|
if (a.stage_candidate and (not a.source_snapshot or not a.preflight)) or (a.preflight and not a.stage_candidate):p.error('Candidate requires --source-snapshot, --stage-candidate and --preflight together')
|
|
check_db2(a.db2)
|
|
if a.source_snapshot:
|
|
names=('basic','points','native','reviewed_source','package');inputs={};hashes={}
|
|
for name in names:inputs[name],hashes[name]=(read_compatibility_package(getattr(a,name))if name=='package'else read_public_json(getattr(a,name)))
|
|
inventory=inventory_item_snapshot(a.source_snapshot)
|
|
inputs_hashes={**hashes,'dbd':sha(a.dbd),'db2':sha(a.db2),'source_manifest':inventory['source_identity']['manifest_sha256']}
|
|
if a.stage_candidate:
|
|
previous,previous_hash=read_public_json(a.preflight)
|
|
result=scalar_candidate(inventory,previous,inputs['basic'],inputs['points'],inputs['native'],fields(a.dbd),inputs['package'],inputs_hashes)
|
|
result['preflight_sha256']=previous_hash
|
|
if bounded_digest(a.preflight)!=previous_hash:raise ValueError('Preflight changed during candidate analysis')
|
|
else:result=batch_report(inventory,**inputs,schema=fields(a.dbd));result['input_sha256']=inputs_hashes
|
|
result['target_validation_scope']='Supplied export contents checked; generation against the destination DB2 tables is not independently repeated.'
|
|
for name,digest in hashes.items():
|
|
if bounded_digest(getattr(a,name),MAX_COMPATIBILITY_PACKAGE_JSON_BYTES if name=='package'else MAX_TARGET_BYTES)!=digest:raise ValueError('Public export changed during classification')
|
|
else:
|
|
names=('source','basic','points','native','reviewed_source','package');inputs={name:json.loads(getattr(a,name).read_text()) for name in names}
|
|
result=report(**inputs,schema=fields(a.dbd));result['input_sha256']={name:sha(getattr(a,name)) for name in (*names,'dbd','db2')}
|
|
with a.output.open('x') as stream:stream.write(json.dumps(result,ensure_ascii=False,sort_keys=bool(a.source_snapshot),allow_nan=False,indent=2)+'\n')
|
|
if a.stage_candidate:print('BLOCKED scalar dry run:',result['selected_count'],'selected IDs; no installable payloads; dependency and actual-client checks remain.')
|
|
else:print('Read-only preflight:',result['source_count'],'source items;',result['metadata_encodable_count'],'metadata-encodable;',result['current_reviewed_metadata_count'],'in current reviewed package; full conversion/real-client checks remain.')
|