Files
linuxcncWebWASM/scripts/generate_glb_machine_acceptance.py

60 lines
3.1 KiB
Python

"""Collect the already executed GLB subproject checks without rerunning them."""
import hashlib
import json
from pathlib import Path
ROOT = Path(__file__).resolve().parents[1]
OUTPUT = ROOT / 'coverage/glb-machine'
def sha(path):
return hashlib.sha256(path.read_bytes()).hexdigest()
reports = [
'browser.report.json', 'motion.report.json', 'gltf-validation.report.json',
'reproducibility.report.json', 'regression-parametric/browser.report.json',
'regression-jog/rtcp-jog-browser.report.json',
]
results = []
for name in reports:
path = OUTPUT / name
data = json.loads(path.read_text())
assert data['status'] == 'verified', f'{name}: {data["status"]}'
results.append({'report_id': data['report_id'], 'path': str(path.relative_to(ROOT)), 'sha256': sha(path)})
browser = json.loads((OUTPUT / 'browser.report.json').read_text())
motion = json.loads((OUTPUT / 'motion.report.json').read_text())
manifest_path = ROOT / 'web/react/public/machines/manifest.json'
manifest = json.loads(manifest_path.read_text())
for entry in manifest['machines']:
assert sha(manifest_path.parent / entry['filename']) == entry['sha256']
assert 'built in' in (OUTPUT / 'build.log').read_text()
assert not browser['browser_errors']
assert len(browser['machines']) == len(motion['machines']) == 2
report = {
'report_id': 'glb-machine-acceptance-v1', 'status': 'verified',
'tasks': [f'GLB-{i:02}' for i in range(1, 7)],
'wasm_sha256': sha(ROOT / 'build-wasm/linuxcnc-sim-core.wasm'),
'reports': results,
'models': manifest['machines'],
'rejected_inputs': sum(len(p['rejected']) for p in browser['parser']),
'static_pose_and_tool_length_samples': sum(len(m['geometry']) for m in browser['machines']),
'imported_rotary_jogs': sum(len(m['jogs']) for m in browser['machines']),
'simultaneous_five_axis_intervals': sum(m['simultaneous_ticks'] for m in motion['machines']),
'executed_program_projection_samples': sum(m['samples'] for m in motion['machines']),
'max_program_projection_error_view_units': max(m['max_error_view_units'] for m in motion['machines']),
'boundaries': [
'Only the versioned orthogonal XYZ-head / AC-or-BC table TRT profile is supported',
'Runtime INI supplies homing, acceleration, periods and validated travel/speed settings',
'Imported GLB assets are kept in page memory; reload requires importing again',
'Original illustrative assets; no manufacturer calibration, collision or generic URDF solver claim',
'No native/WASM source modification; no whole-repository or release parity claim',
],
'evidence': [
{'path': str(p.relative_to(ROOT)), 'sha256': sha(p)}
for p in sorted(OUTPUT.rglob('*'))
if p.is_file() and p.name != 'acceptance.report.json'
],
}
assert report['wasm_sha256'] == browser['wasm_sha256']
(OUTPUT / 'acceptance.report.json').write_text(json.dumps(report, indent=2, ensure_ascii=False) + '\n')
print(json.dumps({k: report[k] for k in ['report_id', 'status', 'rejected_inputs', 'static_pose_and_tool_length_samples', 'imported_rotary_jogs', 'simultaneous_five_axis_intervals', 'executed_program_projection_samples']}, ensure_ascii=False))