refactor(bus): rename ORCHESTRATOR_ACTIVITY → ORCHESTRATOR_TRAFFIC

Aligns the bus token with the DB column value; OrchestratorEvent.kind
is 'traffic'/'file' but the topic was 'activity'/'file'. The asymmetry
made consumer code (UI filter, SSE event names) need a translation
layer. No external subscribers existed yet.
This commit is contained in:
2026-04-26 19:53:40 -04:00
parent 4c37ece39e
commit 900c0c3ef5
2 changed files with 5 additions and 5 deletions

View File

@@ -10,7 +10,7 @@ Token structure (NATS-style, dot-separated):
topology.{topology_id}.status
decky.{decky_id}.state
decky.{decky_id}.traffic
orchestrator.activity.{decky_id}
orchestrator.traffic.{decky_id}
orchestrator.file.{decky_id}
attacker.observed
attacker.scored
@@ -170,7 +170,7 @@ CREDENTIAL_REUSE_DETECTED = "reuse.detected"
# static. Always nested with the destination decky uuid as the third
# token, so consumers can subscribe to a single decky's life-injection
# stream via ``orchestrator.*.<decky_uuid>``.
ORCHESTRATOR_ACTIVITY = "activity"
ORCHESTRATOR_TRAFFIC = "traffic"
ORCHESTRATOR_FILE = "file"
# System event types.
@@ -296,7 +296,7 @@ def identity(event_type: str) -> str:
def orchestrator(event_type: str, decky_id: str) -> str:
"""Build ``orchestrator.<event_type>.<decky_id>``.
*event_type* should be one of :data:`ORCHESTRATOR_ACTIVITY` or
*event_type* should be one of :data:`ORCHESTRATOR_TRAFFIC` or
:data:`ORCHESTRATOR_FILE`. The destination decky is always the
third token so per-decky subscribers can use
``orchestrator.*.<decky_uuid>``.

View File

@@ -39,7 +39,7 @@ def to_row(action: Action, result: ActivityResult) -> dict[str, Any]:
def topic_for(action: Action) -> str:
"""Map an action to its bus topic."""
if isinstance(action, TrafficAction):
return _topics.orchestrator(_topics.ORCHESTRATOR_ACTIVITY, action.dst_uuid)
return _topics.orchestrator(_topics.ORCHESTRATOR_TRAFFIC, action.dst_uuid)
if isinstance(action, FileAction):
return _topics.orchestrator(_topics.ORCHESTRATOR_FILE, action.dst_uuid)
raise TypeError(f"unsupported action type: {type(action)!r}")
@@ -47,7 +47,7 @@ def topic_for(action: Action) -> str:
def event_type_for(action: Action) -> str:
if isinstance(action, TrafficAction):
return _topics.ORCHESTRATOR_ACTIVITY
return _topics.ORCHESTRATOR_TRAFFIC
if isinstance(action, FileAction):
return _topics.ORCHESTRATOR_FILE
raise TypeError(f"unsupported action type: {type(action)!r}")