Skip to content

Conversation

@YuchengZhou821
Copy link
Contributor

@YuchengZhou821 YuchengZhou821 commented Feb 10, 2026

This pull request refactors the runtime configuration system by fully transitioning from the old single-mode configuration to a unified multi-mode format. It introduces a normalization layer so that legacy single-mode configs are automatically converted to multi-mode, simplifying the codebase and user experience. The changes remove all direct dependencies on runtime.single_mode.config, consolidate schema validation logic, and streamline CLI output and validation.

Configuration system refactoring:

  • Removed all imports and usage of runtime.single_mode.config and runtime.single_mode.cortex throughout the codebase, replacing them with runtime.multi_mode.config and ModeCortexRuntime. This ensures only the multi-mode configuration system is used. [1] [2] [3] [4] [5] [6]
  • Added a normalization layer (normalize_to_multi_mode) in src/runtime/normalization.py that automatically converts legacy single-mode configs to the multi-mode format, including validation for required fields.
  • Updated schema validation logic: removed the old src/runtime/config.py file and moved schema loading and validation into src/runtime/multi_mode/config.py. Now, all configs are validated against the appropriate schema after normalization. [1] [2] [3] [4]

CLI and validation improvements:

  • Simplified CLI config listing and validation: removed distinction between "mode-aware" and "standard" configs, so all configs are shown as "Configurations" and are normalized before validation. Also, component validation and summary printing no longer require a config type flag. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12]

Code cleanup:

  • Removed obsolete single-mode configuration classes and functions, and consolidated shared utilities (such as add_meta and RuntimeConfig) into the multi-mode config module.

These changes make configuration handling more robust and future-proof by ensuring all runtime logic operates on a single, unified format.

Copilot AI review requested due to automatic review settings February 10, 2026 19:59
@YuchengZhou821 YuchengZhou821 requested review from a team as code owners February 10, 2026 19:59
@github-actions github-actions bot added robotics Robotics code changes python Python code tests Test files config Configuration files labels Feb 10, 2026

This comment was marked as resolved.

@codecov
Copy link

codecov bot commented Feb 10, 2026

Codecov Report

❌ Patch coverage is 93.33333% with 8 lines in your changes missing coverage. Please review.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
src/cli.py 69.23% 8 Missing ⚠️

📢 Thoughts on this report? Let us know!

Copy link
Contributor

Copilot AI left a comment

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 22 out of 24 changed files in this pull request and generated 4 comments.

Comments suppressed due to low confidence (1)

src/cli.py:1

  • The CLI validates schema before normalization and then proceeds using the normalized config for component validation and summary output. This leaves the normalized structure unvalidated (and can surface different behavior vs load_mode_config). Consider normalizing first and validating the normalized config against the multi-mode schema so the user sees schema errors for the final effective configuration.
import ast

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

Comment on lines 482 to +483
validate_config_schema(raw_config)
raw_config = normalize_to_multi_mode(raw_config)
Copy link

Copilot AI Feb 11, 2026

Choose a reason for hiding this comment

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

This validates the pre-normalized config and never validates the normalized config. That contradicts the PR’s goal (“validated … after normalization”) and can allow invalid normalized multi-mode structures to slip through (e.g., missing required mode fields) without schema enforcement. Normalize first, then validate the normalized output against the multi-mode schema (or run a second validation step after normalization so the final shape is always validated).

Suggested change
validate_config_schema(raw_config)
raw_config = normalize_to_multi_mode(raw_config)
raw_config = normalize_to_multi_mode(raw_config)
validate_config_schema(raw_config)

Copilot uses AI. Check for mistakes.
original_llm_ask = cortex.config.cortex_llm.ask
original_llm_ask = cortex.current_config.cortex_llm.ask

async def mock_llm_ask(prompt: str, messages: List[Dict[str, str]] = []):
Copy link

Copilot AI Feb 11, 2026

Choose a reason for hiding this comment

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

Avoid mutable default arguments. Using [] as a default can leak state between calls/tests. Use messages: Optional[List[Dict[str, str]]] = None and initialize to an empty list inside the function.

Suggested change
async def mock_llm_ask(prompt: str, messages: List[Dict[str, str]] = []):
async def mock_llm_ask(
prompt: str, messages: Optional[List[Dict[str, str]]] = None
):
if messages is None:
messages = []

Copilot uses AI. Check for mistakes.


def _load_schema(schema_file: str) -> dict:
"""Load and cache schema files."""
Copy link

Copilot AI Feb 11, 2026

Choose a reason for hiding this comment

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

The docstring claims schema files are cached, but _load_schema loads from disk every time. Either add caching (e.g., functools.lru_cache) or adjust the docstring to match the implementation.

Suggested change
"""Load and cache schema files."""
"""Load a schema file from disk."""

Copilot uses AI. Check for mistakes.
Comment on lines 480 to +483
config_version = raw_config.get("version")
verify_runtime_version(config_version, config_name)
validate_config_schema(raw_config)
raw_config = normalize_to_multi_mode(raw_config)
Copy link

Copilot AI Feb 11, 2026

Choose a reason for hiding this comment

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

Given normalization is now part of the runtime config load path, add a test that load_mode_config() validates the normalized config (e.g., provide a single-mode config that normalizes into an invalid multi-mode shape and assert a ValidationError after normalization). This will prevent regressions where schema validation accidentally happens only on the pre-normalized input.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

config Configuration files python Python code robotics Robotics code changes tests Test files

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant