Skip to content

hmon: add logic monitor#95

Merged
pawelrutkaq merged 3 commits into
eclipse-score:mainfrom
qorix-group:arkjedrz_logic-monitor
Mar 13, 2026
Merged

hmon: add logic monitor#95
pawelrutkaq merged 3 commits into
eclipse-score:mainfrom
qorix-group:arkjedrz_logic-monitor

Conversation

@arkjedrz

@arkjedrz arkjedrz commented Feb 27, 2026

Copy link
Copy Markdown
Contributor

Add logic monitor to HMON.

Resolved #15

@github-actions

github-actions Bot commented Feb 27, 2026

Copy link
Copy Markdown

License Check Results

🚀 The license check job ran with the Bazel command:

bazel run --lockfile_mode=error //:license-check

Status: ⚠️ Needs Review

Click to expand output
[License Check Output]
Extracting Bazel installation...
Starting local Bazel server (8.4.2) and connecting to it...
INFO: Invocation ID: 3de1ce5a-d144-40bb-b6a3-4565bfbeb42a
Computing main repo mapping: 
Computing main repo mapping: 
Computing main repo mapping: 
WARNING: For repository 'score_rust_policies', the root module requires module version score_rust_policies@0.0.3, but got score_rust_policies@0.0.5 in the resolved dependency graph. Please update the version in your MODULE.bazel or set --check_direct_dependencies=off
Loading: 
Loading: 0 packages loaded
Loading: 0 packages loaded
Loading: 0 packages loaded
    currently loading: 
Loading: 0 packages loaded
    currently loading: 
Loading: 0 packages loaded
    currently loading: 
Loading: 0 packages loaded
    currently loading: 
Analyzing: target //:license-check (1 packages loaded, 0 targets configured)
Analyzing: target //:license-check (1 packages loaded, 0 targets configured)

Analyzing: target //:license-check (37 packages loaded, 9 targets configured)

Analyzing: target //:license-check (89 packages loaded, 9 targets configured)

Analyzing: target //:license-check (89 packages loaded, 9 targets configured)

Analyzing: target //:license-check (145 packages loaded, 2642 targets configured)

Analyzing: target //:license-check (153 packages loaded, 5247 targets configured)

Analyzing: target //:license-check (154 packages loaded, 5922 targets configured)

Analyzing: target //:license-check (160 packages loaded, 7852 targets configured)

Analyzing: target //:license-check (160 packages loaded, 7852 targets configured)

Analyzing: target //:license-check (160 packages loaded, 7852 targets configured)

Analyzing: target //:license-check (163 packages loaded, 9737 targets configured)

Analyzing: target //:license-check (163 packages loaded, 9737 targets configured)

Analyzing: target //:license-check (164 packages loaded, 9861 targets configured)

Analyzing: target //:license-check (169 packages loaded, 9913 targets configured)

INFO: Analyzed target //:license-check (170 packages loaded, 10039 targets configured).
[12 / 16] [Sched] JavaToolchainCompileClasses external/rules_java+/toolchains/platformclasspath_classes
[14 / 16] JavaToolchainCompileBootClasspath external/rules_java+/toolchains/platformclasspath.jar; 0s disk-cache, processwrapper-sandbox
[15 / 16] Building license.check.license_check.jar (); 0s disk-cache, multiplex-worker
INFO: Found 1 target...
Target //:license.check.license_check up-to-date:
  bazel-bin/license.check.license_check
  bazel-bin/license.check.license_check.jar
INFO: Elapsed time: 30.365s, Critical Path: 2.64s
INFO: 16 processes: 12 internal, 3 processwrapper-sandbox, 1 worker.
INFO: Build completed successfully, 16 total actions
INFO: Running command line: bazel-bin/license.check.license_check ./formatted.txt <args omitted>
usage: org.eclipse.dash.licenses.cli.Main [-batch <int>] [-cd <url>]
       [-confidence <int>] [-ef <url>] [-excludeSources <sources>] [-help] [-lic
       <url>] [-project <shortname>] [-repo <url>] [-review] [-summary <file>]
       [-timeout <seconds>] [-token <token>]

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR extends the health monitoring library with new monitor types (heartbeat + logic) and refactors the worker/supervisor client plumbing so the worker can evaluate multiple monitor kinds and report typed evaluation errors across Rust + C++/FFI.

Changes:

  • Add new HeartbeatMonitor (state + evaluator + FFI + C++ wrapper) and LogicMonitor (state-transition validator).
  • Refactor monitor evaluation to pass an HMON starting Instant and to report typed MonitorEvaluationError variants (deadline/heartbeat/logic).
  • Move supervisor API client implementations into a feature-gated supervisor_api_client/ module and adjust build config defaults/features.

