883 files, from working commit b1a079a. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
78 lines
6.6 KiB
Python
78 lines
6.6 KiB
Python
"""One new exact-nibble6 HeightTextureCoord cohort; frozen water checks reused."""
|
|
from pathlib import Path
|
|
import collections,hashlib,json,struct,sys
|
|
sys.path.insert(0,str(Path(__file__).resolve().parents[1]/'ops'))
|
|
from map_asset_preflight import _adt_split_records, _adt_split_chunk, adt_root_magma_candidate, adt_root_still_river_candidate
|
|
J=Path('runtime/continuation-20261027/Source-lava-class2-contract'); OUT=J/'private-ROOT-candidates';OUT.mkdir(exist_ok=True)
|
|
P=J/'completed-magma-rows.private.jsonl';H=J/'held-magma-rows.private.jsonl';result=J/'focused-result.private.json';assert not result.exists()
|
|
ledger=Path('runtime/continuation-20261026/Root-named-openworld-area-status/held-outdoor-liquid-operands.json')
|
|
rows=[r for r in json.loads(ledger.read_text())['rows'] if 2 in r['whole_tile_wet_classes']]
|
|
passed=[json.loads(s) for s in P.read_text().splitlines()] if P.exists() else [];held=[json.loads(s) for s in H.read_text().splitlines()] if H.exists() else []
|
|
done={r['source_reference'] for r in passed+held}
|
|
def enc(rows):return b''.join(_adt_split_chunk(t,p)+z for t,p,z in rows)
|
|
def verify(old,new):
|
|
a,b=_adt_split_records(old),_adt_split_records(new)
|
|
assert [(t,p,z) for t,p,z in a if t not in ('MCNK','MHDR','MH2O')]==[(t,p,z) for t,p,z in b if t not in ('MCNK','MHDR','MH2O')]
|
|
ah=next(p for t,p,z in a if t=='MHDR');bh=next(p for t,p,z in b if t=='MHDR')
|
|
assert all(ah[i*4:i*4+4]==bh[i*4:i*4+4] for i in range(16) if i not in (9,10,11))
|
|
cursor=0
|
|
for t,p,z in b:
|
|
if t in ('MFBO','MH2O','MTXF'):assert struct.unpack_from('<I',bh,dict(MFBO=9,MH2O=10,MTXF=11)[t]*4)[0]==cursor-20
|
|
cursor+=8+len(p)+len(z)
|
|
liquid=next(p for t,p,z in b if t=='MH2O');before=[p for t,p,z in a if t=='MCNK'];after=[p for t,p,z in b if t=='MCNK'];assert len(before)==len(after)==256
|
|
instances=0; vertices=0
|
|
for original,changed in zip(before,after):
|
|
wa=struct.unpack_from('<32I',original);wb=struct.unpack_from('<32I',changed);ca,cb=_adt_split_records(original[128:]),_adt_split_records(changed[128:])
|
|
assert wb[0]==wa[0]&~0x3c and wb[24:26]==(0,0)
|
|
assert all(wa[n]==wb[n] for n in range(1,32) if n not in (22,24,25,29))
|
|
assert [(t,p,z) for t,p,z in ca if t!='MCLQ']==cb
|
|
x,y=wa[1:3];off,n,attrs=struct.unpack_from('<III',liquid,(y*16+x)*12);assert n==(wa[0]&0x3c).bit_count()
|
|
if not n:assert(off,attrs)==(0,0);continue
|
|
raw=next(p for t,p,z in ca if t=='MCLQ')
|
|
for layer in range(n):
|
|
block=raw[layer*804:(layer+1)*804];typ,fmt,lo,hi,ox,oy,w,h,exists,vertex=struct.unpack_from('<HHff4BII',liquid,off+layer*24)
|
|
assert (typ,fmt,ox,oy,w,h)==(7,1,0,0,8,8)
|
|
assert liquid[off+layer*24+4:off+layer*24+12]==block[:8]
|
|
wet=[(i,f) for i,f in enumerate(block[656:720]) if f&15!=15];assert all(f&0x3f==6 for _,f in wet)
|
|
assert struct.unpack_from('<Q',liquid,exists)[0]==sum(1<<i for i,f in wet)
|
|
assert struct.unpack_from('<QQ',liquid,attrs)==tuple(sum(1<<i for i,f in wet if f&mask) for mask in (0x40,0x80))
|
|
assert liquid[vertex:vertex+324]==b''.join(block[12+v*8:16+v*8] for v in range(81))
|
|
assert liquid[vertex+324:vertex+648]==b''.join(block[8+v*8:12+v*8] for v in range(81))
|
|
assert vertex+648<=len(liquid);instances+=1;vertices+=81
|
|
return instances,vertices
|
|
sample=None
|
|
for row in rows:
|
|
if row['source_reference'] in done:continue
|
|
# Strict flow guard remains authoritative: do not reread/reconvert known held inputs.
|
|
if any(b['flow_count'] or b['flow_tail_nonzero'] for b in row['blocks']):
|
|
item=dict(source_reference=row['source_reference'],reason='Frozen count/tail predicate: nonzero flow or unproved trailing flow bytes');held.append(item)
|
|
with H.open('a') as f:f.write(json.dumps(item)+'\n')
|
|
continue
|
|
old=Path(row['input_ROOT']).read_bytes();authority=any(t=='MH2O' for t,p,z in _adt_split_records(old))
|
|
try:new,audit=adt_root_magma_candidate(old,source_legacy_authoritative=authority)
|
|
except ValueError as e:
|
|
item=dict(source_reference=row['source_reference'],reason=str(e));held.append(item)
|
|
with H.open('a') as f:f.write(json.dumps(item)+'\n')
|
|
continue
|
|
count,vertices=verify(old,new);assert count==audit['Magma_instances'];p=OUT/(Path(row['source_reference']).stem+'.root.adt');p.write_bytes(new);p.chmod(0o600)
|
|
item=dict(source_reference=row['source_reference'],input_ROOT=row['input_ROOT'],output_ROOT=str(p),bytes=len(new),sha256=hashlib.sha256(new).hexdigest(),instances=count,vertices=vertices,audit=audit);passed.append(item)
|
|
with P.open('a') as f:f.write(json.dumps(item,separators=(',',':'))+'\n')
|
|
if sample is None:sample=(old,authority)
|
|
assert len(passed)==3 and len(held)==3,(len(passed),held)
|
|
assert sample is not None
|
|
old,authority=sample;top=_adt_split_records(old);ci=next(i for i,(t,p,z) in enumerate(top) if t=='MCNK' and struct.unpack_from('<I',p)[0]&0x3c);cell=top[ci][1];children=_adt_split_records(cell[128:]);mi=next(i for i,(t,p,z) in enumerate(children) if t=='MCLQ');raw=children[mi][1];wet=next(i for i,f in enumerate(raw[656:720]) if f&15!=15)
|
|
refusals=[]
|
|
def refuse(label,offset,value):
|
|
block=bytearray(raw);block[offset:offset+len(value)]=value;cc=list(children);cc[mi]=('MCLQ',bytes(block),b'');rr=list(top);rr[ci]=('MCNK',cell[:128]+enc(cc),b'')
|
|
try:adt_root_magma_candidate(enc(rr),source_legacy_authoritative=authority)
|
|
except ValueError:refusals.append(label)
|
|
else:raise AssertionError(label)
|
|
for label,off,value in [('count1',720,struct.pack('<I',1)),('tail_nonzero',724,b'\1'),('raw_nibble2',656+wet,b'\x42'),('unknown_flag',656+wet,b'\x56'),('NaN_height',12,struct.pack('<f',float('nan'))),('inverted_bounds',0,struct.pack('<ff',10,-10))]:refuse(label,off,value)
|
|
try:adt_root_still_river_candidate(old,source_legacy_authoritative=authority)
|
|
except ValueError:refusals.append('default_water_profile_stays_strict')
|
|
else:raise AssertionError('default magma admission')
|
|
report=dict(status='PASS_NEW_EXACT_NIBBLE6_NATIVE_MAGMA_HEIGHT_UV_CONSTRUCTOR_AND_STRICT_THREE_TILE_BATCH',input_denominator=6,accepted_tiles=3,held_tiles=3,instances=sum(r['instances'] for r in passed),height_and_UV_vertices=sum(r['vertices'] for r in passed),refusals=refusals,nonliquid_geometry_and_children_byteexact=True,height_bounds_u16_UV_wet_fishable_deep_exact=True,Source_flow_tail_guard_unchanged=True,native_profile_LiquidType=7,native_profile_LiquidMaterial=2,native_profile_LVF=1,native_shading_and_flow_equivalence_verified=False,SDK_reads=0,native_actions=0,runtime_acceptance=False)
|
|
result.write_text(json.dumps(report,indent=2)+'\n');result.chmod(0o600)
|
|
(J/'magma-strict-three-component.private.json').write_text(json.dumps(dict(status=report['status'],owner_result=str(result),rows=passed,held=held),indent=2)+'\n')
|
|
print(report['status']);print('3 tiles,',report['instances'],'lava instances; 3 flow-tail holds; no runtime actions.')
|