fix(gateway): a cold daemon boot fits inside the client ensure deadline

Every attaching entrypoint (-z, chat -q, acp, cron, kanban workers) waits on
ensure_gateway_runtime for a cold `gateway run`. Under the parallel e2e shard on
the 32-core runner that boot took 10-20 s and the 30 s default tipped ~130 turns
into `Gateway starting: deadline`. Two changes: `cmd_gateway` no longer seeds the
skill library before dispatch (run_bootstrap seeds it inside the daemon home; the
CLI pass doubled a fresh-home boot), and the default deadline is 60 s across
ensure_gateway_runtime, `hermes gateway ensure --timeout` and the docs.
This commit is contained in:
teknium1
2026-09-24 08:11:42 -07:00
Unverified
parent eb9d6887de
commit 9c7dbc6e6f
4 changed files with 15 additions and 7 deletions
+7 -1
View File
@@ -13,6 +13,12 @@ from urllib.parse import urlsplit
if TYPE_CHECKING:
from gateway.runtime_contract import RuntimeState
# Total startup deadline a client waits for a cold daemon. A cold boot imports the whole
# runtime, seeds the skill library and warms the turn machinery: ~10-20 s on a loaded
# 32-core CI runner with dozens of sibling boots, where 30 s tipped every attaching client
# of a parallel e2e shard into `starting: deadline`. A minute is still a verdict, not a hang.
DEFAULT_ENSURE_TIMEOUT = 60.0
@dataclass(frozen=True)
class GatewayEndpoint:
@@ -168,7 +174,7 @@ def discover_gateway_endpoint(profile_home: str | Path, *, timeout: float = 2.0)
return GatewayDiscovery("inaccessible", reason_code="invalid_control_peer")
def ensure_gateway_runtime(profile_home: str | Path, *, timeout: float = 30.0) -> GatewayDiscovery:
def ensure_gateway_runtime(profile_home: str | Path, *, timeout: float = DEFAULT_ENSURE_TIMEOUT) -> GatewayDiscovery:
"""Ensure once, never install/replace; pending remains pending at deadline.
A successful service command or Popen is not session readiness. After an
+3 -2
View File
@@ -1886,8 +1886,9 @@ def cmd_chat(args):
def cmd_gateway(args):
"""Gateway management commands."""
_sync_bundled_skills_quietly()
# `gateway run` seeds skills itself (run_bootstrap._start_gateway_configure_logging) inside its
# own home; a second pass here doubled a cold boot on a fresh home while every attaching client
# waited on the ensure deadline. Management verbs never need the library.
from hermes_cli.gateway import gateway_command
gateway_command(args)
+2 -2
View File
@@ -97,8 +97,8 @@ def build_gateway_parser(
"4 authorization/profile mismatch; 5 deadline; 6 draining/update-paused; "
"7 inaccessible/conflicting supervisor. Pending startup is not readiness.")
_flag(gateway_ensure, "--json", help="Emit one credential-free JSON result (default)")
gateway_ensure.add_argument("--timeout", default="30",
help="Total startup deadline in seconds (default: 30)")
gateway_ensure.add_argument("--timeout", default="60",
help="Total startup deadline in seconds (default: 60)")
gateway_ensure.set_defaults(func=cmd_gateway_ensure)
gateway_start = gateway_subparsers.add_parser(
+3 -2
View File
@@ -369,7 +369,7 @@ Use `hermes gateway run` instead of `hermes gateway start` — WSL's systemd sup
### Local runtime discovery and startup
```bash
hermes gateway ensure --json --timeout 30
hermes gateway ensure --json --timeout 60
```
`ensure` targets the active profile and emits one JSON object with `state`,
@@ -377,7 +377,8 @@ hermes gateway ensure --json --timeout 30
local discovery reports compatible session readiness. Output contains no bootstrap
tickets or bearer credentials. JSON is also the default without `--json`.
The timeout is a finite, positive total deadline in seconds (default `30`). An
The timeout is a finite, positive total deadline in seconds (default `60`, enough for a
cold daemon boot on a loaded host). An
existing reservation or starting owner is waited for, not replaced. When absence
is established, an existing service takes precedence; an unmanaged process is
requested only when no service is found. This command never installs or rewrites