Guard browser OPFS machine file write helper

This commit is contained in:
2026-06-13 23:27:34 +08:00
parent 54eb7e0ef4
commit baf187e11c
2 changed files with 76 additions and 8 deletions

View File

@@ -2182,3 +2182,61 @@ browser/OPFS boundary guard不改变 LinuxCNC-owned interpreter、INI、tool
```bash ```bash
git status --short && git log -5 --oneline && tail -n 120 text7.txt && awk '/^[一二三四五六七八九十百]+、/ {print}' text7.txt | sort | uniq -d git status --short && git log -5 --oneline && tail -n 120 text7.txt && awk '/^[一二三四五六七八九十百]+、/ {print}' text7.txt | sort | uniq -d
``` ```
三十七、2026-06-13 继续执行记录browser OPFS machine file write helper guard
1. 本批目标。
继续 staged path guard inventory 第三十二轮,收敛 browser OPFS smoke 中 custom
session 机器文件写入的 inline OPFS path
```text
browser-ini-file-session
browser-ini-override-session
```
2. 已完成改动。
- browser smoke 新增 `writeOpfsMachineFile(...)`
- INI-derived custom session 的 custom parameter/tool-table 写入改为走 helper
- explicit override custom session 的 custom parameter/tool-table 写入改为走 helper
- helper 只包装 `opfsMachineFilePath(...)` + `saveTextFile(...)`,不改变写入语义;
- 未修改 OPFS bridge behavior、file-service、path-model、SDK planner、interpreter 或
LinuxCNC-owned runtime semantics。
涉及文件:
```text
wasm-port/tests/browser/interp_smoke.html
```
3. 已完成验证。
```bash
git diff --check
SKIP_INI_BUILD=1 SKIP_INTERP_BUILD=1 wasm-port/tests/browser/verify_interp_browser.sh
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
wasm-port/tests/host/verify_host_smokes.sh
```
提交建议:
```text
Guard browser OPFS machine file write helper
```
4. 下一步工作建议。
继续 staged path guard inventory 第三十三轮,优先扫描 browser OPFS smoke 中
`browser-ini-file-session` 和 `browser-ini-override-session` 的 session path/backup path
组合是否还能再收敛为更小的 session-file helper仍只加 browser/OPFS boundary guard
不改变 LinuxCNC-owned interpreter、INI、tool、parameter 或 runtime semantics。
下一轮第一条命令仍保持:
```bash
git status --short && git log -5 --oneline && tail -n 120 text7.txt && awk '/^[一二三四五六七八九十百]+、/ {print}' text7.txt | sort | uniq -d
```

View File

@@ -4539,6 +4539,12 @@
verifyExpectedOutput(label, await loadTextFile(opfsPath), expectedText); verifyExpectedOutput(label, await loadTextFile(opfsPath), expectedText);
} }
async function writeOpfsMachineFile(machineId, filename, text) {
const opfsPath = opfsMachineFilePath(machineId, filename);
await saveTextFile(opfsPath, text);
return opfsPath;
}
function assertOpfsSessionStaging(label, session, machineId, expectedPaths) { function assertOpfsSessionStaging(label, session, machineId, expectedPaths) {
if (session.machineId !== machineId) { if (session.machineId !== machineId) {
throw new Error(`${label}: unexpected machine id ${session.machineId}`); throw new Error(`${label}: unexpected machine id ${session.machineId}`);
@@ -9389,8 +9395,9 @@
browserIniFileTextPaths, browserIniFileTextPaths,
"browser-ini-file-session", "browser-ini-file-session",
); );
await saveTextFile( await writeOpfsMachineFile(
"linuxcnc/machines/browser-ini-file-session/browser-custom.var", "browser-ini-file-session",
"browser-custom.var",
[ [
"5161 31.25", "5161 31.25",
"5162 62.5", "5162 62.5",
@@ -9400,8 +9407,9 @@
"", "",
].join("\n"), ].join("\n"),
); );
await saveTextFile( await writeOpfsMachineFile(
"linuxcnc/machines/browser-ini-file-session/browser-custom-tool.tbl", "browser-ini-file-session",
"browser-custom-tool.tbl",
"T8 P8 Z4.5 D0.5 ;browser custom tool\n", "T8 P8 Z4.5 D0.5 ;browser custom tool\n",
); );
const loadedIniFileSession = await loadMachineSessionFromOpfs( const loadedIniFileSession = await loadMachineSessionFromOpfs(
@@ -9560,8 +9568,9 @@
browserIniOverrideTextPaths, browserIniOverrideTextPaths,
"browser-ini-override-session", "browser-ini-override-session",
); );
await saveTextFile( await writeOpfsMachineFile(
"linuxcnc/machines/browser-ini-override-session/browser-explicit.var", "browser-ini-override-session",
"browser-explicit.var",
[ [
"5161 41.25", "5161 41.25",
"5162 82.5", "5162 82.5",
@@ -9571,8 +9580,9 @@
"", "",
].join("\n"), ].join("\n"),
); );
await saveTextFile( await writeOpfsMachineFile(
"linuxcnc/machines/browser-ini-override-session/browser-explicit-tool.tbl", "browser-ini-override-session",
"browser-explicit-tool.tbl",
"T9 P9 Z5.5 D0.625 ;browser explicit tool\n", "T9 P9 Z5.5 D0.625 ;browser explicit tool\n",
); );
const loadedIniOverrideSession = await loadMachineSessionFromOpfs( const loadedIniOverrideSession = await loadMachineSessionFromOpfs(