chore: close wasm status contract work

This commit is contained in:
wangdequan
2026-07-08 09:20:47 -04:00
parent 97732ceb0b
commit e69333972c
69 changed files with 20435 additions and 495 deletions

View File

@@ -50,6 +50,16 @@ semantic rewrites:
| Switchkins iterative forward | `genhexkins` runtime probing follows LinuxCNC switchkins iterative-forward behavior, including the first-call warmup path before asserting roundtrip convergence. |
| Browser storage | OPFS remains outside the native core; `runtime/opfs/file-service.js` owns browser text-file persistence, `runtime/opfs/path-model.js` owns host-side storage paths for INI, tool table, parameter, G-code, preview-cache, and session-snapshot content, `runtime/opfs/snapshot-store.js` owns generic JSON session snapshot persistence, `runtime/opfs/machine-file-store.js` owns pure-text machine-file and G-code persistence, `runtime/opfs/linuxcnc-parameter-bridge.js` only copies parameter files between OPFS text storage and the LinuxCNC-backed WASM parameter-file ABI, `runtime/opfs/linuxcnc-tool-table-bridge.js` only copies tool tables between OPFS text storage and the LinuxCNC-backed WASM tool-table ABI, and `runtime/opfs/linuxcnc-machine-session-bridge.js` groups INI, parameter, and tool-table loading while using the LinuxCNC-backed INI SDK for `[EMCIO]RANDOM_TOOLCHANGER`, `[RS274NGC]PARAMETER_FILE`, and `[EMCIO]TOOL_TABLE` when available; explicit host session file-name options take precedence over INI-derived file names, missing INI file-name values fall back to host default parameter/tool-table paths, and path validation remains owned by the OPFS path model, including rejection of traversal or nested path segments from INI-derived file names. |
| INI-context SDK staging | `runtime/sdk/src/sim-config-staging.js` exposes `planIniFileContextStaging()` as a generic host-boundary file planner and `planSimConfigStaging()` as the representative vendored `configs/sim` wrapper. The planner reads INI text plus `tools/source-manifest.txt` to collect `[DISPLAY]OPEN_FILE`, `[EMCIO]TOOL_TABLE`, `[RS274NGC]PARAMETER_FILE`, one or more `[RS274NGC]SUBROUTINE_PATH` entries, one or more `[RS274NGC]USER_M_PATH` entries, and remap-NGC files for staging without relying on browser directory enumeration. `runtime/sdk/src/linuxcnc-interp.js` exposes `runSimConfigProgram()` as the execution convenience only: it writes planned text files into the Emscripten filesystem, applies executable bits for user M-code files, and forwards to existing LinuxCNC-backed C ABI entry points such as `runFileWithIni()` or `runFiveAxisRemapFile()`; neither helper implements interpreter, axis, remap, tool, parameter, or user M-code semantics. |
| Task/motion/HAL WASM runtime | `runtime/core/linuxcnc_wrap/linuxcnc_task_hal_wasm.cpp`, `linuxcnc_motion_runtime.c`, and the phase 2 HAL runtime form a deterministic Web simulation adapter. The current boundary has task-cycle motion snapshots, command buffering, plan/execute/motion-update/subordinate-sync/status-write stages, source-anchored `emctask.cc`/`taskintf.cc`/`emccanon.cc` subsets, a T-033 `taskintf.cc` motion bridge for `emcMotionInit()`/`emcMotionUpdate()`/`emcMotionAbort()` over `lcmot_*`, T-034 traj control mapping for enable/disable/abort/pause/step/resume/set-motion-id, T-035 linear move mapping from `emcTrajLinearMove()` to structured `lcmot_write_linear_move()`, T-036 jog/home/switchkins mapping from `emcJogIncr()``emcJointHome/Unhome()` and `emcMotionSetAout()` to structured `lcmot_write_*` calls, T-037 abort/state/mode mapping from `emcTaskAbort()``emcTaskSetMode()` and `emcTaskSetState()` to a structured `emctask.cc` command result, T-038 determine/update snapshot mapping from `LcmotStatusSnapshot` and the IO estop/error latch into `determineMode()``determineState()` and `emcTaskUpdate()`, T-039 plan wait/open/synch/reset mapping from `emcTaskPlanSetWait/IsWait/ClearWait/Synch/Open/Close/Reset()` into source-anchored plan results over staged FS, T-040 plan read/execute/line/level/command mapping from `emcTaskPlanRead/Execute/Line/Level/Command()` into source-anchored plan IO results that can append staged program work to the interp_list path without host JSON motion plans, config/error read snapshots, motion ERROR and soft-limit injection coverage, and top/task/motion/io DONE/EXEC/ERROR aggregation aligned with `emctaskmain.cc`. It is still not a full native task/HAL promotion: `nativeTaskReady=false`, `nativeHalSyncReady=false`, `fullLinuxCncProgramExecutionReady=false`, and `task_hal_runtime_promoted=0` remain required. |
| Task/motion/HAL WASM runtime T-007 StandaloneEmcStatus | T-007 centralizes the required top/task/motion/io status fields into `StandaloneEmcStatus`, a phased `EMC_STAT` equivalent. `write_status_snapshot()` synchronizes task state/mode/interp/exec, motion snapshot fields, IO error/estop state, and RCS aggregation before status JSON is written; compatibility JSON fields `task`, `motionStatus`, `rcsStatus`, and `taskTopLevelStatus` are exported from the same container through `statusSource=StandaloneEmcStatus` and `emcStatus`. Full upstream `emc_nml.hh` and NML transport remain intentionally unpromoted. |
| Task/motion/HAL WASM runtime T-051-T-055 status JSON contract | T-051 through T-055 extend the same `StandaloneEmcStatus` boundary rather than adding a JSON-owned state machine. `emcStatus.motion.traj` maps `LcmotStatusSnapshot` queue/inpos/id/pause/velocity/pose fields to LinuxCNC `EMC_TRAJ_STAT` names; `emcStatus.task.currentLine/readLine/motionLine/callLevel` come from staged plan and motion snapshot evidence; `emcStatus.motion.axis[]` and `joint[]` expose structured axis/joint arrays while legacy `motionStatus.axis` and `joint0` remain compatibility views; `emcStatus.io.aux/tool/coolant` exposes only shim/unsupported IO boundaries. `tools/verify_task_status_json_contract.sh` fixes this schema and confirms `lctask_read_status_json()` does not call motion JSON or advance motion state. |
| Task/motion/HAL WASM runtime T-041 canon state | T-041 canon init/finish/unit/endpoint mapping brings `INIT_CANON()``ON_RESET()``FINISH()``USE_LENGTH_UNITS()` and external unit/position getters into the source-anchored `emccanon.cc` subset. Drift remains bounded to deterministic status evidence: counters, length/angle units, and endpoint snapshots are surfaced through task status JSON, while full interpreter/canon process ownership is still unpromoted. |
| Task/motion/HAL WASM runtime T-042 canon straight motion | T-042 straight traverse/feed mapping brings `generate_fast_move()``generate_move()``STRAIGHT_TRAVERSE()` and `STRAIGHT_FEED()` into the source-anchored `emccanon.cc` subset. Drift remains bounded to `EMC_TRAJ_LINEAR_MOVE` / `interp_list` evidence and the existing structured `taskintf.cc` motion command boundary; full native canon offsets, tags, feed modes, and NML queue ownership remain unpromoted. |
| Task/motion/HAL WASM runtime T-043 canon dwell/path-control | T-043 dwell/path-control mapping brings `DWELL()` and `SET_MOTION_CONTROL_MODE()` into the source-anchored `emccanon.cc` subset. Drift remains bounded to `EMC_TRAJ_DELAY` / `EMC_TRAJ_SET_TERM_COND` / `interp_list` evidence and task status counters; full native blend planning, queue ownership, and NML transport remain unpromoted. |
| Task/motion/HAL WASM runtime T-044 canon spindle/tool | T-044 spindle/tool command mapping brings `SET_SPINDLE_SPEED()``START_SPINDLE_CLOCKWISE()``START_SPINDLE_COUNTERCLOCKWISE()``STOP_SPINDLE_TURNING()``SELECT_TOOL()``CHANGE_TOOL()``CHANGE_TOOL_NUMBER()` and `RELOAD_TOOLDATA()` into the source-anchored `emccanon.cc` subset. Drift remains bounded to `EMC_SPINDLE_*` / `EMC_TOOL_*` / `interp_list` evidence and task status counters; full native spindle control, IO, tool DB ownership, and NML transport remain unpromoted. |
| Task/motion/HAL WASM runtime T-045 canon motion output/switchkins | T-045 motion output/switchkins mapping brings `SET_MOTION_OUTPUT_BIT()``CLEAR_MOTION_OUTPUT_BIT()``SET_AUX_OUTPUT_BIT()``CLEAR_AUX_OUTPUT_BIT()``SET_MOTION_OUTPUT_VALUE()``SET_AUX_OUTPUT_VALUE()` and `WAIT()` into the source-anchored `emccanon.cc` subset. Drift remains bounded to `EMC_MOTION_SET_DOUT` / `EMC_MOTION_SET_AOUT` / `EMC_AUX_INPUT_WAIT` / `interp_list` evidence, with M428-M430 routed through canon `SET_AUX_OUTPUT_VALUE()` before the existing `taskintf.cc` AOUT boundary; full native IO wait, queue ownership, and NML transport remain unpromoted. |
| Task/motion/HAL WASM runtime T-046 no-JSON main RUN path | T-046 makes staged program RUN the default validation path through `emctask.cc` plan read/command/execute, `emccanon.cc` command envelopes, and `taskintf.cc` motion issue. Drift remains bounded by keeping `loadProgramMotionPlan()` as an explicit timed-plan compatibility/debug entry only; the primary WASM smoke no longer calls `lctask_load_program_motion_plan_json()` before RUN. |
| `emc_nml.hh` status container | Full upstream `src/emc/nml_intf/emc_nml.hh` is evaluated but not vendored or directly included. T-029 records that direct include would pull NML/CMS, RS274, canon/tool-table, and message serialization dependencies before the broader NML transport boundary exists. Current status aggregation therefore remains a phased `StandaloneEmcStatus`/typedef boundary with LinuxCNC field names and validation gates, not byte-level drift from a vendored `emc_nml.hh`. |
## Enforced Non-Drift Rules
@@ -125,6 +135,12 @@ semantic rewrites:
`_ini[...]` lookup with upstream `rs274 -i`; the broader
`namedparam_semantics` fixture still keeps `_hal[...]` lookup on the
documented standalone HAL adapter boundary.
- Task/motion/HAL runtime validation now covers task-cycle motion snapshots,
wait-for-motion queue behavior, motion abort/error/soft-limit subordinate
sync, top/task/motion/io RCS DONE/EXEC/ERROR aggregation, source-anchored
`emctask.cc`/`taskintf.cc`/`emccanon.cc` subsets, and the T-029
`emc_nml.hh` reuse decision. These are runtime-edge validations only and do
not promote native task/HAL readiness.
## Current Drift Conclusion