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

29 lines
2.3 KiB
Python

"""Whole source snapshot, exact link identities; update timing fields only."""
from pathlib import Path
import json,hashlib,sys,struct
sys.path.insert(0,'ops')
from item_effect_compat import compose_matching_link_timings,TABLES,DBD,NATIVE
from item_batch_stage import source_hash
from item_sparse_compat import fields,check_db2
from turtle_data import inventory_item_snapshot
W=Path(__file__).resolve().parent;C=Path('runtime/catalog-items-20261018');pins={}
def read(p):
p=Path(p);raw=p.read_bytes();pins[str(p)]=hashlib.sha256(raw).hexdigest();return json.loads(raw)
package=read('docs/evidence/data/item-sparse-compat/package.json')
source={r['identity'][1]:r['raw_fields']for r in inventory_item_snapshot('runtime/all-item-templates-20261017')['records']}
source.update({p['entry']:p for p in read(W/'source-owned-items.json')})
items=[dict(entry=p['entry'],source=p,source_record_sha256=source_hash(p))for p in source.values()]
schemas={t:fields(DBD/(t+'.dbd'),layout,n)for t,(_,layout,n)in TABLES.items()};maxima={}
registry=read(C/'catalogue-effect-row-registry-v3.json')['slots']
for t,(table,layout,n)in TABLES.items():
check_db2(NATIVE/(t+'.db2'),table,layout)
with(NATIVE/(t+'.db2')).open('rb')as f:maximum=struct.unpack_from('<I',f.read(168),164)[0]
maxima[t]=max([maximum]+[r['effect'if t=='ItemEffect'else'link']for r in registry.values()])
r=compose_matching_link_timings(package,items,read(C/'ItemEffect.json'),read(C/'ItemXItemEffect.json'),schemas,maxima)
result=r.pop('package');r.update(kind='all-source-matching-item-link-timing-stage',source_items=len(items),total_rows=len(result['rows']),inputs=pins,reserved_allocation_floors=maxima,source_owned_selected=sorted(set(r['selected'])&{p['entry']for p in read(W/'source-owned-items.json')}),source_item_effect_definitions_changed=False)
for name,value in [('all-matching-timings-package.json',result),('all-matching-timings-report.json',r)]:
path=W/name;assert not path.exists();path.write_text(json.dumps(value,sort_keys=True,separators=(',',':'))+'\n')
from collections import Counter
print(dict(selected=len(r['selected']),preserved=len(r['preserved']),blocked=len(r['blocked']),slots=len(r['changed_slots']),added_rows=len(r['added']),rows=len(result['rows']),owned_selected=r['source_owned_selected']))
print(Counter(b['reason']for b in r['blocked']))