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

73 lines
6.0 KiB
Python

#!/usr/bin/env python3
"""Isolated source/native MOD_DISARM aura mask proposal; never installs a profile.
Reuse the accepted aura family's effective-table overlay rules and header writer.
Only pure source disarm holders qualify; mixed/instant execution needs separate
review. A native-only effect is never enabled by this presentation policy.
"""
import re
POLICY='named-source-disarm-effect-mask-v1'
NAME='SPELL_AURA_MOD_DISARM'
def namespace(source_header,target_header):
def witness(text):
matches=re.findall(r'(?m)^[ \t]*'+NAME+r'[ \t]*=[ \t]*(\d+)[ \t]*,',text)
if len(matches)!=1 or int(matches[0])!=67:raise ValueError('Unique reviewed literal MOD_DISARM=67 enum required')
return {NAME:67}
return {'source':witness(source_header),'target':witness(target_header)}
def _namespace(proof):
if not isinstance(proof,dict) or set(proof)!={'source','target'}:raise ValueError('Exact source/native namespace required')
for side in ['source','target']:
if not isinstance(proof[side],dict) or set(proof[side])!={NAME} or type(proof[side][NAME])is not int or proof[side][NAME]!=67:raise ValueError('Reviewed named disarm namespace differs')
return 67
def generate(source,native,*,enum_proof,native_parent_ids):
kind=_namespace(enum_proof)
if not isinstance(source,list) or len(source)>100000 or not isinstance(native,list) or len(native)>500000:raise ValueError('Bounded source/native lists required')
if not isinstance(native_parent_ids,(set,frozenset)) or len(native_parent_ids)>500000 or any(type(s)is not int or not 0<s<=0x7fffffff for s in native_parent_ids):raise ValueError('Typed native Spell/SpellName parent set required')
by_spell={};seen_native=set()
for row in native:
if not isinstance(row,dict) or any(type(row.get(k))is not int for k in ['ID','SpellID','DifficultyID','EffectIndex','Effect','EffectAura']):raise ValueError('Typed native effect row required')
if row['ID']<=0 or row['ID'] in seen_native or not 0<row['SpellID']<=0x7fffffff or not 0<=row['EffectIndex']<32 or row['DifficultyID']<0:raise ValueError('Unique native effect identity/index required')
seen_native.add(row['ID'])
if row['DifficultyID']==0:by_spell.setdefault(row['SpellID'],{}).setdefault(row['EffectIndex'],[]).append(row)
seen=set();definitions=[];held=[];candidates=0
for row in source:
if not isinstance(row,dict) or type(row.get('entry'))is not int or not 0<row['entry']<=0x7fffffff or row['entry'] in seen:raise ValueError('Unique typed source spell identity required')
sid=row['entry'];seen.add(sid)
if any(type(row.get(k+str(i)))is not int or not 0<=row[k+str(i)]<=65535 for i in range(1,4) for k in ['effect','effectApplyAuraName']):raise ValueError('Typed source effect shape required')
if not any(row['effect'+str(i)]==6 and row['effectApplyAuraName'+str(i)]==kind for i in range(1,4)):continue
candidates+=1
def hold(reason):held.append({'spell':sid,'reason':reason})
if sid not in native_parent_ids:hold('same-ID native Spell/SpellName parent missing');continue
if any(row['effect'+str(i)] not in [0,6] for i in range(1,4)):hold('source has non-aura execution dependency');continue
indices=[i-1 for i in range(1,4) if row['effect'+str(i)]==6]
if any(row['effectApplyAuraName'+str(i+1)]!=kind for i in indices):hold('source mixes an unreviewed aura family');continue
if any(not row['effect'+str(i)] and row['effectApplyAuraName'+str(i)] for i in range(1,4)):hold('inactive source effect carries ambiguous aura kind');continue
current=by_spell.get(sid,{})
if any(len(current.get(i,[]))!=1 for i in indices):hold('same-ID native effect index missing or ambiguous');continue
if any(current[i][0]['Effect']!=6 or current[i][0]['EffectAura']!=kind for i in indices):hold('named source/native aura kind mismatch');continue
definitions.append({'spell':sid,'active_flags':sum(1<<i for i in indices),'source_effect_indices':indices,'source_aura_types':[kind for _ in indices],'native_aura_types':[kind for _ in indices],'native_effect_ids':[current[i][0]['ID'] for i in indices],'excluded_native_only_indices':sorted(set(current)-set(indices))})
return {'policy':POLICY,'enum_proof':{side:dict(values) for side,values in enum_proof.items()},'native_parent_ids':sorted(native_parent_ids&seen),'definitions':sorted(definitions,key=lambda x:x['spell']),'excluded':sorted(held,key=lambda x:x['spell']),'counts':{'source_rows':len(source),'family_candidates':candidates,'supported':len(definitions),'held':len(held)},'limits':['Admission only; does not create spell metadata, cast, aura, duration or caster provenance.','Pure source disarm holders only; mixed aura and instant execution dependencies remain held.','Only source-correlated same-ID native effect slots; native-only effects excluded.','No combat/UI acceptance claim.']}
def compose(profile,source,native,*,enum_proof,native_parent_ids):
"""Re-derive the review from actual rows, then retain every existing mask."""
if not isinstance(profile,dict) or not isinstance(profile.get('definitions'),list) or len(profile['definitions'])>100000:raise ValueError('Bounded retained profile required')
rows={}
for row in profile['definitions']:
if not isinstance(row,dict):raise ValueError('Typed retained mask row required')
sid=row.get('spell');mask=row.get('active_flags')
if type(sid)is not int or not 0<sid<=0x7fffffff or type(mask)is not int or not 0<mask<256 or sid in rows:raise ValueError('Unique typed retained mask required')
rows[sid]=dict(row)
before={s:r['active_flags'] for s,r in rows.items()};review=generate(source,native,enum_proof=enum_proof,native_parent_ids=native_parent_ids);added=[];conflicts=[]
for row in review['definitions']:
sid=row['spell']
if sid in rows:
if rows[sid]['active_flags']!=row['active_flags']:conflicts.append({'spell':sid,'retained_mask':rows[sid]['active_flags'],'proposed_mask':row['active_flags']})
else:rows[sid]=dict(row);added.append(sid)
if any(rows[s]['active_flags']!=m for s,m in before.items()):raise ValueError('Retained mask changed')
candidate=dict(profile);candidate['definitions']=[rows[s] for s in sorted(rows)]
return candidate,review,{'retained':len(before),'added':added,'conflicts':conflicts}