"""Full acceptance of source continuity, geometry, paired bindings and formal gold.""" from __future__ import annotations import argparse,copy,math from collections import Counter from pathlib import Path import numpy as np import soundfile as sf from .common import * from .geometry import audit,range_queries from .loader import Dataset from .prompts import render from .export import frames from .score import safe_score,evaluate from .runtime import ensure_compute def acceptance(root,pilot=False): ensure_compute();root=root.resolve();config=read(root/'config.json');summary=read(root/'summary.json') assert not (root/'public/preview').exists() assert summary['binaural_previews']==0 groups=list(rows(root/'private/recipes.jsonl')) if pilot:groups=[g for g in groups if (root/'reports/groups'/(g['group_id']+'.json')).exists()] expected_scenes={s['scene_id']:(s,g) for g in groups for s in g['scenes']} planned_groups={g['group_id']:g for g in groups} assert len(groups)==(summary['paired_motion_groups'] if pilot else 500) assert len(expected_scenes)==(summary['physical_scenes'] if pilot else 2000) public={r['scene_id']:r for r in rows(root/'public/test/scenes.jsonl')};assert set(public)==set(expected_scenes) dataset=Dataset(root);bindings={};golds={r['sample_id']:r for r in rows(root/'private/test/gold.jsonl')} assert set(dataset.index)==set(golds) sources={};tasks=Counter();branches=Counter();audio_count=0;rir_count=0;max_gap=0.;max_step=0.;native_tail=0.;unique_crops=set();crop_groups={} for group_index,group in enumerate(groups,1): report=read(root/'reports/groups'/(group['group_id']+'.json'));assert report['passed'] assert not any(f['path'].startswith('public/preview/') for f in report['files']) for file in report['files']:assert sha(root/file['path'])==file['sha256'] for r in rows(root/report['rir_audit_path']): rir_count+=1;native_tail=max(native_tail,r['native_final_50ms_energy_fraction']);assert r['native_final_50ms_energy_fraction']<=1e-7 if r['los']: assert r['direct_angle_error_deg']<=3.;assert abs(r['direct_delay_s']-r['geometric_delay_s'])<=.003 shared=None for scene in group['scenes']: sid=scene['scene_id'];branches[scene['branch']]+=1 if not pilot: donor=scene['absent_keyword_provenance'];other=planned_groups[donor['group_id']] assert other['group_id']!=group['group_id'] assert other['scenes'][0]['keywords'][donor['target_id']]==scene['keywords']['no_match'] assert audit(scene,group['room'],full_visibility=True) is not None assert scene['duration_samples']==group['parent_static_duration_samples'] if config['duration_policy']=='static' else True # Matched branch groups use identical source events, initial body positions, poses and durations. signature=[(e['entity_id'],e['initial_xyz_m'],e.get('events')) for e in scene['humans']+scene['robots']+scene['playback_sources']] if shared is None:shared=signature else:assert signature==shared assert len(scene['moving_entity_ids'])==1 if scene['difficulty']=='easy' else len(scene['moving_entity_ids'])==len(scene['humans'])+len(scene['robots']) for human in scene['humans']: assert len(human['events'])==1 event=human['events'][0];path=root/event['audio_asset'];digest=event['original_source_sha256'] if digest not in sources: assert sha(path)==digest;sources[digest]=sf.read(path,dtype='float32')[0] full=sources[digest];a,b=event['crop_samples'];assert 0<=a=config['minimum_word_alignment_score'] for w in event['words']) cue=tokens(scene['keywords'][human['entity_id']]);assert tokens(event['text'])[:len(cue)]==cue assert sum(tokens(h['events'][0]['text'])[:len(cue)]==cue for h in scene['humans'])==1 unique_crops.add((digest,*event['original_word_indices'])) crop_groups.setdefault((digest,*event['original_word_indices']),set()).add(group['group_id']) for e in scene['humans']+scene['robots']: xyz=position(e,np.array(grid(scene))/SR);step=float(np.max(np.linalg.norm(np.diff(xyz,axis=0),axis=1)));max_step=max(max_step,step);assert step<=.161 for robot in scene['robots']: rec=next(r for r in report['recordings'] if r['scene_id']==sid and r['receiver_robot_id']==robot['entity_id']) assert not any(k.startswith('preview_') for k in rec) wave,rate=sf.read(root/rec['path'],dtype='float32') assert rate==SR and wave.shape==(scene['duration_samples'],4) assert np.isfinite(wave).all() and 0