"""Static checks are deliberately distinct from sandbox reference validation.""" from collections import Counter,defaultdict import hashlib import json from pathlib import Path import re from generators.build import ALLOCATION from generators.specs import oracle,probes def load(path): rows=[json.loads(x) for x in Path(path).read_text().splitlines() if x.strip()] if len({r['id'] for r in rows})!=len(rows):raise ValueError('Duplicate IDs: '+str(path)) return rows def check(root): rows=load(root/'data/smolscript.jsonl');hidden=load(root/'private_tests/hidden.jsonl');refs=load(root/'references/solutions.jsonl') assert len(rows)==350,'Expected exactly 350 examples' assert Counter(r['language'] for r in rows)=={k:sum(v) for k,v in ALLOCATION.items()},'Language allocation' assert Counter(r['difficulty'] for r in rows)=={'easy':210,'medium':105,'moderate':35},'Difficulty allocation' assert {r['id'] for r in rows}=={r['id'] for r in hidden}=={r['id'] for r in refs},'Private/public ID mismatch' assert len({r['prompt'] for r in rows})==350,'Duplicate prompts' hm={r['id']:r for r in hidden};rm={r['id']:r for r in refs} hidden_behavior={};seen={};behavior={};categories=Counter();lengths=[];solutions=[];similarity=[] by_language=defaultdict(list) for r in rows: rid=r['id'];spec=hm[rid]['spec'];kind=spec['kind'];categories[r['category']]+=1 assert r['reference_solution'] is None,'Public reference leakage' assert 1<=r['timeout_seconds']<=10 assert r['difficulty'] in ('easy','medium','moderate') assert r['output_format'] and r['prompt'] assert hm[rid]['tests'],'Missing hidden tests' assert rm[rid]['reference_solution'].strip(),'Missing reference' assert rm[rid]['reference_solution'] not in r['prompt'],'Reference in prompt' lengths.append(len(r['prompt'].split()));solutions.append(len(rm[rid]['reference_solution'].splitlines())) semantic=(r['language'],r['metadata']['semantic_id']) assert semantic not in seen,('Duplicate semantic spec',rid,seen.get(semantic)) seen[semantic]=rid # Input/output fingerprints catch algebraic identities in this bounded DSL. if kind in ('scalar','string','array'): fingerprint=(r['language'],kind,tuple(oracle(spec,x) for x in probes(kind))) assert fingerprint not in behavior,('Equivalent behavior',rid,behavior.get(fingerprint)) behavior[fingerprint]=rid suite_key=(r['language'],kind,tuple(t['expected'] for t in hm[rid]['tests'])) assert suite_key not in hidden_behavior,('Hidden-suite behavior collision',rid) hidden_behavior[suite_key]=rid for t in hm[rid]['tests']+r['tests']: assert oracle(spec,t['input'])==t['expected'],('Oracle mismatch',rid) normalized=re.sub(r'\d+','N',r['prompt'].lower()) words=normalized.split();grams={tuple(words[i:i+3]) for i in range(len(words)-2)} for other,othergrams in by_language[r['language']]: ratio=len(grams&othergrams)/max(1,len(grams|othergrams)) if ratio>=0.85:similarity.append({'a':other,'b':rid,'trigram_jaccard':round(ratio,4)}) by_language[r['language']].append((rid,grams)) # Near-text pairs are disclosed for review; no identical behavioral or semantic # specifications are accepted. Translations across languages are intentional. import pyarrow.parquet as pq parquet=pq.read_table(root/'data/smolscript.parquet').to_pylist() decoded=[{**r,'tests':json.loads(r['tests']),'metadata':json.loads(r['metadata'])} for r in parquet] assert decoded==rows,'JSONL/Parquet mismatch' manifest=json.loads((root/'manifest.json').read_text()) from generation_settings import PROTOCOL assert manifest['evaluation_protocol']==PROTOCOL,'Evaluation protocol mismatch' for name,digest in manifest['files'].items():assert hashlib.sha256((root/name).read_bytes()).hexdigest()==digest,('Hash mismatch',name) return {'static_validation':'passed','examples':len(rows),'languages':dict(Counter(r['language'] for r in rows)), 'difficulty':dict(Counter(r['difficulty'] for r in rows)),'categories':dict(categories), 'prompt_words':{'min':min(lengths),'max':max(lengths),'over_50':sum(n>50 for n in lengths)}, 'solution_lines':{'min':min(solutions),'max':max(solutions)},'exact_duplicates':0,'semantic_duplicates_within_language':0, 'near_text_pairs':similarity,'semantic_check_scope':'finite deterministic probes plus exact DSL/DOM/CSS spec equality; not a general equivalence proof', 'cross_language_policy':'Aligned original tasks intentionally recur across languages for comparable coverage.'}