Reviewed changes

Copilot reviewed 25 out of 26 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
src/health_monitoring_lib/rust/worker.rs Updates monitoring loop to pass a shared starting Instant and log typed monitor errors; removes in-file supervisor client impls.
src/health_monitoring_lib/rust/tag.rs Adds StateTag newtype for logic monitor states; updates tag tests.
src/health_monitoring_lib/rust/supervisor_api_client/stub_supervisor_api_client.rs Adds stub supervisor client implementation behind feature gate.
src/health_monitoring_lib/rust/supervisor_api_client/score_supervisor_api_client.rs Adds SCORE supervisor client implementation (monitor_rs-backed).
src/health_monitoring_lib/rust/supervisor_api_client/mod.rs Introduces SupervisorAPIClient trait and feature-gated implementations.
src/health_monitoring_lib/rust/logic/mod.rs Adds logic module exports.
src/health_monitoring_lib/rust/logic/logic_monitor.rs Implements logic monitor state machine + evaluator + tests.
src/health_monitoring_lib/rust/lib.rs Integrates deadline/heartbeat/logic monitors into HealthMonitorBuilder + HealthMonitor; changes build/start to return Result.
src/health_monitoring_lib/rust/heartbeat/mod.rs Adds heartbeat module wiring and FFI submodule.
src/health_monitoring_lib/rust/heartbeat/heartbeat_state.rs Adds compact atomic heartbeat state representation (+ loom-aware atomics).
src/health_monitoring_lib/rust/heartbeat/heartbeat_monitor.rs Adds heartbeat monitor implementation + builder validation + tests.
src/health_monitoring_lib/rust/heartbeat/ffi.rs Adds FFI for heartbeat monitor builder/monitor and tests.
src/health_monitoring_lib/rust/ffi.rs Extends core FFI to build/start using Result, adds heartbeat builder/get FFI, and maps HealthMonitorError to FFICode.
src/health_monitoring_lib/rust/deadline/mod.rs Re-exports DeadlineEvaluationError for typed evaluation errors.
src/health_monitoring_lib/rust/deadline/deadline_monitor.rs Refactors deadline monitor to use typed DeadlineEvaluationError and updated evaluator signature.
src/health_monitoring_lib/rust/common.rs Introduces HasEvalHandle, typed MonitorEvaluationError, shared evaluation signature, and time conversion helpers.
src/health_monitoring_lib/cpp/tests/health_monitor_test.cpp Extends C++ test to build/get/use heartbeat monitor.
src/health_monitoring_lib/cpp/include/score/hm/heartbeat/heartbeat_monitor.h Adds C++ API surface for heartbeat monitor + builder.
src/health_monitoring_lib/cpp/include/score/hm/health_monitor.h Adds heartbeat monitor APIs to C++ HealthMonitor(Builder).
src/health_monitoring_lib/cpp/heartbeat_monitor.cpp Implements C++ heartbeat monitor wrapper calling Rust FFI.
src/health_monitoring_lib/cpp/health_monitor.cpp Wires heartbeat builder/get calls through Rust FFI.
src/health_monitoring_lib/Cargo.toml Adds features (default stub; optional score uses monitor_rs) and loom dependency config.
src/health_monitoring_lib/BUILD Adds heartbeat C++ sources/headers and adjusts crate feature flags for Bazel targets.
examples/rust_supervised_app/src/main.rs Updates example to handle build()/start() returning Result.
Cargo.toml Sets workspace default-members and adds cfg(loom) lint configuration.
Cargo.lock Adds new dependency entries (loom + transitive deps).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/health_monitoring_lib/rust/heartbeat/heartbeat_monitor.rs Outdated
Comment thread src/health_monitoring_lib/rust/heartbeat/heartbeat_monitor.rs
match value {
value if value == LogicEvaluationError::InvalidState as u8 => LogicEvaluationError::InvalidState,
value if value == LogicEvaluationError::InvalidTransition as u8 => LogicEvaluationError::InvalidTransition,
_ => panic!("Invalid underlying value of logic evaluation error."),

Copilot AI Feb 27, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

impl From<u8> for LogicEvaluationError panics on unknown values. Since this conversion is used when interpreting AtomicU8 state during evaluate, an unexpected value would crash the monitoring thread/process instead of reporting an error. Please make this conversion non-panicking (e.g., map unknown values to InvalidState or return Option/Result) and handle that path in evaluate.

Suggested change
_ => panic!("Invalid underlying value of logic evaluation error."),
_ => LogicEvaluationError::InvalidState,

Copilot uses AI. Check for mistakes.
Comment thread src/health_monitoring_lib/rust/lib.rs Outdated
Comment thread src/health_monitoring_lib/rust/heartbeat/heartbeat_state.rs Outdated
@github-actions

Copy link
Copy Markdown

The created documentation from the pull request is available at: docu-html

@arkjedrz arkjedrz force-pushed the arkjedrz_logic-monitor branch from 38a2bdf to 07352fd Compare March 2, 2026 07:34
@arkjedrz arkjedrz temporarily deployed to workflow-approval March 2, 2026 07:34 — with GitHub Actions Inactive
@arkjedrz arkjedrz temporarily deployed to workflow-approval March 2, 2026 07:34 — with GitHub Actions Inactive
@arkjedrz arkjedrz force-pushed the arkjedrz_logic-monitor branch from 07352fd to f96e585 Compare March 3, 2026 13:07
@arkjedrz arkjedrz temporarily deployed to workflow-approval March 3, 2026 13:07 — with GitHub Actions Inactive
@arkjedrz arkjedrz temporarily deployed to workflow-approval March 3, 2026 13:07 — with GitHub Actions Inactive
@arkjedrz arkjedrz force-pushed the arkjedrz_logic-monitor branch from f96e585 to 4ab21c9 Compare March 4, 2026 14:50
@arkjedrz arkjedrz had a problem deploying to workflow-approval March 4, 2026 14:50 — with GitHub Actions Failure
@arkjedrz arkjedrz had a problem deploying to workflow-approval March 4, 2026 14:50 — with GitHub Actions Failure
@arkjedrz arkjedrz force-pushed the arkjedrz_logic-monitor branch from 4ab21c9 to 743411c Compare March 5, 2026 10:32
@arkjedrz arkjedrz had a problem deploying to workflow-approval March 5, 2026 10:32 — with GitHub Actions Failure
@arkjedrz arkjedrz had a problem deploying to workflow-approval March 5, 2026 10:32 — with GitHub Actions Failure
@arkjedrz arkjedrz marked this pull request as ready for review March 5, 2026 10:45
@arkjedrz arkjedrz requested a review from Copilot March 5, 2026 10:46

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

Comment thread src/health_monitoring_lib/rust/logic/logic_monitor.rs Outdated
Comment thread src/health_monitoring_lib/rust/logic/logic_monitor.rs Outdated
Comment thread src/health_monitoring_lib/rust/tag.rs
Comment thread src/health_monitoring_lib/rust/logic/logic_monitor.rs Outdated

@pawelrutkaq pawelrutkaq left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stopped as my comment will probably simplify more code

Comment thread src/health_monitoring_lib/rust/logic/logic_monitor.rs
Comment thread src/health_monitoring_lib/rust/tag.rs
Comment thread src/health_monitoring_lib/rust/logic/logic_monitor.rs Outdated
@arkjedrz arkjedrz force-pushed the arkjedrz_logic-monitor branch from 743411c to 4686fb0 Compare March 5, 2026 13:58
@arkjedrz arkjedrz had a problem deploying to workflow-approval March 5, 2026 13:58 — with GitHub Actions Failure
@arkjedrz arkjedrz had a problem deploying to workflow-approval March 5, 2026 13:58 — with GitHub Actions Failure

protected:
std::optional<internal::FFIHandle> __drop_by_rust_impl()
std::optional<internal::FFIHandle> _drop_by_rust_impl()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

_drop_by_rust_impl -> drop_by_rust_impl

Compilers like GCC, Clang, and MSVC often use leading underscores for internal macros or system-level functions. If a future update to your compiler introduces a macro or an internal header named _drop_by_rust_impl, your code will fail to compile—or worse, behave unpredictably—and it will be considered your fault, not the compiler’s, because you used a reserved naming pattern.

@paulquiring paulquiring Mar 6, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

__ and _ is just considered not a good style. They are reserved.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That one's fine. It was previously double underscore, and that's actually an issue.
https://devblogs.microsoft.com/oldnewthing/20230109-00/?p=107685

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes one underscore flowed by a lower letter is not and issue. One underscore followed by a capital letter is also reserved. From the link you shared:

grafik

It is best practice to use the namespace detail or internal to indicate to user to not use it directly.

@paulquiring

Copy link
Copy Markdown
Contributor

The rust part looks like it supports monitoring from multiple threads. I could not find any hint how to set this up correctly form the cpp side.

@arkjedrz arkjedrz force-pushed the arkjedrz_logic-monitor branch from 4686fb0 to 6247d38 Compare March 6, 2026 12:58
@arkjedrz arkjedrz temporarily deployed to workflow-approval March 6, 2026 12:58 — with GitHub Actions Inactive
@arkjedrz arkjedrz temporarily deployed to workflow-approval March 6, 2026 12:58 — with GitHub Actions Inactive
@arkjedrz arkjedrz force-pushed the arkjedrz_logic-monitor branch from 6247d38 to 48bc6f2 Compare March 6, 2026 13:28
@arkjedrz arkjedrz temporarily deployed to workflow-approval March 6, 2026 13:28 — with GitHub Actions Inactive
@arkjedrz arkjedrz temporarily deployed to workflow-approval March 6, 2026 13:28 — with GitHub Actions Inactive
Comment thread src/health_monitoring_lib/rust/logic/logic_state.rs Outdated
Comment thread src/health_monitoring_lib/rust/logic/logic_state.rs Outdated
Comment thread src/health_monitoring_lib/rust/logic/logic_monitor.rs
Comment thread src/health_monitoring_lib/rust/logic/logic_monitor.rs Outdated
current_state_node.tag, target_state
);
let error = LogicEvaluationError::InvalidTransition;
let _ = self.logic_state.update(|mut current_state| {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since the handle is only reading the values, you can simply use store or swap, no need to use update

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please recheck.

Comment thread src/health_monitoring_lib/rust/logic/logic_monitor.rs

// Find index of target state, then change current state.
let target_state_index = self.find_index_by_tag(target_state)?;
let _ = self.logic_state.update(|mut current_state| {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no update needed as above

Comment thread src/health_monitoring_lib/rust/logic/logic_monitor.rs
Comment thread src/health_monitoring_lib/rust/logic/logic_monitor.rs
Comment thread src/health_monitoring_lib/rust/logic/logic_monitor.rs
@arkjedrz arkjedrz temporarily deployed to workflow-approval March 9, 2026 13:04 — with GitHub Actions Inactive
@arkjedrz arkjedrz temporarily deployed to workflow-approval March 9, 2026 13:04 — with GitHub Actions Inactive
@arkjedrz arkjedrz requested a review from pawelrutkaq March 9, 2026 14:06
@pawelrutkaq

Copy link
Copy Markdown
Contributor

@paulquiring any more comments or fine for You ?

Add logic monitor to HMON.
- Add const constructor to `StateTag`.
- Atomic `LogicState` containing current state index and monitor status.
- Updated logic monitor API.
- Reworked internal of logic monitor.
- Move `loom` imports to `common`.
- Remove `Sync` from `LogicMonitor`.
  - `PhantomUnsync` added to `common`.
- `LogicEvaluationError` -> replace `From` with `TryFrom`.
- Replace `monitor_status` and `set_monitor_status` type.
  - From `u8` to `LogicEvaluationError`.
- Replace `update` with `swap` in `LogicState`.
@arkjedrz arkjedrz force-pushed the arkjedrz_logic-monitor branch from fb1c854 to 9e81eb0 Compare March 12, 2026 12:20
@arkjedrz arkjedrz temporarily deployed to workflow-approval March 12, 2026 12:23 — with GitHub Actions Inactive
@arkjedrz arkjedrz temporarily deployed to workflow-approval March 12, 2026 12:27 — with GitHub Actions Inactive
@pawelrutkaq

Copy link
Copy Markdown
Contributor

@paulquiring if some issues are still there that you forsee please leave comments and we will adress them in follow up PR. Thanks

@pawelrutkaq pawelrutkaq merged commit 63df054 into eclipse-score:main Mar 13, 2026
19 of 22 checks passed
@arkjedrz arkjedrz deleted the arkjedrz_logic-monitor branch March 13, 2026 07:38
SimonKozik pushed a commit to etas-contrib/score_lifecycle that referenced this pull request Mar 24, 2026
* hmon: add logic monitor

Add logic monitor to HMON.

* hmon: reworked logic monitor

- Add const constructor to `StateTag`.
- Atomic `LogicState` containing current state index and monitor status.
- Updated logic monitor API.
- Reworked internal of logic monitor.

* hmon: logic monitor post-review fixes

- Move `loom` imports to `common`.
- Remove `Sync` from `LogicMonitor`.
  - `PhantomUnsync` added to `common`.
- `LogicEvaluationError` -> replace `From` with `TryFrom`.
- Replace `monitor_status` and `set_monitor_status` type.
  - From `u8` to `LogicEvaluationError`.
- Replace `update` with `swap` in `LogicState`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[HmLib] Rust Logical Monitor API

4 participants