"""Hash-check existing embedded source blocks; compare the published shared table, no reexecution.""" import hashlib,json,math,pathlib,re P=pathlib.Path(__file__).parent old=json.loads((P/'return-161.json').read_text());text=old['report_md'];recovered={};manifest=[] for index,m in enumerate(re.finditer(r'^```([^\n]*)\n(.*?)^```[ \t]*$',text,re.M|re.S)): body=m[2];sha=hashlib.sha256(body.encode('utf-8')).hexdigest() for name,want in old['hashes'].items(): if sha==want: assert name not in recovered;recovered[name]=body manifest.append({'name':name,'sha256':sha,'bytes':len(body.encode('utf-8')),'fenced_block_zero_based':index,'exact_bytes_no_transformation':True}) assert len(recovered)==8 and 'out-L-ext.txt' in recovered table=recovered['out-L-ext.txt'];part=table[table.index('[T] L(T_x, p)'):table.index('[D] THE DIAGONAL')] levels=[5,7,11,13,17,19,23,29];cells={};ps=[] for line in part.split('\n'): parts=line.split() if len(parts)!=9 or not parts[0].isdigit():continue prime=int(parts[0]);ps.append(prime) for level,value in zip(levels,parts[1:]): if value!='-':cells[level,prime]=int(value) prime_list=[q for q in range(7,1010) if all(q%d for d in range(2,math.isqrt(q)+1))] assert ps==prime_list and len(ps)==166 assert set(cells)=={(x,q) for x in levels for q in prime_list if q>=x} assert len(cells)==1307 bank=json.loads((P/'L-grid-622.json').read_text());differences=[] for row in bank['rows']: original=cells[row['level'],row['p']] if original!=row['L']:differences.append({'level':row['level'],'p':row['p'],'return161':original,'return622':row['L']}) assert len(bank['rows'])==280 and not differences out={'source':'https://solveathome.org/projects/twin-primes/return/161','recovered_blocks':manifest,'unrecovered_hash_names':sorted(set(old['hashes'])-set(recovered)),'old_domain':{'levels':levels,'primes_from':7,'primes_to':1009,'prime_rows':166,'condition':'p >= tile level','numeric_cells':1307,'note':'The table includes seven p=level cells. These are outside622s strict p>level domain.'},'comparison':{'shared_cells':280,'matches':280,'differences':differences},'scope':'Extraction and data comparison only. Eight embedded blocks match their advertised hashes exactly despite blob URLs404. Full1307-cell arithmetic was not rerun.'} (P/'embedded-recovery.json').write_text(json.dumps(out,indent=2));print(json.dumps(out))