#!/usr/bin/env bash set -euo pipefail cd "$(dirname "$0")" # LinuxCNC source basis: this guard keeps the local source map aligned with the # LinuxCNC-root relative rs274 manifests that drive native and WASM source-link # probes. It validates documentation/manifest drift only; it does not add CNC # behavior, expand smoke parsing, or interpret G-code. python3 - <<'PY' from pathlib import Path source_map = Path("docs/linuxcnc-rs274-source-map.md").read_text(encoding="utf-8") native_manifest = Path("linuxcnc-rs274-source-files.txt").read_text(encoding="utf-8").splitlines() wasm_manifest = Path("linuxcnc-rs274-wasm-source-files.txt").read_text(encoding="utf-8").splitlines() expected = { "### Interpreter core": [ Path(line.split(":", 2)[1]).name for line in native_manifest if line.startswith("core:") ], "### Python binding modules": [ Path(line.split(":", 2)[1]).name for line in native_manifest if line.startswith("binding:") ], "### WASM-safe source core": [ line.split(":", 2)[1] for line in wasm_manifest if line.startswith("core:") ], "### WASM-blocked sources": [ line.split(":", 2)[1] for line in wasm_manifest if line.startswith("blocked:") ], "### WASM-tracked headers": [ line.split(":", 2)[1] for line in wasm_manifest if line.startswith("header:") ], "### WASM-blocked headers": [ line.split(":", 2)[1] for line in wasm_manifest if line.startswith("blocked-header:") ], "### WASM metadata sources": [ line.split(":", 2)[1] for line in wasm_manifest if line.startswith("metadata:") ], } actual = {section: [] for section in expected} active_section = None for line in source_map.splitlines(): if line in expected: active_section = line continue if active_section and line.startswith("### "): active_section = None if active_section and line.startswith("- `"): actual[active_section].append(line.split("`", 2)[1]) labels = { "### Interpreter core": "interpreter core", "### Python binding modules": "Python binding module", "### WASM-safe source core": "WASM-safe source core", "### WASM-blocked sources": "WASM-blocked source", "### WASM-tracked headers": "WASM-tracked header", "### WASM-blocked headers": "WASM-blocked header", "### WASM metadata sources": "WASM metadata source", } for section, expected_entries in expected.items(): if actual[section] != expected_entries: raise SystemExit( f"docs/linuxcnc-rs274-source-map.md {labels[section]} list no longer matches source manifest" ) for phrase in [ "must not add CNC behavior", "must not expand the temporary smoke parser", "source coverage only", "must not become browser API fields", "temporary smoke parser fallback behavior", "Browser-hostile dependencies must remain tracked blockers", "./check-linuxcnc-rs274-source-map.sh", "does not interpret G-code", ]: if phrase not in source_map: raise SystemExit(f"docs/linuxcnc-rs274-source-map.md missing boundary phrase: {phrase}") for entry in [ "test-native.sh", "test-linuxcnc-source-link.sh", "build-wasm.sh", ]: text = Path(entry).read_text(encoding="utf-8") if "./check-linuxcnc-rs274-source-map.sh" not in text: raise SystemExit(f"{entry} must run ./check-linuxcnc-rs274-source-map.sh") PY