Skip to content

feat(500-application): add 514-wasm-msg-to-dss WASM map operator with DSS enrichment pattern#356

Merged
katriendg merged 11 commits intomainfrom
feat/354-msg-dss
Apr 9, 2026
Merged

feat(500-application): add 514-wasm-msg-to-dss WASM map operator with DSS enrichment pattern#356
katriendg merged 11 commits intomainfrom
feat/354-msg-dss

Conversation

@katriendg
Copy link
Copy Markdown
Collaborator

Description

Added src/500-application/514-wasm-msg-to-dss — a reusable WASM map operator that writes any incoming JSON message to the AIO Distributed State Store (DSS) under a configurable key, then passes the message through unchanged to downstream nodes. This operator enables no-code DSS enrichment in any dataflow graph using AIO's built-in transform capabilities.

The operator extracts keys using RFC 6901 JSON Pointer syntax, supports optional TTL and namespace prefix configuration, and implements a passthrough-first architecture where the original message is always returned regardless of DSS write outcome.

Operator Implementation

The core operator in lib.rs (423 lines) accepts four configuration parameters — keyPath and ttlSeconds (required), keyPrefix and onMissing (optional) — validated exhaustively at init time. The operator extracts scalar values at the specified JSON Pointer path, constructs a namespaced key, writes the full payload to DSS, and returns the message unchanged. Graceful degradation handles non-UTF8 payloads, invalid JSON, missing keys, and DSS write failures with warning logs and passthrough behavior. 22 unit tests cover value conversion, JSON Pointer extraction, and key construction.

Build and Deployment

build-wasm.sh compiles to the wasm32-wasip2 target with an optimized release profile (LTO, panic=abort, size-optimized, stripped binary). push-to-acr.sh publishes the WASM module and graph definition as separate ORAS artifacts to Azure Container Registry, injecting the version from Cargo.toml into the graph YAML at push time.

Blueprint Integration

A dataflow-graphs-msg-to-dss.tfvars.example file was added to blueprints/full-single-node-cluster/terraform/ demonstrating a complete three-node dataflow graph: MQTT source, msg-to-dss-key operator, and MQTT destination. The example indexes device state by /deviceId with a device: prefix and 24-hour TTL, and includes commented alternatives for nested keys, array-indexed keys, and strict error handling.

Related Issue

Closes #354

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Blueprint modification or addition
  • Component modification or addition
  • Documentation update
  • CI/CD pipeline change
  • Other (please describe):

Implementation Details

The operator uses OnceLock<OperatorConfig> for thread-safe singleton configuration and serde_json::Value::pointer() for RFC 6901-compliant JSON Pointer resolution. The wasm_graph_sdk (v1.1.3) from the Azure IoT SDKs registry provides the map operator macro, state store API, and logging infrastructure. The Cargo configuration targets wasm32-wasip2 with --export-table rustflag for Component Model compliance.

The graph definition (graph-msg-to-dss-key.yaml) declares a source → map → sink topology with all four configuration parameters documented. The ${VERSION} placeholder is resolved by envsubst during the ACR push step.

The component directory structure mirrors the existing 512-avro-to-json pattern with .cargo/config.toml, operators/, resources/graphs/, and scripts/ directories.

Testing Performed

  • Terraform plan/apply
  • Blueprint deployment test
  • Unit tests
  • Integration tests
  • Bug fix includes regression test (see Test Policy)
  • Manual validation
  • Other:

22 unit tests validate value conversion (string, integer, float, boolean, null, object, array), JSON Pointer extraction (top-level, nested, array-indexed, deep nesting, missing paths), and key construction (with/without prefix, numeric/boolean values). WASM binary built and pushed to ACR. Dataflow graph deployed and validated with terraform apply on the full-single-node-cluster blueprint.

Validation Steps

  1. Run cargo test in src/500-application/514-wasm-msg-to-dss/operators/msg-to-dss-key/ — 22 tests should pass
  2. Run ./scripts/build-wasm.sh from src/500-application/514-wasm-msg-to-dss/ — WASM binary produced at operators/msg-to-dss-key/target/wasm32-wasip2/release/msg_to_dss_key.wasm
  3. Review dataflow-graphs-msg-to-dss.tfvars.example for correct HCL syntax and graph topology
  4. Verify graph YAML schema and connection definitions in resources/graphs/graph-msg-to-dss-key.yaml

Checklist

  • I have updated the documentation accordingly
  • I have added tests to cover my changes
  • All new and existing tests passed
  • I have run terraform fmt on all Terraform code
  • I have run terraform validate on all Terraform code
  • I have run az bicep format on all Bicep code
  • I have run az bicep build to validate all Bicep code
  • I have checked for any sensitive data/tokens that should not be committed
  • Lint checks pass (run applicable linters for changed file types)

Security Review

  • No credentials, secrets, or tokens are hardcoded or logged
  • RBAC and identity changes follow least-privilege principles
  • No new network exposure or public endpoints introduced without justification
  • Dependency additions or updates have been reviewed for known vulnerabilities
  • Container image changes use pinned digests or SHA references

