fix: watchdog config drift check uses YAML parse, not grep (#377) #398

Merged
Rockachopa merged 1 commits from burn/377-1776117775 into main 2026-04-14 00:34:17 +00:00
Owner

Closes #377

Bug

check_config_drift() in model-watchdog.py grepped for the first provider: line in each config file to check for drift. This is fragile because config.yaml has provider: on lines 3, 55, 73, 83, 86, etc. — only works because the first one happens to be model.provider.

If anyone adds a provider: field above model: (e.g. fallback_model.provider), the watchdog would false-positive on every run.

Fix

# Before (fragile grep)
for line in content.split('\n'):
    if line.strip().startswith('provider:'):
        actual = line.split(':', 1)[1].strip()
        break  # takes the FIRST provider: line

# After (YAML parse)
cfg = yaml.safe_load(content) or {}
actual = (cfg.get('model') or {}).get('provider', '')

Also includes a fallback for environments without yaml: an indentation-aware scan that only matches provider: under the model: block (indent > 0, preceded by model: at indent 0).

This file was previously only in ~/.hermes/bin/ (local). Adding it to the repo so fixes are version-controlled.

Closes #377 ## Bug `check_config_drift()` in `model-watchdog.py` grepped for the first `provider:` line in each config file to check for drift. This is fragile because `config.yaml` has `provider:` on lines 3, 55, 73, 83, 86, etc. — only works because the first one happens to be `model.provider`. If anyone adds a `provider:` field above `model:` (e.g. `fallback_model.provider`), the watchdog would false-positive on every run. ## Fix ```python # Before (fragile grep) for line in content.split('\n'): if line.strip().startswith('provider:'): actual = line.split(':', 1)[1].strip() break # takes the FIRST provider: line # After (YAML parse) cfg = yaml.safe_load(content) or {} actual = (cfg.get('model') or {}).get('provider', '') ``` Also includes a fallback for environments without `yaml`: an indentation-aware scan that only matches `provider:` under the `model:` block (indent > 0, preceded by `model:` at indent 0). This file was previously only in `~/.hermes/bin/` (local). Adding it to the repo so fixes are version-controlled.
Timmy added 1 commit 2026-04-13 22:13:22 +00:00
fix: config drift check uses YAML parse not grep (#377)
Some checks failed
Forge CI / smoke-and-build (pull_request) Failing after 59s
87867f3d10
Timmy reviewed 2026-04-13 23:21:41 +00:00
Timmy left a comment
Author
Owner

PR #398: fix: watchdog config drift check uses YAML parse, not grep (#377)

Good fix. The new check_config_drift() properly parses YAML to read model.provider instead of grepping for the first provider: line. The fallback for missing PyYAML (indentation-aware line scan) is a nice touch.

Minor notes:

  • shell=True in subprocess.run calls throughout the script is a minor security concern for a watchdog, though acceptable since this runs locally with trusted inputs.
  • The bare except: in check_session_meta should be except Exception: to avoid catching KeyboardInterrupt/SystemExit.
  • get_hermes_pid_for_tty uses grep [h]ermes shell trick -- works but brittle if process names change.

LGTM.

**PR #398: fix: watchdog config drift check uses YAML parse, not grep (#377)** Good fix. The new `check_config_drift()` properly parses YAML to read `model.provider` instead of grepping for the first `provider:` line. The fallback for missing PyYAML (indentation-aware line scan) is a nice touch. Minor notes: - `shell=True` in `subprocess.run` calls throughout the script is a minor security concern for a watchdog, though acceptable since this runs locally with trusted inputs. - The bare `except:` in `check_session_meta` should be `except Exception:` to avoid catching `KeyboardInterrupt`/`SystemExit`. - `get_hermes_pid_for_tty` uses `grep [h]ermes` shell trick -- works but brittle if process names change. LGTM.
Rockachopa merged commit 8d0cad13c4 into main 2026-04-14 00:34:16 +00:00
Sign in to join this conversation.
No Reviewers
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Timmy_Foundation/hermes-agent#398