uns_live_audit
Capture live MQTT topic traffic from an industrial broker, then audit topic naming conformance and sprawl to close the UNS governance loop.
Instructions
[READ][risk=low] Capture the LIVE UNS topic tree (bounded) then audit it.
Closes the governance loop: subscribes to a live broker, collects up to
``max_msgs`` messages or until ``duration_s`` (whichever first), then runs the
naming-conformance + topic-sprawl audit over the observed topics. Never an
open-ended loop.
Args:
endpoint: Endpoint name from config (protocol must be 'mqtt').
topic: Topic filter to capture under (default '#').
duration_s: Capture window in seconds (1..60, capped server-side).
max_msgs: Max messages to capture (1..500, capped server-side).
allowed_roots: Permitted top-level segments; others are flagged (optional).
min_segments: Minimum namespace depth a well-formed topic must have.
max_leaf_parents: A leaf under more than this many parents is scattered.
Returns dict: the uns_topic_audit result (topic_count, depth, verdict, findings)
plus capture:{endpoint, topic, observed_messages, unique_topics, topics[]}.
Example: uns_live_audit(topic="factory/#", duration_s=8, allowed_roots=["factory"]).
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| topic | No | # | |
| endpoint | No | ||
| max_msgs | No | ||
| duration_s | No | ||
| min_segments | No | ||
| allowed_roots | No | ||
| max_leaf_parents | No |