feat(tra-922): MQTT topic routing — {org_slug}/ prefix + data-driven subscriptions#475
Open
mikestankavich wants to merge 9 commits into
Open
feat(tra-922): MQTT topic routing — {org_slug}/ prefix + data-driven subscriptions#475mikestankavich wants to merge 9 commits into
mikestankavich wants to merge 9 commits into
Conversation
…riven MQTT subscriptions Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Subscriber subscribes to exactly the registered publish_topics via the topicroute registry (OnConnect bulk-subscribe + per-CRUD Subscribe/Unsubscribe + 5m reconcile ticker), instead of a static MQTT_TOPIC firehose. handleMessage routes via the registry map with a resolve_scan_topic fallback. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…gistry on CRUD Create/Update validate that an mqtt publish_topic starts with the caller org's identifier (400 on violation); unchanged topics on edit are grandfathered; web_ble devices are exempt. Successful CRUD reconciles the topic registry so the subscriber tracks adds/removes inline. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
… parse Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
🚀 Preview Deployment Update ✅ This PR has been successfully merged into the preview branch. The preview environment will update shortly at: https://app.preview.trakrf.id |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
TRA-922 — MQTT topic routing:
{org_slug}/-prefixedpublish_topic+ data-driven subscriptionsCloses the two problems surfaced 2026-06-04: the coarse
MQTT_TOPICfilter silently constrained the "free-form"publish_topic, and cross-org topic collisions were latent under the per-org-only unique index.Decisions (resolved with Mike)
publish_topics are forced to start with{org_slug}/(organizations.identifier, globally unique → cross-org collision structurally impossible; sets up the{org_slug}/#ACL namespace for TRA-857). Thetrakrf.id/root is dropped.trakrf.id/C4DEE229A176/reads, MK107, …) keep working untouched.#-firehose + cache). A newtopicrouteregistry owns both the in-memorypublish_topic→routemap (message routing) and the broker subscription set. The subscriber subscribes to exactly the registered topics — the broker filters, not the app — soMQTT_TOPICretires entirely (no static filter to configure, no cloud chart hand-off needed),publish_topicstays truly free-form, and there's no negative cache.What's here
list_active_scan_topics()(SECURITY DEFINER) — enumerates every org's live mqtt topics for the registry;resolve_scan_topickept as the message-path fallback.internal/services/topicroute—Registry(Reconcile / Lookup / Topics / SetManager); reconciles on boot, on scan-device CRUD, on a 5-min ticker, and on every MQTTOnConnect(bulk re-subscribe).OnConnectbulk-subscribesregistry.Topics();Subscribe/Unsubscribeapply CRUD deltas;handleMessageroutes via the registry with aresolve_scan_topicfallback.MQTT_TOPICremoved from config +deploy/edge/.env.example.{org_slug}/prefix (400 on violation; web_ble exempt; unchanged-topic edits grandfathered) and reconciles the registry after each mutation./users/me—current_org.identifieradded so the UI can prefill the prefix.readerKeyFromTopic(backend + frontend) — relaxed the fixedtrakrf.id/root to any first segment so Live Reads keeps working for both new and grandfathered topics.ScanDeviceFormprefills{org_slug}/on create + help text.Tests (all green)
topicrouteregistry (add/remove/no-manager/snapshot),config(MQTT_TOPIC retired),readerKeyFromTopic(both schemes),ScanDeviceFormprefill.list_active_scan_topics(mqtt-only, excludes web_ble/deleted), scan-device prefix validation (wrong/correct/grandfathered/no-identifier),/users/meidentifier.just backend build, frontendtypecheck/lint/test(1184 passing)..envshould dropMQTT_TOPIC— subscriptions are now data-driven. Grandfathered demo topics keep flowing regardless (the subscriber subscribes to them by exact string).mqtt.topicchange is required (the static filter is gone, not relaxed).🤖 Generated with Claude Code