# Question: are OPEN/PARTIAL registry rows 7-21 current against served ledgers? # This refreshes generated table cells from their owning ledgers. It does not # adjudicate imported mathematics or promote the underlying twin-prime target. import argparse, difflib, hashlib, json, pathlib, re parser=argparse.ArgumentParser() parser.add_argument('--registry',required=True) parser.add_argument('--sources',required=True) parser.add_argument('--questions-api',required=True) parser.add_argument('--output',required=True) parser.add_argument('--patch',required=True) parser.add_argument('--manifest',required=True) args=parser.parse_args() original=pathlib.Path(args.registry).read_text() sections=original.split('## 2.')[0] rows=[] def cells(line): return [s.strip() for s in re.split(r'(?',text,re.S) block=next(block for block in blocks if re.search(r'^id:\s*'+re.escape(row['id'])+r'\s*$',block,re.M)) row['new_status']=re.search(r'^status:\s*(.*)$',block,re.M).group(1).strip() row['new_verdict']=re.search(r'^verdict:\s*(.*)$',block,re.M).group(1).strip() row['source_sha256']=hashlib.sha256(text.encode()).hexdigest() row['changed']=row['status']!=row['new_status'] or row['verdict']!=row['new_verdict'] lookup={row['id']:row for row in selected} new_lines=[] replacement_counts={identifier:0 for identifier in lookup} for line in original.splitlines(keepends=True): identifier=re.search(r'`(Q-[^`]+)`',line) if not line.startswith('|') or not identifier or identifier.group(1) not in lookup: new_lines.append(line);continue row=lookup[identifier.group(1)] if not row['changed']:new_lines.append(line);continue columns=cells(line) assert len(columns) in [5,6] # Both index layouts carry the same ledger verdict. Escape literal bars # before constructing Markdown; the API parser issue is a separate bug. verdict=row['new_verdict'].replace('|','\\|') status_index,verdict_index=(2,3) if len(columns)==5 else (1,3) columns[status_index]=row['new_status'];columns[verdict_index]=verdict new_lines.append('| '+' | '.join(columns)+' |'+('\n' if line.endswith('\n') else '')) replacement_counts[row['id']]+=1 updated=''.join(new_lines) for row in selected: assert replacement_counts[row['id']]==(2 if row['changed'] else 0) pathlib.Path(args.output).write_text(updated) patch=''.join(difflib.unified_diff(original.splitlines(True),updated.splitlines(True),fromfile='a/research/QUESTIONS.md',tofile='b/research/QUESTIONS.md',n=1)) pathlib.Path(args.patch).write_text(patch) manifest={'job_id':665,'window':[7,21],'open_partial_total_api':len(ordered),'scope':'served-ledger synchronization, not proof review','base_sha256':hashlib.sha256(original.encode()).hexdigest(),'updated_sha256':hashlib.sha256(updated.encode()).hexdigest(),'rows':selected,'replacements':replacement_counts} pathlib.Path(args.manifest).write_text(json.dumps(manifest,indent=2,sort_keys=True)+'\n') print(json.dumps({'rows_checked':len(selected),'rows_changed':[row['id'] for row in selected if row['changed']],'table_lines_changed':sum(replacement_counts.values()),'base_sha256':manifest['base_sha256'],'updated_sha256':manifest['updated_sha256']},sort_keys=True))