The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.
Rust agent-orchestrationai-agentsai-assistantdesktopllmlocal-firstmcppersonal-aiprivacyrustsecond-braintauri
docs: standardize punctuation in README files
Steven Enamakel146ccdba7070
diff --git a/crates/openhuman-core/src/agent/learning/README.md b/crates/openhuman-core/src/agent/learning/README.mdindex 85a92aef36..82a4d25289 100644--- a/crates/openhuman-core/src/agent/learning/README.md+++ b/crates/openhuman-core/src/agent/learning/README.md@@ -45,12 +45,12 @@ The subsystem is organised in phases (issue #566): **Phase 1** the candidate taxRe-exported from `mod.rs`:-- **Candidate types**: `Buffer`, `CueFamily`, `EvidenceRef`, `FacetClass`, `LearningCandidate`.-- **Cache / detector**: `FacetCache`, `StabilityDetector`.-- **Hooks**: `ReflectionHook`, `ToolTrackerHook`, `UserProfileHook` (all impl `PostTurnHook`).-- **Prompt**: `LearnedContextSection`, `UserProfileSection`, `MemoryAccessSection`, `MemoryWriteSection`, `MEMORY_ACCESS_INSTRUCTION`, `memory_write_instruction`, `any_tool_offered`, `load_learned_from_cache`, and the tool-name constants `MEMORY_READ_TOOLS`, `MEMORY_WRITE_TOOLS`, `MEMORY_STORE_TOOL`, `MEMORY_WRITE_DELEGATE_TOOL`, `SAVE_PREFERENCE_TOOL`.-- **Profile**: `ProfileMdRenderer`.-- **Schemas**: `all_learning_controller_schemas`, `all_learning_registered_controllers`, `learning_schemas`.+- Candidate types: `Buffer`, `CueFamily`, `EvidenceRef`, `FacetClass`, `LearningCandidate`.+- Cache / detector: `FacetCache`, `StabilityDetector`.+- Hooks: `ReflectionHook`, `ToolTrackerHook`, `UserProfileHook` (all impl `PostTurnHook`).+- Prompt: `LearnedContextSection`, `UserProfileSection`, `MemoryAccessSection`, `MemoryWriteSection`, `MEMORY_ACCESS_INSTRUCTION`, `memory_write_instruction`, `any_tool_offered`, `load_learned_from_cache`, and the tool-name constants `MEMORY_READ_TOOLS`, `MEMORY_WRITE_TOOLS`, `MEMORY_STORE_TOOL`, `MEMORY_WRITE_DELEGATE_TOOL`, `SAVE_PREFERENCE_TOOL`.+- Profile: `ProfileMdRenderer`.+- Schemas: `all_learning_controller_schemas`, `all_learning_registered_controllers`, `learning_schemas`.Not re-exported but public within the module: `candidate::global()`, the `linkedin_enrichment::*` pipeline fns, `transcript_ingest::ingest_*`, `scheduler::{spawn_rebuild_loop, register_event_trigger, DEFAULT_REBUILD_INTERVAL}`, and `stability_detector` constants (`TAU_*`, `HALF_LIFE_*`, `BUDGET_*`, `stability`, `half_life`, `class_budget`).@@ -81,8 +81,8 @@ Facet handlers build a `FacetCache` over `crate::memory::ops::guard::active_memoUses the typed event bus (`crates/openhuman-core/src/core/bus.rs`, the process-wide `BUS` singleton; `core/events.rs` for `DomainEvent`; handlers implement `tinybus::EventHandler<DomainEvent>`):-- **Publishes**: `DomainEvent::CacheRebuilt { added, evicted, kept, total_size, rebuilt_at }` after each rebuild (`stability_detector.rs`).-- **Subscribes**:+- Publishes: `DomainEvent::CacheRebuilt { added, evicted, kept, total_size, rebuilt_at }` after each rebuild (`stability_detector.rs`).+- Subscribes:- `profile_md_renderer.rs` (`ProfileMdRenderer::subscribe`) → `CacheRebuilt` → re-render `PROFILE.md` blocks.- `scheduler.rs` (`RebuildTriggerHandler`, domains `memory` / `tree_summarizer`) → `DocumentCanonicalized` (email/document) and `TreeSummarizerPropagated` → debounced (60 s) rebuild.- `extract/signature.rs` → `DocumentCanonicalized` (email) → emit Identity candidates.@@ -93,7 +93,7 @@ These are subscriber registrations rather than a single `bus.rs`; subscriptions- **`user_profile_facets`** (the ambient cache), accessed via `FacetCache`, which delegates to the `MemoryProfile` family of the active `MemoryGuard` (`list_active`, `list_all`, `get`, `upsert`, `set_user_state`, `delete`, `drop_below_threshold`; `reset_non_pinned` is a free fn in `cache.rs`). The SQL lives in the memory driver, not in this crate. Rows are `tinymemory_api::provider::ProfileFacet { key, value, state, user_state, stability, confidence, evidence_count, evidence_refs, class, cue_families, first/last_seen_at, … }`.- **KV memory namespaces** (via the `Memory` trait): `learning_observations`, `learning_patterns`, `learning_reflections`, `user_profile`, `tool_effectiveness`, plus transcript-ingest `conversation_memory` / `conversation_reflections`. LinkedIn enrichment also upserts the scraped profile through the guard's documents family (`put_profile_document` in `linkedin_enrichment/memory_persistence.rs`) and writes `{workspace_dir}/PROFILE.md`.-- **In-memory**: the global `candidate::Buffer` (transient evidence, not persisted) and per-session state in `extract/heuristics.rs`.+- In-memory: the global `candidate::Buffer` (transient evidence, not persisted) and per-session state in `extract/heuristics.rs`.## Dependencies@@ -122,7 +122,7 @@ These are subscriber registrations rather than a single `bus.rs`; subscriptions- **Class is encoded in the key prefix** (`style/verbosity`, `goal/learn_rust`). `candidate.key` carries no prefix; the detector prepends `class_prefix`. Legacy rows without a recognised prefix are skipped by rebuild.- **`emit_candidates_*` uses the global buffer length as a synthetic `episodic_id`** (a Phase-2 placeholder noted to be replaced by a real `episodic_log` row id).- **Goal facets render value-only** (full sentence, no key prefix) in both prompt injection and `PROFILE.md`; other classes render `**key**: value`.-- **`load_learned_from_cache` is async**: the facet store sits behind the memory driver, so it is a driver call (it used to be a synchronous SQLite read) and degrades to empty on error. Both the cache path and the legacy KV-namespace path are still active (KV slated for later removal).+- `load_learned_from_cache` is async: the facet store sits behind the memory driver, so it is a driver call (it used to be a synchronous SQLite read) and degrades to empty on error. Both the cache path and the legacy KV-namespace path are still active (KV slated for later removal).- **Reflection has a local/cloud gate.** The `ReflectionSource::Local` route requires `Config::workload_uses_local("learning")` (an `ollama:` `learning_provider`); if off it falls back to the optional cloud `ChatModel` or no-ops (empty string), and an empty response is a clean-skip sentinel that rolls back the throttle counter. Per-session reflections are throttled by `max_reflections_per_session`.- **LinkedIn enrichment short-circuits** if `PROFILE.md` already exists, and the Composio-only Gmail-search stage is documented as currently erroring (Gmail-via-Composio removed), callers should pass `preset_profile_url` obtained via the frontend's webview Gmail helper.- **Transcript ingestion is heuristic-only by design** (no hard LLM dependency) so it can run as a background task without provider credentials.diff --git a/crates/openhuman-core/src/cron/README.md b/crates/openhuman-core/src/cron/README.mdindex 7616572888..8b542b9994 100644--- a/crates/openhuman-core/src/cron/README.md+++ b/crates/openhuman-core/src/cron/README.md@@ -17,9 +17,9 @@ Scheduled-job runtime. Owns cron-expression and human-delay parsing, the persist## Job types-- **`shell`**: `run_job_command_with_timeout` refuses the command unless the `SecurityPolicy` (`SecurityPolicy::from_config`, built once in `scheduler::run` and per call in `execute_job_now`) passes `can_act`, `is_rate_limited`, and `is_command_allowed`; a `blocked by security policy:` result is never retried.-- **`agent`**: the scheduler builds an `Agent` directly and runs a turn (see below); it does not go through `agent::triage`.-- **`flow`**: a `flows::Flow` schedule-trigger binding, the mechanism behind a workflow's [schedule trigger](../../../../gitbooks/features/workflows.md). `flows/ops/triggers.rs::bind_schedule_trigger` creates it via `add_flow_schedule_job` (idempotent through `find_flow_schedule_job`) from both `flows_set_enabled` and `reconcile_schedule_triggers_on_boot`. Its `command` column carries the bound flow's id; on fire `run_flow_schedule_job` publishes `DomainEvent::FlowScheduleTick { flow_id }` instead of running anything itself. `flows::bus::FlowTriggerSubscriber` does the actual dispatch. Never created via the `cron_add` agent tool, whose `job_type` enum is `shell` / `agent` only.+- `shell`: `run_job_command_with_timeout` refuses the command unless the `SecurityPolicy` (`SecurityPolicy::from_config`, built once in `scheduler::run` and per call in `execute_job_now`) passes `can_act`, `is_rate_limited`, and `is_command_allowed`; a `blocked by security policy:` result is never retried.+- `agent`: the scheduler builds an `Agent` directly and runs a turn (see below); it does not go through `agent::triage`.+- `flow`: a `flows::Flow` schedule-trigger binding, the mechanism behind a workflow's [schedule trigger](../../../../gitbooks/features/workflows.md). `flows/ops/triggers.rs::bind_schedule_trigger` creates it via `add_flow_schedule_job` (idempotent through `find_flow_schedule_job`) from both `flows_set_enabled` and `reconcile_schedule_triggers_on_boot`. Its `command` column carries the bound flow's id; on fire `run_flow_schedule_job` publishes `DomainEvent::FlowScheduleTick { flow_id }` instead of running anything itself. `flows::bus::FlowTriggerSubscriber` does the actual dispatch. Never created via the `cron_add` agent tool, whose `job_type` enum is `shell` / `agent` only.### Agent jobs@@ -53,18 +53,18 @@ Cron publishes through `core/bus.rs` using variants declared in `core/events.rs`A cron job's `DeliveryConfig.mode` decides where its output ends up. `DeliveryConfig::default()` is `none`; the `cron_add` tool substitutes `proactive` when an agent job is created without a `delivery` block.-- **`proactive`**: `deliver_if_configured` publishes+- `proactive`: `deliver_if_configured` publishes`DomainEvent::ProactiveMessageRequested`. The proactive subscriber(`channels::proactive`) always pushes to the in-app web stream and additionallymirrors to `channels_config.active_channel` when set. Use for jobs whosenatural surface is the desktop UI (briefings, app-pushed notifications).-- **`announce`**: explicit channel-targeted delivery. Requires `channel` and+- `announce`: explicit channel-targeted delivery. Requires `channel` and`to`; publishes `DomainEvent::CronDeliveryRequested` and lands only in thatchannel. The agent layer should pick this mode when a cron is created from anon-web channel (Telegram, Discord, Slack, …) so the reminder ends up wherethe user asked for it. The `cron_add` tool validates `to` against thechannel's `allowed_users` to reject cross-tenant targets.-- **`none`**: silent; output is stored in `last_output` only.+- `none`: silent; output is stored in `last_output` only.The `[Channel context]` block built in `channels/runtime/dispatch/helpers.rs`for non-web inbound turns instructs the model to default to `announce` with thediff --git a/crates/openhuman-core/src/cron/scheduler_gate/README.md b/crates/openhuman-core/src/cron/scheduler_gate/README.mdindex 5bd4ad5c79..74d9d7ed00 100644--- a/crates/openhuman-core/src/cron/scheduler_gate/README.md+++ b/crates/openhuman-core/src/cron/scheduler_gate/README.md@@ -25,7 +25,7 @@ Gates background AI work (memory-tree digests, embeddings, summarisation, triageFrom `mod.rs`:- **Functions** (`gate`): `init_global(&Config)`, `current_policy() -> Policy`, `current_signals() -> Signals`, `wait_for_capacity() -> Option<LlmPermit>`, `is_signed_out() -> bool`, `set_signed_out(bool)`.-- **Types**: `LlmPermit` (RAII semaphore guard, `#[must_use]`), `Policy` (`Aggressive` / `Normal` / `Throttled` / `Paused { reason }`), `PauseReason` (`UserDisabled` / `OnBattery` / `CpuPressure` / `SignedOut` / `Unknown`), `Signals`.+- Types: `LlmPermit` (RAII semaphore guard, `#[must_use]`), `Policy` (`Aggressive` / `Normal` / `Throttled` / `Paused { reason }`), `PauseReason` (`UserDisabled` / `OnBattery` / `CpuPressure` / `SignedOut` / `Unknown`), `Signals`.- Not re-exported but `pub` on `gate`: `update_config(SchedulerGateConfig)`.- Test-only: `SignedOutTestGuard` (RAII flag snapshot/restore), `try_acquire_llm_permit`, `available_llm_permits`.@@ -56,10 +56,10 @@ No dependency on any other `openhuman` domain or on `crate::core::*`.Consumed in-process across the codebase (discoverable via `grep scheduler_gate`):-- **Background workers / pipelines**: `memory/schema.rs`, `memory_queue/worker.rs`, `memory_tree/tree/rpc.rs`, `memory_sync/composio/periodic.rs`, `subconscious/engine.rs`, `learning/reflection.rs`, `autocomplete/core/engine.rs`, `task_sources/route.rs`, `agent/triage/evaluator.rs`.-- **Inference layer**: `inference/provider/openhuman_backend.rs`, `inference/provider/factory.rs`, `inference/local/service/{vision_embed.rs,public_infer.rs}`, `inference/voice/postprocess.rs`.+- Background workers / pipelines: `memory/schema.rs`, `memory_queue/worker.rs`, `memory_tree/tree/rpc.rs`, `memory_sync/composio/periodic.rs`, `subconscious/engine.rs`, `learning/reflection.rs`, `autocomplete/core/engine.rs`, `task_sources/route.rs`, `agent/triage/evaluator.rs`.+- Inference layer: `inference/provider/openhuman_backend.rs`, `inference/provider/factory.rs`, `inference/local/service/{vision_embed.rs,public_infer.rs}`, `inference/voice/postprocess.rs`.- **Credentials lifecycle** (signed-out kill switch): `credentials/ops.rs`, `credentials/bus.rs`.-- **Bootstrap / transport**: `core/jsonrpc.rs` (calls `init_global` during server bootstrap), `core/observability.rs`, plus the domain wiring in `openhuman/mod.rs` and config schema in `config/schema/scheduler_gate.rs`.+- Bootstrap / transport: `core/jsonrpc.rs` (calls `init_global` during server bootstrap), `core/observability.rs`, plus the domain wiring in `openhuman/mod.rs` and config schema in `config/schema/scheduler_gate.rs`.## Notes / gotchas@@ -67,7 +67,7 @@ Consumed in-process across the codebase (discoverable via `grep scheduler_gate`)- **Backoff happens before semaphore acquisition** so a `Paused`/`Throttled` mode doesn't pile tasks into the semaphore wait queue: they sit in the policy poll loop instead.- **`current_policy()` defaults to `Normal` and `wait_for_capacity()` acquires directly when `STATE` is uninitialised** (unit tests / pre-`init_global` bootstrap) so callers never deadlock on a sampler that will never start.- **Signed-out override is gated on `STATE.get().is_some()`** on both the reader (`current_policy`/`wait_for_capacity`) and writer (`set_signed_out`) sides. Without this, a stale per-test `signed_out=true` flag (from `clear_session` / 401 / `SessionExpiredSubscriber` tests) would make every later `wait_for_capacity` caller poll forever: the source of the post-#1516 triage-evaluator hangs.-- **Test isolation**: in `cfg(test)` the semaphore and signed-out flag are keyed per tokio runtime ID (`test_state`) so parallel cargo workers and libtest thread reuse don't leak state across `#[tokio::test]`s. `SignedOutTestGuard` snapshots/restores the flag and bypasses the writer-side `STATE` gate.+- Test isolation: in `cfg(test)` the semaphore and signed-out flag are keyed per tokio runtime ID (`test_state`) so parallel cargo workers and libtest thread reuse don't leak state across `#[tokio::test]`s. `SignedOutTestGuard` snapshots/restores the flag and bypasses the writer-side `STATE` gate.- **`init_global` is idempotent** (`std::sync::Once`); live config changes go through `update_config`, which recomputes the policy immediately.- **Server-mode detection** never infers server from "no battery" alone (desktops have none); it requires Linux + no battery + no `DISPLAY`/`WAYLAND_DISPLAY`, or explicit env / k8s / docker signals.- `PauseReason::OnBattery` and `CpuPressure` are the active power-aware (#1073) reasons; `Unknown` is a placeholder fallback.diff --git a/crates/openhuman-tinyhumans/src/hosted/announcements/README.md b/crates/openhuman-tinyhumans/src/hosted/announcements/README.mdindex 38ef998774..21e7f21f61 100644--- a/crates/openhuman-tinyhumans/src/hosted/announcements/README.md+++ b/crates/openhuman-tinyhumans/src/hosted/announcements/README.md@@ -1,7 +1,7 @@# announcementsThin RPC adapter for the product-announcements feed. Like its `hosted`-siblings it owns no business logic, state, or authorization — it forwards an+siblings it owns no business logic, state, or authorization: it forwards anauthenticated request to the TinyHumans backend and passes the responsethrough verbatim.@@ -13,7 +13,7 @@ through verbatim.closed with a clear error when none is stored.- Fold the backend's 404 (`BackendApiError::AnnouncementNotFound`, noqualifying announcement) into the same `null` "no announcement" success- outcome instead of surfacing it as an error — the feature is cosmetic and+ outcome instead of surfacing it as an error: the feature is cosmetic andthe 404 is a normal outcome, not a failure worth reporting.## Key files@@ -39,20 +39,20 @@ registered into the global registry via `crates/openhuman-core/src/core/all.rs`:None. The domain reads the stored session token but does not persistanything. Dismissal is tracked client-side by announcement id(`app/src/store/announcementSlice.ts`, `shownIds`, persisted through-`userScopedStorage`) — this module has no notion of "dismissed".+`userScopedStorage`): this module has no notion of "dismissed".## Dependencies- `crate::security::credentials::session_support::require_live_session_token`- — rejects an expired token locally instead of firing a doomed backend 401+ : rejects an expired token locally instead of firing a doomed backend 401(same guard as `billing/ops.rs`).- `crate::api::config::effective_backend_api_url`, `crate::api::BackendOAuthClient`- — resolve the backend base URL and issue the authed JSON request, carrying+ : resolve the backend base URL and issue the authed JSON request, carryingthe sanitized `x-sdk-name` product identity (`crate::api::product`) on everycall.-- `crate::api::flatten_authed_error` — flattens any non-404 backend/session+- `crate::api::flatten_authed_error`: flattens any non-404 backend/sessionerror for the RPC caller.-- `crate::rpc::RpcOutcome` (re-export of `openhuman_rpc`) — return wrapper+- `crate::rpc::RpcOutcome` (re-export of `openhuman_rpc`): return wrappercarrying value + log line.## Gatingdiff --git a/crates/openhuman-tinyhumans/src/hosted/billing/README.md b/crates/openhuman-tinyhumans/src/hosted/billing/README.mdindex 7cfcd1fd2c..a8eb8052fc 100644--- a/crates/openhuman-tinyhumans/src/hosted/billing/README.md+++ b/crates/openhuman-tinyhumans/src/hosted/billing/README.md@@ -1,6 +1,6 @@# billing-Thin RPC adapter domain over the hosted backend's payment API. It exposes plan lookup, Stripe/Coinbase purchase and top-up flows, credit balance/transactions, auto-recharge + saved-card management, and coupon redemption through the standard controller registry (`openhuman.billing_*`). It holds **no payment logic or state of its own** — every operation forwards an authenticated HTTPS request to the backend (`/payments/*`, `/coupons/*`) and surfaces the JSON response verbatim. Authorization, plan ownership, tenant isolation, and payment policy are enforced backend-side.+Thin RPC adapter domain over the hosted backend's payment API. It exposes plan lookup, Stripe/Coinbase purchase and top-up flows, credit balance/transactions, auto-recharge + saved-card management, and coupon redemption through the standard controller registry (`openhuman.billing_*`). It holds **no payment logic or state of its own**: every operation forwards an authenticated HTTPS request to the backend (`/payments/*`, `/coupons/*`) and surfaces the JSON response verbatim. Authorization, plan ownership, tenant isolation, and payment policy are enforced backend-side.## Responsibilities@@ -25,8 +25,8 @@ Thin RPC adapter domain over the hosted backend's payment API. It exposes plan lFrom `mod.rs`:-- `ops::*` — async handlers: `get_summary`, `get_current_plan`, `get_balance`, `get_transactions`, `get_auto_recharge`, `update_auto_recharge`, `get_cards`, `create_setup_intent`, `update_card`, `delete_card`, `purchase_plan`, `create_portal_session`, `top_up_credits`, `create_coinbase_charge`, `redeem_coupon`, `get_user_coupons`. Each takes `&Config` (plus typed params) and returns `Result<RpcOutcome<Value>, String>`.-- `all_billing_controller_schemas()`, `all_billing_registered_controllers()`, `billing_schemas(function: &str)` — registry wiring.+- `ops::*`: async handlers: `get_summary`, `get_current_plan`, `get_balance`, `get_transactions`, `get_auto_recharge`, `update_auto_recharge`, `get_cards`, `create_setup_intent`, `update_card`, `delete_card`, `purchase_plan`, `create_portal_session`, `top_up_credits`, `create_coinbase_charge`, `redeem_coupon`, `get_user_coupons`. Each takes `&Config` (plus typed params) and returns `Result<RpcOutcome<Value>, String>`.+- `all_billing_controller_schemas()`, `all_billing_registered_controllers()`, `billing_schemas(function: &str)`: registry wiring.## RPC / controllers@@ -67,21 +67,21 @@ None of its own; stateless adapter. The only state it reads is the backend sessi## Dependencies-- `crate::api::config::effective_backend_api_url` — resolves the backend base URL from `config.api_url`.-- `crate::api::jwt::get_session_token` — reads the stored app-session JWT.-- `crate::api::BackendOAuthClient` — performs the authenticated JSON HTTP request (`authed_json`).-- `crate::config::Config` — config struct (`api_url`); `config::rpc::load_config_with_timeout` in handlers.-- `crate::rpc::RpcOutcome` — standard RPC return/logging wrapper.-- `crate::core::all::{ControllerFuture, RegisteredController}` and `crate::core::{ControllerSchema, FieldSchema, TypeSchema}` — controller registry types.+- `crate::api::config::effective_backend_api_url`: resolves the backend base URL from `config.api_url`.+- `crate::api::jwt::get_session_token`: reads the stored app-session JWT.+- `crate::api::BackendOAuthClient`: performs the authenticated JSON HTTP request (`authed_json`).+- `crate::config::Config`: config struct (`api_url`); `config::rpc::load_config_with_timeout` in handlers.+- `crate::rpc::RpcOutcome`: standard RPC return/logging wrapper.+- `crate::core::all::{ControllerFuture, RegisteredController}` and `crate::core::{ControllerSchema, FieldSchema, TypeSchema}`: controller registry types.- External crates: `reqwest` (`Method`), `serde`/`serde_json`, `urlencoding` (path-segment encoding for `paymentMethodId`).## Used by-- `crates/openhuman-core/src/core/all.rs` — registers `all_billing_registered_controllers()` (controllers, ~L215) and `all_billing_controller_schemas()` (schemas, ~L346) into the global registry. This is the sole in-tree consumer.+- `crates/openhuman-core/src/core/all.rs`: registers `all_billing_registered_controllers()` (controllers, ~L215) and `all_billing_controller_schemas()` (schemas, ~L346) into the global registry. This is the sole in-tree consumer.## Notes / gotchas-- **No local authorization** — security is delegated entirely to the backend; a missing/invalid session yields the backend 401/403 surfaced verbatim as an RPC error string. JWTs/API keys are never logged.+- **No local authorization**: security is delegated entirely to the backend; a missing/invalid session yields the backend 401/403 surfaced verbatim as an RPC error string. JWTs/API keys are never logged.- `top_up_credits` and `create_coinbase_charge` default gateway/interval (`stripe`, `annual`); `normalize_gateway` lowercases and whitelists `stripe`/`coinbase`, treating empty/whitespace as default-to-stripe.- `amountUsd` must be finite and `> 0` (NaN/±Inf/≤0 rejected pre-HTTP).- `paymentMethodId` is `urlencoding::encode`'d into the path; empty/whitespace ids are rejected.diff --git a/crates/openhuman-tinyhumans/src/hosted/referral/README.md b/crates/openhuman-tinyhumans/src/hosted/referral/README.mdindex 2d77541fad..6766796383 100644--- a/crates/openhuman-tinyhumans/src/hosted/referral/README.md+++ b/crates/openhuman-tinyhumans/src/hosted/referral/README.md@@ -1,6 +1,6 @@# referral-Thin RPC adapter domain for the referral program. It does **not** own any business logic, state, or schema of its own — it makes authenticated `reqwest` calls to the hosted backend's `/referral/*` endpoints and surfaces the raw `data` payloads to the CLI / JSON-RPC clients. It exists primarily because the desktop WebView `fetch` to the backend can fail with a generic "Load failed" (CORS / TLS / WebKit), so these ops reuse the same server-side `reqwest` path as the billing domain.+Thin RPC adapter domain for the referral program. It does **not** own any business logic, state, or schema of its own: it makes authenticated `reqwest` calls to the hosted backend's `/referral/*` endpoints and surfaces the raw `data` payloads to the CLI / JSON-RPC clients. It exists primarily because the desktop WebView `fetch` to the backend can fail with a generic "Load failed" (CORS / TLS / WebKit), so these ops reuse the same server-side `reqwest` path as the billing domain.## Responsibilities@@ -43,26 +43,26 @@ An unrecognized `function` name returns an `unknown` placeholder schema with an## Persistence-None of its own. The domain is stateless — it reads the backend session token from the credentials store via `get_session_token` but does not persist anything.+None of its own. The domain is stateless: it reads the backend session token from the credentials store via `get_session_token` but does not persist anything.## Dependencies-- `crate::api::config::effective_backend_api_url` — resolves the effective backend API base URL from `config.api_url`.-- `crate::api::jwt::get_session_token` — reads the stored backend session token.-- `crate::api::BackendOAuthClient` — issues authenticated JSON requests (`authed_json`) to the backend.-- `crate::config::Config` — config struct passed into ops; `config::rpc::load_config_with_timeout` is used by the schema handlers.-- `crate::core::all::{ControllerFuture, RegisteredController}` and `crate::core::{ControllerSchema, FieldSchema, TypeSchema}` — controller registry types.-- `crate::rpc::RpcOutcome` — return wrapper carrying value + logs.+- `crate::api::config::effective_backend_api_url`: resolves the effective backend API base URL from `config.api_url`.+- `crate::api::jwt::get_session_token`: reads the stored backend session token.+- `crate::api::BackendOAuthClient`: issues authenticated JSON requests (`authed_json`) to the backend.+- `crate::config::Config`: config struct passed into ops; `config::rpc::load_config_with_timeout` is used by the schema handlers.+- `crate::core::all::{ControllerFuture, RegisteredController}` and `crate::core::{ControllerSchema, FieldSchema, TypeSchema}`: controller registry types.+- `crate::rpc::RpcOutcome`: return wrapper carrying value + logs.- Test-only: `crate::security::credentials::{AuthService, APP_SESSION_PROVIDER, DEFAULT_AUTH_PROFILE_NAME}` for seeding session tokens in unit tests.## Used by-- `crates/openhuman-core/src/core/all.rs` — registers `all_referral_registered_controllers()` into the controller registry (line ~213) and `all_referral_controller_schemas()` into the schema list (line ~345), exposing both methods to CLI and JSON-RPC.+- `crates/openhuman-core/src/core/all.rs`: registers `all_referral_registered_controllers()` into the controller registry (line ~213) and `all_referral_controller_schemas()` into the schema list (line ~345), exposing both methods to CLI and JSON-RPC.## Notes / gotchas-- No `types.rs`, `store.rs`, `tools.rs`, or `bus.rs` — this is a pure RPC adapter, not a stateful domain. No agent tools, no event-bus subscribers.+- No `types.rs`, `store.rs`, `tools.rs`, or `bus.rs`: this is a pure RPC adapter, not a stateful domain. No agent tools, no event-bus subscribers.- Both ops fail closed when no session token is stored, with the error `"no backend session token; run auth_store_session first"`.-- Eligibility for `claim` ("only users who have not yet subscribed") is enforced **by the backend**, not in this module — it merely forwards the request.+- Eligibility for `claim` ("only users who have not yet subscribed") is enforced **by the backend**, not in this module: it merely forwards the request.- Trimming/whitespace-dropping of `deviceFingerprint` happens in both `ops::claim_referral` and the schema handler `handle_referral_claim` (defensive, redundant filtering).- The module deliberately mirrors the billing domain's server-side `reqwest` path to avoid WebView `fetch` "Load failed" failures.diff --git a/crates/openhuman-tinyhumans/src/hosted/team/README.md b/crates/openhuman-tinyhumans/src/hosted/team/README.mdindex dae43943f5..82f820d26f 100644--- a/crates/openhuman-tinyhumans/src/hosted/team/README.md+++ b/crates/openhuman-tinyhumans/src/hosted/team/README.md@@ -1,6 +1,6 @@# team-Team management RPC adapters. This domain is a **thin proxy to the hosted backend**: every operation forwards an authenticated HTTP request to the OpenHuman backend (`/teams/*`) and returns the raw JSON response verbatim. It owns **no local state, no domain types, and no server-side authorization** — the backend enforces team ownership, role permissions, and tenant isolation; non-authorized callers receive the backend's 401/403 surfaced as an RPC error string. Covers team CRUD, membership, role changes, invites, usage, and active-team switching.+Team management RPC adapters. This domain is a **thin proxy to the hosted backend**: every operation forwards an authenticated HTTP request to the OpenHuman backend (`/teams/*`) and returns the raw JSON response verbatim. It owns **no local state, no domain types, and no server-side authorization**: the backend enforces team ownership, role permissions, and tenant isolation; non-authorized callers receive the backend's 401/403 surfaced as an RPC error string. Covers team CRUD, membership, role changes, invites, usage, and active-team switching.## Responsibilities@@ -17,7 +17,7 @@ Team management RPC adapters. This domain is a **thin proxy to the hosted backen| File | Role || --- | --- || `crates/openhuman-tinyhumans/src/hosted/team/mod.rs` | Export-only: declares `ops`/`schemas`, re-exports all ops fns and the controller-schema pair. |-| `crates/openhuman-tinyhumans/src/hosted/team/ops.rs` | Business logic — async fns that build a path, attach the session JWT, call the backend, and wrap the response in `RpcOutcome::single_log`. Contains URL-path builder + id-normalization helpers and their unit tests. |+| `crates/openhuman-tinyhumans/src/hosted/team/ops.rs` | Business logic: async fns that build a path, attach the session JWT, call the backend, and wrap the response in `RpcOutcome::single_log`. Contains URL-path builder + id-normalization helpers and their unit tests. || `crates/openhuman-tinyhumans/src/hosted/team/schemas.rs` | Controller schemas (`all_team_controller_schemas`, `all_team_registered_controllers`, `team_schemas`), param structs, and `handle_*` adapters that load config, deserialize params, and delegate to `ops`. || `crates/openhuman-tinyhumans/src/hosted/team/schemas_tests.rs` | Sibling test module for `schemas.rs` (wired via `#[path]`). |@@ -25,7 +25,7 @@ Team management RPC adapters. This domain is a **thin proxy to the hosted backenRe-exported from `mod.rs`:-- **Ops (all `async fn(... ) -> Result<RpcOutcome<Value>, String>`):** `get_usage` (re-exported from `integrations::client::budget_gate`, which owns the `/teams/me/usage` probe, its failure backoff and the managed-tool budget gate — the integrations client is its main consumer), `list_members`, `list_teams`, `get_team`, `create_team`, `update_team`, `delete_team`, `switch_team`, `leave_team`, `join_team`, `create_invite`, `remove_member`, `change_member_role`, `list_invites`, `revoke_invite`.+- **Ops (all `async fn(... ) -> Result<RpcOutcome<Value>, String>`):** `get_usage` (re-exported from `integrations::client::budget_gate`, which owns the `/teams/me/usage` probe, its failure backoff and the managed-tool budget gate: the integrations client is its main consumer), `list_members`, `list_teams`, `get_team`, `create_team`, `update_team`, `delete_team`, `switch_team`, `leave_team`, `join_team`, `create_invite`, `remove_member`, `change_member_role`, `list_invites`, `revoke_invite`.- **Schemas:** `all_team_controller_schemas`, `all_team_registered_controllers`, `team_schemas`.Internal helpers in `ops.rs` (`require_token`, `normalize_id`, `build_api_path`, `get_authed_value`) are private.@@ -36,21 +36,21 @@ Namespace `team`. Registered controllers (RPC method `openhuman.team_<function>`| Method | Backend call | Required inputs | Optional || --- | --- | --- | --- |-| `team_get_usage` | `GET /teams/me/usage` | — | — |-| `team_list_members` | `GET /teams/:teamId/members` | `teamId` | — |-| `team_list_teams` | `GET /teams` | — | — |-| `team_get_team` | `GET /teams/:teamId` | `teamId` | — |-| `team_create_team` | `POST /teams` | `name` | — |+| `team_get_usage` | `GET /teams/me/usage` | none |: |+| `team_list_members` | `GET /teams/:teamId/members` | `teamId` | none |+| `team_list_teams` | `GET /teams` | none |: |+| `team_get_team` | `GET /teams/:teamId` | `teamId` | none |+| `team_create_team` | `POST /teams` | `name` | none || `team_update_team` | `PUT /teams/:teamId` | `teamId` | `name` |-| `team_delete_team` | `DELETE /teams/:teamId` | `teamId` | — |-| `team_switch_team` | `POST /teams/:teamId/switch` | `teamId` | — |-| `team_leave_team` | `POST /teams/:teamId/leave` | `teamId` | — |-| `team_join_team` | `POST /teams/join` | `code` | — |+| `team_delete_team` | `DELETE /teams/:teamId` | `teamId` | none |+| `team_switch_team` | `POST /teams/:teamId/switch` | `teamId` | none |+| `team_leave_team` | `POST /teams/:teamId/leave` | `teamId` | none |+| `team_join_team` | `POST /teams/join` | `code` | none || `team_create_invite` | `POST /teams/:teamId/invites` | `teamId` | `maxUses`, `expiresInDays` |-| `team_list_invites` | `GET /teams/:teamId/invites` | `teamId` | — |-| `team_revoke_invite` | `DELETE /teams/:teamId/invites/:inviteId` | `teamId`, `inviteId` | — |-| `team_remove_member` | `DELETE /teams/:teamId/members/:userId` | `teamId`, `userId` | — |-| `team_change_member_role` | `PUT /teams/:teamId/members/:userId/role` | `teamId`, `userId`, `role` | — |+| `team_list_invites` | `GET /teams/:teamId/invites` | `teamId` | none |+| `team_revoke_invite` | `DELETE /teams/:teamId/invites/:inviteId` | `teamId`, `inviteId` | none |+| `team_remove_member` | `DELETE /teams/:teamId/members/:userId` | `teamId`, `userId` | none |+| `team_change_member_role` | `PUT /teams/:teamId/members/:userId/role` | `teamId`, `userId`, `role` | none |Outputs are raw backend JSON (`result` field; array for list endpoints). Params are camelCase; `handle_*` fns deserialize via `serde_json::from_value` and surface `invalid params: …` on failure.@@ -68,23 +68,23 @@ None local. State lives in the hosted backend. The only stored value it reads is## Dependencies-- `crate::api::config::effective_backend_api_url` — resolves the backend base URL from `Config.api_url`.-- `crate::api::jwt::get_session_token` — pulls the session JWT used to authenticate every request.-- `crate::api::BackendOAuthClient` — HTTP client; `authed_json(token, method, path, body)` performs the authed call.-- `crate::config::Config` — config passed into every op; `config::rpc::load_config_with_timeout` loads it inside each `handle_*`.-- `crate::core::all::{ControllerFuture, RegisteredController}` and `crate::core::{ControllerSchema, FieldSchema, TypeSchema}` — controller registry types.-- `crate::rpc::RpcOutcome` — return wrapper (`single_log`).+- `crate::api::config::effective_backend_api_url`: resolves the backend base URL from `Config.api_url`.+- `crate::api::jwt::get_session_token`: pulls the session JWT used to authenticate every request.+- `crate::api::BackendOAuthClient`: HTTP client; `authed_json(token, method, path, body)` performs the authed call.+- `crate::config::Config`: config passed into every op; `config::rpc::load_config_with_timeout` loads it inside each `handle_*`.+- `crate::core::all::{ControllerFuture, RegisteredController}` and `crate::core::{ControllerSchema, FieldSchema, TypeSchema}`: controller registry types.+- `crate::rpc::RpcOutcome`: return wrapper (`single_log`).- `reqwest` (`Method`, `Url`) for HTTP + path building; `serde` / `serde_json` for params and bodies.## Used by-- `crates/openhuman-core/src/core/all.rs` — registers `all_team_registered_controllers()` into the controller registry and `all_team_controller_schemas()` into the schema list (the standard controller-only exposure path). No domain branches in `cli.rs` / `jsonrpc.rs`.+- `crates/openhuman-core/src/core/all.rs`: registers `all_team_registered_controllers()` into the controller registry and `all_team_controller_schemas()` into the schema list (the standard controller-only exposure path). No domain branches in `cli.rs` / `jsonrpc.rs`.## Notes / gotchas-- **Pure proxy.** No type modeling of teams/members/invites — everything is `serde_json::Value` passthrough; the backend is the source of truth.+- **Pure proxy.** No type modeling of teams/members/invites: everything is `serde_json::Value` passthrough; the backend is the source of truth.- **Error rendering:** `get_authed_value` maps failures with `{e:#}` (full anyhow chain), deliberately not `e.to_string()`, so the underlying cause (DNS/TLS/timeout/non-2xx) is preserved for Sentry rather than the truncated `backend request GET /teams` label (see the in-code note referencing OPENHUMAN-TAURI-AD / TAURI-B2).-- **Path safety:** `build_api_path` clears and pushes segments through `url::path_segments_mut`, percent-encoding reserved chars, spaces, and Unicode — ids like `team/with?reserved` cannot escape their segment.+- **Path safety:** `build_api_path` clears and pushes segments through `url::path_segments_mut`, percent-encoding reserved chars, spaces, and Unicode: ids like `team/with?reserved` cannot escape their segment.- **Validation precedence is deterministic** (tested): `team_id` is normalized before `user_id` before `role`, so error messages are stable regardless of which other fields are also invalid.- `update_team` only includes `name` in the body when present and non-empty after trimming; an empty/whitespace name is dropped rather than sent.- Missing/blank session token yields `no backend session token; run auth_store_session first` before any network attempt.