Additional Notes

  • The tfvars example is an .example file and does not affect existing blueprint deployments.
  • onMissing=error mode drops the message when the key path is not found, which is a deliberate design choice for strict validation scenarios documented in the issue.

Add msg-to-dss-key WASM operator that writes JSON messages to the AIO
Distributed State Store under a configurable key extracted via JSON
Pointer (RFC 6901) with configurable TTL and passthrough behavior.

- Implement operator with OnceLock config, init validation, state store
  write, and 22 unit tests (all passing)
- Create graph definition, build/push scripts, and blueprint tfvars example
- Document enrichment stitching pattern with  syntax
- Update src/500-application/README.md with new component entry
@katriendg katriendg requested a review from a team as a code owner April 7, 2026 13:40
@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 7, 2026

📚 Documentation Health Report

Generated on: 2026-04-07 13:45:05 UTC

📈 Documentation Statistics

Category File Count
Main Documentation 235
Infrastructure Components 192
Blueprints 39
Learning Platform 89
GitHub Resources 44
AI Assistant Guides (Copilot) 17
Total 616

🏗️ Three-Tree Architecture Status

  • ✅ Bicep Documentation Tree: Auto-generated navigation
  • ✅ Terraform Documentation Tree: Auto-generated navigation
  • ✅ README Documentation Tree: Manual README organization

🔍 Quality Metrics

  • Frontmatter Validation:
    success
  • Sidebar Generation: success
  • Link Validation: success
  • Build Test: skipped

This report is automatically generated by the Documentation Automation workflow.

@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 7, 2026

📚 Documentation Health Report

Generated on: 2026-04-07 14:37:10 UTC

📈 Documentation Statistics

Category File Count
Main Documentation 235
Infrastructure Components 192
Blueprints 39
Learning Platform 89
GitHub Resources 44
AI Assistant Guides (Copilot) 17
Total 616

🏗️ Three-Tree Architecture Status

  • ✅ Bicep Documentation Tree: Auto-generated navigation
  • ✅ Terraform Documentation Tree: Auto-generated navigation
  • ✅ README Documentation Tree: Manual README organization

🔍 Quality Metrics

  • Frontmatter Validation:
    success
  • Sidebar Generation: success
  • Link Validation: success
  • Build Test: skipped

This report is automatically generated by the Documentation Automation workflow.

@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 7, 2026

📚 Documentation Health Report

Generated on: 2026-04-07 20:00:18 UTC

📈 Documentation Statistics

Category File Count
Main Documentation 235
Infrastructure Components 192
Blueprints 39
Learning Platform 89
GitHub Resources 44
AI Assistant Guides (Copilot) 17
Total 616

🏗️ Three-Tree Architecture Status

  • ✅ Bicep Documentation Tree: Auto-generated navigation
  • ✅ Terraform Documentation Tree: Auto-generated navigation
  • ✅ README Documentation Tree: Manual README organization

🔍 Quality Metrics

  • Frontmatter Validation:
    success
  • Sidebar Generation: success
  • Link Validation: success
  • Build Test: skipped

This report is automatically generated by the Documentation Automation workflow.

…e_config in msg-to-dss-key

- Add food manufacturing lot traceability use case with ASCII diagram to README
- Extract parse_config() from init for validation logic reuse and testability
- Add comprehensive parse_config unit tests covering valid and invalid inputs

🚀 - Generated by Copilot
@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 8, 2026

📚 Documentation Health Report

Generated on: 2026-04-08 06:40:39 UTC

📈 Documentation Statistics

Category File Count
Main Documentation 235
Infrastructure Components 192
Blueprints 39
Learning Platform 89
GitHub Resources 44
AI Assistant Guides (Copilot) 17
Total 616

🏗️ Three-Tree Architecture Status

  • ✅ Bicep Documentation Tree: Auto-generated navigation
  • ✅ Terraform Documentation Tree: Auto-generated navigation
  • ✅ README Documentation Tree: Manual README organization

🔍 Quality Metrics

  • Frontmatter Validation:
    success
  • Sidebar Generation: success
  • Link Validation: success
  • Build Test: skipped

This report is automatically generated by the Documentation Automation workflow.

@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 9, 2026

📚 Documentation Health Report

Generated on: 2026-04-09 08:20:44 UTC

📈 Documentation Statistics

Category File Count
Main Documentation 233
Infrastructure Components 196
Blueprints 39
Learning Platform 89
GitHub Resources 49
AI Assistant Guides (Copilot) 17
Total 623

🏗️ Three-Tree Architecture Status

  • ✅ Bicep Documentation Tree: Auto-generated navigation
  • ✅ Terraform Documentation Tree: Auto-generated navigation
  • ✅ README Documentation Tree: Manual README organization

🔍 Quality Metrics

  • Frontmatter Validation:
    success
  • Sidebar Generation: success
  • Link Validation: success
  • Build Test: skipped

This report is automatically generated by the Documentation Automation workflow.

@katriendg katriendg merged commit db882a5 into main Apr 9, 2026
38 checks passed
@katriendg katriendg deleted the feat/354-msg-dss branch April 9, 2026 08:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(app): add 514-wasm-msg-to-dss WASM map operator with DSS enrichment pattern

2 participants