Skip to content

Commit 917c9b2

Browse files
Merge pull request #171 from thegridelectric/dev
0.5.6 -- gnrmic_tx -> amq.topic etc
2 parents 787ebb7 + 8441274 commit 917c9b2

9 files changed

Lines changed: 60 additions & 8 deletions

File tree

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "gridworks-base"
3-
version = "0.5.5"
3+
version = "0.5.6"
44
description = "Gridworks Base"
55
readme = "README.md"
66
authors = [

rabbit/rabbitconfig/dev_definitions.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,14 @@
167167
"routing_key": "rjb.#",
168168
"source": "timemic_tx",
169169
"vhost": "d1__1"
170+
},
171+
{
172+
"arguments": {},
173+
"destination": "amq.topic",
174+
"destination_type": "exchange",
175+
"routing_key": "rjb.#",
176+
"source": "gnrmic_tx",
177+
"vhost": "d1__1"
170178
}
171179
],
172180
"exchanges": [

rabbit/rabbitconfig/prod_definitions.json renamed to rabbit/rabbitconfig/hybrid_definitions.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,14 @@
167167
"routing_key": "rjb.#",
168168
"source": "timemic_tx",
169169
"vhost": "hw1__1"
170+
},
171+
{
172+
"arguments": {},
173+
"destination": "amq.topic",
174+
"destination_type": "exchange",
175+
"routing_key": "rjb.#",
176+
"source": "gnrmic_tx",
177+
"vhost": "hw1__1"
170178
}
171179
],
172180
"exchanges": [

src/gwbase/rabbit_definitions.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,15 @@
2020
# The committed broker-definitions artifacts: filename -> build kwargs.
2121
# Single source for both the generator (writes them) and the CI drift-guard
2222
# (test_definitions_drift.py regenerates and diffs). Dev carries the
23-
# non-secret smqPublic credential; prod carries none (injected at deploy).
23+
# non-secret smqPublic credential; hybrid carries none (injected at deploy).
24+
# A vhost is `<universe>__<run>` — run 1 of each universe here; provisioning
25+
# a further run of a universe (hw1__2, …) regenerates with that vhost.
2426
DEFINITION_ARTIFACTS: list[tuple[str, dict[str, Any]]] = [
2527
(
2628
"dev_definitions.json",
2729
{"vhost": "d1__1", "user": "smqPublic", "password": "smqPublic"},
2830
),
29-
("prod_definitions.json", {"vhost": "hw1__1"}),
31+
("hybrid_definitions.json", {"vhost": "hw1__1"}),
3032
]
3133

3234
# Fixed 4-byte salt so the dev password hash is deterministic (the dev

src/gwbase/topology.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,18 @@ def exchange_bindings() -> list[BindingSpec]:
130130
f"{MessageCategory.JsonBroadcast.value}.#",
131131
)
132132
)
133+
# Same bridge for the grid-node-registry's BROADCASTS (`g.node.forest`
134+
# topology changes, radio_channel = the audience-known alias), so
135+
# MQTT-native actors can passively hear ancestor renames too. The forest
136+
# carries aliases + immutable ids only — never coordinates — so it is
137+
# safe to cross to the MQTT side.
138+
bindings.append(
139+
BindingSpec(
140+
publish_exchange(RoutingClass.GridNodeRegistry),
141+
AMQP_TOPIC,
142+
f"{MessageCategory.JsonBroadcast.value}.#",
143+
)
144+
)
133145
return bindings
134146

135147

src/gwbase/transport_encoding.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,20 @@
1111
class TransportClass(StrEnum):
1212
"""Closed taxonomy of routable classes on the rabbit transport. This
1313
is NOT Sema vocabulary; in particular ``Supervisor`` is not a member of
14-
``gw.g.node.class`` because a Supervisor is not a GNode."""
14+
``gw.g.node.class`` because a Supervisor is not a GNode.
15+
16+
Actor-tier map (which runtime tier a class rides):
17+
18+
- **Orchestrator (non-GNode, ServiceSettings):** ``Supervisor``,
19+
``TimeCoordinator``, ``GridNodeRegistry`` — orchestration/infra
20+
participants with no ``g.node.gt`` identity file at boot.
21+
- **GridworksActor (GNode identity):** ``TerminalAsset``,
22+
``LeafTransactiveNode``, ``MarketMaker``, ``PriceForecastService``,
23+
``WeatherForecastService``.
24+
- **No gwbase runtime:** ``Scada`` (MQTT-native, reached via
25+
``amq.topic``) and ``ConnectivityNode`` (passive — a map vertex,
26+
not an actor).
27+
"""
1528

1629
TerminalAsset = "TerminalAsset"
1730
LeafTransactiveNode = "LeafTransactiveNode"

tests/test_rabbit_definitions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def test_dev_definitions_include_user_and_permissions() -> None:
3535
]
3636

3737

38-
def test_prod_definitions_have_no_baked_credential() -> None:
38+
def test_hybrid_definitions_have_no_baked_credential() -> None:
3939
d = build_definitions(vhost="hw1__1")
4040
assert d["vhosts"] == [{"name": "hw1__1"}]
4141
assert d["users"] == []

tests/test_topology.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,9 @@ def test_exchanges_cover_ear_plus_a_pair_per_class() -> None:
5555
def test_bindings_cover_edges_and_ear_taps() -> None:
5656
bindings = topo.exchange_bindings()
5757
# one per routing edge, plus one ear tap per AMQP class, plus the
58-
# amq.topic ear tap, plus the timemic -> amq.topic MQTT bridge tap
59-
assert len(bindings) == len(topo.ROUTING_EDGES) + len(topo.AMQP_ACTOR_CLASSES) + 2
58+
# amq.topic ear tap, plus the timemic and gnrmic -> amq.topic MQTT
59+
# bridge taps
60+
assert len(bindings) == len(topo.ROUTING_EDGES) + len(topo.AMQP_ACTOR_CLASSES) + 3
6061

6162
# a known direct edge: ltnmic_tx -> super_tx on *.*.ltn.*.super.*
6263
assert any(
@@ -78,3 +79,11 @@ def test_bindings_cover_edges_and_ear_taps() -> None:
7879
and b.routing_key == "rjb.#"
7980
for b in bindings
8081
)
82+
# registry broadcasts (g.node.forest) cross too, so MQTT-native actors
83+
# can passively hear ancestor renames
84+
assert any(
85+
b.source == "gnrmic_tx"
86+
and b.destination == "amq.topic"
87+
and b.routing_key == "rjb.#"
88+
for b in bindings
89+
)

uv.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)