Skip to content

Specifications (behaviour briefs and executable specs)

The specifications/ folder is the SDK's source of truth for what the runtime is supposed to do: prose briefs under prompts/ and Gherkin scenarios under specs/ that pytest-bdd executes inside the normal test run. This page lists every brief with a link into GitLab, explains how the .feature files bind to tests/ and count towards the coverage job, and records the inconsistencies worth fixing. The folder sits outside the documentation tree on purpose: it names engine, proxy and Consul internals and is denylisted for the vendored node-author guide.

Layout

specifications/
  README.md                  layout, framework, substrate, how to add a feature
  external-dependencies.md   sibling repos and private wheels the specs assume
  prompts/                   prose briefs: general.md, 001..003 (purpose, architecture, glossary), 1XX/2XX per feature
  specs/<area>/0NN-*.feature Gherkin scenarios, one directory per feature area
  specs/steps/*.py           step definitions (outcome_steps.py is generic, the rest are SDK-specific)

The convention comes from the sibling neuraverse-node-engine and neuraverse-node-engine-proxy repositories: code is added in response to a failing specification, not the other way round. Read prompts/general.md before any numbered prompt; it carries the cross-cutting rules and the step-layer reuse principle.

Behaviour briefs (specifications/prompts/)

All links point at main; replace main with a tag to read the brief as it was at a release.

Number Brief Purpose
general general.md Cross-cutting principles for every spec and feature area; read first.
001 001-system-purpose.md What the SDK is for: the library every node container imports, the node classes that extend it.
002 002-architecture.md Read-once component map of the node container process. The current transition table is in Architecture.
003 003-key-concepts.md Glossary used across prompts, feature files and step modules.
120 120-initialize-node.md NodeBase.initialize(): the one-time setup per lifecycle issued by NodeController.initialize_node.
130 130-run-node.md NodeBase.execute() and execute_background(): one run of the node's work on its own thread.
140 140-stop-node.md NodeBase.stop(): the idempotent destroy chain behind StopNode.
160 160-reconfigure-lifecycle.md Stop, Configure, Run cycles; the highest-priority field-bug surface ("second Run does nothing").
170 170-status-resend.md Status-stream re-send and the [resend] marker on heartbeat items.
171 171-status-resend-proto-followup.md Follow-up: an is_resend proto field to replace the string prefix (needs an entities change).
180 180-pause-resume.md pause() and resume() as in-process entry points for PauseNode and ResumeNode.
190 190-status-stream-subscriber.md SubscribeNodeStatusStream subscriber lifecycle: fan-out, sentinel, replay buffer. See Status and health streams.
200 200-data-viz-topics.md GetDataVisualizationTopics: read-only enumeration of what the UI can subscribe to.
210 210-data-visualization.md StartDataVisualization and StopDataVisualization: the streamer bridge, extend-in-place, PASSIVE on node stop, sources-ready timeout. See Data visualization streamer.
220 220-mqtt-triggers.md Cross-node MQTT trigger propagation from publisher to every subscribed node.
230 230-dataflow-routing.md CompositeDataFlow routing: which adapter publishes each output port and receives each input port.
240 240-service-registry-resilience.md Behaviour when the Consul agent is unreachable during register_node at bootstrap. See Registration and discovery.

There is no numbered brief for the admin REST API (specs/admin/), the gRPC routing layer (specs/grpc-routing/), the controller lifecycle scenarios (specs/controller-lifecycle/) or the scene-builder client (specs/scene-builder/); those areas are specified by their feature files alone.

How the specs run

The framework is pytest-bdd: Gherkin .feature files plus Python step definitions, same runner and same coverage report as the unit tests. The wiring is:

Piece Where Role
bdd_features_base_dir = "specifications/specs" pyproject.toml, [tool.pytest.ini_options] Resolves the relative directory each loader passes to scenarios().
pythonpath = ["."] and asyncio_mode = "auto" same block Makes the repo root importable and runs async steps without markers. Marker spec is declared for the BDD scenarios.
tests/specs/test_<area>_specs.py one file per area A two-line loader: from pytest_bdd import scenarios; scenarios("<area>"). Its docstring names the prompt the area implements.
tests/specs/conftest.py Prepends the repo root to sys.path and star-imports the step modules from specifications/specs/steps/, each listed explicitly, so pytest sees the step registrations and fixtures.
specifications/specs/steps/*.py Step definitions. outcome_steps.py is the generic allow/deny outcome capture (the engine and proxy repositories publish equivalent modules); the others are SDK-specific.

Feature areas and their loaders:

specs/<area>/ Loader Brief
admin test_admin_specs.py none
controller-lifecycle test_controller_lifecycle_specs.py none
dataflow-routing test_dataflow_routing_specs.py 230
data-visualization test_data_visualization_specs.py 210
data-viz-topics test_data_viz_topics_specs.py 200
grpc-routing test_grpc_routing_specs.py none
initialize test_initialize_specs.py 120
lifecycle test_lifecycle_specs.py 160
mqtt-triggers test_mqtt_triggers_specs.py 220
pause, resume test_pause_specs.py, test_resume_specs.py 180
run test_run_specs.py 130
scene-builder test_scene_builder_specs.py none
service-registry test_service_registry_specs.py 240
status-resend test_status_resend_specs.py 170
status-stream-subscriber test_status_stream_subscriber_specs.py 190
stop test_stop_specs.py 140

Substrate

The SDK has no storage, so the specs run entirely in-process and patch at the boundary: the MQTT broker at the MQTTHandler singleton (connect, subscribe, publish are tracked, never sent), gRPC node services at the NodeClient level, LiveKit at the data_visualization_streamer module, ROS at the ROSDataFlowAdapter. specifications/README.md reserves a future @e2e tier that would bring the SDK up in a subprocess against a real MQTT broker.

The coverage job

.gitlab-ci.yml runs one coverage job on merge requests, branches and tags:

PYTHONPATH="$(pwd):$(pwd)/src:$PYTHONPATH" poetry run pytest --cov=neuraverse_sdk \
    --cov-report=term --cov-report=html --cov-report=xml tests examples
poetry run coverage report -m

PYTHONPATH must contain the project root: without it the specifications package does not import, pytest-bdd silently loads no scenarios, and the coverage number drops to the unit tests alone. examples/ is part of the run because the guide's example nodes carry their own tests. The thresholds and exclusions live in pyproject.toml: fail_under = 70 (lowered from 80 when the suite moved from unit tests to specs, to be raised again once a LiveKit plus ROS harness covers the streamer), branch coverage on, node_manager_service.py and api/http/* omitted. The job publishes a Cobertura report and the htmlcov/ artifact; the badge regex is TOTAL.+ ([0-9]{1,3}%).

Run the same thing locally from neuraverse-node-sdk-python/; tests/specs -q alone is enough while iterating on a feature file.

Adding a feature

  1. Write the prompt in prompts/ (prose: what the SDK does, required behaviour, what the spec does not cover, tier coverage).
  2. Add .feature files under specs/<area>/ with executable scenarios.
  3. Add or extend step definitions in specs/steps/, and register a new module in tests/specs/conftest.py.
  4. For a new area, add tests/specs/test_<area>_specs.py with scenarios("<area>").
  5. Run poetry run pytest tests/specs; the new scenarios must fail first, then production code makes them pass.

Unit tests in tests/ stay for algorithmic edge cases that do not read well in Gherkin. Coverage is the union of both.

Known inconsistencies

  • prompts/210-data-visualization.md links to tests/test_data_visualization_streamer.py, which no longer exists; the streamer's remaining unit tests are tests/test_data_visualization_ice.py and tests/test_data_visualization_json.py.
  • external-dependencies.md lists the private wheels at neuraverse_entities_apis_messages 2.4.0, lib-python-neuraverse-common 2.6.0 and the service libraries at 2.2.0; pyproject.toml pins 2.38.0, ^2.9.0, 2.3.0 and 2.6.0. The pyproject is authoritative; the release tooling reads it, not the lock file or this table.
  • prompts/002-architecture.md predates the 2.39 pause and resume semantics; use Architecture for the state table.