"""Finalize audit/v49/out/bad_tasks.json by adding the 7 verified D5 tasks in graph_mining_method_selection/happy-llama and recording full-build D3/D4/D9_no_final tags consistently across all affected task IDs. Validates schema: every value has {'defects': [...], 'fixable': bool, 'fix': str}. """ import collections, glob, json import zstandard V = '/' OUT_V48 = V + 'build_v2/out_v49/' SAMPLE_SET = {x.strip() for x in open(V + 'build_v2/sample_v49/ids.txt') if x.strip()} bt = json.load(open(V + 'audit/v49/out/bad_tasks.json')) idx_by_tid = {r['task_id']: r for r in json.load(open(OUT_V48 + 'metadata/task_index.json'))} tt_map = {} for ln in open(V + 'audit/v2/out/runs_trace_truth.jsonl'): if ln.strip(): d = json.loads(ln) tt_map[(d['task'], d['model'])] = d works = {w['task']: w for w in ( json.loads(zstandard.ZstdDecompressor().decompress(open(p, 'rb').read(), max_output_size=1 << 31)) for p in sorted(glob.glob(OUT_V48 + 'work/*.json.zst')) )} gt_full_map = {t['task_id']: t['gt'] for w in works.values() for r in w['runs'] for t in r.get('tasks', [])} EXTRA_INFRA = ( 'Verifier GPU control failed', 'HarnessInfrastructureFailure', 'Verifier GPU endpoint returned HTTP', 'Trusted verification measurements are unavailable', 'Verifier setup exhausted its execution envelope', 'Owned platform provisioning could not complete', 'Verifier GPU sandbox run failed', ) # 1. Add the 7 verified D5 tasks in graph_mining_method_selection/happy-llama D5_VERIFIED = { 'graph-mining-method-selection--happy-llama--r029': [23, 26], 'graph-mining-method-selection--happy-llama--r043': [23, 26, 30, 31, 42, 44, 46], 'graph-mining-method-selection--happy-llama--r052': [23, 26, 30, 31, 42, 44, 46], 'graph-mining-method-selection--happy-llama--r053': [23, 26, 30, 31, 42, 44, 46], 'graph-mining-method-selection--happy-llama--r056': [23, 26, 30, 31, 42, 44, 46], 'graph-mining-method-selection--happy-llama--r059': [23, 26, 30, 31, 42, 44, 46], 'graph-mining-method-selection--happy-llama--r078': [61, 62, 63, 64, 65, 72, 73, 74, 75, 76, 77], } for tid, js in D5_VERIFIED.items(): msg = (f'in environment/context/submissions.json mark submission(s) {js} as seen (JSON-escaped \\"job\\":N ' f'completed output was already shown before the cut) and drop {js} from targets.json, instruction.md, ' f'tests/ground_truth.json, and solution/solve.sh; recompute baselines') if tid in bt: if 'D5' not in bt[tid]['defects']: bt[tid]['defects'].append('D5') if bt[tid]['fixable']: bt[tid]['fix'] += '; ' + msg else: bt[tid] = {'defects': ['D5'], 'fixable': True, 'fix': msg} # 2. Ensure sample tasks that also had D3/D4 train targets or missing final target in out_v48 shards carry those tags for out_v48 too for tid in sorted(SAMPLE_SET): r = idx_by_tid[tid] rk = (r['fcs_task'], r['model']) tt = tt_map[rk] gt_f = gt_full_map[tid] d3_t = [g['index'] for g in gt_f if g['kind'] == 'train' and tt['nodes'][g['index']]['d3_no_result']] d4_t = [g['index'] for g in gt_f if g['kind'] == 'train' and not tt['nodes'][g['index']]['d3_no_result'] and tt['nodes'][g['index']]['status'] != 'passed' and any(pat.lower() in (tt['nodes'][g['index']]['summary'] + ' ' + tt['nodes'][g['index']]['fail_reason']).lower() for pat in EXTRA_INFRA)] ta = next(x for x in tt['tasks'] if x['task_id'] == tid) extra_defs = [] extra_fixes = [] if d3_t: extra_defs.append('D3') extra_fixes.append(f'in out_v48 shard (already filtered in sample/): drop no-result train target(s) {d3_t}') if d4_t: extra_defs.append('D4') extra_fixes.append(f'in out_v48 shard (already filtered in sample/): drop infra-failed train target(s) {d4_t}') if not ta['has_final_node']: extra_defs.append('D9_no_final') extra_fixes.append(f'in out_v48 shard (already added in sample/): append final target index {tt["n_nodes"]} with official score {float(tt["formal_score"] or 0.0)}') if extra_defs: if tid not in bt: bt[tid] = {'defects': extra_defs, 'fixable': True, 'fix': '; '.join(extra_fixes)} else: for ed in extra_defs: if ed not in bt[tid]['defects']: bt[tid]['defects'].append(ed) if bt[tid]['fixable'] and extra_fixes: bt[tid]['fix'] += '; ' + '; '.join(extra_fixes) # Sort keys & validate schema bt_sorted = {} for tid in sorted(bt): e = bt[tid] assert isinstance(e['defects'], list) and len(e['defects']) >= 1 assert isinstance(e['fixable'], bool) assert isinstance(e['fix'], str) and len(e['fix']) >= 10 assert tid in idx_by_tid, f'Unknown task id {tid}' bt_sorted[tid] = e json.dump(bt_sorted, open(V + 'audit/v49/out/bad_tasks.json', 'w'), indent=1) c_full = collections.Counter(d for e in bt_sorted.values() for d in e['defects']) samp_entries = {t: e for t, e in bt_sorted.items() if t in SAMPLE_SET} c_samp = collections.Counter(d for e in samp_entries.values() for d in e['defects']) print('Saved bad_tasks.json! Total entries (full):', len(bt_sorted), 'fixable:', sum(1 for e in bt_sorted.values() if e['fixable']), 'unfixable:', sum(1 for e in bt_sorted.values() if not e['fixable'])) print('Sample entries:', len(samp_entries), 'fixable:', sum(1 for e in samp_entries.values() if e['fixable']), 'unfixable:', sum(1 for e in samp_entries.values() if not e['fixable'])) print('Full defect counts:', dict(sorted(c_full.items()))) print('Sample defect counts:', dict(sorted(c_samp.items())))