From 0b09c3c069d801a84045dab9eef64e9e4c1ee959 Mon Sep 17 00:00:00 2001 From: wangdequan Date: Sat, 13 Jun 2026 18:10:10 +0800 Subject: [PATCH] Guard OPFS path helper staging --- text7.txt | 65 +++++++++++++++++++ .../tests/opfs/node/verify_file_service.mjs | 24 +++++-- 2 files changed, 83 insertions(+), 6 deletions(-) diff --git a/text7.txt b/text7.txt index 0af62dc..d67e350 100644 --- a/text7.txt +++ b/text7.txt @@ -1687,3 +1687,68 @@ file-service 或 runtime semantics。 ```bash git status --short && git log -5 --oneline && tail -n 120 text7.txt && awk '/^[一二三四五六七八九十百]+、/ {print}' text7.txt | sort | uniq -d ``` + +二十九、2026-06-13 继续执行记录:OPFS path helper staging guard + +1. 本批目标。 + +继续 staged path guard inventory 第二十四轮,处理 OPFS path helper 剩余散点: + +```text +defaultMachinePaths("xyzab-tdr") +machineFilePaths("xyzab-tdr") +previewCachePath("fixture", "nested/preview.json") +``` + +2. 已完成改动。 + +- Node OPFS smoke 新增 `assertMachineFileStoragePaths(...)`; +- `defaultMachinePaths(...)` 的默认 machine file path map 改为走专用 path guard; +- `machineFilePaths(...)` 的默认 machine file path map 改为走专用 path guard; +- 增加 `previewCachePath(...)` custom invalid filename rejection; +- 未修改 OPFS file-service、machine-file-store、path-model、preview cache 或 runtime + semantics。 + +涉及文件: + +```text +wasm-port/tests/opfs/node/verify_file_service.mjs +``` + +3. 已完成的目标验证。 + +```bash +git diff --check +wasm-port/tests/opfs/node/verify_file_service.sh +``` + +4. 本批剩余建议验证。 + +```bash +wasm-port/tools/verify_vendor_sync.sh +wasm-port/tools/verify_no_standalone_cnc_semantics.sh +SKIP_INTERP_BUILD=1 wasm-port/tests/wasm/node/verify_interp_wasm.sh +SKIP_INTERP_BUILD=1 wasm-port/tests/wasm/node/verify_sim_configs_inventory_wasm.sh +SKIP_INI_BUILD=1 SKIP_INTERP_BUILD=1 wasm-port/tests/browser/verify_interp_browser.sh +wasm-port/tests/host/verify_host_smokes.sh +``` + +如果通过,提交建议: + +```text +Guard OPFS path helper staging +``` + +5. 下一步工作建议。 + +继续 staged path guard inventory 第二十五轮,优先扫描 OPFS bridge default path helpers, +例如 `restoreMachineParametersFromOpfs(...)`、`loadMachineToolTableFromOpfs(...)`、 +`saveMachineToolTableToOpfs(...)` 的默认 OPFS path 与 custom WASM path 对账;仍只加 +filesystem/OPFS path guard,不改变 bridge behavior、file-service 或 runtime +semantics。 + +下一轮第一条命令仍保持: + +```bash +git status --short && git log -5 --oneline && tail -n 120 text7.txt && awk '/^[一二三四五六七八九十百]+、/ {print}' text7.txt | sort | uniq -d +``` diff --git a/wasm-port/tests/opfs/node/verify_file_service.mjs b/wasm-port/tests/opfs/node/verify_file_service.mjs index 8a95990..095b7a9 100644 --- a/wasm-port/tests/opfs/node/verify_file_service.mjs +++ b/wasm-port/tests/opfs/node/verify_file_service.mjs @@ -119,6 +119,18 @@ function assertPreviewCacheStoragePath(cacheKey, path, filename = "preview.json" ); } +function assertMachineFileStoragePaths(machineId, paths) { + assert.deepEqual( + paths, + { + ini: `linuxcnc/machines/${machineId}/machine.ini`, + toolTable: `linuxcnc/machines/${machineId}/tool.tbl`, + parameters: `linuxcnc/machines/${machineId}/linuxcnc.var`, + }, + `${machineId} machine file OPFS path drift`, + ); +} + assert.equal(await getOpfsRoot(storage), root); assert.equal(normalizeOpfsPath("linuxcnc/machines/xyzab.ini"), "linuxcnc/machines/xyzab.ini"); @@ -145,12 +157,8 @@ assertSessionSnapshotStoragePath( sessionSnapshotPath("session-1", "custom-snapshot.json"), "custom-snapshot.json", ); -assert.deepEqual(defaultMachinePaths("xyzab-tdr"), { - ini: "linuxcnc/machines/xyzab-tdr/machine.ini", - toolTable: "linuxcnc/machines/xyzab-tdr/tool.tbl", - parameters: "linuxcnc/machines/xyzab-tdr/linuxcnc.var", -}); -assert.deepEqual(machineFilePaths("xyzab-tdr"), defaultMachinePaths("xyzab-tdr")); +assertMachineFileStoragePaths("xyzab-tdr", defaultMachinePaths("xyzab-tdr")); +assertMachineFileStoragePaths("xyzab-tdr", machineFilePaths("xyzab-tdr")); const snapshotPayload = { files: { @@ -653,6 +661,10 @@ assert.throws( () => sessionSnapshotPath("session-1", "nested/snapshot.json"), /Invalid session snapshot filename/, ); +assert.throws( + () => previewCachePath("fixture", "nested/preview.json"), + /Invalid preview cache filename/, +); assert.throws( () => gcodeProgramPath("../escape.ngc"), /Invalid G-code filename/,