# Checks this dataset: 100 counted trial folders, every trial.json with all of Scale's keys, the pass counts (Haiku # 38/50, Sonnet 46/50), trials.parquet with Scale's 50 columns in Scale's order and Arrow types (concat_tables with # Scale's table), nulls for the foreground's A22 and sentinel_ok, harness_errors as attempts.json, the CDB-G04 system # prompts, the manifests' sha256, and no secrets. # uv run --with pandas --with pyarrow python validate.py import glob, hashlib, json, pathlib, re, sys import pandas as pd HERE = pathlib.Path(__file__).resolve().parent RUNS = {'kubi-haiku-5-5-2026-11-23': 38, 'kubi-sonnet-5-5-2026-11-23': 46} TASKS = ['mb-09', 'mb-10', 'mb-11', 'ir-01', 'ir-02', 'ir-03', 'ir-04', 'cdb-g02', 'cdb-g03', 'cdb-g04'] TRIAL_KEYS = ['trial_id', 'task', 'task_file', 'probe', 'condition', 'run_index', 'seed', 'prompt', 'system_prompt', 'max_turns', 'timeout_s', 'os', 'driver', 'computer', 'settings', 'app', 'model', 'harness', 'harness_version', 'framework_version', 'bench_commit', 'trycua_commit', 'started_at', 'ended_at', 'status', 'steps', 'agent_error', 'cost_usd', 'cost_from_calls', 'cost_usd_reported', 'tokens', 'num_turns', 'duration_s', 'model_calls', 'tool_calls', 'tool_errors', 'reward', 'passed', 'grade', 'gui_only_trajectory'] COLUMNS = ['trial_id', 'run', 'os', 'driver', 'driver_version', 'task', 'probe', 'title', 'condition', 'model', 'harness', 'harness_version', 'effort', 'reward', 'passed', 'on_board', 'run_index', 'seed', 'task_file', 'task_passed', 'task_score', 'task_checks', 'gui_only', 'gui_only_violations', 'user_undisturbed', 'a22_key_focus', 'a22_window_raised', 'a22_typing', 'a22_pointer', 'a22_clipboard', 'a22_space', 'a22_dialog', 'a22_activation', 'sentinel_ok', 'agent_error', 'cost_usd', 'cost_usd_reported', 'model_calls', 'num_turns', 'tool_calls', 'tool_errors', 'duration_s', 'agent_window_s', 'harness_errors', 'started_at', 'recording', 'trajectory', 'timeline', 'sentinel_log', 'workspace'] SECRETS = re.compile(r'kubi_[A-Za-z0-9]{20,}|sk-or-v1-[0-9a-f]{64}|sk-ant-[A-Za-z0-9_-]+|Bearer [A-Za-z0-9._~+/=-]{16,}' r'|openrouter\.ai/workspaces/[^/\s"]+/keys/[0-9a-f]{16,}') problems = [] def check(ok, msg): if not ok: problems.append(msg) for run, want in RUNS.items(): want_ids = {f'{t}-r{i}-foreground' for t in TASKS for i in range(1, 6)} have = {p.name for p in (HERE / 'runs/linux' / run).iterdir() if p.is_dir()} check(have == want_ids, f'{run}: trial folders {len(have)}, missing {sorted(want_ids - have)[:5]}, extra {sorted(have - want_ids)[:5]}') passed = 0 for tid in sorted(have): d = HERE / 'runs/linux' / run / tid t = json.load(open(d / 'trial.json')) miss = [k for k in TRIAL_KEYS if k not in t] check(not miss, f'{run}/{tid}: trial.json lacks {miss}') check(t['trial_id'] == tid, f'{run}/{tid}: trial_id {t["trial_id"]}') passed += bool(t['passed']) for f in ('grade.json', 'trajectory.json', 'attempts.json', 'manifest.json', 'timeline.json', 'server_log.jsonl', 'agent_view.mp4'): check((d / f).is_file(), f'{run}/{tid}: no {f}') tl = json.load(open(d / 'timeline.json')) for c in tl['calls']: # a call with no server record must be one the MCP refused, or one that needs no screen check(c['kubi_server'] is not None or c['error'] or c['tool'] in ('list_screens', 'guide', 'status', 'viewer_link'), f'{run}/{tid}: call {c["i"]} ({c["tool"]}) has no server record and no error') m = json.load(open(d / 'manifest.json')) for f in m['files']: check(hashlib.sha256((d / f['path']).read_bytes()).hexdigest() == f['sha256'], f'{run}/{tid}: sha256 of {f["path"]}') check(passed == want, f'{run}: {passed} passed, want {want}') print(f'{run}: {len(have)} trials, {passed}/{len(have)} passed') df = pd.read_parquet(HERE / 'results/trials.parquet') check(list(df.columns) == COLUMNS, f'trials.parquet columns differ: {set(df.columns) ^ set(COLUMNS)}') scale = HERE.parent / 'scale/trials.parquet' if scale.exists(): check(list(pd.read_parquet(scale).columns) == list(df.columns), "trials.parquet columns are not Scale's") check(len(df) == 100 and df.on_board.all(), f'trials.parquet: {len(df)} rows') for run, want in RUNS.items(): k = int(df[df.run == run].passed.sum()) check(k == want, f'trials.parquet {run}: {k} passed') print(f'trials.parquet: {len(df)} rows, {len(df.columns)} columns', "(Scale's columns, Scale's order)" if list(df.columns) == COLUMNS else '') # Arrow types: Scale's, field for field, so the two tables concatenate as they are import pyarrow as pa, pyarrow.parquet as pq ours = pq.read_table(HERE / 'results/trials.parquet') if scale.exists(): st = pq.read_table(scale) diff = [(f.name, str(f.type), str(ours.schema.field(f.name).type)) for f in st.schema if ours.schema.field(f.name).type != f.type] check(not diff, f'trials.parquet Arrow types differ from Scale\'s: {diff}') try: both = pa.concat_tables([st.replace_schema_metadata(None), ours.replace_schema_metadata(None)]) check(both.num_rows == st.num_rows + ours.num_rows, 'concat_tables row count') print(f'concat_tables with Scale\'s trials.parquet: {st.num_rows} + {ours.num_rows} = {both.num_rows} rows') except Exception as e: check(False, f'pyarrow.concat_tables with Scale\'s table failed: {e}') nulltyped = [f.name for f in ours.schema if pa.types.is_null(f.type)] check(not nulltyped, f'null-typed columns: {nulltyped}') # nulls where the foreground has no value; harness_errors as attempts.json records for c in ['sentinel_ok', 'user_undisturbed'] + [c for c in COLUMNS if c.startswith('a22_')]: check(df[c].isna().all(), f'trials.parquet {c} is not all null') he = {(r.run, r.trial_id): r.harness_errors for r in df.itertuples()} for (run, tid), n in he.items(): a = json.load(open(HERE / 'runs/linux' / run / tid / 'attempts.json'))['harness_errors'] check(n == sum(a.values()), f'{run}/{tid}: harness_errors {n}, attempts.json {a}') print('harness_errors > 0:', {k: v for k, v in he.items() if v}) # CDB-G04: system_prompt is the generic one we sent, with a note on Scale's browser variant g04 = 0 for f in sorted(HERE.glob('runs/linux/*/cdb-g04-*/trial.json')) + sorted(HERE.glob('excluded/*/cdb-g04-*/trial.json')): t = json.load(open(f)) check('Do not use the network.' in t['system_prompt'] and 'internet' not in t['system_prompt'], f'{f}: system_prompt') check('system_prompt_note' in t.get('kubi', {}), f'{f}: no kubi.system_prompt_note') g04 += 1 check(g04 == 15, f'{g04} CDB-G04 trial.json files, want 15 (10 counted, 5 excluded)') print(f'CDB-G04 system prompts: {g04} trial.json files, all the generic prompt with a note') hits = 0 for p in HERE.rglob('*'): if p.is_file() and p.suffix in ('.json', '.jsonl', '.md', '.csv', '.txt', '.html', '.py'): if p.name == 'validate.py' or p.name == 'build.py': continue hits += len(SECRETS.findall(p.read_text(errors='replace'))) elif p.is_file() and p.suffix == '.parquet': t = pd.read_parquet(p) for c in t.columns: if t[c].dtype == object or str(t[c].dtype).startswith('str'): hits += int(t[c].astype(str).str.count(SECRETS.pattern).sum()) check(hits == 0, f'{hits} secret-shaped strings') print(f'secret scan: {hits} hits') print('OK' if not problems else 'PROBLEMS:\n' + '\n'.join(problems)) sys.exit(1 if problems else 0)