Guard browser machine text-store staging

This commit is contained in:
2026-06-13 17:36:12 +08:00
parent 0d90a5b513
commit 41a9cd65c1
2 changed files with 118 additions and 6 deletions

View File

@@ -1425,3 +1425,72 @@ machine-file-store 或 session 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 继续执行记录browser machine text-store staging guard
1. 本批目标。
继续 staged path guard inventory 第二十轮,处理 browser OPFS/machine text store 默认
OPFS path 对账:
```text
linuxcnc/machines/<machine>/machine.ini
linuxcnc/machines/<machine>/tool.tbl
linuxcnc/machines/<machine>/linuxcnc.var
```
2. 已完成改动。
- browser 侧新增 `assertMachineTextStorePaths(...)`
- `browser-interp` 的 `saveMachineTextFiles(...)` 返回 path map 增加默认 OPFS path
guard
- `browser-random-toolchanger` 的 `saveMachineTextFiles(...)` 返回 path map 增加默认
OPFS path guard
- `browser-ini-file-session` 与 `browser-ini-override-session` 的 machine text-store
path map 增加默认 OPFS path guard
- invalid parameter/tool INI negative session 的 machine text-store path map 增加默认
OPFS path guard
- 未修改 OPFS file-service、machine-file-store、path-model、machine file 内容或
session 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
```
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
wasm-port/tests/host/verify_host_smokes.sh
```
如果通过,提交建议:
```text
Guard browser machine text-store staging
```
5. 下一步工作建议。
继续 staged path guard inventory 第二十一轮,优先扫描 OPFS gcode program storage
边界,例如 `saveGcodeProgram(...)` / `loadGcodeProgram(...)` 与
`linuxcnc/gcode/<filename>` path 对账;仍只加 filesystem/OPFS path guard不改变
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
```

View File

@@ -4478,6 +4478,19 @@
}
}
function assertMachineTextStorePaths(label, paths, machineId) {
const expectedPaths = {
ini: `linuxcnc/machines/${machineId}/machine.ini`,
toolTable: `linuxcnc/machines/${machineId}/tool.tbl`,
parameters: `linuxcnc/machines/${machineId}/linuxcnc.var`,
};
for (const [name, expectedPath] of Object.entries(expectedPaths)) {
if (paths[name] !== expectedPath) {
throw new Error(`${label}: unexpected ${name} OPFS path ${paths[name]}`);
}
}
}
function generatedToolTablePath(wasmPath, expectedWasmPath) {
if (wasmPath !== expectedWasmPath) {
throw new Error(`browser_tool_table_fixture_${expectedWasmPath}: path drift`);
@@ -8981,7 +8994,7 @@
].join("\n"),
);
await saveMachineTextFiles("browser-interp", {
const browserInterpTextPaths = await saveMachineTextFiles("browser-interp", {
ini: "[EMC]\nMACHINE = browser-interp\n",
toolTable: "T2 P7 Z3.125 D1.5 I12 J34 Q4 ;browser finish tool\n",
parameters: [
@@ -8994,6 +9007,11 @@
"",
].join("\n"),
});
assertMachineTextStorePaths(
"opfs_save_machine_text_files_staging",
browserInterpTextPaths,
"browser-interp",
);
const loadedSession = await loadMachineSessionFromOpfs(
interp,
"browser-interp",
@@ -9137,7 +9155,7 @@
].join("\n"),
);
await saveMachineTextFiles("browser-random-toolchanger", {
const browserRandomTextPaths = await saveMachineTextFiles("browser-random-toolchanger", {
ini: [
"[EMC]",
"MACHINE = browser-random-toolchanger",
@@ -9160,6 +9178,11 @@
"",
].join("\n"),
});
assertMachineTextStorePaths(
"opfs_save_random_machine_text_files_staging",
browserRandomTextPaths,
"browser-random-toolchanger",
);
const loadedRandomSession = await loadMachineSessionFromOpfs(
interp,
"browser-random-toolchanger",
@@ -9243,7 +9266,7 @@
].join("\n"),
);
await saveMachineTextFiles("browser-ini-file-session", {
const browserIniFileTextPaths = await saveMachineTextFiles("browser-ini-file-session", {
ini: [
"[EMC]",
"MACHINE = browser-ini-file-session",
@@ -9256,6 +9279,11 @@
"",
].join("\n"),
});
assertMachineTextStorePaths(
"opfs_save_ini_named_machine_text_files_staging",
browserIniFileTextPaths,
"browser-ini-file-session",
);
await saveTextFile(
"linuxcnc/machines/browser-ini-file-session/browser-custom.var",
[
@@ -9410,7 +9438,7 @@
].join("\n"),
);
await saveMachineTextFiles("browser-ini-override-session", {
const browserIniOverrideTextPaths = await saveMachineTextFiles("browser-ini-override-session", {
ini: [
"[EMC]",
"MACHINE = browser-ini-override-session",
@@ -9423,6 +9451,11 @@
"",
].join("\n"),
});
assertMachineTextStorePaths(
"opfs_save_ini_override_machine_text_files_staging",
browserIniOverrideTextPaths,
"browser-ini-override-session",
);
await saveTextFile(
"linuxcnc/machines/browser-ini-override-session/browser-explicit.var",
[
@@ -9579,7 +9612,7 @@
].join("\n"),
);
await saveMachineTextFiles("browser-invalid-param-file-session", {
const invalidParamFileTextPaths = await saveMachineTextFiles("browser-invalid-param-file-session", {
ini: [
"[EMC]",
"MACHINE = browser-invalid-param-file-session",
@@ -9589,6 +9622,11 @@
"",
].join("\n"),
});
assertMachineTextStorePaths(
"opfs_save_invalid_param_machine_text_files_staging",
invalidParamFileTextPaths,
"browser-invalid-param-file-session",
);
const invalidParamFileSessionOptions = {
iniSdk: ini,
iniWasmPath: "/work/browser-invalid-param-file-session.ini",
@@ -9612,7 +9650,7 @@
/Invalid parameter filename/,
);
await saveMachineTextFiles("browser-invalid-tool-file-session", {
const invalidToolFileTextPaths = await saveMachineTextFiles("browser-invalid-tool-file-session", {
ini: [
"[EMC]",
"MACHINE = browser-invalid-tool-file-session",
@@ -9622,6 +9660,11 @@
"",
].join("\n"),
});
assertMachineTextStorePaths(
"opfs_save_invalid_tool_machine_text_files_staging",
invalidToolFileTextPaths,
"browser-invalid-tool-file-session",
);
const invalidToolFileSessionOptions = {
iniSdk: ini,
iniWasmPath: "/work/browser-invalid-tool-file-session.ini",