Skip to main content
Loading navigation

Build a Sparkplug B Dual-Gateway Telemetry Failover Router — implementation

Prompt source

implementation96 lines11 sectionsNo variables1 code block
## Build
Simulate primary gateway link drops using Sparkplug B edge telemetry. Synthesize backup path failover routing rules, redundant node reconnection sequences, and telemetry consistency audit reports for industrial network admins.

## User
Industrial Automation Network Admin

## Workflow
1. Monitor simulated Sparkplug B edge node heartbeat flags and broker connectivity payload logs.
2. Simulate primary gateway connection timeouts and isolate unacknowledged telemetry batches using sequence numbers.
3. Construct redundant gateway routing rules and generate sequential fallback connection procedures for edge devices.
4. Compile a simulated dual-gateway readiness dossier, summarizing metric continuity risks and secondary bandwidth constraints.

## Interface
Dual-gateway state visualizer with packet transmission timelines, unacknowledged message queues, and simulated failover path configuration.

## Data
Generate synthetic broker logs with Sparkplug B edge node birth, death, and data message traces. Store in a local SQLite file. Log entries should be treated as simplified synthetic app records, not complete official schema files.
Starter examples below are synthetic. They are not downloaded records.

## Source
[Eclipse Sparkplug](https://raw.githubusercontent.com/eclipse-sparkplug/sparkplug/master/README.md)
Sparkplug B stateful MQTT message exchange and edge node sequence numbering (bdSeq) detailed in Source 2.

## Tools
dspy, pydantic, sqlite3.
DSPy compiles robust prompt pipelines to extract outage patterns from dense network log streams.
Fast instruction model capable of log pattern classification and chronological ordering of mock network events.

## 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
- Detects exact sequence number gaps representing isolated batches during simulated gateway transition events.
- Synthesizes chronological failover steps mapping offline nodes to the standby gateway.
- Emits explicit bandwidth limitation warnings when secondary gateway utilization exceeds 85% capacity.

## Starter Examples
```json
[
  {
    "input": {
      "primary_gateway": {
        "id": "GW_01",
        "status": "OFFLINE",
        "last_seq": 105
      },
      "secondary_gateway": {
        "id": "GW_02",
        "status": "STANDBY",
        "bandwidth_util_pct": 35
      },
      "edge_nodes": [
        {
          "node_id": "NODE_PACK_A",
          "unacked_packets": 12,
          "last_seq_sent": 117
        }
      ]
    },
    "expected_output": {
      "failover_feasibility": "FEASIBLE",
      "calculated_data_gap_packets": 12,
      "routing_sequence": [
        "Promote GW_02 from STANDBY to ACTIVE",
        "Route NODE_PACK_A to GW_02",
        "Request replay for seq 106 to 117"
      ],
      "risk_flag": "LOW"
    }
  },
  {
    "input": {
      "primary_gateway": {
        "id": "GW_01",
        "status": "OFFLINE",
        "last_seq": 500
      },
      "secondary_gateway": {
        "id": "GW_02",
        "status": "DEGRADED",
        "bandwidth_util_pct": 94
      },
      "edge_nodes": [
        {
          "node_id": "NODE_LINE_B",
          "unacked_packets": 140,
          "last_seq_sent": 640
        }
      ]
    },
    "expected_output": {
      "failover_feasibility": "CONSTRAINED",
      "calculated_data_gap_packets": 140,
      "routing_sequence": [
        "Throttle non-essential telemetry on NODE_LINE_B",
        "Route NODE_LINE_B to GW_02 at reduced frequency"
      ],
      "risk_flag": "HIGH"
    }
  }
]
```

## Safety
Software rehearsal environment only. All network traffic and broker failover actions are mock-simulated.
Use mock external writes. Require human review before any real deployment.