9fe9d27865
Consolidate next-stage docs, archive superseded narratives, and preserve frozen document inputs. Retain invalid P2 pairs, partial RootXY training, failed attempts and nonselectable checkpoints as explicit limitations. Include supervised evaluation/training, desktop GPU admission, bounded evidence and atomic-publication monitor repairs with CPU regressions. Ignore local dotenv configuration. Validation: 1403 passed, 6 skipped for contact-cycle and related contracts/CLI tests. Full-suite legacy ABI and registration tests require Python 3.12/Torch 2.10/pxr; no runtime checks relaxed. No new physical run or accepted skill.
76 lines
3.8 KiB
Python
76 lines
3.8 KiB
Python
"""Fresh-interpreter worker bootstrap regression. No Kit, policy or physics."""
|
|
import subprocess
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
import pytest
|
|
|
|
ROOT = Path(__file__).resolve().parents[1]
|
|
|
|
|
|
@pytest.mark.parametrize('protocol_index,expected_rows', [(0, 2), (1, 20), (2, 20)])
|
|
@pytest.mark.parametrize('reproduce_legacy', [False, True])
|
|
def test_worker_bootstrap_has_no_private_protocol_alias(
|
|
tmp_path, protocol_index, expected_rows, reproduce_legacy):
|
|
# A separate interpreter matters: the larger runner test module intentionally
|
|
# imports CPU planning aliases during collection, hiding runtime pollution.
|
|
code = r'''
|
|
import importlib.util, json, sys
|
|
from pathlib import Path
|
|
root, output, index, count = Path(sys.argv[1]), Path(sys.argv[2]), int(sys.argv[3]), int(sys.argv[4])
|
|
spec = importlib.util.spec_from_file_location('bootstrap_runner', root / 'scripts/evaluate_cycle_sim_residual.py')
|
|
r = importlib.util.module_from_spec(spec)
|
|
sys.modules[spec.name] = r
|
|
spec.loader.exec_module(r)
|
|
b = r.cpu_module('evaluation_budget')
|
|
assert '_evaluation_cpu_evaluation_protocol' not in sys.modules
|
|
assert r.protocol_stage(r.PROTOCOLS[index]) == ('P1' if index == 0 else 'P2')
|
|
try:
|
|
r.protocol_stage('unregistered-protocol.json')
|
|
except ValueError:
|
|
pass
|
|
else:
|
|
raise AssertionError('unknown protocol admitted')
|
|
row = {'index': 0, 'status': 'reserved', 'reserved_physical_calls': 91000,
|
|
'rollout_cap': 90000, 'initialization_cap': 1000,
|
|
'started_boottime': b.boottime(), 'deadline_boottime': b.boottime() + 600,
|
|
'grant': {'boot_id': b.boot_id(), 'trial_indices': [0]}}
|
|
(output / 'launch-0').mkdir()
|
|
(output / 'manifest.json').write_text('{}')
|
|
(output / 'inventory.json').write_text('{}')
|
|
row['grant']['inventory_sha256'] = b.digest(output / 'inventory.json')
|
|
b.durable_write(output / 'budget.json', b.encode({'launches': [row]}))
|
|
payload = {'launch_identity': r.launch_identity(), 'reservation': row, 'arguments': {
|
|
'artifact_root': str(output), 'inventory': str(output / 'inventory.json'),
|
|
'manifest': str(output / 'manifest.json'),
|
|
'trusted_manifest_sha256': b.digest(output / 'manifest.json'), 'protocol': r.PROTOCOLS[index]}}
|
|
entered = []
|
|
def stop_before_kit(*args):
|
|
assert '_evaluation_cpu_evaluation_protocol' not in sys.modules, 'private planning alias leaked'
|
|
entered.append(True)
|
|
raise RuntimeError('CPU boundary reached without planning imports; no Kit authorized')
|
|
r.real_runtime = stop_before_kit
|
|
assert r.run_worker(payload) == 1
|
|
result = json.loads((output / 'launch-0/result.json').read_text())
|
|
assert entered == [True], result['failures']
|
|
assert len(result['rows']) == count
|
|
assert all(row['status'] == 'not_run' for row in result['rows'])
|
|
assert result['observed_counts'] is None and result['optimizer_steps'] == 0
|
|
assert not result['continuation_eligible'] and not result['accepted_skill']
|
|
assert result['failures'][0]['context']['message'].startswith('CPU boundary reached')
|
|
assert '_evaluation_cpu_evaluation_protocol' not in sys.modules
|
|
assert not any(name.startswith(('isaaclab', 'omni.')) for name in sys.modules)
|
|
'''
|
|
if reproduce_legacy:
|
|
# Reproduce the original defect only in the isolated CPU child. This
|
|
# proves the test detects it without rolling back production sources.
|
|
code = code.replace("row = {'index': 0", "r.protocol_stage = lambda p: r.cpu_module('evaluation_protocol').load_protocol(root / p).document['stage']\nrow = {'index': 0", 1)
|
|
completed = subprocess.run(
|
|
[sys.executable, '-c', code, str(ROOT), str(tmp_path), str(protocol_index), str(expected_rows)],
|
|
capture_output=True, text=True, timeout=30)
|
|
if reproduce_legacy:
|
|
assert completed.returncode != 0
|
|
assert 'private planning alias leaked' in completed.stderr
|
|
else:
|
|
assert completed.returncode == 0, completed.stdout + completed.stderr
|