参考所有分组,完成尽量多的内容:收紧switchkins source-map边界守卫

This commit is contained in:
cnc
2026-06-05 06:57:11 +08:00
parent f64db24060
commit 79077fa695
2 changed files with 22 additions and 3 deletions

View File

@@ -6,7 +6,8 @@ cd "$(dirname "$0")"
# LinuxCNC source basis: this guard ties generated switchkins/remap aliases and # LinuxCNC source basis: this guard ties generated switchkins/remap aliases and
# config cases to LinuxCNC configs/sim INI REMAP entries, remap_subs # config cases to LinuxCNC configs/sim INI REMAP entries, remap_subs
# #<kinstype> assignments, and halcmd loadusr parsing sources. It validates # #<kinstype> assignments, and halcmd loadusr parsing sources. It validates
# generator/table policy only; it does not add CNC behavior or expand smoke. # generator/table policy only; it does not add CNC behavior, expand smoke
# parsing, or interpret G-code.
linuxcnc_root=${LINUXCNC_ROOT:-../linuxcnc} linuxcnc_root=${LINUXCNC_ROOT:-../linuxcnc}
linuxcnc_root=$(cd "$linuxcnc_root" && pwd) linuxcnc_root=$(cd "$linuxcnc_root" && pwd)
@@ -70,11 +71,14 @@ if f"| LinuxCNC switchkins REMAP INI sources | {len(remap_inis)} |" not in sourc
raise SystemExit("docs/linuxcnc-switchkins-remap-source-map.md REMAP INI source count mismatch") raise SystemExit("docs/linuxcnc-switchkins-remap-source-map.md REMAP INI source count mismatch")
required_phrases = [ required_phrases = [
"must not add new smoke parser behavior", "must not add CNC behavior",
"must not expand the temporary smoke parser",
"`#<kinstype>` assignments", "`#<kinstype>` assignments",
"[EMCIO] TOOL_TABLE` entries are source coverage only", "[EMCIO] TOOL_TABLE` entries are source coverage only",
"must not become generated switchkins aliases", "must not become generated switchkins aliases",
"./check-linuxcnc-switchkins-remap-source-map.sh",
"./check-linuxcnc-switchkins-remap-table.sh linuxcnc-kinematics-source-files.txt", "./check-linuxcnc-switchkins-remap-table.sh linuxcnc-kinematics-source-files.txt",
"does not interpret G-code",
] ]
for phrase in required_phrases: for phrase in required_phrases:
if phrase not in source_map: if phrase not in source_map:
@@ -82,6 +86,15 @@ for phrase in required_phrases:
f"docs/linuxcnc-switchkins-remap-source-map.md is missing boundary phrase: {phrase}" f"docs/linuxcnc-switchkins-remap-source-map.md is missing boundary phrase: {phrase}"
) )
for entry in [
"test-native.sh",
"test-linuxcnc-source-link.sh",
"build-wasm.sh",
]:
text = Path(entry).read_text(encoding="utf-8")
if "./check-linuxcnc-switchkins-remap-source-map.sh" not in text:
raise SystemExit(f"{entry} must run ./check-linuxcnc-switchkins-remap-source-map.sh")
case_fields = {case["field"] for case in json_cases} case_fields = {case["field"] for case in json_cases}
source_only_field_re = re.compile(r"asset|metadata|tool|tooldata|tool_table|TOOL_TABLE", re.I) source_only_field_re = re.compile(r"asset|metadata|tool|tooldata|tool_table|TOOL_TABLE", re.I)
bad_fields = [field for field in case_fields if source_only_field_re.search(field)] bad_fields = [field for field in case_fields if source_only_field_re.search(field)]

View File

@@ -1,7 +1,7 @@
# LinuxCNC switchkins/remap source map # LinuxCNC switchkins/remap source map
This map records the source basis for generated M428/M429/M430 switchkins This map records the source basis for generated M428/M429/M430 switchkins
aliases and config cases. It is a generator/table map only; it must not add new smoke parser behavior or expose LinuxCNC source-only assets as browser API fields. aliases and config cases. It is a generator/table map only; it must not add CNC behavior, must not expand the temporary smoke parser, and must not expose LinuxCNC source-only assets as browser API fields.
## LinuxCNC Source Basis ## LinuxCNC Source Basis
@@ -31,6 +31,12 @@ aliases and config cases. It is a generator/table map only; it must not add new
are source coverage, not browser API surface. are source coverage, not browser API surface.
- Generated tables must continue to derive M428/M429/M430 kinstypes from - Generated tables must continue to derive M428/M429/M430 kinstypes from
LinuxCNC remap `#<kinstype>` assignments, not from hand-authored behavior. LinuxCNC remap `#<kinstype>` assignments, not from hand-authored behavior.
- `test-native.sh`, `test-linuxcnc-source-link.sh`, and `build-wasm.sh` must
run `./check-linuxcnc-switchkins-remap-source-map.sh` before consuming
generated config aliases, source-linked LinuxCNC objects, or browser
artifacts.
- The switchkins/remap source-map guard validates LinuxCNC source/config
ownership and generated table drift only; it does not interpret G-code.
## Checks ## Checks