Datasets:
Download verify_plans.py from dCoder30/RSIGame-plan-corpus: direct link, hf CLI and curl.
- Browser
- Download file 2.43 kB
-
https://huggingface.co/datasets/dCoder30/RSIGame-plan-corpus/resolve/main/verify_plans.py
- Command line
-
hf download hf://datasets/dCoder30/RSIGame-plan-corpus/verify_plans.py
-
curl -L -o verify_plans.py https://huggingface.co/datasets/dCoder30/RSIGame-plan-corpus/resolve/main/verify_plans.py
2.43 kB
| """Verify distilled plans against the real games. | |
| The failure mode that would silently poison the corpus is a plan naming files | |
| that do not exist -- a hallucinated `src/PlayerController.ts` in a Godot project | |
| trains the model to invent paths. So every backticked path in the plan is checked | |
| against the actual file tree, and the engine's file vocabulary is checked too. | |
| """ | |
| import json | |
| import re | |
| import sys | |
| from pathlib import Path | |
| ROOTS = [Path('/tmp/plan_src/basegen_unpublished'), Path('/tmp/plan_src/_basegames_new'), | |
| Path('/tmp/plan_src/gen953_opengame_0'), Path('/tmp/plan_src/gen953_opengame_1'), | |
| Path('/tmp/plan_src/gen953_opengame_2')] | |
| WRONG_VOCAB = { | |
| 'godot': re.compile(r'\.ts\b|package\.json|vite|Phaser', re.I), | |
| 'web': re.compile(r'\.gd\b|\.tscn\b|project\.godot', re.I), | |
| } | |
| path = sys.argv[1] if len(sys.argv) > 1 else '/tmp/plan_pilot.jsonl' | |
| rows = [json.loads(l) for l in open(path) if l.strip()] | |
| print(f'{len(rows)} rows in {path}\n') | |
| tot_paths = tot_missing = vocab_bad = 0 | |
| for r in rows: | |
| task, engine = r['task'], r['engine'] | |
| d = next((x / task for x in ROOTS if (x / task).is_dir()), None) | |
| plan = r['messages'][-1]['content'] | |
| refs = set(re.findall(r'`([^`]+)`', plan)) | |
| refs = {x for x in refs if '/' in x or '.' in x} | |
| missing = [] | |
| if d: | |
| have = {str(p.relative_to(d)) for p in d.rglob('*') if p.is_file()} | |
| for ref in refs: | |
| clean = ref.strip().lstrip('./') | |
| if clean not in have and not any(h.endswith('/' + clean) or h == clean for h in have): | |
| missing.append(ref) | |
| tot_paths += len(refs) | |
| tot_missing += len(missing) | |
| bad = WRONG_VOCAB[engine].findall(plan) | |
| if bad: | |
| vocab_bad += 1 | |
| flag = '' if not missing and not bad else ' <-- CHECK' | |
| print(f'{task:<36} {engine:<6} {len(plan):>5}ch paths={len(refs):<3} ' | |
| f'missing={len(missing):<3} wrong-vocab={len(bad)}{flag}') | |
| if missing[:4]: | |
| print(f' missing: {missing[:4]}') | |
| if bad[:4]: | |
| print(f' wrong vocab: {bad[:4]}') | |
| print() | |
| pct = 100 * tot_missing / max(1, tot_paths) | |
| print(f'paths referenced: {tot_paths} not found in the game: {tot_missing} ({pct:.1f}%)') | |
| print(f'rows using the wrong engine vocabulary: {vocab_bad}/{len(rows)}') | |
| print() | |
| if pct > 10 or vocab_bad: | |
| print('QUALITY GATE FAILED - fix the prompt before scaling up') | |
| sys.exit(1) | |
| print('QUALITY GATE PASSED') | |