Skip to content

Health monitor C++ implementation - #1117

Draft
arkjedrz wants to merge 16 commits into
eclipse-score:mainfrom
qorix-group:arkjedrz_new-hmon-cpp
Draft

arkjedrz wants to merge 16 commits into
eclipse-score:mainfrom
qorix-group:arkjedrz_new-hmon-cpp

Conversation

@arkjedrz

Copy link
Copy Markdown
Contributor

C++ implementation of health monitor. Mostly same as Rust, but with some changes applied (e.g., changes in error handling, different order of logs).
Previous C++ bindings to Rust implementation are removed.

Once merged - PR containing Rust update to maintain parity is necessary.

@pawelrutkaq

Copy link
Copy Markdown
Contributor

FYI: The code was internally reviewed (not as single PR ) and this is just a pushout. The main algos did not changed comapred to rust

@arkjedrz

Copy link
Copy Markdown
Contributor Author

C++ health monitor: old API to new API

Scope

This report maps the old C++ health monitor API to the new one.
The old API wraps the Rust core over FFI, in namespace score::mw::health with headers under score/mw/health/.
The new API is a native C++ implementation, in namespace score::health_monitor with headers under score/health_monitor/.
The old API is the state before commit d637f26797, and the new API is the state at adfcdeddc7.
The Rust API and its FFI do not change.

Build targets

Old New Notes
//score/health_monitor:health_monitoring_cc //score/health_monitor:health_monitoring_cc The alias stays. It now points to //score/health_monitor/src/cpp:health_monitor instead of the FFI wrapper.
//score/health_monitor/src/cpp:health_monitoring_cc_stub_supervisor --//score/health_monitor/src/cpp:supervisor_client=//score/health_monitor/src/cpp:stub_supervisor_client A label_flag selects the supervisor backend. The default is :alive_supervisor_client.
None //score/health_monitor/src/cpp:supervisor_client_interface An external backend depends on it and defines SupervisorClient::Create().
None //score/health_monitor/src/cpp:mock Test-only gmock classes for application tests.
@score_baselibs//score/log_rust/stdout_logger_cpp_init Not needed The new implementation logs through mw::log.
Link of health_monitoring_lib_ffi (Rust) Not needed The C++ library has no Rust dependency.

Headers

Old New
score/mw/health/health_monitor.h (includes all others) score/health_monitor/health_monitor.h and score/health_monitor/health_monitor_builder.h
score/mw/health/common.h score/health_monitor/time_range.h and score/health_monitor/error.h
score/mw/health/deadline_monitor.h score/health_monitor/deadline_monitor.h, score/health_monitor/deadline_monitor_builder.h and score/health_monitor/deadline.h
score/mw/health/heartbeat_monitor.h score/health_monitor/heartbeat_monitor.h and score/health_monitor/heartbeat_monitor_builder.h
score/mw/health/logic_monitor.h score/health_monitor/logic_monitor.h and score/health_monitor/logic_monitor_builder.h
score/mw/health/thread.h score/health_monitor/thread_parameters.h
score/mw/health/tag.h score/health_monitor/tag.h
None score/health_monitor/taken.h
None score/health_monitor/supervisor_client.h
None score/health_monitor/mock_health_monitor.h, mock_deadline_monitor.h, mock_deadline.h, mock_heartbeat_monitor.h, mock_logic_monitor.h, mock_taken.h

The new health_monitor.h does not include the builder headers.
Include each header that the code uses.

Namespaces

Old New
score::mw::health score::health_monitor
score::mw::health::deadline score::health_monitor
score::mw::health::heartbeat score::health_monitor
score::mw::health::logic score::health_monitor
score::mw::health::internal (FFICode, FFIHandle, RustDroppable, DroppableFFIHandle) Removed
None score::health_monitor::testing (mocks and MakeTaken())

Return types

Old New
score::cpp::expected<T, Error> score::Result<T>
void with an assert on failure score::Result<void>
Monitor or deadline by value Taken<T>, a move-only handle with shared ownership
HealthMonitor by value std::unique_ptr<HealthMonitor>

Access a Taken<T> through ->, * or Get().
Access the health monitor through ->.

HealthMonitorBuilder

