883 files, from working commit b1a079a. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
67 lines
4.9 KiB
Python
67 lines
4.9 KiB
Python
#!/usr/bin/env python3
|
|
"""Focused signed resistance representation and complete four-parent boundary."""
|
|
import argparse,copy,json,pathlib,struct,sys
|
|
sys.path.insert(0,str(pathlib.Path(__file__).resolve().parents[1]/'ops'))
|
|
from item_sparse_compat import encode,intrinsic_stat_fields,package_pages
|
|
|
|
def f32(x):return struct.unpack('<f',struct.pack('<f',x))[0]
|
|
def decode_amount(c,p):
|
|
v=f32(f32(c*f32(p))*f32(.0001))
|
|
return int(v+(.5 if v>=0 else -.5))
|
|
|
|
def main():
|
|
ap=argparse.ArgumentParser();ap.add_argument('--stage',type=pathlib.Path,required=True);ap.add_argument('--family-only',action='store_true',help='Resume only the failed control/family boundary using saved prefix PASS');a=ap.parse_args()
|
|
load=lambda p:json.loads(pathlib.Path(p).read_text())
|
|
ctx=load(a.stage/'context.json');schema=ctx['schema']
|
|
if a.family_only:
|
|
assert load(a.stage/'prefix-validation.json')['status']=='PASS'
|
|
else:
|
|
pkg=load(a.stage/'package-compact.json');base=load(ctx['base'])
|
|
assert len(base['rows'])==83597 and len(pkg['rows'])==83605
|
|
assert pkg['rows'][:83597]==base['rows'],'Prior rows changed'
|
|
assert pkg['pushes']==package_pages(pkg['rows']),'Page ownership differs'
|
|
assert {(r['table_name'],r['id']) for r in pkg['rows'][83597:]}=={(t,i) for t in ['Item','ItemSparse'] for i in [51784,61555,61568,84501]}
|
|
(a.stage/'prefix-validation.json').write_text(json.dumps({'status':'PASS','base_rows':83597,'rows':83605,'prefix_exact':True,'pages_exact':True,'new_identity_set_exact':True},indent=2)+'\n')
|
|
field=next(x for x in schema if x[0]=='StatPercentEditor')
|
|
assert field[1]=='int' and field[2:]==[32,False,10],'Signed native coefficient schema differs'
|
|
control=ctx['original_negative_control'];assert control['ID']==10555
|
|
assert [(t,c) for t,c in zip(control['StatModifier_bonusStat'],control['StatPercentEditor']) if c<0]==[(53,-500000),(51,-500000),(55,-500000),(52,-500000),(54,-500000)]
|
|
assert len(encode({'StatPercentEditor':control['StatPercentEditor']},[field]))==40,'Original signed coefficient array must encode without unsigned coercion'
|
|
schools=[('fire_res',51),('frost_res',52),('holy_res',53),('shadow_res',54),('nature_res',55),('arcane_res',56)]
|
|
seen=set();negative=0
|
|
for row in ctx['family']:
|
|
src=row['source'];record=row['record'];budget=row['budget'];seen.add(src['entry'])
|
|
pairs=list(zip(record['StatModifier_bonusStat'],record['StatPercentEditor']))
|
|
nonzero=[(t,c) for t,c in pairs if t!=-1 and c]
|
|
assert src['inventory_type'] in(6,12),'Reviewed family budget class differs'
|
|
index=1 # Waist/trinket RandPropPoints column, retained native budget contract.
|
|
quality='SuperiorF' if src['quality'] in(3,7) else 'EpicF' if src['quality'] in(4,5,6) else 'GoodF'
|
|
denominator=budget[quality][index]
|
|
for key,kind in schools:
|
|
expected=src.get(key,0);hits=[c for t,c in pairs if t==kind]
|
|
assert len(hits)==bool(expected),(src['entry'],key,'lost or duplicated school')
|
|
if expected:
|
|
assert decode_amount(hits[0],denominator)==expected,(src['entry'],key)
|
|
assert (hits[0]<0)==(expected<0)
|
|
negative+=expected<0
|
|
# Existing positive primary/armor fields must be unchanged when signed
|
|
# resistance penalties are omitted from the independent comparison.
|
|
positive=copy.deepcopy(src)
|
|
for key,_ in schools:
|
|
if positive.get(key,0)<0:positive[key]=0
|
|
old=intrinsic_stat_fields(positive,budget,armor_baseline=row['armor_baseline'],shield_block=True)
|
|
positives=[(t,c) for t,c in zip(old['StatModifier_bonusStat'],old['StatPercentEditor']) if t!=-1 and c]
|
|
assert [(t,c) for t,c in nonzero if t not in {k for _,k in schools} or src[next(n for n,k in schools if k==t)]>0]==positives
|
|
assert encode(record,schema).hex()==row['component']['wire_hex']
|
|
assert seen=={51784,61555,61568,84501} and negative==8,(seen,negative)
|
|
# Signed admission does not weaken the ten-slot capacity or reviewed budget.
|
|
probe=copy.deepcopy(ctx['family'][0]['source'])
|
|
for i in range(1,11):probe['stat_type'+str(i)]=3;probe['stat_value'+str(i)]=1
|
|
try:intrinsic_stat_fields(probe,ctx['family'][0]['budget'],armor_baseline=ctx['family'][0]['armor_baseline'],shield_block=True)
|
|
except ValueError as e:assert 'capacity' in str(e)
|
|
else:raise AssertionError('Signed resistance overflow was truncated')
|
|
receipt={'status':'PASS','base_rows':83597,'new_rows':8,'rows':83605,'whole_family':sorted(seen),'negative_source_slots':negative,'original_native_control':10555,'prior_prefix_exact':True,'page_ownership_exact':True,'positive_stat_preservation':True,'capacity_guard_preserved':True,'runtime_acceptance':False}
|
|
(a.stage/'validation.json').write_text(json.dumps(receipt,indent=2)+'\n')
|
|
print('PASS:4parents/8negative slots, original signed control, unchanged prefix/pages and guards')
|
|
if __name__=='__main__':main()
|