Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

ci(ci-lite): include openhuman-session in CI paths

Steven Enamakel08d578ee1033
diff --git a/.github/workflows/ci-lite.yml b/.github/workflows/ci-lite.yml
index 5e30e33cfa..51332ef43b 100644
--- a/.github/workflows/ci-lite.yml
+++ b/.github/workflows/ci-lite.yml
@@ -157,6 +157,7 @@ jobs:
- 'Cargo.toml'
- 'crates/openhuman-core/**'
- 'crates/openhuman-embed/**'
+ - 'crates/openhuman-session/**'
- 'crates/openhuman-tui/**'
- 'Cargo.lock'
- 'build.rs'
@@ -191,6 +192,7 @@ jobs:
- 'Cargo.toml'
- 'crates/openhuman-core/Cargo.toml'
- 'crates/openhuman-embed/Cargo.toml'
+ - 'crates/openhuman-session/Cargo.toml'
- 'crates/openhuman-tui/Cargo.toml'
- 'Cargo.lock'
- 'build.rs'
@@ -208,6 +210,7 @@ jobs:
- 'crates/openhuman-core/src/**'
- 'crates/openhuman-embed/src/**'
- 'crates/openhuman-embed/tests/**'
+ - 'crates/openhuman-session/src/**'
- 'crates/openhuman-tui/src/**'
- 'crates/openhuman-tui/tests/**'
- 'tests/**'
@@ -460,6 +463,15 @@ jobs:
bash scripts/ci-cancel-aware.sh cargo check -p openhuman-embed --no-default-features
bash scripts/ci-cancel-aware.sh cargo test -p openhuman-embed
+ - name: Check session crate
+ if: needs.changes.outputs['rust-core'] == 'true'
+ # `openhuman-session` is the host-side login/session owner shared by the
+ # Tauri shell and the TUI. It has no `openhuman` dependency, so it
+ # compiles in seconds and its tests run against in-process stubs.
+ run: |
+ bash scripts/ci-cancel-aware.sh cargo clippy -p openhuman-session --all-targets -- -D warnings
+ bash scripts/ci-cancel-aware.sh cargo test -p openhuman-session
+
- name: Cache CEF binary distribution
if: needs.changes.outputs['rust-tauri'] == 'true'
uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6
diff --git a/crates/openhuman-session/README.md b/crates/openhuman-session/README.md
new file mode 100644
index 0000000000..ab7953d533
--- /dev/null
+++ b/crates/openhuman-session/README.md
@@ -0,0 +1,45 @@
+# openhuman-session
+
+Login and backend-session ownership for OpenHuman **hosts**. The core
+(`openhuman`) only holds and uses a backend credential — a TinyHumans session
+JWT or API key — and never obtains, validates, exchanges or refreshes one. This
+crate is where those steps live, shared by the Tauri shell
+(`crates/openhuman-app`, over the core's loopback JSON-RPC) and the TUI
+(`crates/openhuman-tui`, over an in-process `CoreRuntime`).
+
+No `openhuman` dependency: the shell's own Cargo world must be able to build it,
+and core policy must not leak back in through it.
+
+## Pieces
+
+| Module | Role |
+| --- | --- |
+| `credential` | `Credential` / `CredentialKind` (`session`, `api-key`, `local`), local-session shape detection, JWT `exp` decode, subject-claim and `/auth/me`-payload user-id extraction. |
+| `client` | `SessionClient`: `POST /auth/login-token/consume`, `GET /auth/me`, and `validate_for_store` (12 s budget, one retry, transient classification). Sends `x-sdk-name` / `x-core-version` / `x-tauri-version` from `ClientHeaders`. schannel on Windows, rustls elsewhere. |
+| `cache` | `CurrentUserCache`: 5 s TTL, stale-while-revalidate, negative cache with a bounded backoff, keyed on `(base_url, secret)`. |
+| `link` | `CoreLink` trait (`invoke(method, params)`) plus the `auth.set_credential` / `auth.clear_credential` / `auth.get_state` / `auth.get_session_token` / `config.resolve_api_url` helpers. |
+| `manager` | `SessionManager<L: CoreLink>`: `login_with_token`, `store_session_token`, `store_api_key`, `logout`, `current_user`, `state`, and a broadcast of `SessionEvent::{Changed, Expired}`. |
+| `identity` | Process-global `peek_user_id()` for synchronous Sentry hooks. |
+
+## Flow
+
+```
+login token ──consume──▶ JWT ──validate (/auth/me)──▶ auth.set_credential {token, kind, userId, user}
+ │ rejected: nothing stored (REJECTED)
+ │ unreachable + live exp + subject: stored with
+ │ {pendingBackendValidation:true}, revalidated in the background
+current_user ──cache──▶ /auth/me ──rejected──▶ auth.clear_credential + SessionEvent::Expired
+```
+
+The core is the store of record; the manager keeps no copy of the secret and
+reads it back through the link when it needs to refresh.
+
+## Environment
+
+- `OPENHUMAN_AUTH_ME_TIMEOUT_MS` — store-time validation budget (default 12000; the legacy `OPENHUMAN_AUTH_ME_STORE_TIMEOUT_MS` is still honoured).
+- `OPENHUMAN_AUTH_FETCH_TIMEOUT_SECS` — current-user refresh budget (2–12, default 5).
+
+## Tests
+
+`cargo test -p openhuman-session` — in-process axum stubs for the backend and a
+fake `CoreLink`; no network, no core.