Old New Notes
HealthMonitorBuilder() HealthMonitorBuilder{} The new constructor is implicit.
AddDeadlineMonitor(const MonitorTag&, deadline::DeadlineMonitorBuilder&&) && AddDeadlineMonitor(const MonitorTag&, DeadlineMonitorBuilder&&) && noexcept
AddHeartbeatMonitor(const MonitorTag&, heartbeat::HeartbeatMonitorBuilder&&) && AddHeartbeatMonitor(const MonitorTag&, HeartbeatMonitorBuilder&&) && noexcept
AddLogicMonitor(const MonitorTag&, logic::LogicMonitorBuilder&&) && AddLogicMonitor(const MonitorTag&, LogicMonitorBuilder&&) && noexcept
WithSupervisorApiCycle(std::chrono::milliseconds) && WithSupervisorApiCycle(std::chrono::milliseconds) && noexcept The default stays 500 ms. A negative value no longer asserts. Build() rejects it.
WithInternalProcessingCycle(std::chrono::milliseconds) && WithInternalProcessingCycle(std::chrono::milliseconds) && noexcept The default stays 100 ms. A negative value no longer asserts. Build() rejects it.
WithThreadParameters(ThreadParameters&&) && WithThreadParameters(ThreadParameters&&) && noexcept
score::cpp::expected<HealthMonitor, Error> Build() && score::Result<std::unique_ptr<HealthMonitor>> Build() && noexcept See the error mapping.

HealthMonitor

Old New Notes
class HealthMonitor final, movable Abstract class HealthMonitor, not copyable and not movable HealthMonitorMock implements it for tests.
expected<deadline::DeadlineMonitor, Error> GetDeadlineMonitor(const MonitorTag&) Result<Taken<DeadlineMonitor>> GetDeadlineMonitor(const MonitorTag&) noexcept
expected<heartbeat::HeartbeatMonitor, Error> GetHeartbeatMonitor(const MonitorTag&) Result<Taken<HeartbeatMonitor>> GetHeartbeatMonitor(const MonitorTag&) noexcept
expected<logic::LogicMonitor, Error> GetLogicMonitor(const MonitorTag&) Result<Taken<LogicMonitor>> GetLogicMonitor(const MonitorTag&) noexcept
void Start() score::Result<void> Start() noexcept The old call aborts on failure. The new call returns kNotTaken, kSupervisorUnavailable or kAlreadyStarted.

Deadline monitor

Old New Notes
deadline::DeadlineMonitorBuilder() DeadlineMonitorBuilder{}
DeadlineMonitorBuilder::AddDeadline(const DeadlineTag&, const TimeRange&) && DeadlineMonitorBuilder::AddDeadline(const DeadlineTag&, const TimeRange&) && noexcept A repeated deadline tag makes Build() fail. A monitor without deadlines makes Build() fail.
class deadline::DeadlineMonitor final, movable Abstract class DeadlineMonitor, not movable Held as Taken<DeadlineMonitor>. DeadlineMonitorMock implements it.
expected<Deadline, Error> DeadlineMonitor::GetDeadline(const DeadlineTag&) Result<Taken<Deadline>> DeadlineMonitor::GetDeadline(const DeadlineTag&) noexcept Threads can call it concurrently.
class deadline::Deadline final, movable Abstract class Deadline, not movable Held as Taken<Deadline>. DeadlineMock implements it.
expected<DeadlineHandle, Error> Deadline::Start() Result<DeadlineHandle> Deadline::Start() noexcept
deadline::DeadlineHandle DeadlineHandle Move-constructible in both.
void DeadlineHandle::Stop() void DeadlineHandle::Stop() noexcept The old call aborts on a moved-from handle. The new call does nothing.
~Deadline() asserts that no handle exists Precondition: the handle is destroyed before its Taken<Deadline>

Heartbeat monitor

Old New Notes
heartbeat::HeartbeatMonitorBuilder(const TimeRange&) explicit HeartbeatMonitorBuilder(const TimeRange&) noexcept Build() still rejects a minimum that is at most half the internal cycle.
class heartbeat::HeartbeatMonitor final, movable Abstract class HeartbeatMonitor, not movable Held as Taken<HeartbeatMonitor>. HeartbeatMonitorMock implements it.
void HeartbeatMonitor::Heartbeat() void HeartbeatMonitor::Heartbeat() noexcept Any thread can call it. More than one heartbeat in one internal cycle is a failure.

Logic monitor

