Files
praxisandClaude Fable 5.2 45ecd73fe0 Evidence records
1888 files, from working commit b1a079a.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-19 01:32:48 +02:00

66 lines
6.5 KiB
Python

"""Stage authentic Wrath674 plus the reviewed missing flat modifier definition."""
from pathlib import Path
import sys,json,hashlib,copy
R=Path.cwd();sys.path.insert(0,str(R/'ops'));W=Path(__file__).resolve().parent
from turtle_data import DBC,spell_layout
from spell_passive_compat import TABLES,SUPPLEMENTAL_TABLES,fields,db2_header,BUILD
from spell_definition_common import REQUIRED_REFERENCE_TABLES,NEW_DEFINITION_CHILD_TABLES
from content_package_stage import compose_definition_candidates
from spell_flat_modifier_compat import new_component
from item_sparse_compat import package_pages,package_payloads,fields as set_fields
from item_set_compat import generate,extract_sets,TABLES as SET_TABLES
load=lambda p:json.loads(Path(p).read_text());digest=lambda p:hashlib.sha256(Path(p).read_bytes()).hexdigest()
pins={}
def pinned(p):
p=Path(p);pins[str(p)]=digest(p);return load(p)
# Installer-preserved immutable pre-batch package supports repeatable regeneration.
pkg=pinned(R/'recovery/native-item-batch-20261020-033106/0-package.json');assert len(pkg['rows'])==40247
native={t:pinned(W/'native'/(t+'.json'))for t in REQUIRED_REFERENCE_TABLES}
for t in REQUIRED_REFERENCE_TABLES:
effective={r['ID']:r for r in native[t]}
for row in pkg['rows']:
if row['table_name']!=t:continue
if row.get('record_status','valid')=='removed':effective.pop(row['id'],None)
else:effective[row['id']]=dict(row['record'],ID=row['id'])
native[t]=list(effective.values())
old=R/'runtime/octo-praxis-import-20261017/armor-components'
for t in ('SpellCastTimes','SpellDuration','SpellRange'):native[t]=pinned(old/('skill-context-'+t+'.json'))
server=Path('/home/praxis/Servers/tortoise-docker/data/dbc');source_tables={t:DBC(server/(t+'.dbc'),n)for t,n in dict(SpellIcon=2,SpellCastTimes=4,SpellDuration=4,SpellRange=22).items()}
for t in source_tables:pins[str(source_tables[t].path)]=source_tables[t].digest()
dbd=R.parent/'tools/WoWDBDefs/definitions';target=R.parent/'servers/trinity-forever/install/bin/dbc/enUS';tables={t:(TABLES|SUPPLEMENTAL_TABLES)[t]for t in('Spell','SpellName',*NEW_DEFINITION_CHILD_TABLES)}
schemas={t:fields(dbd/(t+'.dbd'),t)for t in tables};maxima={};metadata={}
for t,(table,layout,field_sha) in tables.items():
maximum=db2_header(target/(t+'.db2'),table,layout);maxima[t]=max([maximum]+[r['id']for r in pkg['rows']if r['table_name']==t]);metadata[t]=dict(table_hash=hex(table),layout_hash=hex(layout),serialized_field_sha256=field_sha,native_max_id=maximum,allocation_bound=maxima[t],db2_sha256=digest(target/(t+'.db2')),dbd_sha256=digest(dbd/(t+'.dbd')))
source=DBC(R/'runtime/octo-spell-block-fill-owned-20261017/capture/Spell.dbc',173);o=spell_layout();pins[str(source.path)]=source.digest()
inventory=dict(source=[dict(id=r[0],family=r[o['SpellClassSet']],mask=r[o['SpellClassMask']]|r[o['SpellClassMask']+1]<<32)for r in source.rows],target=pinned(W/'native-warrior-class.json'))
# Overlay actual installed class options before deriving target bit coverage.
classes={r['SpellID']:r for r in inventory['target']}
for r in native['SpellClassOptions']:
if r['SpellClassSet']==4:classes[r['SpellID']]=r
inventory['target']=sorted(classes.values(),key=lambda r:r['SpellID'])
affect_path=W/'source-affect.tsv';pins[str(affect_path)]=digest(affect_path);affect_masks={}
for line in affect_path.read_text().splitlines():
entry,index,mask=map(int,line.split('\t'));key=f'{entry}:{index}';assert key not in affect_masks;affect_masks[key]=mask
src=pinned(W/'normalized-modifier.json');proof=src['flat_modifier_namespace'];raw=(W/'healingwavegreater.blp').read_bytes();pins[str(W/'healingwavegreater.blp')]=digest(W/'healingwavegreater.blp')
asset=dict(path='interface/icons/spell_nature_healingwavegreater.blp',bytes=len(raw),sha256=digest(W/'healingwavegreater.blp'),magic_hex=raw[:4].hex())
component=new_component([src],native,schemas,maxima,dict(schema_version=1,build=BUILD,SpellEffect={}),source_tables=source_tables,target_icon_names={136042:[asset['path']]},new_icon_ids={'53204':136042},icon_assets=[asset],read_icon=lambda p:raw if p==asset['path']else b'',modifier_namespace=proof,affect_inventory=inventory,affect_masks=affect_masks)
component.update(native_tables=metadata,input_sha256=pins.copy())
before=pinned(W/'original-spell-absence.json');assert before['world_readiness_confirmed']and before['local_only']and not before['external_gateway_running']
staged=compose_definition_candidates(pkg,[component],schemas,before['spells'])
candidate=copy.deepcopy(pkg);candidate.update(rows=staged['rows'],push_id=staged['push_id'],pushes=package_pages(staged['rows']))
# Use the existing authoritative45-column set converter and stable global IDs.
all_sets=pinned(R/'runtime/catalog-items-20261018/all-item-set-components.json');old_registry=all_sets['registry'];reg=dict(version=1,slots={k:v for k,v in old_registry['slots'].items()if k.startswith('674:')})
source_path=Path('/home/praxis/Servers/tortoise-docker/data/dbc/ItemSet.dbc');sets,exceptions=extract_sets(source_path);sets=[s for s in sets if s['id']==674];assert len(sets)==1; pins[str(source_path)]=digest(source_path)
set_schemas={t:set_fields(dbd/(t+'.dbd'),layout,count)for t,(_,layout,count)in SET_TABLES.items()}
set_max=db2_header(target/'ItemSetSpell.db2',*SET_TABLES['ItemSetSpell'][:2]);set_component=generate(sets,pinned(W/'native/ItemSet.json'),pinned(W/'native/ItemSetSpell.json'),set_schemas,set_max,reg)
occupied={(r['table_name'],r['id'])for r in candidate['rows']}
for r in set_component['records']:assert (r['table_name'],r['id'])not in occupied,(r['table_name'],r['id'])
candidate['rows']+=set_component['records'];candidate['push_id']=package_payloads(candidate['rows'])[0];candidate['pushes']=package_pages(candidate['rows'])
ext=copy.deepcopy(candidate.get('definition_extension',{}));ext['source_spell_ids']=sorted(set(ext.get('source_spell_ids',[]))|{53204});candidate['definition_extension']=ext
assert candidate['rows'][:len(pkg['rows'])]==pkg['rows']
for p,h in pins.items():assert digest(p)==h,p
report=dict(preserved_rows=len(pkg['rows']),added_spell_records=staged['added_count'],added_set_records=len(set_component['records']),total_rows=len(candidate['rows']),source_set=674,members=sets[0]['item_ids'],bonuses=set_component['dependencies'],input_sha256=pins,modifier_maps=component['spells'][0]['affect_mappings'],installed=False,engine_loaded=False,gameplay_verified=False)
for name,value in [('package.json',candidate),('modifier-component.json',component),('set-component.json',set_component),('report.json',report)]:
(W/name).write_text(json.dumps(value,sort_keys=True,separators=(',',':'))+'\n')
print(json.dumps(report,indent=2))