wifi-densepose/firmware/esp32-csi-node/main
rUv 2c136aca74
fix(protocol): resolve 0xC511_0004 magic collision (closes #928) (#931)
* fix(ci): SAST actually scans the code + drop deprecated flaky semgrep action

Two real problems in the Static Application Security Testing job:

1. **It scanned a path that no longer exists.** `bandit -r src/` and
   `semgrep … src/` pointed at the repo-root `src/`, but the Python code
   moved to `archive/v1/src/` (64 .py files) when the runtime was rewritten
   in Rust. So the SAST scan matched nothing — a silent no-op (this is also
   why `bandit-results.sarif` was "Path does not exist" on recent runs).
   Fixed both to `archive/v1/src/`.

2. **Deprecated + redundant + flaky semgrep step.** The
   `returntocorp/semgrep-action@v1` step pulled `returntocorp/semgrep-agent:v1`
   from Docker Hub every run (intermittently timing out → red check, e.g. on
   #929) and is EOL. It was redundant: the pip `semgrep --sarif` step is what
   feeds GitHub Security; the action only pushed to the Semgrep cloud app via
   SEMGREP_APP_TOKEN. Removed it and folded its `p/docker` + `p/kubernetes`
   rulesets into the pip semgrep command, so coverage is preserved with no
   Docker pull.

The job stays `continue-on-error: true` (non-gating). YAML validated.

Co-Authored-By: claude-flow <ruv@ruv.net>

* fix(protocol): resolve 0xC511_0004 magic collision (closes #928)

Background

`0xC511_0004` was assigned to two different packet formats in firmware
— `EDGE_FUSED_MAGIC` (ADR-063, 48-byte `edge_fused_vitals_pkt_t`) and
`WASM_OUTPUT_MAGIC` (ADR-040, variable-length `wasm_output_pkt_t`).
Both were transmitted. The sensing-server only had a WASM parser for
that magic and no fused-vitals parser, so on the ESP32-C6 + MR60BHA2
mmWave configuration the fused-vitals packet was silently misparsed
as a malformed WASM output — `breathing_rate` was read as
`event_count`, mmWave-fused vitals were lost, and spurious WASM events
were emitted to subscribers.

Fix

1. Reassign `WASM_OUTPUT_MAGIC` to `0xC511_0007` (next free slot per
   the registry in `rv_feature_state.h`). Smaller blast radius than
   moving fused-vitals — the registry already treats `0xC511_0004` as
   fused-vitals canonical and several years of deployed feature
   tracking depends on that assignment.

2. Add `parse_edge_fused_vitals` + `EdgeFusedVitalsPacket` in
   `wifi-densepose-sensing-server::main`. Byte layout taken directly
   from `edge_processing.h:129`, mirroring the firmware's
   `_Static_assert(sizeof(edge_fused_vitals_pkt_t) == 48)` so future
   firmware changes that grow the packet will break this parser
   loudly instead of silently.

3. Add a dispatch arm in the UDP receive loop. Fused-vitals is tried
   BEFORE WASM so a stale firmware (still emitting 0xC511_0004 with
   the WASM payload) fails to parse as fused-vitals (size mismatch),
   then fails to parse as WASM (magic mismatch on the new 0x...0007),
   and gets dropped — a deliberate "fail loud" outcome rather than the
   pre-fix silent garbage.

4. Update the registry comment in `rv_feature_state.h` to add the new
   0x...0007 row.

5. Add five tests in a new `issue_928_magic_collision_tests` mod:
   - `parse_edge_fused_vitals_extracts_fields_correctly`
   - `parse_edge_fused_vitals_rejects_short_buffer`
   - `parse_edge_fused_vitals_rejects_wrong_magic`
   - `parse_wasm_output_rejects_legacy_0004_magic`
   - `parse_wasm_output_accepts_new_0007_magic`

WebSocket payload

Fused-vitals now broadcasts as `{"type": "edge_fused_vitals", ...}`
with the mmWave-specific block nested under `mmwave`. Schema is
additive — existing subscribers that only inspect `type` are
unaffected; subscribers that switch on `type` gain a new branch.

Deployment note

This is a wire-protocol change. Firmware older than this commit that
emits WASM output on 0xC511_0004 will lose its WASM event stream
against an updated host (host expects 0xC511_0007). Per the issue
discussion, "fail loud" is preferred to silent misparsing. Operators
running C6+mmWave should reflash firmware concurrent with the host
upgrade.

Test results
  cargo test -p wifi-densepose-sensing-server --no-default-features
  --bin sensing-server
  → 122 passed / 0 failed (5 new + 117 existing, unchanged)

Co-Authored-By: claude-flow <ruv@ruv.net>
2026-06-03 11:56:35 +02:00
..
lp_core ADR-110: ESP32-C6 firmware extension (#764) 2026-05-23 15:34:48 -04:00
CMakeLists.txt ADR-110: ESP32-C6 firmware extension (#764) 2026-05-23 15:34:48 -04:00
Kconfig.projbuild ADR-110: ESP32-C6 firmware extension (#764) 2026-05-23 15:34:48 -04:00
adaptive_controller.c ADR-081: Implement 5-layer adaptive CSI mesh firmware kernel (#404) 2026-04-20 10:38:23 -04:00
adaptive_controller.h ADR-081: Implement 5-layer adaptive CSI mesh firmware kernel (#404) 2026-04-20 10:38:23 -04:00
adaptive_controller_decide.c ADR-081: Implement 5-layer adaptive CSI mesh firmware kernel (#404) 2026-04-20 10:38:23 -04:00
c6_lp_core.c ADR-110: ESP32-C6 firmware extension (#764) 2026-05-23 15:34:48 -04:00
c6_lp_core.h ADR-110: ESP32-C6 firmware extension (#764) 2026-05-23 15:34:48 -04:00
c6_softap_he.c ADR-110: ESP32-C6 firmware extension (#764) 2026-05-23 15:34:48 -04:00
c6_softap_he.h ADR-110: ESP32-C6 firmware extension (#764) 2026-05-23 15:34:48 -04:00
c6_sync_espnow.c ADR-110: ESP32-C6 firmware extension (#764) 2026-05-23 15:34:48 -04:00
c6_sync_espnow.h ADR-110: ESP32-C6 firmware extension (#764) 2026-05-23 15:34:48 -04:00
c6_timesync.c ADR-110: ESP32-C6 firmware extension (#764) 2026-05-23 15:34:48 -04:00
c6_timesync.h ADR-110: ESP32-C6 firmware extension (#764) 2026-05-23 15:34:48 -04:00
c6_twt.c ADR-110: ESP32-C6 firmware extension (#764) 2026-05-23 15:34:48 -04:00
c6_twt.h ADR-110: ESP32-C6 firmware extension (#764) 2026-05-23 15:34:48 -04:00
csi_collector.c fix(firmware): capture DATA frames on display-less boards — #893/#866/#897 2026-06-02 09:57:19 +02:00
csi_collector.h fix(firmware): capture DATA frames on display-less boards — #893/#866/#897 2026-06-02 09:57:19 +02:00
display_hal.c docs: update README with ADR-045–048, Observatory, adaptive classifier, AMOLED display 2026-03-05 10:20:48 -05:00
display_hal.h docs: update README with ADR-045–048, Observatory, adaptive classifier, AMOLED display 2026-03-05 10:20:48 -05:00
display_task.c fix(firmware): capture DATA frames on display-less boards — #893/#866/#897 2026-06-02 09:57:19 +02:00
display_task.h fix(firmware): capture DATA frames on display-less boards — #893/#866/#897 2026-06-02 09:57:19 +02:00
display_ui.c fix(firmware): defensive node_id capture prevents runtime clobber (#390) 2026-04-15 13:47:34 -04:00
display_ui.h docs: update README with ADR-045–048, Observatory, adaptive classifier, AMOLED display 2026-03-05 10:20:48 -05:00
edge_processing.c fix(firmware): add vTaskDelay(1) yields in process_frame() at tier>=2 to fix WDT storm (#683) 2026-05-21 09:20:21 -04:00
edge_processing.h feat: ADR-069 ESP32 CSI → Cognitum Seed RVF pipeline (v0.5.4-esp32) 2026-04-02 19:32:18 -04:00
idf_component.yml fix(led): disable onboard WS2812 LED during CSI collection (#273) 2026-05-17 18:18:10 -04:00
lv_conf.h docs: update README with ADR-045–048, Observatory, adaptive classifier, AMOLED display 2026-03-05 10:20:48 -05:00
main.c fix(firmware): capture DATA frames on display-less boards — #893/#866/#897 2026-06-02 09:57:19 +02:00
mmwave_sensor.c refactor(mmwave): use sizeof() in mr60_process_frame bounds checks (#414) 2026-05-17 18:15:01 -04:00
mmwave_sensor.h feat: ADR-063/064 mmWave sensor fusion + multimodal ambient intelligence (#269) 2026-03-15 16:10:10 -04:00
mock_csi.c feat: QEMU ESP32-S3 testing platform + swarm configurator (ADR-061/062) (#260) 2026-03-14 13:39:51 -04:00
mock_csi.h feat: QEMU ESP32-S3 testing platform + swarm configurator (ADR-061/062) (#260) 2026-03-14 13:39:51 -04:00
nvs_config.c feat: happiness scoring pipeline + ESP32 swarm with Cognitum Seed (#285) 2026-03-20 18:46:34 -04:00
nvs_config.h feat: happiness scoring pipeline + ESP32 swarm with Cognitum Seed (#285) 2026-03-20 18:46:34 -04:00
ota_update.c release: ESP32-S3 firmware v0.6.5 — Tmr Svc stack + OTA init refactor (#628) 2026-05-18 17:05:35 -04:00
ota_update.h feat: complete vendor repos, add edge intelligence and WASM modules 2026-03-02 23:53:25 -05:00
power_mgmt.c feat: complete vendor repos, add edge intelligence and WASM modules 2026-03-02 23:53:25 -05:00
power_mgmt.h feat: complete vendor repos, add edge intelligence and WASM modules 2026-03-02 23:53:25 -05:00
rv_feature_state.c ADR-081: Implement 5-layer adaptive CSI mesh firmware kernel (#404) 2026-04-20 10:38:23 -04:00
rv_feature_state.h fix(protocol): resolve 0xC511_0004 magic collision (closes #928) (#931) 2026-06-03 11:56:35 +02:00
rv_mesh.c ADR-081: Implement 5-layer adaptive CSI mesh firmware kernel (#404) 2026-04-20 10:38:23 -04:00
rv_mesh.h ADR-081: Implement 5-layer adaptive CSI mesh firmware kernel (#404) 2026-04-20 10:38:23 -04:00
rv_radio_ops.h ADR-081: Implement 5-layer adaptive CSI mesh firmware kernel (#404) 2026-04-20 10:38:23 -04:00
rv_radio_ops_esp32.c ADR-081: Implement 5-layer adaptive CSI mesh firmware kernel (#404) 2026-04-20 10:38:23 -04:00
rv_radio_ops_mock.c ADR-081: Implement 5-layer adaptive CSI mesh firmware kernel (#404) 2026-04-20 10:38:23 -04:00
rvf_parser.c firmware/esp32-csi-node: IDF 6 build, HE CSI config, unicore DSP, provision chip detect (#522) 2026-05-17 18:00:40 -04:00
rvf_parser.h feat: complete vendor repos, add edge intelligence and WASM modules 2026-03-02 23:53:25 -05:00
stream_sender.c fix: rate-limit CSI sends and add ENOMEM backoff to prevent crash (#132) 2026-03-03 16:00:40 -05:00
stream_sender.h fix(docker): Update Dockerfile paths from src/ to v1/src/ 2026-02-28 13:38:21 -05:00
swarm_bridge.c ADR-110: ESP32-C6 firmware extension (#764) 2026-05-23 15:34:48 -04:00
swarm_bridge.h feat: happiness scoring pipeline + ESP32 swarm with Cognitum Seed (#285) 2026-03-20 18:46:34 -04:00
wasm_runtime.c fix(firmware): defensive node_id capture prevents runtime clobber (#390) 2026-04-15 13:47:34 -04:00
wasm_runtime.h fix(protocol): resolve 0xC511_0004 magic collision (closes #928) (#931) 2026-06-03 11:56:35 +02:00
wasm_upload.c fix: security hardening — replace fake HMAC, add path traversal protection, OTA auth (ADR-050) 2026-03-06 13:11:04 -05:00
wasm_upload.h feat: complete vendor repos, add edge intelligence and WASM modules 2026-03-02 23:53:25 -05:00