Old New Notes
logic::LogicMonitorBuilder(const StateTag&) explicit LogicMonitorBuilder(const StateTag&) noexcept
AddState(const StateTag&, const std::vector<StateTag>&) && AddState(const StateTag&, score::cpp::span<const StateTag>) && noexcept A std::vector or std::array converts to the span.
class logic::LogicMonitor final, movable Abstract class LogicMonitor, not movable Held as Taken<LogicMonitor>. LogicMonitorMock implements it.
expected<StateTag, Error> LogicMonitor::Transition(const StateTag&) Result<StateTag> LogicMonitor::Transition(const StateTag&) noexcept
expected<StateTag, Error> LogicMonitor::State() Result<StateTag> LogicMonitor::State() const noexcept Now const.

Tags

Old New Notes
class MonitorTag : public Tag<MonitorTag> using MonitorTag = details::Tag<details::MonitorTagKind>
class DeadlineTag : public Tag<DeadlineTag> using DeadlineTag = details::Tag<details::DeadlineTagKind>
class StateTag : public Tag<StateTag> using StateTag = details::Tag<details::StateTagKind>
explicit Tag(const char (&)[N]) constexpr explicit Tag(const char (&)[N]) noexcept Tags can be constexpr. A mutable char array is rejected at compile time.
operator==, operator!= (members) operator==, operator!= (hidden friends, constexpr) Both compare the text.
None Data(), Size()

TimeRange

Old New Notes
TimeRange in common.h TimeRange in time_range.h Both abort if min < 0 or min > max.
std::uint64_t MinMs() const std::chrono::milliseconds Min() const noexcept
std::uint64_t MaxMs() const std::chrono::milliseconds Max() const noexcept

Thread parameters

Old New Notes
SchedulerPolicy::Other SchedulerPolicy::kOther
SchedulerPolicy::Fifo SchedulerPolicy::kFifo
SchedulerPolicy::RoundRobin SchedulerPolicy::kRoundRobin
int32_t SchedulerPolicyPriorityMin(SchedulerPolicy) std::int32_t SchedulerPolicyPriorityMin(SchedulerPolicy) noexcept
int32_t SchedulerPolicyPriorityMax(SchedulerPolicy) std::int32_t SchedulerPolicyPriorityMax(SchedulerPolicy) noexcept
SchedulerParameters(SchedulerPolicy, int32_t) constexpr SchedulerParameters(SchedulerPolicy, std::int32_t) noexcept The old constructor aborts on a priority outside the range. Build() now returns kInvalidArgument.
SchedulerParameters::Policy(), Priority() SchedulerParameters::Policy(), Priority() Now constexpr and noexcept.
ThreadParameters() ThreadParameters{}
ThreadParameters::WithSchedulerParameters(SchedulerParameters) && ThreadParameters::WithSchedulerParameters(SchedulerParameters) && noexcept
ThreadParameters::Affinity(const std::vector<size_t>&) && ThreadParameters::WithAffinity(score::cpp::span<const std::size_t>) && noexcept Renamed.
ThreadParameters::StackSize(size_t) && ThreadParameters::WithStackSize(std::size_t) && noexcept Renamed.
None GetSchedulerParameters(), GetAffinity(), GetStackSize()

Removed snake_case API

The old API keeps deprecated snake_case forwarders.
The new API has no snake_case names.

