From a12c0166b50db0e8fad3d9e26be5bf93c3175ddb Mon Sep 17 00:00:00 2001 From: cnc Date: Thu, 4 Jun 2026 19:22:34 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8F=82=E8=80=83=E6=89=80=E6=9C=89=E5=88=86?= =?UTF-8?q?=E7=BB=84=EF=BC=8C=E5=AE=8C=E6=88=90=E5=B0=BD=E9=87=8F=E5=A4=9A?= =?UTF-8?q?=E7=9A=84=E5=86=85=E5=AE=B9=E3=80=82=E7=A6=81=E6=AD=A2=E9=A1=BA?= =?UTF-8?q?=E6=89=8B=E6=89=A9=E5=8A=9F=E8=83=BD=20smoke=EF=BC=9A=E9=94=81?= =?UTF-8?q?=E5=AE=9AOPFS=E8=A6=86=E7=9B=96=E6=9D=A1=E7=9B=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- check-linuxcnc-opfs-source-map.sh | 38 +++++++++++++++++++++++++++++++ docs/linuxcnc-opfs-source-map.md | 11 +++++++++ 2 files changed, 49 insertions(+) diff --git a/check-linuxcnc-opfs-source-map.sh b/check-linuxcnc-opfs-source-map.sh index 2c58418..46d0ba5 100755 --- a/check-linuxcnc-opfs-source-map.sh +++ b/check-linuxcnc-opfs-source-map.sh @@ -34,6 +34,13 @@ grep -F '`Interp::save_parameters()` for `filename + ".new"`' \ grep -F 'must not add independent filesystem behavior or expand the temporary smoke parser' \ docs/linuxcnc-opfs-source-map.md >/dev/null grep -F 'parseFileWithParameterFile()' docs/linuxcnc-opfs-source-map.md >/dev/null +grep -F 'OPFS Coverage' docs/linuxcnc-opfs-source-map.md >/dev/null +grep -F '| `web/src/wasm-core.js` |' docs/linuxcnc-opfs-source-map.md >/dev/null +grep -F '| `web/src/app.js` |' docs/linuxcnc-opfs-source-map.md >/dev/null +grep -F '| `web/test-browser-wasm-smoke-opfs-basic-sections.js` |' docs/linuxcnc-opfs-source-map.md >/dev/null +grep -F '| `web/test-browser-wasm-smoke-opfs-parameter-sections.js` |' docs/linuxcnc-opfs-source-map.md >/dev/null +grep -F '| `web/test-browser-wasm-smoke-opfs-mirror-sections.js` |' docs/linuxcnc-opfs-source-map.md >/dev/null +grep -F '| `web/test-browser-wasm-smoke-app-sections.js` |' docs/linuxcnc-opfs-source-map.md >/dev/null grep -F 'const LINUXCNC_DEFAULT_PARAMETER_FILE = "rs274ngc.var";' web/src/wasm-core.js >/dev/null grep -F '`${LINUXCNC_DEFAULT_PARAMETER_FILE}.new`' web/src/wasm-core.js >/dev/null @@ -47,8 +54,39 @@ grep -F 'OPFS workspace is required for browser program parsing' web/src/app.js grep -F 'runSection("opfs parameter restore in new instance"' test-web-wasm-browser-smoke.sh >/dev/null grep -F 'runSection("opfs invalid parameter restore failures"' test-web-wasm-browser-smoke.sh >/dev/null grep -F 'runSection("opfs stale parameter state cleanup"' test-web-wasm-browser-smoke.sh >/dev/null +grep -F 'runSection("opfs program parse and restore"' test-web-wasm-browser-smoke.sh >/dev/null +grep -F 'runSection("browser app opfs restore"' test-web-wasm-browser-smoke.sh >/dev/null if grep -R -n -E 'localStorage|sessionStorage|indexedDB|showOpenFilePicker|showSaveFilePicker|showDirectoryPicker|webkitRequestFileSystem|FileReader' web/src; then echo "browser app/wasm code must not add filesystem persistence outside OPFS" >&2 exit 1 fi + +python3 - <<'PY' +from pathlib import Path + +source_map = Path("docs/linuxcnc-opfs-source-map.md").read_text(encoding="utf-8") +coverage_entries = [ + "web/src/wasm-core.js", + "web/src/app.js", + "web/test-browser-wasm-smoke-opfs-basic-sections.js", + "web/test-browser-wasm-smoke-opfs-parameter-sections.js", + "web/test-browser-wasm-smoke-opfs-mirror-sections.js", + "web/test-browser-wasm-smoke-app-sections.js", +] +for entry in coverage_entries: + if f"| `{entry}` |" not in source_map: + raise SystemExit(f"docs/linuxcnc-opfs-source-map.md missing OPFS coverage entry: {entry}") + +required_phrases = [ + "programs/current.ngc", + "parameters/rs274ngc.var", + "LinuxCNC `read_text()`", + "`.new`, `.bak`, failure, and stale-state semantics", + "OPFS/WASM mirror persistence", + "app-level OPFS program, parameter, backup, and reload behavior", +] +for phrase in required_phrases: + if phrase not in source_map: + raise SystemExit(f"docs/linuxcnc-opfs-source-map.md missing OPFS coverage phrase: {phrase}") +PY diff --git a/docs/linuxcnc-opfs-source-map.md b/docs/linuxcnc-opfs-source-map.md index a5c3ebb..248285b 100644 --- a/docs/linuxcnc-opfs-source-map.md +++ b/docs/linuxcnc-opfs-source-map.md @@ -15,6 +15,17 @@ persistence. It is a policy and bridge map only; it must not add independent fil `Interp::save_parameters()` for `filename + ".new"`, backup, and replacement writes. +## OPFS Coverage + +| Entry | Boundary | +| --- | --- | +| `web/src/wasm-core.js` | Keeps LinuxCNC parameter restore/save bridge files under the OPFS workspace and cleans WASM scratch files. | +| `web/src/app.js` | Persists browser programs at `programs/current.ngc` and LinuxCNC parameters at `parameters/rs274ngc.var`. | +| `web/test-browser-wasm-smoke-opfs-basic-sections.js` | Verifies OPFS program file reads through LinuxCNC `read_text()` and rejects unsafe paths. | +| `web/test-browser-wasm-smoke-opfs-parameter-sections.js` | Verifies OPFS parameter restore, save, `.new`, `.bak`, failure, and stale-state semantics. | +| `web/test-browser-wasm-smoke-opfs-mirror-sections.js` | Verifies OPFS/WASM mirror persistence used by source-backed file parsing and parameter movement. | +| `web/test-browser-wasm-smoke-app-sections.js` | Verifies app-level OPFS program, parameter, backup, and reload behavior. | + ## Browser Bridge Boundary - `web/src/wasm-core.js` must keep LinuxCNC parameter persistence routed