mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-11-17 04:11:35 +00:00
Review follow-up on the auth-store lock timeout copy (#124533): - The 'likely holder' half of the timeout message was an unconditional literal, asserted even when no holder exists. Holders now stamp their pid into the lock file on acquire (cleared on release), and the timeout reads it back through a liveness probe: a live foreign pid is named, a stale pid or an empty file stays silent. - Permanent lock failures (ENOSYS/EOPNOTSUPP on flock-unsupported filesystems, bad fd) used to burn the whole deadline and then blame a holder that does not exist. Non-contention errnos now propagate immediately; EACCES stays retried because msvcrt reports both real contention and ACL denials as EACCES. - The shared Nous store lock raises through the same _file_lock on the same init path (resolve_nous_access_token) but its message did not match the routed prefix, so init fell back to the /model + hermes setup advice this PR exists to remove. Both prefixes now route to the contention copy, and the Nous timeout names its lock file too.
39 lines
1.9 KiB
Python
39 lines
1.9 KiB
Python
"""User-facing copy for assistant-start failures must match the failure's actual cause.
|
|
|
|
When init dies waiting for a cross-process auth lock — the profile auth-store lock or the shared
|
|
Nous store lock, both on the ``resolve_nous_access_token`` init path (#124533) — the cause is
|
|
contention with another hermes process (a dashboard or a slow credential refresh), so the generic
|
|
/model / `hermes setup` hints would send the user re-checking credentials that are fine.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
import pytest
|
|
|
|
from tui_gateway.user_messages import agent_init_failed_message
|
|
|
|
|
|
@pytest.mark.parametrize("exc_text", [
|
|
"Timed out waiting for auth store lock (/home/u/.hermes/profiles/coder/auth.lock); "
|
|
"another hermes process (pid 4242) probably still holds it "
|
|
"(e.g. a dashboard or a slow credential refresh)",
|
|
"Timed out waiting for auth store lock (/home/u/.hermes/profiles/coder/auth.lock)",
|
|
"Timed out waiting for shared Nous auth lock (/home/u/.hermes/shared/nous.lock)",
|
|
], ids=["auth-store-with-holder", "auth-store-no-holder", "shared-nous-store"])
|
|
def test_auth_lock_timeout_contention_gets_the_wait_copy(exc_text):
|
|
message = agent_init_failed_message(TimeoutError(exc_text))
|
|
assert "/model" not in message
|
|
assert "hermes setup" not in message
|
|
assert "lock" in message and "dashboard" in message # actionable: what holds it, what to do
|
|
|
|
|
|
def test_generic_timeout_keeps_the_model_setup_hints():
|
|
# A TimeoutError that is NOT an auth lock (e.g. a network connect timeout) must not
|
|
# be misread as lock contention.
|
|
message = agent_init_failed_message(TimeoutError("connect timed out"))
|
|
assert "/model" in message and "hermes setup" in message
|
|
|
|
|
|
def test_other_init_failures_keep_the_model_setup_hints():
|
|
message = agent_init_failed_message(RuntimeError("provider bootstrap failed"))
|
|
assert "/model" in message and "hermes setup" in message
|