Old (deprecated) New
HealthMonitorBuilder::add_deadline_monitor() HealthMonitorBuilder::AddDeadlineMonitor()
HealthMonitorBuilder::add_heartbeat_monitor() HealthMonitorBuilder::AddHeartbeatMonitor()
HealthMonitorBuilder::add_logic_monitor() HealthMonitorBuilder::AddLogicMonitor()
HealthMonitorBuilder::with_supervisor_api_cycle() HealthMonitorBuilder::WithSupervisorApiCycle()
HealthMonitorBuilder::with_internal_processing_cycle() HealthMonitorBuilder::WithInternalProcessingCycle()
HealthMonitorBuilder::thread_parameters() HealthMonitorBuilder::WithThreadParameters()
HealthMonitorBuilder::build() HealthMonitorBuilder::Build()
HealthMonitor::get_deadline_monitor() HealthMonitor::GetDeadlineMonitor()
HealthMonitor::get_heartbeat_monitor() HealthMonitor::GetHeartbeatMonitor()
HealthMonitor::get_logic_monitor() HealthMonitor::GetLogicMonitor()
HealthMonitor::start() HealthMonitor::Start()
DeadlineMonitorBuilder::add_deadline() DeadlineMonitorBuilder::AddDeadline()
DeadlineMonitor::get_deadline() DeadlineMonitor::GetDeadline()
Deadline::start() Deadline::Start()
DeadlineHandle::stop() DeadlineHandle::Stop()
HeartbeatMonitor::heartbeat() HeartbeatMonitor::Heartbeat()
LogicMonitorBuilder::add_state() LogicMonitorBuilder::AddState()
LogicMonitor::transition() LogicMonitor::Transition()
LogicMonitor::state() LogicMonitor::State()
TimeRange::min_ms() TimeRange::Min()
TimeRange::max_ms() TimeRange::Max()
scheduler_policy_priority_min() SchedulerPolicyPriorityMin()
scheduler_policy_priority_max() SchedulerPolicyPriorityMax()
SchedulerParameters::policy() SchedulerParameters::Policy()
SchedulerParameters::priority() SchedulerParameters::Priority()
ThreadParameters::scheduler_parameters() ThreadParameters::WithSchedulerParameters()
ThreadParameters::affinity() ThreadParameters::WithAffinity()
ThreadParameters::stack_size() ThreadParameters::WithStackSize()

Error mapping

The old enum class Error carries the FFI return codes.
The new enum class ErrorCode lives in a score::result error domain.
One old code can map to more than one new code, so the table lists each call.

Call Condition Old Error New ErrorCode
HealthMonitorBuilder::Build() No monitor was added WrongState kNoMonitors
HealthMonitorBuilder::Build() Supervisor cycle is not a multiple of the internal cycle InvalidArgument kInvalidArgument
HealthMonitorBuilder::Build() A cycle is zero, negative or above steady_clock::duration::max() Assert for a negative cycle kInvalidArgument
HealthMonitorBuilder::Build() Heartbeat minimum is at most half the internal cycle InvalidArgument kInvalidArgument
HealthMonitorBuilder::Build() A logic monitor has no states WrongState kInvalidArgument
HealthMonitorBuilder::Build() A transition target or the initial state is not added InvalidArgument kInvalidArgument
HealthMonitorBuilder::Build() A monitor tag repeats Accepted, the last one wins kInvalidArgument
HealthMonitorBuilder::Build() A deadline tag or a state repeats Accepted, the last one wins kInvalidArgument
HealthMonitorBuilder::Build() A deadline monitor has no deadline Accepted kInvalidArgument
HealthMonitorBuilder::Build() A priority is outside the range of its policy Assert in SchedulerParameters kInvalidArgument
HealthMonitor::Get*Monitor() No monitor of this kind has the tag NotFound kUnknownTag
HealthMonitor::Get*Monitor() An earlier call returned the monitor NotFound kAlreadyTaken
HealthMonitor::Get*Monitor() Start() succeeded earlier NotFound kAlreadyStarted
HealthMonitor::Start() A monitor is not taken Assert kNotTaken
HealthMonitor::Start() The supervisor is not reachable Not reported kSupervisorUnavailable
HealthMonitor::Start() An earlier call started the worker Assert kAlreadyStarted
DeadlineMonitor::GetDeadline() No deadline has the tag NotFound kUnknownTag
DeadlineMonitor::GetDeadline() A handle of the deadline exists AlreadyExists kAlreadyTaken
Deadline::Start() A handle of the deadline exists WrongState kDeadlineRunning
Deadline::Start() The deadline missed its range earlier Failed kDeadlineFailed
LogicMonitor::Transition() The current state does not allow the target Failed kInvalidTransition
LogicMonitor::Transition() An earlier transition failed Failed kInvalidState
LogicMonitor::State() An earlier transition failed Failed kInvalidState
None Null pointer over FFI NullParameter No counterpart

To check an error, compare result.error() with an ErrorCode value, for example result.error() == ErrorCode::kAlreadyTaken.
MakeError() and ErrorDomain in error.h create errors and their messages.

Behaviour changes

A Taken<T> handle shares ownership of its object with the health monitor.
A taken monitor or deadline stays valid after the health monitor is destroyed, but nothing checks it then.
Destroying a Taken<Deadline> makes the deadline available to the next GetDeadline() call.
HealthMonitor::Get*Monitor() fails after a successful Start().
HealthMonitor::Start() connects to the supervisor, so call it before report_running().
The process terminates if the worker thread cannot start or cannot apply its ThreadParameters.
The health monitor does not allocate memory after Start().
The process terminates if a deadline would end later than 2^32 - 1 ms after the creation of its monitor.
The worker stops the alive notifications at the first failure, so the supervisor detects it.

