Skip to content

fix: watch source mode config files for multi-mode hot reload#2143

Open
dolepee wants to merge 1 commit intoOpenMind:mainfrom
dolepee:qdee-mode-hotreload-source-watch
Open

fix: watch source mode config files for multi-mode hot reload#2143
dolepee wants to merge 1 commit intoOpenMind:mainfrom
dolepee:qdee-mode-hotreload-source-watch

Conversation

@dolepee
Copy link

@dolepee dolepee commented Feb 6, 2026

Overview

Extends the multi-mode hot-reload system to watch source configuration files (and their referenced sub-configs), not just the generated runtime config snapshot.

Previously, ModeCortexRuntime only monitored the runtime config file for changes. If a user edited the original source config or any mode file it references, changes were silently ignored until a full restart. This patch closes that gap.

Relates to #984

Type of change

  • Bug fix
  • New feature

Changes

  • Source config resolution (_get_source_config_path): resolves the original mode config file from mode_config_name, handling absolute paths, relative paths, and the default config/ directory.
  • Config reference extraction (_extract_config_references): parses a JSON5 config and recursively discovers any .json/.json5 file paths referenced as string values (skipping URLs).
  • Multi-file watch set (_get_watched_config_paths): builds the complete set of files to monitor — runtime config + source config + all referenced configs.
  • Mtime tracking (_refresh_watched_config_mtimes): replaces the single last_modified check with a dict of per-file mtimes so any watched file change triggers a reload.
  • Smart reload path (_reload_config(reload_from_runtime=...)): when only the runtime snapshot changed, reloads from the snapshot; when source files changed, reloads from the original source and regenerates the runtime snapshot to keep them in sync.

Checklist

  • Code complies with style guidelines
  • Self-review completed
  • Tests added/updated (if applicable)
  • Local testing completed

Impact

This is scoped entirely to multi_mode/cortex.py and its tests. It does not touch single-mode, does not add new dependencies (uses the existing json5 import), and is fully backward-compatible — the default behaviour when only the runtime config changes is identical to before.

Additional Information

This is complementary to the single-mode selective field reload work discussed in #984. That bounty focuses on partial field-level reloading in single_mode/cortex.py; this PR addresses a different gap — ensuring multi-mode source config files and their references are properly watched alongside the runtime snapshot.

@dolepee dolepee requested review from a team as code owners February 6, 2026 15:24
@github-actions github-actions bot added robotics Robotics code changes python Python code tests Test files labels Feb 6, 2026
@dolepee dolepee force-pushed the qdee-mode-hotreload-source-watch branch from 68993c2 to 3f82275 Compare February 6, 2026 16:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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