Skip to content

Conversation

@farukk77
Copy link

@farukk77 farukk77 commented Feb 9, 2026

What

This PR upgrades runtime hot-reload from polling-based mtime checks to watchdog file-system events (with polling fallback), and moves “partial vs full reload” decisions into the runtime via a field-level patch.

Why

  • Faster and more reliable config reload triggers (no polling delay when watchdog is available)
  • Clear separation of concerns: watcher only signals “changed”, runtime decides what to do
  • Safer reload semantics: partial updates only for whitelisted prompt/governance fields; full reload otherwise
  • More robust runtime config writes on Windows via atomic replace

Changes

  • Add watchdog dependency and an async-friendly debounced file watcher ( AsyncFileWatcher )
  • Single-mode: patch-based reload decision + watchdog integration + polling fallback
  • Multi-mode: same patch-based pattern + watchdog integration + polling fallback
  • ConfigProvider: write runtime config atomically using os.replace and json5.dump
  • Tests updated/added to cover watchdog-triggered reload and reload safety

Key files

  • src/runtime/hot_reload/watcher.py
  • src/runtime/single_mode/cortex.py
  • src/runtime/multi_mode/cortex.py
    • src/providers/config_provider.py
  • tests/runtime/**/test_cortex*.py

Verification

  • Ran targeted hot-reload related tests:
    • tests/runtime/single_mode/test_cortex.py
    • tests/runtime/multi_mode/test_cortex.py
    • tests/runtime/multi_mode/test_cortex_mode_transition.py

Refactor CortexRuntime into ModeCortexRuntime to support mode-aware functionality. Introduce mode management and configuration handling for dynamic operational modes.
Updated config provider to use json5 for dumping and improved temp file handling.
Add extensive tests for mode transitions in cortex runtime, covering various scenarios including input triggers, emergency mode handling, and transition callbacks.
Add unit tests for ModeCortexRuntime class including hot reload functionality and mode transitions.
Add tests for CortexRuntime including hot reload functionality and configuration change detection.
Refactor ModeCortexRuntime to CortexRuntime and update configuration handling for single mode.
Added support for hot-reloading configuration using a watchdog mechanism. Enhanced the reload logic to apply partial updates based on changes in the configuration file.
@farukk77 farukk77 requested review from a team as code owners February 9, 2026 21:50
@github-actions github-actions bot added dependencies Pull requests that update a dependency file robotics Robotics code changes python Python code tests Test files config Configuration files labels Feb 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

config Configuration files dependencies Pull requests that update a dependency file 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