Test support

The old API has no mocks.
The new :mock target gives gmock classes in score::health_monitor::testing.

Interface Mock Header
HealthMonitor HealthMonitorMock score/health_monitor/mock_health_monitor.h
DeadlineMonitor DeadlineMonitorMock score/health_monitor/mock_deadline_monitor.h
Deadline DeadlineMock score/health_monitor/mock_deadline.h
HeartbeatMonitor HeartbeatMonitorMock score/health_monitor/mock_heartbeat_monitor.h
LogicMonitor LogicMonitorMock score/health_monitor/mock_logic_monitor.h
Taken<T> MakeTaken(T&) score/health_monitor/mock_taken.h

MakeTaken() wraps a mock in a Taken<T> that owns nothing, so a mocked Get* call can return it.

Example

Old code, from examples/cpp_health_monitor_supervised_app/main.cpp before d637f26797:

#include <score/mw/health/common.h>
#include <score/mw/health/health_monitor.h>
#include <score/mw/log/rust/stdout_logger_init.h>

score::mw::log::rust::StdoutLoggerBuilder builder;
builder.Context("APP").LogLevel(score::mw::log::rust::LogLevel::Verbose).SetAsDefaultLogger();

using namespace score::mw::health;

auto builder_mon = deadline::DeadlineMonitorBuilder().AddDeadline(
    DeadlineTag("deadline_1"), TimeRange(std::chrono::milliseconds(50), std::chrono::milliseconds(100)));
MonitorTag ident("monitor");

auto hm_res = HealthMonitorBuilder()
                  .AddDeadlineMonitor(ident, std::move(builder_mon))
                  .WithInternalProcessingCycle(std::chrono::milliseconds(50))
                  .WithSupervisorApiCycle(std::chrono::milliseconds(50))
                  .Build();
auto hm = std::move(*hm_res);

auto deadline_monitor_res = hm.GetDeadlineMonitor(ident);
hm.Start();
score::mw::lifecycle::report_running();

auto deadline_mon = std::move(*deadline_monitor_res);
auto deadline_res = deadline_mon.GetDeadline(DeadlineTag("deadline_1"));
auto deadline_guard = deadline_res.value().Start();

New code:

#include <score/health_monitor/deadline.h>
#include <score/health_monitor/deadline_monitor.h>
#include <score/health_monitor/deadline_monitor_builder.h>
#include <score/health_monitor/health_monitor.h>
#include <score/health_monitor/health_monitor_builder.h>
#include <score/health_monitor/tag.h>
#include <score/health_monitor/time_range.h>

using namespace score::health_monitor;

auto deadline_builder = DeadlineMonitorBuilder{}.AddDeadline(
    DeadlineTag{"deadline_1"}, TimeRange{std::chrono::milliseconds(50), std::chrono::milliseconds(100)});
constexpr MonitorTag kDeadlineMonitor{"deadline_monitor"};

auto hm_res = HealthMonitorBuilder{}
                  .AddDeadlineMonitor(kDeadlineMonitor, std::move(deadline_builder))
                  .WithInternalProcessingCycle(std::chrono::milliseconds(50))
                  .WithSupervisorApiCycle(std::chrono::milliseconds(50))
                  .Build();
const auto hm = std::move(hm_res).value();

const auto deadline_mon = hm->GetDeadlineMonitor(kDeadlineMonitor).value();
const auto deadline = deadline_mon->GetDeadline(DeadlineTag{"deadline_1"}).value();

if (!hm->Start().has_value())
{
    return EXIT_FAILURE;
}
score::mw::lifecycle::report_running();

const auto deadline_guard = deadline->Start();

The short form calls value() without a check, which aborts on an error.
Production code checks has_value() first, as the example application does.

The current example also uses a heartbeat monitor and a logic monitor.
See examples/cpp_health_monitor_supervised_app/main.cpp and tests/integration/complex_monitoring/component_complex_monitoring.cpp.

