Skip to content

The agent that grows with you

fix(onboarding): the due stamp watches shared Nous auth and the managed layer

alt-glitch85ba673a3654
diff --git a/tests/tui_gateway/test_onboarding_welcome_claim.py b/tests/tui_gateway/test_onboarding_welcome_claim.py
index 7ab0c4e394c..4af9c3b09b6 100644
--- a/tests/tui_gateway/test_onboarding_welcome_claim.py
+++ b/tests/tui_gateway/test_onboarding_welcome_claim.py
@@ -157,3 +157,37 @@ def test_the_due_answer_is_worked_out_at_boot_and_served_from_there(portal, monk
assert answers[0]["run"] is True and answers[0]["eligible"] is True and answers == [answers[0]] * 3
assert callers and set(callers) == {"onboarding-due"} # the requests themselves never walk the ladder
+
+
+def _connector_guest_from_another_profile(_managed: Path) -> None:
+ from hermes_cli.auth_nous import _write_shared_nous_state
+ from tests.hermes_cli.anon_portal import PORTAL
+
+ _write_shared_nous_state({"auth_method": anon_auth.ANON_AUTH_METHOD, "account_tier": anon_auth.ANON_ACCOUNT_TIER,
+ "anon_token": "anon_other", "client_id": anon_auth.ANON_CLIENT_ID,
+ "portal_base_url": PORTAL, anon_auth.WELCOME_CLAIM_FLAG: False})
+
+
+ELSEWHERE = {
+ "shared_connector_guest": (_connector_guest_from_another_profile, "eligible"),
+ "managed_onboarding_off": (lambda managed: (managed / "config.yaml").write_text("onboarding:\n run: false\n",
+ encoding="utf-8"), "run"),
+}
+
+
[email protected]("change", list(ELSEWHERE))
+def test_the_cached_due_answer_follows_shared_auth_and_the_managed_layer(portal, monkeypatch, tmp_path, change):
+ from hermes_cli import free_tier_bootstrap
+
+ managed = tmp_path / "managed"
+ managed.mkdir()
+ monkeypatch.setenv("HERMES_MANAGED_DIR", str(managed))
+ as_local_desktop_backend(monkeypatch)
+ free_tier_bootstrap.run_bootstrap(announce=False)
+ cached = _call("onboarding.state")["result"]
+ assert (cached["run"], cached["eligible"]) == (True, True)
+ write, moved = ELSEWHERE[change]
+
+ write(managed)
+
+ assert _call("onboarding.state")["result"][moved] is False
diff --git a/tui_gateway/methods_onboarding.py b/tui_gateway/methods_onboarding.py
index 415f3742b3f..736a1e695b2 100644
--- a/tui_gateway/methods_onboarding.py
+++ b/tui_gateway/methods_onboarding.py
@@ -53,13 +53,28 @@ def _due_now(*, assume_fresh: bool = False) -> dict[str, bool]:
def _due_stamp() -> tuple:
- """The files the due answer reads, by size and mtime: the root config (``onboarding.run``) and
- the default profile's config, ``.env`` and ``auth.json`` (what carries a first chat)."""
+ """The files the due answer reads, by their config-cache signature: the root config
+ (``onboarding.run``), the default profile's config, ``.env`` and ``auth.json`` (what carries a
+ first chat), the shared Nous store (another profile's sign-in or connector guest) and the managed
+ layer's ``config.yaml`` and ``.env`` (an admin's onboarding or provider policy)."""
+ from hermes_cli import managed_scope
from hermes_constants import get_default_hermes_root
+ from utils import file_signature
home = Path(_profile_home("default") or get_default_hermes_root())
- paths = (get_default_hermes_root() / "config.yaml", home / "config.yaml", home / ".env", home / "auth.json")
- return tuple((st.st_size, st.st_mtime_ns) if (st := _stat(path)) else None for path in paths)
+ managed = managed_scope.get_managed_dir()
+ paths = (get_default_hermes_root() / "config.yaml", home / "config.yaml", home / ".env", home / "auth.json",
+ *_shared_nous_store(), *((managed / "config.yaml", managed / ".env") if managed else ()))
+ return tuple(file_signature(st) if (st := _stat(path)) else None for path in paths)
+
+
+def _shared_nous_store() -> tuple[Path, ...]:
+ """The shared Nous store as ``_read_shared_nous_state`` finds it: none when the test seat belt trips."""
+ from hermes_cli.auth_nous import _nous_shared_store_path
+ try:
+ return (_nous_shared_store_path(),)
+ except RuntimeError:
+ return ()
def _stat(path):