feat(gateway): auto-restart dispatcher on hermes_cli code changes - #31
Conversation
|
Warning Review limit reached
More reviews will be available in 20 minutes and 45 seconds. Learn how PR review limits work. Your organization has run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📥 CommitsReviewing files that changed from the base of the PR and between 2dd78f3 and f2b817a9127dae1e08c09a17a7c2e5f7b7a5e6ea. 📒 Files selected for processing (3)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
🔎 Lint report:
|
| Rule | Count |
|---|---|
unresolved-import |
2 |
First entries
tests/gateway/test_code_watcher.py:23: [unresolved-import] unresolved-import: Cannot resolve imported module `pytest`
gateway/code_watcher.py:298: [unresolved-import] unresolved-import: Cannot resolve imported module `psutil`
✅ Fixed issues: none
Unchanged: 5040 pre-existing issues carried over.
Diagnostics are surfaced as warnings — this check never fails the build.
|
auto-review: changes requested. Matrix checks (U1–U5, C1–C5)
Code-quality judgment (role-reviewer)Overall the implementation is solid. The two issues above are the only blockers. Once fixed:
Required fixes before approval
Amend the commit, force-push, and CI should go green. |
1dd9d4b to
f2b817a
Compare
|
Fix push (run 3): Addressed the two sdlc-review rejections:
|
|
auto-review: approved, awaiting human merge + kanban_approve. Matrix checks (U1-U5, C1-C5): All pass.
Code-quality judgment (role-reviewer): APPROVED — no blockers. 4-level platform fallback in _get_process_start_time() is documented and intentional. CodeWatcher is well-scoped, daemon thread correctly stopped on shutdown. Tests are behavioral. |
Adds gateway/code_watcher.py — a background daemon thread that polls the mtime of every hermes-agent .py file imported into sys.modules. When any file's mtime is newer than the gateway process start time, the watcher logs a warning and calls os.execv to reload in-place, preserving the PID for launchd/systemd supervisors. This eliminates the stale-dispatcher-runs-old-code class of bugs: a PR merging while the gateway is running will be picked up within 60 seconds (one poll cycle) without any manual restart. Changes: - gateway/code_watcher.py: new module — CodeWatcher class, start_code_watcher() factory, helper functions - gateway/run.py: start_code_watcher() called alongside the cron thread in start_gateway(); stopped cleanly on shutdown - tests/gateway/test_code_watcher.py: 21 unit tests covering env opt-out, config opt-out, mtime detection, os.execv invocation, file filtering Config opt-outs: gateway.auto_restart_on_code_change: false (config.yaml) HERMES_GATEWAY_NO_AUTO_RESTART=1 (env, wins over config) Fixes: stale-gateway recurring pattern documented in kanban t_014159c0
f2b817a to
a9b7540
Compare
|
Warning Review limit reached
More reviews will be available in 2 minutes and 29 seconds. Learn how PR review limits work. Your organization has run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
auto-review: approved. All U1-U5 and C1-C5 pass. Matrix checks (U1–U5, C1–C5):
Code-quality judgment (role-reviewer): APPROVED, no Blockers or Majors.
Awaiting Sahil's merge + kanban_approve. |
Adds gateway/code_watcher.py — a background daemon thread that polls the mtime of every hermes-agent .py file imported into sys.modules. When any file's mtime is newer than the gateway process start time, the watcher logs a warning and calls os.execv to reload in-place, preserving the PID for launchd/systemd supervisors. This eliminates the stale-dispatcher-runs-old-code class of bugs: a PR merging while the gateway is running will be picked up within 60 seconds (one poll cycle) without any manual restart. Changes: - gateway/code_watcher.py: new module — CodeWatcher class, start_code_watcher() factory, helper functions - gateway/run.py: start_code_watcher() called alongside the cron thread in start_gateway(); stopped cleanly on shutdown - tests/gateway/test_code_watcher.py: 21 unit tests covering env opt-out, config opt-out, mtime detection, os.execv invocation, file filtering Config opt-outs: gateway.auto_restart_on_code_change: false (config.yaml) HERMES_GATEWAY_NO_AUTO_RESTART=1 (env, wins over config) Fixes: stale-gateway recurring pattern documented in kanban t_014159c0 Co-authored-by: Sahil (AI) <266772320+sahilm-ai@users.noreply.github.com>
Adds gateway/code_watcher.py — a background daemon thread that polls the mtime of every hermes-agent .py file imported into sys.modules. When any file's mtime is newer than the gateway process start time, the watcher logs a warning and calls os.execv to reload in-place, preserving the PID for launchd/systemd supervisors. This eliminates the stale-dispatcher-runs-old-code class of bugs: a PR merging while the gateway is running will be picked up within 60 seconds (one poll cycle) without any manual restart. Changes: - gateway/code_watcher.py: new module — CodeWatcher class, start_code_watcher() factory, helper functions - gateway/run.py: start_code_watcher() called alongside the cron thread in start_gateway(); stopped cleanly on shutdown - tests/gateway/test_code_watcher.py: 21 unit tests covering env opt-out, config opt-out, mtime detection, os.execv invocation, file filtering Config opt-outs: gateway.auto_restart_on_code_change: false (config.yaml) HERMES_GATEWAY_NO_AUTO_RESTART=1 (env, wins over config) Fixes: stale-gateway recurring pattern documented in kanban t_014159c0 Co-authored-by: Sahil (AI) <266772320+sahilm-ai@users.noreply.github.com>
Adds gateway/code_watcher.py — a background daemon thread that polls the mtime of every hermes-agent .py file imported into sys.modules. When any file's mtime is newer than the gateway process start time, the watcher logs a warning and calls os.execv to reload in-place, preserving the PID for launchd/systemd supervisors. This eliminates the stale-dispatcher-runs-old-code class of bugs: a PR merging while the gateway is running will be picked up within 60 seconds (one poll cycle) without any manual restart. Changes: - gateway/code_watcher.py: new module — CodeWatcher class, start_code_watcher() factory, helper functions - gateway/run.py: start_code_watcher() called alongside the cron thread in start_gateway(); stopped cleanly on shutdown - tests/gateway/test_code_watcher.py: 21 unit tests covering env opt-out, config opt-out, mtime detection, os.execv invocation, file filtering Config opt-outs: gateway.auto_restart_on_code_change: false (config.yaml) HERMES_GATEWAY_NO_AUTO_RESTART=1 (env, wins over config) Fixes: stale-gateway recurring pattern documented in kanban t_014159c0 Co-authored-by: Sahil (AI) <266772320+sahilm-ai@users.noreply.github.com>
Adds gateway/code_watcher.py — a background daemon thread that polls the mtime of every hermes-agent .py file imported into sys.modules. When any file's mtime is newer than the gateway process start time, the watcher logs a warning and calls os.execv to reload in-place, preserving the PID for launchd/systemd supervisors. This eliminates the stale-dispatcher-runs-old-code class of bugs: a PR merging while the gateway is running will be picked up within 60 seconds (one poll cycle) without any manual restart. Changes: - gateway/code_watcher.py: new module — CodeWatcher class, start_code_watcher() factory, helper functions - gateway/run.py: start_code_watcher() called alongside the cron thread in start_gateway(); stopped cleanly on shutdown - tests/gateway/test_code_watcher.py: 21 unit tests covering env opt-out, config opt-out, mtime detection, os.execv invocation, file filtering Config opt-outs: gateway.auto_restart_on_code_change: false (config.yaml) HERMES_GATEWAY_NO_AUTO_RESTART=1 (env, wins over config) Fixes: stale-gateway recurring pattern documented in kanban t_014159c0 Co-authored-by: Sahil (AI) <266772320+sahilm-ai@users.noreply.github.com>
Adds gateway/code_watcher.py — a background daemon thread that polls the mtime of every hermes-agent .py file imported into sys.modules. When any file's mtime is newer than the gateway process start time, the watcher logs a warning and calls os.execv to reload in-place, preserving the PID for launchd/systemd supervisors. This eliminates the stale-dispatcher-runs-old-code class of bugs: a PR merging while the gateway is running will be picked up within 60 seconds (one poll cycle) without any manual restart. Changes: - gateway/code_watcher.py: new module — CodeWatcher class, start_code_watcher() factory, helper functions - gateway/run.py: start_code_watcher() called alongside the cron thread in start_gateway(); stopped cleanly on shutdown - tests/gateway/test_code_watcher.py: 21 unit tests covering env opt-out, config opt-out, mtime detection, os.execv invocation, file filtering Config opt-outs: gateway.auto_restart_on_code_change: false (config.yaml) HERMES_GATEWAY_NO_AUTO_RESTART=1 (env, wins over config) Fixes: stale-gateway recurring pattern documented in kanban t_014159c0 Co-authored-by: Sahil (AI) <266772320+sahilm-ai@users.noreply.github.com>
Adds gateway/code_watcher.py — a background daemon thread that polls the mtime of every hermes-agent .py file imported into sys.modules. When any file's mtime is newer than the gateway process start time, the watcher logs a warning and calls os.execv to reload in-place, preserving the PID for launchd/systemd supervisors. This eliminates the stale-dispatcher-runs-old-code class of bugs: a PR merging while the gateway is running will be picked up within 60 seconds (one poll cycle) without any manual restart. Changes: - gateway/code_watcher.py: new module — CodeWatcher class, start_code_watcher() factory, helper functions - gateway/run.py: start_code_watcher() called alongside the cron thread in start_gateway(); stopped cleanly on shutdown - tests/gateway/test_code_watcher.py: 21 unit tests covering env opt-out, config opt-out, mtime detection, os.execv invocation, file filtering Config opt-outs: gateway.auto_restart_on_code_change: false (config.yaml) HERMES_GATEWAY_NO_AUTO_RESTART=1 (env, wins over config) Fixes: stale-gateway recurring pattern documented in kanban t_014159c0 Co-authored-by: Sahil (AI) <266772320+sahilm-ai@users.noreply.github.com>
Adds gateway/code_watcher.py — a background daemon thread that polls the mtime of every hermes-agent .py file imported into sys.modules. When any file's mtime is newer than the gateway process start time, the watcher logs a warning and calls os.execv to reload in-place, preserving the PID for launchd/systemd supervisors. This eliminates the stale-dispatcher-runs-old-code class of bugs: a PR merging while the gateway is running will be picked up within 60 seconds (one poll cycle) without any manual restart. Changes: - gateway/code_watcher.py: new module — CodeWatcher class, start_code_watcher() factory, helper functions - gateway/run.py: start_code_watcher() called alongside the cron thread in start_gateway(); stopped cleanly on shutdown - tests/gateway/test_code_watcher.py: 21 unit tests covering env opt-out, config opt-out, mtime detection, os.execv invocation, file filtering Config opt-outs: gateway.auto_restart_on_code_change: false (config.yaml) HERMES_GATEWAY_NO_AUTO_RESTART=1 (env, wins over config) Fixes: stale-gateway recurring pattern documented in kanban t_014159c0 Co-authored-by: Sahil (AI) <266772320+sahilm-ai@users.noreply.github.com>
Adds gateway/code_watcher.py — a background daemon thread that polls the mtime of every hermes-agent .py file imported into sys.modules. When any file's mtime is newer than the gateway process start time, the watcher logs a warning and calls os.execv to reload in-place, preserving the PID for launchd/systemd supervisors. This eliminates the stale-dispatcher-runs-old-code class of bugs: a PR merging while the gateway is running will be picked up within 60 seconds (one poll cycle) without any manual restart. Changes: - gateway/code_watcher.py: new module — CodeWatcher class, start_code_watcher() factory, helper functions - gateway/run.py: start_code_watcher() called alongside the cron thread in start_gateway(); stopped cleanly on shutdown - tests/gateway/test_code_watcher.py: 21 unit tests covering env opt-out, config opt-out, mtime detection, os.execv invocation, file filtering Config opt-outs: gateway.auto_restart_on_code_change: false (config.yaml) HERMES_GATEWAY_NO_AUTO_RESTART=1 (env, wins over config) Fixes: stale-gateway recurring pattern documented in kanban t_014159c0 Co-authored-by: Sahil (AI) <266772320+sahilm-ai@users.noreply.github.com>
Adds gateway/code_watcher.py — a background daemon thread that polls the mtime of every hermes-agent .py file imported into sys.modules. When any file's mtime is newer than the gateway process start time, the watcher logs a warning and calls os.execv to reload in-place, preserving the PID for launchd/systemd supervisors. This eliminates the stale-dispatcher-runs-old-code class of bugs: a PR merging while the gateway is running will be picked up within 60 seconds (one poll cycle) without any manual restart. Changes: - gateway/code_watcher.py: new module — CodeWatcher class, start_code_watcher() factory, helper functions - gateway/run.py: start_code_watcher() called alongside the cron thread in start_gateway(); stopped cleanly on shutdown - tests/gateway/test_code_watcher.py: 21 unit tests covering env opt-out, config opt-out, mtime detection, os.execv invocation, file filtering Config opt-outs: gateway.auto_restart_on_code_change: false (config.yaml) HERMES_GATEWAY_NO_AUTO_RESTART=1 (env, wins over config) Fixes: stale-gateway recurring pattern documented in kanban t_014159c0 Co-authored-by: Sahil (AI) <266772320+sahilm-ai@users.noreply.github.com>
Adds gateway/code_watcher.py — a background daemon thread that polls the mtime of every hermes-agent .py file imported into sys.modules. When any file's mtime is newer than the gateway process start time, the watcher logs a warning and calls os.execv to reload in-place, preserving the PID for launchd/systemd supervisors. This eliminates the stale-dispatcher-runs-old-code class of bugs: a PR merging while the gateway is running will be picked up within 60 seconds (one poll cycle) without any manual restart. Changes: - gateway/code_watcher.py: new module — CodeWatcher class, start_code_watcher() factory, helper functions - gateway/run.py: start_code_watcher() called alongside the cron thread in start_gateway(); stopped cleanly on shutdown - tests/gateway/test_code_watcher.py: 21 unit tests covering env opt-out, config opt-out, mtime detection, os.execv invocation, file filtering Config opt-outs: gateway.auto_restart_on_code_change: false (config.yaml) HERMES_GATEWAY_NO_AUTO_RESTART=1 (env, wins over config) Fixes: stale-gateway recurring pattern documented in kanban t_014159c0 Co-authored-by: Sahil (AI) <266772320+sahilm-ai@users.noreply.github.com>
Adds gateway/code_watcher.py — a background daemon thread that polls the mtime of every hermes-agent .py file imported into sys.modules. When any file's mtime is newer than the gateway process start time, the watcher logs a warning and calls os.execv to reload in-place, preserving the PID for launchd/systemd supervisors. This eliminates the stale-dispatcher-runs-old-code class of bugs: a PR merging while the gateway is running will be picked up within 60 seconds (one poll cycle) without any manual restart. Changes: - gateway/code_watcher.py: new module — CodeWatcher class, start_code_watcher() factory, helper functions - gateway/run.py: start_code_watcher() called alongside the cron thread in start_gateway(); stopped cleanly on shutdown - tests/gateway/test_code_watcher.py: 21 unit tests covering env opt-out, config opt-out, mtime detection, os.execv invocation, file filtering Config opt-outs: gateway.auto_restart_on_code_change: false (config.yaml) HERMES_GATEWAY_NO_AUTO_RESTART=1 (env, wins over config) Fixes: stale-gateway recurring pattern documented in kanban t_014159c0 Co-authored-by: Sahil (AI) <266772320+sahilm-ai@users.noreply.github.com>
Adds gateway/code_watcher.py — a background daemon thread that polls the mtime of every hermes-agent .py file imported into sys.modules. When any file's mtime is newer than the gateway process start time, the watcher logs a warning and calls os.execv to reload in-place, preserving the PID for launchd/systemd supervisors. This eliminates the stale-dispatcher-runs-old-code class of bugs: a PR merging while the gateway is running will be picked up within 60 seconds (one poll cycle) without any manual restart. Changes: - gateway/code_watcher.py: new module — CodeWatcher class, start_code_watcher() factory, helper functions - gateway/run.py: start_code_watcher() called alongside the cron thread in start_gateway(); stopped cleanly on shutdown - tests/gateway/test_code_watcher.py: 21 unit tests covering env opt-out, config opt-out, mtime detection, os.execv invocation, file filtering Config opt-outs: gateway.auto_restart_on_code_change: false (config.yaml) HERMES_GATEWAY_NO_AUTO_RESTART=1 (env, wins over config) Fixes: stale-gateway recurring pattern documented in kanban t_014159c0 Co-authored-by: Sahil (AI) <266772320+sahilm-ai@users.noreply.github.com>
Adds gateway/code_watcher.py — a background daemon thread that polls the mtime of every hermes-agent .py file imported into sys.modules. When any file's mtime is newer than the gateway process start time, the watcher logs a warning and calls os.execv to reload in-place, preserving the PID for launchd/systemd supervisors. This eliminates the stale-dispatcher-runs-old-code class of bugs: a PR merging while the gateway is running will be picked up within 60 seconds (one poll cycle) without any manual restart. Changes: - gateway/code_watcher.py: new module — CodeWatcher class, start_code_watcher() factory, helper functions - gateway/run.py: start_code_watcher() called alongside the cron thread in start_gateway(); stopped cleanly on shutdown - tests/gateway/test_code_watcher.py: 21 unit tests covering env opt-out, config opt-out, mtime detection, os.execv invocation, file filtering Config opt-outs: gateway.auto_restart_on_code_change: false (config.yaml) HERMES_GATEWAY_NO_AUTO_RESTART=1 (env, wins over config) Fixes: stale-gateway recurring pattern documented in kanban t_014159c0 Co-authored-by: Sahil (AI) <266772320+sahilm-ai@users.noreply.github.com>
Adds gateway/code_watcher.py — a background daemon thread that polls the mtime of every hermes-agent .py file imported into sys.modules. When any file's mtime is newer than the gateway process start time, the watcher logs a warning and calls os.execv to reload in-place, preserving the PID for launchd/systemd supervisors. This eliminates the stale-dispatcher-runs-old-code class of bugs: a PR merging while the gateway is running will be picked up within 60 seconds (one poll cycle) without any manual restart. Changes: - gateway/code_watcher.py: new module — CodeWatcher class, start_code_watcher() factory, helper functions - gateway/run.py: start_code_watcher() called alongside the cron thread in start_gateway(); stopped cleanly on shutdown - tests/gateway/test_code_watcher.py: 21 unit tests covering env opt-out, config opt-out, mtime detection, os.execv invocation, file filtering Config opt-outs: gateway.auto_restart_on_code_change: false (config.yaml) HERMES_GATEWAY_NO_AUTO_RESTART=1 (env, wins over config) Fixes: stale-gateway recurring pattern documented in kanban t_014159c0 Co-authored-by: Sahil (AI) <266772320+sahilm-ai@users.noreply.github.com>
Adds gateway/code_watcher.py — a background daemon thread that polls the mtime of every hermes-agent .py file imported into sys.modules. When any file's mtime is newer than the gateway process start time, the watcher logs a warning and calls os.execv to reload in-place, preserving the PID for launchd/systemd supervisors. This eliminates the stale-dispatcher-runs-old-code class of bugs: a PR merging while the gateway is running will be picked up within 60 seconds (one poll cycle) without any manual restart. Changes: - gateway/code_watcher.py: new module — CodeWatcher class, start_code_watcher() factory, helper functions - gateway/run.py: start_code_watcher() called alongside the cron thread in start_gateway(); stopped cleanly on shutdown - tests/gateway/test_code_watcher.py: 21 unit tests covering env opt-out, config opt-out, mtime detection, os.execv invocation, file filtering Config opt-outs: gateway.auto_restart_on_code_change: false (config.yaml) HERMES_GATEWAY_NO_AUTO_RESTART=1 (env, wins over config) Fixes: stale-gateway recurring pattern documented in kanban t_014159c0 Co-authored-by: Sahil (AI) <266772320+sahilm-ai@users.noreply.github.com>
Adds gateway/code_watcher.py — a background daemon thread that polls the mtime of every hermes-agent .py file imported into sys.modules. When any file's mtime is newer than the gateway process start time, the watcher logs a warning and calls os.execv to reload in-place, preserving the PID for launchd/systemd supervisors. This eliminates the stale-dispatcher-runs-old-code class of bugs: a PR merging while the gateway is running will be picked up within 60 seconds (one poll cycle) without any manual restart. Changes: - gateway/code_watcher.py: new module — CodeWatcher class, start_code_watcher() factory, helper functions - gateway/run.py: start_code_watcher() called alongside the cron thread in start_gateway(); stopped cleanly on shutdown - tests/gateway/test_code_watcher.py: 21 unit tests covering env opt-out, config opt-out, mtime detection, os.execv invocation, file filtering Config opt-outs: gateway.auto_restart_on_code_change: false (config.yaml) HERMES_GATEWAY_NO_AUTO_RESTART=1 (env, wins over config) Fixes: stale-gateway recurring pattern documented in kanban t_014159c0 Co-authored-by: Sahil (AI) <266772320+sahilm-ai@users.noreply.github.com>
Adds gateway/code_watcher.py — a background daemon thread that polls the mtime of every hermes-agent .py file imported into sys.modules. When any file's mtime is newer than the gateway process start time, the watcher logs a warning and calls os.execv to reload in-place, preserving the PID for launchd/systemd supervisors. This eliminates the stale-dispatcher-runs-old-code class of bugs: a PR merging while the gateway is running will be picked up within 60 seconds (one poll cycle) without any manual restart. Changes: - gateway/code_watcher.py: new module — CodeWatcher class, start_code_watcher() factory, helper functions - gateway/run.py: start_code_watcher() called alongside the cron thread in start_gateway(); stopped cleanly on shutdown - tests/gateway/test_code_watcher.py: 21 unit tests covering env opt-out, config opt-out, mtime detection, os.execv invocation, file filtering Config opt-outs: gateway.auto_restart_on_code_change: false (config.yaml) HERMES_GATEWAY_NO_AUTO_RESTART=1 (env, wins over config) Fixes: stale-gateway recurring pattern documented in kanban t_014159c0 Co-authored-by: Sahil (AI) <266772320+sahilm-ai@users.noreply.github.com>
Adds gateway/code_watcher.py — a background daemon thread that polls the mtime of every hermes-agent .py file imported into sys.modules. When any file's mtime is newer than the gateway process start time, the watcher logs a warning and calls os.execv to reload in-place, preserving the PID for launchd/systemd supervisors. This eliminates the stale-dispatcher-runs-old-code class of bugs: a PR merging while the gateway is running will be picked up within 60 seconds (one poll cycle) without any manual restart. Changes: - gateway/code_watcher.py: new module — CodeWatcher class, start_code_watcher() factory, helper functions - gateway/run.py: start_code_watcher() called alongside the cron thread in start_gateway(); stopped cleanly on shutdown - tests/gateway/test_code_watcher.py: 21 unit tests covering env opt-out, config opt-out, mtime detection, os.execv invocation, file filtering Config opt-outs: gateway.auto_restart_on_code_change: false (config.yaml) HERMES_GATEWAY_NO_AUTO_RESTART=1 (env, wins over config) Fixes: stale-gateway recurring pattern documented in kanban t_014159c0 Co-authored-by: Sahil (AI) <266772320+sahilm-ai@users.noreply.github.com>
Summary
Fixes the recurring "stale-dispatcher-runs-old-code" class of bugs (kanban
t_014159c0).When a PR merges to
main, any gateway process started before the merge keeps executingold code from memory. This shows up as workers spawned after the merge still running
the buggy behavior the fix supposedly cured — because the dispatcher never reloaded.
Solution:
gateway/code_watcher.py— a background daemon thread that polls themtime of every hermes-agent .py file imported into
sys.modules. When any file'smtime is newer than the gateway process start time, the watcher logs a warning and
calls
os.execvto reload in-place, preserving the PID for launchd/systemd supervisors.Changes
gateway/code_watcher.py(new) —CodeWatcherclass,start_code_watcher()factorygateway/run.py— hooksstart_code_watcher()alongside the cron ticker instart_gateway()tests/gateway/test_code_watcher.py(new) — 21 unit tests, all passingOpt-outs
Config (
~/.hermes/config.yaml):Env (wins over config):
Trigger policy
stat()calls per tick)os.execvpreserves PID — launchd/systemd supervisors don't see a process replacementVerification
Smoke test run locally with a fake process start time (5 minutes in the past) and
os.execvmonkeypatched to record calls instead of actually re-exec'ing:Manual smoke test recipe (for PR reviewer / Sahil):
Screenshot N/A — log lines verified via stdout capture pasted above.
Tests