From 4cb52ef2e7a114eb859a89ebceb0cb6b1035c537 Mon Sep 17 00:00:00 2001 From: wangdequan Date: Sat, 13 Jun 2026 17:43:45 +0800 Subject: [PATCH] Guard OPFS gcode program staging --- text7.txt | 65 +++++++++++++++++++ .../tests/opfs/node/verify_file_service.mjs | 23 +++++-- 2 files changed, 82 insertions(+), 6 deletions(-) diff --git a/text7.txt b/text7.txt index 99c527f..5ff4d3c 100644 --- a/text7.txt +++ b/text7.txt @@ -1494,3 +1494,68 @@ gcode storage、file-service 或 interpreter 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 gcode program staging guard + +1. 本批目标。 + +继续 staged path guard inventory 第二十一轮,处理 OPFS gcode program storage path: + +```text +linuxcnc/gcode/fixture.ngc +linuxcnc/gcode/custom-fixture.ngc +``` + +2. 已完成改动。 + +- Node OPFS smoke 新增 `assertGcodeProgramStoragePath(...)`; +- `gcodeProgramPath(...)` 的 fixture 与 custom fixture 路径改为走专用 path guard; +- `saveGcodeProgram(...)` 的 fixture 与 custom fixture 返回路径改为走专用 path guard; +- `loadGcodeProgram(...)` 的读取内容验证保持不变; +- invalid gcode filename rejection 验证保持不变; +- 未修改 OPFS file-service、machine-file-store、path-model、gcode 内容或 interpreter + 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 gcode program staging +``` + +5. 下一步工作建议。 + +继续 staged path guard inventory 第二十二轮,优先扫描 OPFS snapshot storage path +边界,例如 `sessionSnapshotPath(...)` / `saveSessionSnapshot(...)` 与 +`linuxcnc/sessions//snapshot.json` 或 custom snapshot filename 对账;仍只加 +filesystem/OPFS path guard,不改变 snapshot schema、file-service 或 session 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 a8fd49a..34eb24d 100644 --- a/wasm-port/tests/opfs/node/verify_file_service.mjs +++ b/wasm-port/tests/opfs/node/verify_file_service.mjs @@ -95,14 +95,25 @@ const storage = { getDirectory: async () => root, }; +function assertGcodeProgramStoragePath(filename, path) { + assert.equal( + path, + `linuxcnc/gcode/${filename}`, + `${filename} G-code OPFS path drift`, + ); +} + assert.equal(await getOpfsRoot(storage), root); assert.equal(normalizeOpfsPath("linuxcnc/machines/xyzab.ini"), "linuxcnc/machines/xyzab.ini"); assert.equal(machineIniPath("xyzab-tdr"), "linuxcnc/machines/xyzab-tdr/machine.ini"); assert.equal(toolTablePath("xyzab-tdr"), "linuxcnc/machines/xyzab-tdr/tool.tbl"); assert.equal(parameterFilePath("xyzab-tdr"), "linuxcnc/machines/xyzab-tdr/linuxcnc.var"); -assert.equal(gcodeProgramPath("fixture.ngc"), "linuxcnc/gcode/fixture.ngc"); -assert.equal(gcodeProgramPath("custom-fixture.ngc"), "linuxcnc/gcode/custom-fixture.ngc"); +assertGcodeProgramStoragePath("fixture.ngc", gcodeProgramPath("fixture.ngc")); +assertGcodeProgramStoragePath( + "custom-fixture.ngc", + gcodeProgramPath("custom-fixture.ngc"), +); assert.equal(previewCachePath("fixture"), "linuxcnc/preview-cache/fixture/preview.json"); assert.equal(sessionSnapshotPath("session-1"), "linuxcnc/sessions/session-1/snapshot.json"); assert.equal( @@ -200,14 +211,14 @@ assert.deepEqual(await loadMachineTextFiles("xyzab-tdr", { storage }), { toolTable: "T0 P0 ; no tool\nT2 P2 Z1.25 D0.25\n", parameters: "5161 0.0\n5162 0.0\n", }); -assert.equal( +assertGcodeProgramStoragePath( + "fixture.ngc", await saveGcodeProgram("fixture.ngc", "G0 X0 Y0\nM2\n", { storage }), - "linuxcnc/gcode/fixture.ngc", ); assert.equal(await loadGcodeProgram("fixture.ngc", { storage }), "G0 X0 Y0\nM2\n"); -assert.equal( +assertGcodeProgramStoragePath( + "custom-fixture.ngc", await saveGcodeProgram("custom-fixture.ngc", "G1 X1 F10\nM2\n", { storage }), - "linuxcnc/gcode/custom-fixture.ngc", ); assert.equal(await loadGcodeProgram("custom-fixture.ngc", { storage }), "G1 X1 F10\nM2\n");