The C++ API in score/health_monitor/src/cpp wraps the Rust core through its FFI.
Remove this wrapper, its tests and the targets cpp_unit_tests, cpp_integration_tests and health_monitoring_cc_stub_supervisor.
A native C++ implementation replaces the wrapper in the next commits.
The Rust core and its FFI do not change.
Until the native implementation is complete, the health_monitoring_cc alias, the C++ example and the complex monitoring integration test refer to targets that do not exist.

Signed-off-by: Arkadiusz Jedrzejewski <arkadiusz.jedrzejewski.ext@qorix.ai>
Add the interfaces, value types, error domain, gmock mocks and unit tests of a native C++ health monitor in score/health_monitor/src/cpp.
Applications include the public headers as score/health_monitor/<file>.h and the mocks as score/health_monitor/mock_<name>.h.
The health_monitoring_cc alias points to the new :health_monitor target.

- The builders are declared here and defined in a later step.
- Every interface method, builder call, Deadline::Start() and the TimeRange constructor are noexcept.
  Errors come back through score::Result.
- HealthMonitor::Start() documents that a failure to create the worker or to apply its ThreadParameters terminates the process.
- MonitorTag, DeadlineTag and StateTag are each asserted to be standard-layout and trivially copyable.

Signed-off-by: Arkadiusz Jedrzejewski <arkadiusz.jedrzejewski.ext@qorix.ai>
Each C++ health monitor test records the comp_req__health_monitor__* requirements that it verifies through gtest RecordProperty.
It also records the test type, the derivation technique and a description.
This follows the S-CORE test-to-requirement linking convention, so docs-as-code links the tests to the requirements.

Signed-off-by: Arkadiusz Jedrzejewski <arkadiusz.jedrzejewski.ext@qorix.ai>
Port the Rust heartbeat monitor to HeartbeatMonitorImpl<Clock> in score/health_monitor/src/cpp/heartbeat_monitor.
Its Create() factory checks the cycle, and one atomic word holds the heartbeat state.
Add the internal MonitorEvaluator seam, a logger that names the monitor tag in every log line, and a fake clock for tests.
Define the HeartbeatMonitorBuilder constructor.
The unit tests record the comp_req__health_monitor__* requirements that they verify through gtest RecordProperty.

Signed-off-by: Arkadiusz Jedrzejewski <arkadiusz.jedrzejewski.ext@qorix.ai>
The C++ health monitor runtime ports the Rust health monitor runtime.
HealthMonitorBuilder::Build() validates the configuration and creates the heartbeat monitors.
Build() rejects deadline monitors and logic monitors.
Build() rejects a supervisor or internal cycle that steady_clock::duration cannot hold.
HealthMonitor::GetHeartbeatMonitor() returns each heartbeat monitor only once.
HealthMonitor::Start() connects the supervisor client and starts a jthread worker.
The worker evaluates every monitor in each internal cycle.
The worker sends an alive notification to the supervisor in each supervisor cycle.
The worker stops at the first monitor failure.
Each monitor logs its own evaluation failure.
A NonRelocatableVector holds the monitor entries and does not grow after Build().
The label_flag //score/health_monitor/src/cpp:supervisor_client selects the supervisor client backend.
The backend is the launch manager alive client by default, a stub, or an external cc_library.
The public API tests use the stub backend and need no launch manager.

Signed-off-by: Arkadiusz Jedrzejewski <arkadiusz.jedrzejewski.ext@qorix.ai>
Port the Rust logic monitor to C++.
HealthMonitorBuilder::Build() now creates logic monitors, and HealthMonitor::GetLogicMonitor() returns each logic monitor only once.
The unit tests record the requirements that they verify.

Signed-off-by: Arkadiusz Jedrzejewski <arkadiusz.jedrzejewski.ext@qorix.ai>
Port the Rust deadline monitor to C++.
HealthMonitorBuilder::Build() now creates deadline monitors, and HealthMonitor::GetDeadlineMonitor() returns each deadline monitor only once.
Taken<T> gets a release hook, so a released deadline is available to the next GetDeadline() call without an allocation.
The unit tests record the requirements that they verify.

Signed-off-by: Arkadiusz Jedrzejewski <arkadiusz.jedrzejewski.ext@qorix.ai>
A blocked start log on the worker thread moved the start time of the monitors later.
Heartbeats on time then counted as too early, and the first evaluation and alive notification came late.
Start() now logs before it creates the worker.
RecorderMock tests prove that healthy cycles do not log, and that failure logs come after the decisions that they report.

