Skip to content

feed-definitions Specification

Purpose

Feed definitions: shared JSON documents on a context (cfg.feed.<NAME>) that say which market-data topics a set of WebSocketFeed connections serves, and how clients connect and disconnect them.

Requirements

Requirement: Feed Definition Document

A feed definition SHALL be a JSON document describing the WebSocketFeed connections (websocket-feed) that serve a set of market-data topics: name (an identifier: lower-case letters, digits and _, at most 32, with a letter), optional description, preset (a venue preset of market-data-devkit), world (act or hyp.<NAME>, default act), optional universe and the topics (Feed Topics). It MAY carry $schema.

Scenario: A name with a capital

  • WHEN a definition's name is Binance_BTC
  • THEN validation SHALL refuse it at /name

Requirement: Feed Definition Settings

A definition SHALL also carry reconnect (boolean, default true: the feeds' autoreconnect), secrets (feed secret name to a reference into the cluster's worker Secret, never a value) and feed (further feed config keys, strings). Unknown keys SHALL be refused by name; the fields of the TUI's World definitions this version does not support (type, ws_url, handshake, subscribe, routing, topic) SHALL be refused naming them.

Scenario: An unsupported field

  • WHEN a definition carries handshake
  • THEN validation SHALL refuse it with the path /handshake and say the field is not supported yet

Requirement: Feed Topics

A definition's topics SHALL be its topics (templates like the worker registry's, re-bound to its world and expanded from pairs and intervals), else pairs x families (x intervals for a family whose entity has an interval, e.g. candle.update), each family named by the naming library at the preset's venue for the definition's world. A definition SHALL name at least one topic.

Scenario: Candles per interval

  • WHEN a definition has preset binance, pairs BTC_USDT, families candle.update and intervals 1m,5m
  • THEN its topics SHALL be act.exchange.binance.candle.update.BTC_USDT.1m and act.exchange.binance.candle.update.BTC_USDT.5m

Requirement: Feed Topic Checks

A family that needs intervals the definition does not give SHALL be an error naming it. pairs or intervals that none of its topics binds (e.g. intervals next to orderbook.update only) SHALL be a warning at its path, naming the families that would use them; it SHALL not prevent saving.

Scenario: Unused intervals

  • WHEN a definition has preset binance, pairs BTC_USDT, families orderbook.update and intervals 1m
  • THEN it SHALL be valid with the topic act.exchange.binance.orderbook.update.BTC_USDT and warn at /intervals that no family listed takes an interval (candle.update does)

Requirement: Shared Feed Definitions

Definitions SHALL be kept in the context's state at cfg.feed.<NAME> with their names in cfg.feed.index (market-data-devkit's naming fragment, entity feed_registry), shared by every client of the context. Only admins SHALL write them, through the write gate.

Scenario: Seen by every client

  • WHEN an admin saves a definition in one client
  • THEN every client of that context SHALL list it

Requirement: Connect and Disconnect

Connecting a definition SHALL resolve its topics with market-data-devkit's resolver (owner = the definition's name, its preset for its venue, the owner's current feeds) and refuse an incomplete plan naming the topics left out. A definition's feeds SHALL be the members of its feed group (id from market-data-devkit's naming fragment). Disconnecting SHALL delete that group. Nothing SHALL connect a definition on its own.

Scenario: Disconnect

  • WHEN the user disconnects a definition with two feeds
  • THEN its feed group SHALL be deleted, and both feeds with it

Requirement: Applying a Feed Plan

Connecting SHALL apply the plan: - create the definition's feed group if it is missing; - create or serve each feed as a member of that group; - delete the group's feeds the plan no longer names, with the definition's secrets, feed keys and reconnect, tagging the feeds with the standard tags name, world, universe, venue, endpoint and managed-by.

Connecting again after an edit SHALL bring the feeds to the edited topics.

Scenario: Reconnect after an edit

  • WHEN a connected definition gains a pair and is connected again
  • THEN its feed SHALL serve the new pair's topics as well, without a second feed while the preset's limits allow

Requirement: Feed Status

A client SHALL show a definition's state from the members of its feed group: disconnected (none), connected (all report connected), partly connected otherwise, with their message rate and latency.

Scenario: Partly connected

  • WHEN one of a definition's two feeds reports connecting
  • THEN the definition SHALL show partly connected

Scenario: Asked while connecting

  • WHEN a feed answered status with connecting and later reports connected in a lifecycle status event
  • THEN the client SHALL show it connected (the newer report wins)

Requirement: Feed Definition Schema and Conformance

The definition's JSON Schema SHALL be published (feed-definition.v1.schema.json), generated from the validator and checked for drift. Conformance vectors (conformance/feed-definitions/: documents, their verdicts and their topics) SHALL be run by every client; they live with the web app, the first client, until the TUI implements this spec.

Scenario: Vectors in a client

  • WHEN a client implements feed definitions
  • THEN it SHALL pass every conformance vector