"""Job #2807 (pursue route 57). Is route 57's many-to-one edge still needed? Measure, on the SERVED registry (docs snapshot main) against the public mirror's registry (github.com/solveathome/twin-primes 2c61769, 2026-09-16): section-2 rows, statuses, pointer edges into history/staging/, distinct and shared targets (return #1416's measure1670.py, imported unchanged), the OPEN rows that left OPEN with their served status and records cell, every status transition, and whether the served generator carries any cross-id key (scored_in / answered_by / scores). Usage: python3 check2807.py SERVED_QUESTIONS.md MIRROR_QUESTIONS.md SERVED_questions.js [MIRROR_questions.js] Deterministic: reads the given files only; stdout is the record.""" import hashlib, importlib.util, json, os, re, sys here = os.path.dirname(os.path.abspath(__file__)) spec = importlib.util.spec_from_file_location('measure1670', os.path.join(here, 'measure1670.py')) m = importlib.util.module_from_spec(spec); spec.loader.exec_module(m) def sha(p): return hashlib.sha256(open(p, 'rb').read()).hexdigest() served, mirror, gen = sys.argv[1], sys.argv[2], sys.argv[3] mgen = sys.argv[4] if len(sys.argv) > 4 else None a, b = m.measure(served), m.measure(mirror) def summ(x): return {'bytes': x['bytes'], 'rows': x['rows'], 'ids': x['ids'], 'OPEN': x['status_counts'].get('OPEN', 0), 'ANSWERED': x['status_counts'].get('ANSWERED', 0), 'edges': x['edges'], 'distinct_targets': x['distinct_targets'], 'shared_targets': x['shared_targets']} out = {'instrument': 'check2807.py', 'job': 2807, 'inputs': {'served_questions_sha256': sha(served), 'mirror_questions_sha256': sha(mirror), 'served_generator_sha256': sha(gen)}, 'served': summ(a), 'mirror': summ(b)} left = sorted(set(b['open_rows']) - set(a['open_rows'])); new = sorted(set(a['open_rows']) - set(b['open_rows'])) out['left_open'] = {i: {'served_status': a['_rows'][i]['status'], 'served_records': re.findall(r'\]\(([^)]+)\)', a['_rows'][i]['cells'][-1]), 'mirror_records': re.findall(r'\]\(([^)]+)\)', b['_rows'][i]['cells'][-1]), 'served_verdict_names_other_record': sorted(set(re.findall(r'([A-Za-z0-9._-]+\.md)', a['_rows'][i]['cells'][3])) - {os.path.basename(r) for r in re.findall(r'\]\(([^)]+)\)', a['_rows'][i]['cells'][-1])})} for i in left} out['new_open'] = new out['status_counts'] = {'served': dict(sorted(a['status_counts'].items())), 'mirror': dict(sorted(b['status_counts'].items()))} ch = {} for i in sorted(set(a['_rows']) & set(b['_rows'])): if a['_rows'][i]['status'] != b['_rows'][i]['status']: ch.setdefault(b['_rows'][i]['status'] + ' -> ' + a['_rows'][i]['status'], []).append(i) out['status_transitions'] = dict(sorted(ch.items())) out['served_open_rows'] = sorted(a['open_rows']) keys = ['scored_in', 'answered_by', 'scores:', 'superseded_by'] out['generator_cross_id_keys'] = {'served': {k: open(gen, encoding='utf-8').read().count(k) for k in keys}} if mgen: out['generator_cross_id_keys']['mirror'] = {k: open(mgen, encoding='utf-8').read().count(k) for k in keys} out['served_generator_bytes'] = os.path.getsize(gen) if mgen: out['mirror_generator_bytes'] = os.path.getsize(mgen) print(json.dumps(out, indent=1, ensure_ascii=False))