367 files, from working commit b1a079a. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
97 lines
6.2 KiB
Python
97 lines
6.2 KiB
Python
#!/usr/bin/env python3
|
|
"""Prepare conservative hidden-Spell exclusions for the initial locator gate.
|
|
|
|
Original70334 constructor2A99022 excludes generic spellbook insertion when
|
|
compact attribute word0 has0x80. This emitter joins the existing native
|
|
SpellMisc inventory and package overrides by child ID, then emits only valid
|
|
canonical Spell IDs with one unambiguous default child and hidden0x80 in every
|
|
observed effective difficulty. Missing/ambiguous metadata remains required.
|
|
No passive/class filtering, client memory, DB export, build or installation.
|
|
"""
|
|
import argparse
|
|
from collections import Counter,defaultdict
|
|
import hashlib,json
|
|
from pathlib import Path
|
|
import class_spell_compat as builder
|
|
from octo_client_data import canonical_sha256
|
|
|
|
MASK=0x80
|
|
ROOT=Path(__file__).resolve().parents[1]
|
|
def digest(path):return hashlib.sha256(Path(path).read_bytes()).hexdigest()
|
|
def classify(package,native,schema):
|
|
effective={}
|
|
for source in native:
|
|
rec=builder.normalize_native_export(source,schema)
|
|
builder.codec.encode(rec,schema)
|
|
if rec['ID']in effective:raise ValueError('Duplicate native SpellMisc child ID')
|
|
effective[rec['ID']]=rec
|
|
canonical=set();seen=set()
|
|
for row in package['rows']:
|
|
table=row.get('table_name')
|
|
if table not in('Spell','SpellMisc'):continue
|
|
key=(table,row['id'])
|
|
if key in seen:raise ValueError('Duplicate package Spell/SpellMisc identity')
|
|
seen.add(key)
|
|
status=row.get('record_status','valid')
|
|
if status not in('valid','removed'):raise ValueError('Unreviewed canonical record status')
|
|
if table=='Spell':
|
|
if int(row['table_hash'],16)!=0xe111669e:raise ValueError('Canonical Spell table identity differs')
|
|
if status=='valid':canonical.add(row['id'])
|
|
continue
|
|
if int(row['table_hash'],16)!=0xc603ee28:raise ValueError('SpellMisc table identity differs')
|
|
if status=='removed':effective.pop(row['id'],None);continue
|
|
wire=bytes.fromhex(row['wire_hex'])
|
|
if hashlib.sha256(wire).hexdigest()!=row['sha256']:raise ValueError('Package SpellMisc wire SHA differs')
|
|
rec=builder.decode(wire,schema,row['id'])
|
|
if row.get('record')is not None and rec!=row['record']:raise ValueError('Package SpellMisc record/wire disagreement')
|
|
if builder.codec.encode(rec,schema)!=wire:raise ValueError('Package SpellMisc schema roundtrip differs')
|
|
effective[row['id']]=rec
|
|
by_spell=defaultdict(list)
|
|
for rec in effective.values():by_spell[rec['SpellID']].append(rec)
|
|
hidden=[];held=[];stats=Counter()
|
|
for ident in sorted(canonical):
|
|
rows=sorted(by_spell.get(ident,[]),key=lambda r:r['ID'])
|
|
defaults=[r for r in rows if r['DifficultyID']==0]
|
|
if len(defaults)!=1:
|
|
reason='no_effective_default'if not defaults else'ambiguous_effective_default'
|
|
held.append(dict(spell=ident,reason=reason,child_ids=[r['ID']for r in rows]));stats[reason]+=1;continue
|
|
if not all((int(r['Attributes'][0])&0xffffffff)&MASK for r in rows):stats['nonhidden_or_mixed_difficulty']+=1;continue
|
|
hidden.append(dict(spell=ident,default_child_id=defaults[0]['ID'],children=[dict(id=r['ID'],difficulty=r['DifficultyID'],attrs0=int(r['Attributes'][0])&0xffffffff,record_sha256=canonical_sha256(r))for r in rows]));stats['hidden_excluded']+=1
|
|
return dict(hidden_ids=[r['spell']for r in hidden],hidden=hidden,held=held,stats=dict(stats),canonical_count=len(canonical),effective_children=len(effective))
|
|
def header(ids,package_pin,native_pin):
|
|
if ids!=sorted(set(ids))or any(type(v)is not int or not 0<v<=0x7fffffff for v in ids):raise ValueError('Sorted unique bounded hidden IDs required')
|
|
data=','.join(str(v)+'u'for v in ids)if ids else'0u'
|
|
return '''#pragma once
|
|
/* Candidate-only original70334 generic-book hidden mask0x80 exclusions.
|
|
* No blanket passive/class filtering. Missing/ambiguous metadata is absent
|
|
* from this set and therefore remains required by the canonical gate.
|
|
* package SHA256: %s
|
|
* native SpellMisc SHA256: %s
|
|
*/
|
|
#include <stdint.h>
|
|
#include <stddef.h>
|
|
#define GW_SPELLBOOK_HIDDEN_READINESS_COUNT %du
|
|
static const uint32_t gw_spellbook_hidden_readiness_ids[%d] = {%s};
|
|
static inline int gw_spellbook_hidden_for_initial_gate(uint32_t spell) {
|
|
size_t low=0, high=GW_SPELLBOOK_HIDDEN_READINESS_COUNT;
|
|
while(low<high) {
|
|
size_t middle=low+(high-low)/2u;
|
|
uint32_t value=gw_spellbook_hidden_readiness_ids[middle];
|
|
if(value<spell)low=middle+1u;
|
|
else if(value>spell)high=middle;
|
|
else return 1;
|
|
}
|
|
return 0;
|
|
}
|
|
'''%(package_pin,native_pin,len(ids),max(1,len(ids)),data)
|
|
def main():
|
|
p=argparse.ArgumentParser(description=__doc__);p.add_argument('--package',type=Path,required=True);p.add_argument('--native-misc',type=Path,required=True);p.add_argument('--dbd',type=Path,default=ROOT.parent/'tools/WoWDBDefs/definitions');p.add_argument('--output',type=Path,required=True);a=p.parse_args()
|
|
output=a.output.resolve()
|
|
if not output.is_relative_to(ROOT/'runtime')or output.exists():raise ValueError('Fresh owned runtime output required')
|
|
schema=builder.checked_schema(a.dbd,'SpellMisc');package=json.loads(a.package.read_text());result=classify(package,json.loads(a.native_misc.read_text()),schema);packagepin=digest(a.package);nativepin=digest(a.native_misc)
|
|
output.mkdir();(output/'gateway').mkdir();h=output/'gateway/spellbook_hidden_readiness.h';h.write_text(header(result['hidden_ids'],packagepin,nativepin))
|
|
result.update(state='ORIGINAL_HIDDEN_MASK_INITIAL_GATE_CANDIDATE_NOT_ACCEPTED',package=str(a.package.resolve()),package_sha256=packagepin,native_misc=str(a.native_misc.resolve()),native_misc_sha256=nativepin,header=str(h),header_sha256=digest(h),mask=MASK,policy='exactly_one_default_and_all_observed_effective_children_hidden',unknown_metadata='remains required; native export is observed local inventory, not a full encrypted-record completeness claim',native_accepted=False,build_or_install=False)
|
|
(output/'report.private.json').write_text(json.dumps(result,indent=2)+'\n')
|
|
print('Hidden-mask candidate:',len(result['hidden_ids']),'sorted IDs;',len(result['held']),'unknown/ambiguous IDs remain required.')
|
|
if __name__=='__main__':main()
|