Skip to content

Refactor of monitors for v1. Way cleaner Monitoring API.#868

Merged
gbin merged 6 commits into
masterfrom
gbin/monitoring_not_guessing_task_mapping
Feb 27, 2026
Merged

Refactor of monitors for v1. Way cleaner Monitoring API.#868
gbin merged 6 commits into
masterfrom
gbin/monitoring_not_guessing_task_mapping

Conversation

@gbin

@gbin gbin commented Feb 27, 2026

Copy link
Copy Markdown
Collaborator

Summary

The structure was kind of shitty, wrong and not extensible: instead of multiple shots injection of static info through the trait and new to pass a the config + list of taskids

Now we only pass a Metadata structure so consolemon doesn't have to recompute a lot of task mapping etc that we already do at runtime creation.

And it was buggy with the bridges, it was spotted with the flight controller task mapping.

Related issues

  • Closes #

Changes

Testing

  • just fmt
  • just lint
  • just test
  • optional full just std-ci (if std/runtime paths are impacted)
  • optional full just nostd-ci (if embedded/no_std paths are impacted)
  • Other (please specify):

pro-tip: just with no parameters in the root defaults to just fmt, just lint, and just test.

Checklist

  • I have updated docs or examples where needed
  • I have added or updated tests where needed
  • I have considered platform impact (Linux/macOS/Windows/embedded)
  • I have considered config/logging changes (if applicable)
  • This change is not a breaking change (or I documented it below)

Breaking changes (if any)

Additional context

@gbin gbin added bug Something isn't working enhancement New feature or request breaking include in changelog labels Feb 27, 2026
@gbin gbin changed the title Refactor of monitors for v1. Refactor of monitors for v1. Way cleaner Monitoring API. Feb 27, 2026
@gbin gbin requested a review from Copilot February 27, 2026 18:01

Copilot AI 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.

Pull request overview

This PR refactors the monitoring API by consolidating initialization parameters into structured metadata objects, eliminating the need for post-construction setters and fixing bridge component mapping issues.

Changes:

  • Replaced multiple initialization methods (new, set_topology, set_copperlist_info, set_execution_probe) with a single new(metadata, runtime) constructor
  • Introduced CuMonitoringMetadata and CuMonitoringRuntime to bundle static and dynamic monitoring context
  • Fixed bridge component monitoring by computing proper component-to-slot mappings at code generation time

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
examples/cu_monitoring/src/main.rs Updated example monitor to use new metadata-based initialization
core/cu29_runtime/src/monitoring.rs Added metadata/runtime structures and refactored CuMonitor trait
core/cu29_runtime/src/curuntime.rs Updated runtime construction to build and pass monitoring metadata
core/cu29_runtime/src/config.rs Extracted DEFAULT_MISSION_ID constant
core/cu29_derive/src/lib.rs Updated codegen to build component metadata and mapping arrays
components/monitors/cu_safetymon/tests/safety_monitoring.rs Updated tests to construct metadata objects
components/monitors/cu_safetymon/src/std_impl.rs Refactored to use metadata-based initialization
components/monitors/cu_safetymon/src/nostd_impl.rs Updated signature to match new trait
components/monitors/cu_logmon/src/lib.rs Refactored to use metadata-based initialization
components/monitors/cu_logmon/examples/demo.rs Updated example to construct metadata
components/monitors/cu_consolemon/src/lib.rs Refactored to use metadata and removed manual mapping logic

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

Comment on lines +1091 to +1092
let task_ids = task_specs.ids.clone();
let ids = build_monitored_ids(&task_ids, &mut culist_bridge_specs);

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.

The variable task_ids is cloned and immediately passed to build_monitored_ids, but the original task_specs.ids could be used directly on line 1092. This clone appears unnecessary unless task_specs.ids is borrowed elsewhere.

Suggested change
let task_ids = task_specs.ids.clone();
let ids = build_monitored_ids(&task_ids, &mut culist_bridge_specs);
let ids = build_monitored_ids(&task_specs.ids, &mut culist_bridge_specs);

Copilot uses AI. Check for mistakes.
#sim_tasks_instanciator

pub const TASKS_IDS: &'static [&'static str] = &[#( #ids ),*];
pub const TASK_IDS: &'static [&'static str] = &[#( #task_ids ),*];

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.

The constant was renamed from TASKS_IDS to TASK_IDS, but all the string references in debug messages still use the old plural form 'tasks' (e.g., 'Task' instead of 'tasks'). Consider whether this naming should be TASKS_IDS for consistency with the terminology used throughout the codebase, or update comments/messages to match the singular form.

Suggested change
pub const TASK_IDS: &'static [&'static str] = &[#( #task_ids ),*];
pub const TASKS_IDS: &'static [&'static str] = &[#( #task_ids ),*];

Copilot uses AI. Check for mistakes.
@gbin gbin merged commit d1b1a80 into master Feb 27, 2026
27 checks passed
@gbin gbin deleted the gbin/monitoring_not_guessing_task_mapping branch February 27, 2026 18:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaking bug Something isn't working enhancement New feature or request include in changelog

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants