Topology
Reference for the Topology view's shared data (openspec change groups-and-topology:
topology). It covers nodes and links through topics, topic families, health
levels, group health, derived group links, "upstream failing", "no producer seen"
and the grouping tree. The web app and the TUI compute the view from what they
already hold: the workers, triggers and groups they read once and keep current
from pushed events. They import the function below and copy no topology logic. A
client that computes the view itself checks its result against the same vectors.
Python (virtufin.domain_devkit.topology) |
TypeScript (@virtufin/domain-devkit) |
|---|---|
build_topology(snapshot: Mapping[str, Any], names: NameRegistry) -> dict[str, Any] |
buildTopology(input: TopologyInput, names: NameRegistry): Topology |
worker_level(worker: Mapping[str, Any]) -> str |
workerLevel(worker: TopologyWorker): HealthLevel |
trigger_level(trigger: Mapping[str, Any], listened: Iterable[str]) -> str |
triggerLevel(trigger: TopologyTrigger, listened: ReadonlySet<string>): HealthLevel |
topic_family(topic, names) |
topicFamily(topic, names) (topic families) |
FAILING, DEGRADED, IDLE, OK, LEVELS, SEVERITY |
LEVEL_FAILING … LEVEL_OK, HEALTH_LEVELS, HEALTH_SEVERITY |
clients.topology_vectors(name) |
TOPOLOGY_VECTORS[name] |
Both functions are pure: no I/O and no clock. The TypeScript one is browser-safe.
names composes every fragment whose topics are shown, as for topic_family.
Input
| Item | Fields |
|---|---|
| worker (or connection) | id; state, the last lifecycle transition (registered, loaded, starting, online, degraded, failed, load-failed, stopped); status, the last status report since it came online; gap, an input gap since it came online; paced, outputs held by pacing; inputs, its topics; outputs, its recorded output topics (WorkerInfo.output_topics); groups; tags |
| trigger | id; target, the target topic; scheduled; groups |
| group | id; parents |
An absent list is empty, an absent flag is false and an absent status is none. The
client clears status and gap when the worker comes online again. Only the
endpoint tag (worker-devkit's infra key) is read. Other tags never change the view.
Health levels
| Level | Worker or connection | Trigger |
|---|---|---|
| failing | failed or load-failed; or up (online, degraded) and reports lease-lost or failed |
— |
| degraded | up, and degraded, or reports degraded or disconnected, or gap, or paced |
scheduled, and no worker listens to its target |
| idle | not up: stopped, registered, loaded, starting (whatever it reported before) |
not scheduled |
| ok | online with none of the above |
scheduled, and a worker listens to its target (also a stopped one) |
Failing outranks degraded. There is no silence detection: a worker that has published nothing for an hour is ok.
Output
| Part | Python key | TypeScript key | What it holds |
|---|---|---|---|
| workers | workers |
workers |
id, level, upstream_failing / upstreamFailing: the failing workers recorded to publish to one of its input topics, itself excluded. The mark never changes a level. |
| triggers | triggers |
triggers |
id, level |
| topic families | families |
families |
family, topics, count, no_producer_seen / noProducerSeen: workers listen to the family, but neither a worker is recorded to publish to it nor a trigger targets it |
| endpoints | endpoints |
endpoints |
the distinct endpoint tag values |
| links | links |
links |
from, to ({kind, id}, kind trigger, family, worker or endpoint) and the topics the link carries: trigger → target family, family → listening worker, worker → recorded output family, worker → endpoint. No link joins two workers, or a trigger and a worker. |
| group health | groups |
groups |
id, level, counts per level, total, descendants. These count the distinct workers and triggers of the group and its descendants, so an item reached by several paths counts once. The level is the worst of the non-idle items, and idle when all are idle (an empty group is idle). |
| derived group links | group_links |
groupLinks |
{from, to}: a direct member of from listens to a topic a direct member of to is recorded to publish to. Never from a group to itself. |
| tree | tree |
tree |
the root groups, each {kind: group, id, shared, children}, then {kind: ungrouped, children} when items are in no group. Children are the child groups, then workers, then triggers, as {kind, id, shared}. A group under several parents appears under each, and so does an item in several groups. Both are marked shared. Ids of unknown groups are ignored. |
Every list is sorted: ids and topics by code point, links by from kind, from id,
to kind, to id. Two clients therefore agree exactly. To filter to one group, use
its descendants.
from virtufin_naming import NameRegistry
from virtufin.domain_devkit.topology import build_topology
view = build_topology(
{
"triggers": [{"id": "tick.1m", "target": "x.demo.tick.1m", "scheduled": True}],
"workers": [{"id": "s", "state": "online", "inputs": ["x.demo.tick.1m"]}],
},
NameRegistry.load(),
)
view["links"] # tick.1m -> x.demo.tick.1m -> s
Vectors
topology/topology.v1.json holds one case per scenario of the topology spec, plus
edge cases: every worker level, trigger levels, a trigger with no listener, a
family fed only by a trigger, a
diamond of groups (members counted once), an empty group, a group under several
parents, ids of unknown groups, and links only through topics. A case lists only
the parts it is about. The fixture fragment test.market.yaml supplies the market
topics. The package ships the vectors, as TOPOLOGY_VECTORS in TypeScript and
clients.topology_vectors(name) in Python, so a client can also run them.