Build a Sparkplug B Edge Device Connection Lifecycle Monitor — implementation
Linked challenge: Build a Sparkplug B Edge Device Connection Lifecycle Monitor
Prompt source
implementation85 lines11 sectionsNo variables1 code block
## Build
Monitor Sparkplug B DBIRTH, NDEATH, and DDEATH payloads to verify stateful device connection sequences. Generate connection audit reports identifying orphaned nodes or malformed birth sequences for network reliability engineers.
## User
IIoT Network Reliability Engineer
## Workflow
1. Ingest simulated Sparkplug B lifecycle payloads including DBIRTH, NDEATH, and DDEATH messages.
2. Validate MQTT topic structures and sequence numbers against the Eclipse Tahu specification rules.
3. Identify out-of-order state transitions or orphaned devices lacking proper death certificates.
4. Synthesize mock connection audit reports detailing non-compliant edge node behaviors and state machine violations for human review.
## Interface
CLI dashboard or web console summarizing node connectivity states and audit reports of sequence gaps.
## Data
Generate simplified synthetic Sparkplug B JSON payloads reflecting state transitions with intentional sequence gaps and disconnected node scenarios.
Starter examples below are synthetic. They are not downloaded records.
## Source
[Eclipse Sparkplug](https://raw.githubusercontent.com/eclipse-sparkplug/sparkplug/master/README.md)
Implements Sparkplug B specification rules for connection lifecycle tracking and birth/death certificates.
## Tools
mastra-ai, paho-mqtt, pydantic.
Mastra AI provides deterministic workflow orchestration suited for evaluating sequential payload streams and triggering conditional audit alerts.
Requires an agent capable of structured parameter evaluation; lightweight local or hosted model.
## Deliverables
Submit runnable source, pinned dependencies, setup commands, a working interface, example outputs, and a recorded end-to-end demo. Include tests and an action log.
## Acceptance
- Parses normalized Sparkplug B lifecycle payloads according to specification v3.0.0 conventions.
- Flags nodes with sequence number gaps or missing DBIRTH baseline messages.
- Generates structured audit reports for orphaned nodes lacking death certificates.
- Properly tracks node connectivity states across message types to enforce sequence logic.
## Starter Examples
```json
[
{
"input": {
"node_id": "EdgeGateway_01",
"record_type": "simplified_synthetic_app_record",
"events": [
{
"message_type": "DBIRTH",
"seq": 0
},
{
"message_type": "DDATA",
"seq": 1
},
{
"message_type": "DDATA",
"seq": 3
}
]
},
"expected_output": {
"node_id": "EdgeGateway_01",
"status": "SEQUENCE_VIOLATION",
"orphaned_node": false,
"missing_sequences": [
2
],
"audit_recommendation": "Investigate dropped MQTT packets"
}
},
{
"input": {
"node_id": "EdgeGateway_02",
"record_type": "simplified_synthetic_app_record",
"events": [
{
"message_type": "DBIRTH",
"seq": 0
}
],
"current_broker_status": "DISCONNECTED"
},
"expected_output": {
"node_id": "EdgeGateway_02",
"status": "ORPHANED_NODE",
"orphaned_node": true,
"missing_sequences": [],
"audit_recommendation": "Missing NDEATH certificate"
}
}
]
```
## Safety
Maintains read-only monitoring of message payloads without altering broker states or dropping client connections.
Use mock external writes. Require human review before any real deployment.