Skip to main content

Module contract

Module contract 

Source
Expand description

Contract monitors on target, and the /diagnostics reporter they publish through — issues 1635 and 1676, ONE implementation for every language.

RFC-0052 / phase-296 W3b: a contracted image bakes monitor tables (min_rate_hz / max_latency_ms per publisher, max_age_ms per subscriber), the executor checks them every spin and logs each violation at detection (issue 0514’s floor). Issue 1635 made a C or C++ image also PUBLISH each one as a DiagnosticArray on /diagnostics, through a reporter nros-cpp armed when the tables were installed. The Rust entry (nros::main!) installed no table at all (issue 1676), so it neither monitored nor reported.

This module is that reporter, moved up to the umbrella so the three languages share it: DiagSink (one /diagnostics publisher and its two counters) and its violation sink, used by nros-cpp‘s nros_cpp_install_monitors and by install_contract_monitors, which the nros::main! expansion calls before the first node is created. The mapping from a violation to a report is nros-diagnostics’ (DiagnosticReporter::report_violation, streamed by write_violation_reports so the report never sits on the spin thread’s stack as a value), so a violation reads the same from every road. The executor hands the reporter its queued verdicts off the judged dispatch (phase-474 I7), and one report carries as many as fit one message.

Structs§

ContractReporter
Static storage for one executor’s DiagSink — what a Rust entry owns in place of the C++ context’s diag field.
DiagSink
One executor’s /diagnostics reporter: the publisher and two counters.

Constants§

DIAG_TOPIC
The topic ROS 2’s diagnostics tooling reads.

Functions§

arm_reporter⚠
Arm one executor’s /diagnostics reporter in slot, and point the executor’s violation sink at it — THE arming step, shared by install_contract_monitors (Rust) and nros-cpp’s nros_cpp_install_monitors (C and C++), issue 1693.
install_contract_hazards⚠
phase-462 W3b – install a contracted Rust image’s hazard table on one executor, after install_contract_monitors (each hazard’s guards index the two tables that call installs). nros::main! emits this only for an executor whose tables observe a hazard; the observer then reports hazard-detected, hazard-reaction and hazard-recovered through the reporter that call armed.
install_contract_monitors⚠
Install a contracted Rust image’s monitor tables on one executor, and arm its /diagnostics reporter — issue 1676.