Signed-off-by: Arkadiusz Jedrzejewski <arkadiusz.jedrzejewski.ext@qorix.ai>
The C++ example and the complex monitoring integration test use the API of the native C++ health monitor.
They log through mw::log and no longer link the Rust stdout logger.
Their behaviour does not change.

Signed-off-by: Arkadiusz Jedrzejewski <arkadiusz.jedrzejewski.ext@qorix.ai>
Compile-time checks show that a time range or a cycle cannot be set from microseconds or fractional milliseconds.
A separate test binary counts every operator new after Start() while all three monitor kinds report and the worker runs, and expects none.

Signed-off-by: Arkadiusz Jedrzejewski <arkadiusz.jedrzejewski.ext@qorix.ai>
The example now reports a heartbeat and moves a logic monitor between two states in each loop, next to the existing deadline measurement.
The -d and -m options and the SIGUSR1 supervision failure keep their behaviour, so the demo verification is unchanged.

Signed-off-by: Arkadiusz Jedrzejewski <arkadiusz.jedrzejewski.ext@qorix.ai>
The detailed design shows the src/cpp and src/rust trees and states that the two implementations are independent.
The C++ code no longer uses the Rust FFI, which stays part of the Rust implementation.
The module safety plan names the new C++ test targets, and the static analysis README uses :health_monitor as its example target.

Signed-off-by: Arkadiusz Jedrzejewski <arkadiusz.jedrzejewski.ext@qorix.ai>
ReleaseHook deletes its copy and move operations, because a handle keeps the address of its hook, and the Taken converting constructor is explicit and its assignments are lvalue-qualified.
This removes the MISRA C++:2023 results for rules 4.1.2, 7.11.3, 15.0.2, 15.1.3 and 18.4.1 in taken.h.

Signed-off-by: Arkadiusz Jedrzejewski <arkadiusz.jedrzejewski.ext@qorix.ai>
namespace score::health_monitor::details
{

DeadlineImpl::DeadlineImpl(
time}};
}

HealthMonitorImpl::HealthMonitorImpl(

} // namespace

Worker::Worker(
The supervisor client backends included internal/logger.h, which was a private header of :health_monitor_base.
internal/logger.h is now the :logger library, and the backends depend on the targets of the headers they include.
ToLogString moves to internal/log_string.h, so :logger does not need tag.h of :health_monitor_base.
:health_monitor_base depends on the mw/log targets that provide its log headers.
:error and :supervisor_client_interface drop their unused dependencies.
This removes the findings of the Bazel dependency check (DWYU).

Signed-off-by: Arkadiusz Jedrzejewski <arkadiusz.jedrzejewski.ext@qorix.ai>
Every file includes the headers of the symbols it uses, and the targets depend on the libraries of those headers.
The files that log include the mw/log headers directly.
An IWYU pragma: export in internal/logger.h makes IWYU 0.26 abort with a failed assertion.
The score_baselibs mapping names span.hpp as the header of score::cpp::span.
Before, IWYU asked for type_traits.hpp, which only forward-declares span.
thread_setup.cpp includes <algorithm> and <array> only on QNX, where it uses them.
It keeps <climits> for PTHREAD_STACK_MIN in place of the private glibc header.

Signed-off-by: Arkadiusz Jedrzejewski <arkadiusz.jedrzejewski.ext@qorix.ai>
The constructors of DeadlineImpl, HealthMonitorImpl and Worker take more than five parameters.
Each parameter is a dependency that the object needs, and a parameter struct would add indirection without making the code easier to read.
An in-source codeql comment above each definition suppresses the cpp/number-of-parameters-per-function result with this rationale.

Signed-off-by: Arkadiusz Jedrzejewski <arkadiusz.jedrzejewski.ext@qorix.ai>
@arkjedrz
arkjedrz deployed to workflow-approval November 27, 2026 14:35 — with GitHub Actions Active
@arkjedrz
arkjedrz deployed to workflow-approval November 27, 2026 14:35 — with GitHub Actions Active
@github-actions

Copy link
Copy Markdown
Contributor

Documentation preview for this pull request is available at:
pr-1117: https://eclipse-score.github.io/lifecycle/pr-1117/

This branch was successfully deployed

1 active deployment
workflow-approval — ae4f31e0 Deployed Nov 27, 2026 by arkjedrz via Build and test x86_64-qnx / approval #2907
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Backlog

Development

Successfully merging this pull request may close these issues.

3 participants