Skip to content

The agent that grows with you

fix(gateway): a probe skip during reconcile keeps a parked profile parked

Teknium73f6357be28a
diff --git a/gateway/run_profile_reconcile.py b/gateway/run_profile_reconcile.py
index a4a4a66a919..0ec21501a1d 100644
--- a/gateway/run_profile_reconcile.py
+++ b/gateway/run_profile_reconcile.py
@@ -114,6 +114,7 @@ class GatewayProfileReconcileMixin:
async with self._reconcile_lock():
active = getattr(self, "_primary_profile_name", None) or "default"
live = {str(name): Path(home) for name, home in profiles_to_serve(multiplex=True)}
+ listed = set(live) # a probe skip below is not a deletion: it never clears a parked verdict
known = dict(self._served_profile_homes or {})
from gateway.status import live_gateway_pid_for_home
@@ -154,7 +155,7 @@ class GatewayProfileReconcileMixin:
self._profile_probe_timeout_warned = timed_out
sigs = self._served_profile_signatures or {}
from gateway.run_runtime import unpark_profile
- for name in [n for n in self._parked_profile_names() if n not in live]:
+ for name in [n for n in self._parked_profile_names() if n not in listed]:
unpark_profile(self, name)
parked = self._parked_profile_names()
# The watcher never re-parks the same profile every cycle; a creator's explicit signal does.
diff --git a/tests/gateway/test_reconcile_probe_skip_keeps_parked.py b/tests/gateway/test_reconcile_probe_skip_keeps_parked.py
new file mode 100644
index 00000000000..661ce78ac5b
--- /dev/null
+++ b/tests/gateway/test_reconcile_probe_skip_keeps_parked.py
@@ -0,0 +1,30 @@
+"""A profile skipped by the own-gateway probe this cycle keeps its parked verdict (N114)."""
+from unittest.mock import patch
+
+import pytest
+
+from tests.gateway.test_multiplex_hot_serve import _mkprofile, _runner
+
+
+async def test_probe_skip_keeps_a_parked_profile_parked(tmp_path, monkeypatch):
+ from gateway import run_profile_reconcile as reconcile_mod
+ from gateway.run import MultiplexConfigError
+
+ runner, home = _runner(tmp_path, monkeypatch)
+ _mkprofile(home, 'alpha', 'DISCORD_BOT_TOKEN=alpha-token\n')
+ with patch('hermes_cli.profiles.get_active_profile_name', return_value='default'):
+ await runner._start_secondary_profile_adapters()
+ _mkprofile(home, 'delta', 'DISCORD_BOT_TOKEN=delta-token\n')
+
+ async def park(name, profile_home, claimed):
+ raise MultiplexConfigError('open dm_policy')
+
+ runner._start_one_profile_adapters = park
+ assert (await runner.reconcile_served_profiles())['parked'] == ['delta']
+
+ # The next cycle's own-gateway probe stalls for delta: unprovable, skipped this cycle.
+ monkeypatch.setattr('gateway.status.live_gateway_pid_for_home', lambda profile_home: None)
+ monkeypatch.setattr(reconcile_mod, '_OWN_GATEWAY_PROBE_TIMEOUT_SECS', 0.0)
+ await runner.reconcile_served_profiles(reason='watcher')
+ assert 'delta' in runner.session_runtime_descriptor['parked_profiles']