7.2 KiB
21-04 HAL Component Precompile Manifest 实现缺口复核
后续状态:本文件记录实施前缺口。P1 已由
26完成,halcompile 派生、manifest、真实 thread/net 执行和 Web 代表配置 gate 已由27完成;动态模块加载边界不变。
定位
本文件落实 ACC-033/INT-020:在 19-04动态加载与预编译Manifest复核.md 已完成源码边界复核之后,继续检查 wasm-port 和 web-rtcp-5axis-xyzbc-trt-sim-plan 是否已经具备 HAL 基础组件的预编译 manifest 和 truth-table gate。
覆盖 04 条目:
4.7 and2 组件4.8 or2 组件4.9 not 组件4.10 mux2 组件4.11 scale 组件4.16 loadrt 加载组件
严格口径:LinuxCNC .comp 源码已定位、HAL 文件中出现 loadrt mux2/loadrt scale、或 runtime 能记录 loadrt:<name> 事件,都不能自动等价为 WASM 已执行组件函数。只有组件进入预编译 manifest、WASM symbol、pin/param/function 模型和 truth-table / thread-net gate 后,才能将 04 的基础组件项晋级为完成。
LinuxCNC 组件源码对照
| 04 项 | 组件 | 本地 LinuxCNC 源码 | pin/param/function | 公式或真值表 |
|---|---|---|---|---|
| 4.7 | and2 |
linuxcnc/src/hal/components/and2.comp |
in0 bit in、in1 bit in、out bit out、function _ |
out = in0 && in1 |
| 4.8 | or2 |
linuxcnc/src/hal/components/or2.comp |
in0 bit in、in1 bit in、out bit out、function _ |
`out = in0 |
| 4.9 | not |
linuxcnc/src/hal/components/not.comp |
in bit in、out bit out、function _ |
out = ! in |
| 4.10 | mux2 |
linuxcnc/src/hal/components/mux2.comp |
sel bit in、in0 float in、in1 float in、out float out、function _ |
sel ? in1 : in0 |
| 4.11 | scale |
linuxcnc/src/hal/components/scale.comp |
in float in、gain float in、offset float in、out float out、function _ |
out = in * gain + offset |
上述组件均带有 option period no,在 LinuxCNC 原生 HAL 中可通过 loadrt、net、setp、addf 进入线程执行。Web/WASM 对标时,必须证明等效执行链,而不能只登记源码路径。
当前实现复核
wasm-port
本轮检索未发现以下实现资产:
hal_component_precompile_manifest
component_precompile_manifest
verify_hal_component_precompile_manifest.mjs
truth-table gate for and2/or2/not/mux2/scale
当前已有 verify_hal_runtime.sh 可证明:
- HAL pin/signal/param/net 基础模型。
addf到 thread scheduler 的基础能力。loadusrblocked evidence。loadrt语句可被记录为loadrt:<name>事件。
但该 gate 不执行 and2、or2、not、mux2、scale 的组件函数,不覆盖 mux2 的 sel=false/true 两路,也不覆盖 scale 的 gain/offset 浮点公式。
web-rtcp-5axis-xyzbc-trt-sim-plan
目标 Web 项目的 native evidence 中能看到 LinuxCNC HAL 文件行,例如:
loadrt mux2 names=J0_mux,J1_mux,J2_mux,J3_mux,J4_mux
loadrt scale names=rpm_rps
net sample:enable motion.motion-enabled => J0_mux.sel J1_mux.sel J2_mux.sel J3_mux.sel J4_mux.sel
addf J0_mux servo-thread
addf J1_mux servo-thread
addf J2_mux servo-thread
addf J3_mux servo-thread
addf J4_mux servo-thread
addf rpm_rps servo-thread
这些行说明原生 LinuxCNC 代表配置确实使用 mux2 和 scale,可以作为源码/配置对照证据;但当前 Web 项目未见可机读的 component precompile manifest,也未见组件输出与输入的 truth-table / formula JSON 证据,因此不能把 native HAL 文件行直接晋级为 WASM/Web 组件执行通过。
必须补齐的 Manifest 和 Gate
Manifest 最小字段
建议文件名:
wasm-port/runtime/manifests/hal_component_precompile_manifest.json
最小字段:
| 字段 | 规则 |
|---|---|
component |
and2、or2、not、mux2、scale |
linuxcncSource |
指向 linuxcnc/src/hal/components/*.comp |
sourceHash |
记录 .comp 文件哈希,防止源码漂移 |
loadrtName |
HAL 文件中允许的 loadrt 名称 |
pins[] |
每个 pin 的 name、direction、type、defaultValue |
params[] |
如组件有参数,记录 name、type、defaultValue |
functionName |
function _ 或生成后的函数入口 |
wasmSymbol |
预编译后导出的 C ABI/WASM symbol |
threadAddfSupported |
是否允许通过 addf 加入 virtual thread |
formula |
对 scale/mux2 等记录公式 |
truthTable |
对 bit 组件记录全部输入组合 |
tests[] |
指向 Node/Browser gate |
Gate 最小规则
建议命令:
cd wasm-port && node tests/wasm/node/verify_hal_component_precompile_manifest.mjs
cd wasm-port && node tests/wasm/node/verify_hal_component_truth_tables.mjs
最小验证:
and2truth table 覆盖 4 组输入。or2truth table 覆盖 4 组输入。nottruth table 覆盖 2 组输入。mux2覆盖sel=false和sel=true,并验证 float 输出来自正确输入。scale覆盖至少 3 组in/gain/offset,并设置浮点容差。loadrt <component>只能从 allowlist 实例化预编译组件;未知组件必须 blocked。addf <instance> servo-thread后,thread scheduler 执行一次必须更新输出 pin。net连接后,输出 pin 变化必须进入 signal snapshot。
当前严格状态
| 04 项 | 当前状态 | 原因 | 晋级条件 |
|---|---|---|---|
4.7 and2 |
待实现 manifest/truth-table gate | .comp 源码已定位;未见预编译 manifest 或 truth table |
补 manifest、WASM symbol、4 组 truth table、thread/net gate |
4.8 or2 |
待实现 manifest/truth-table gate | 同上 | 同上 |
4.9 not |
待实现 manifest/truth-table gate | 同上 | 补 2 组 truth table、thread/net gate |
4.10 mux2 |
待实现 manifest/formula gate | native evidence 中有 loadrt mux2,但无 WASM 公式执行证据 |
补 sel=false/true formula gate、thread/net gate |
4.11 scale |
待实现 manifest/formula gate | native evidence 中有 loadrt scale,但无 WASM 公式执行证据 |
补 in*gain+offset formula gate、浮点容差和 thread/net gate |
4.16 loadrt |
Blocked 或预编译 allowlist 条件通过 | 当前 loadrt 只记录事件,不执行任意动态加载 |
补 allowlist manifest;未知组件 blocked;已知组件实例化走预编译 symbol |
结论
ACC-033/INT-020 已完成实现缺口复核。LinuxCNC .comp 源码和目标 Web native evidence 中的 loadrt mux2/loadrt scale 行可以作为来源证据;但当前两个目标项目尚未形成 HAL component precompile manifest、WASM symbol、truth-table/formula gate 和 thread/net execution proof。后续不得把 loadrt 事件记录、HAL 文件文本或 native evidence 中的 loadrt mux2/scale 行直接宣称为 04 4.7-4.11 已完成;只有补齐 manifest 和 gate 后才能晋级。
后续状态
上述缺口已由 ACC-038/INT-025 和 ACC-039/INT-026 闭合:五个组件已进入 P1/source hash、halcompile 派生、precompile manifest、truth-table/formula、thread/net、unknown blocked、session reset 和 Web XYZAC 代表配置 gate。当前严格结论见 27-04-HAL-Component-Precompile-Runtime-Gate实施记录.md;任意动态模块加载仍保持 Blocked。