"""Diagnostic scope validation; never starts Kit or robot optimization.""" import copy import json from pathlib import Path import pytest from SkillFactory.legs.contact_cycle.training import load_training_config, make_manifest, require_authorization ROOT = Path(__file__).resolve().parents[1] CONFIG = ROOT/'configs/contact_cycle/training_diagnostic_v1.json' def test_diagnostic_scope_gates_and_algorithm_are_not_relaxed(): pilot = load_training_config(CONFIG, ROOT) full = load_training_config(ROOT/'configs/contact_cycle/training_v1.json', ROOT) proposal = json.loads((ROOT/pilot['proposal']).read_text()) original = json.loads((ROOT/full['proposal']).read_text()) assert proposal['gates'] == original['gates'] assert pilot['algorithm'] == full['algorithm'] assert pilot['task_config'] == full['task_config'] assert pilot['seeds'] == [91101] assert pilot['max_total_transitions'] == 512*128*32 == 2097152 assert pilot['max_total_wall_s'] == 1800 assert pilot['max_artifact_bytes'] == 1024**3 manifest = make_manifest(ROOT, CONFIG) assert 'diagnostic candidate' in manifest['selection'] assert manifest['accepted_skill'] is False with pytest.raises(PermissionError): require_authorization(None, manifest) @pytest.mark.parametrize('key,value', [ ('seeds', [91101, 91102, 91103]), ('seeds', [95101]), ('updates_per_seed', 1024), ('num_envs', 256), ('horizon', 64), ('max_total_wall_s', 1801), ('max_artifact_bytes', 1073741825), ('max_total_transitions', 2097153), ('validation_interval', 128), ('validation_seed', 95101), ]) def test_pilot_rejects_scope_expansion_even_with_matching_proposal(tmp_path, key, value): cfg = copy.deepcopy(json.loads(CONFIG.read_text())) proposal = json.loads((ROOT/cfg['proposal']).read_text()) cfg[key] = value if key in proposal['proposed_training']: proposal['proposed_training'][key] = value proposal_path = tmp_path/'proposal.json' proposal_path.write_text(json.dumps(proposal)) cfg['proposal'] = str(proposal_path) path = tmp_path/'config.json' path.write_text(json.dumps(cfg)) with pytest.raises(ValueError): load_training_config(path, ROOT) def test_full_study_does_not_silently_become_a_pilot(tmp_path): cfg = json.loads(CONFIG.read_text()) cfg['format'] = 'skillfactory.contact-cycle-training.v1' path = tmp_path/'bad_full.json' path.write_text(json.dumps(cfg)) with pytest.raises(ValueError): load_training_config(path, ROOT)