Skip to content

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

fix(security): correct session lifecycle credential handling

Steven Enamakelfe7bb8e5e116
diff --git a/crates/openhuman-core/src/integrations/composio/client_tests.rs b/crates/openhuman-core/src/integrations/composio/client_tests.rs
index cd4d2d25ea..48466dd6ff 100644
--- a/crates/openhuman-core/src/integrations/composio/client_tests.rs
+++ b/crates/openhuman-core/src/integrations/composio/client_tests.rs
@@ -132,7 +132,7 @@ impl Drop for DirectAuthFailureGuard {
}
}
-#[path = "client_tests_part_01_tests.rs"]
-mod part_01_tests;
-#[path = "client_tests_part_02_tests.rs"]
-mod part_02_tests;
+#[path = "client_authorize_and_execute_tests.rs"]
+mod authorize_and_execute_tests;
+#[path = "client_triggers_and_factory_tests.rs"]
+mod triggers_and_factory_tests;
diff --git a/crates/openhuman-core/src/memory/sources/schemas/coding_session_schemas.rs b/crates/openhuman-core/src/memory/sources/schemas/coding_session_schemas.rs
new file mode 100644
index 0000000000..6b6d8d5337
--- /dev/null
+++ b/crates/openhuman-core/src/memory/sources/schemas/coding_session_schemas.rs
@@ -0,0 +1,72 @@
+//! Schemas and handlers for coding-session discovery and ingestion.
+
+use serde_json::{Map, Value};
+
+use crate::core::all::ControllerFuture;
+use crate::core::{ControllerSchema, FieldSchema, TypeSchema};
+use crate::memory::sources::rpc;
+
+use super::{parse_value, to_json, NAMESPACE};
+
+pub(super) fn schema(function: &str) -> Option<ControllerSchema> {
+ Some(match function {
+ "coding_session_status" => ControllerSchema {
+ namespace: NAMESPACE,
+ function: "coding_session_status",
+ description: "Discover local Codex and Claude Code session histories and report the human-authored evidence available for memory ingestion.",
+ inputs: vec![],
+ outputs: vec![FieldSchema {
+ name: "sources",
+ ty: TypeSchema::Array(Box::new(TypeSchema::Ref("CodingSessionSourceStatus"))),
+ comment: "Discovery and evidence counts for each supported coding-agent session source.",
+ required: true,
+ }],
+ },
+ "ingest_coding_sessions" => ControllerSchema {
+ namespace: NAMESPACE,
+ function: "ingest_coding_sessions",
+ description: "Distill human-authored turns from local Codex and Claude Code sessions into the TinyCortex persona memory layer.",
+ inputs: vec![
+ FieldSchema {
+ name: "backfill",
+ ty: TypeSchema::Bool,
+ comment: "When true, reprocess all discovered sessions; otherwise ingest only changed sessions.",
+ required: false,
+ },
+ FieldSchema {
+ name: "max_sessions",
+ ty: TypeSchema::U64,
+ comment: "Maximum session digests for this run (clamped to 1,000).",
+ required: false,
+ },
+ ],
+ outputs: vec![
+ FieldSchema { name: "mode", ty: TypeSchema::String, comment: "Executed run mode.", required: true },
+ FieldSchema { name: "files_seen", ty: TypeSchema::U64, comment: "Discovered coding-session files.", required: true },
+ FieldSchema { name: "sessions_processed", ty: TypeSchema::U64, comment: "Coding sessions distilled successfully.", required: true },
+ FieldSchema { name: "sessions_skipped", ty: TypeSchema::U64, comment: "Unchanged sessions skipped during an incremental run.", required: true },
+ FieldSchema { name: "sessions_failed", ty: TypeSchema::U64, comment: "Sessions retained for retry after provider failure.", required: true },
+ FieldSchema { name: "evidence_units", ty: TypeSchema::U64, comment: "Human-authored evidence units extracted.", required: true },
+ FieldSchema { name: "observations", ty: TypeSchema::U64, comment: "Persona observations distilled.", required: true },
+ FieldSchema { name: "budget_hit", ty: TypeSchema::Bool, comment: "Whether the run stopped at its session/call budget.", required: true },
+ FieldSchema { name: "pack_path", ty: TypeSchema::Option(Box::new(TypeSchema::String)), comment: "Compiled persona pack path when written.", required: false },
+ ],
+ },
+ _ => return None,
+ })
+}
+
+pub(super) fn handle_coding_session_status(_params: Map<String, Value>) -> ControllerFuture {
+ Box::pin(async move { to_json(rpc::coding_session_status_rpc().await?) })
+}
+
+pub(super) fn handle_ingest_coding_sessions(params: Map<String, Value>) -> ControllerFuture {
+ Box::pin(async move {
+ // `rpc::CodingSessionIngestRequest`, not the engine path: this adapter
+ // names its own domain's request type, the way every sibling here does.
+ // See the re-export's docs in `rpc/coding_sessions.rs` for why the type
+ // is still the engine's underneath (#5560).
+ let req = parse_value::<rpc::CodingSessionIngestRequest>(Value::Object(params))?;
+ to_json(rpc::ingest_coding_sessions_rpc(req).await?)
+ })
+}
diff --git a/crates/openhuman-core/src/security/credentials/ops/session_lifecycle.rs b/crates/openhuman-core/src/security/credentials/ops/session_lifecycle.rs
index 9da8d9f0e9..334dd6c476 100644
--- a/crates/openhuman-core/src/security/credentials/ops/session_lifecycle.rs
+++ b/crates/openhuman-core/src/security/credentials/ops/session_lifecycle.rs
@@ -41,8 +41,8 @@ const AUTH_ME_STORE_TRANSIENT_STATUSES: &[u16] = &[408, 429, 500, 502, 503, 504,
/// live-`exp` JWT), so the user lands in the app with deferred revalidation
/// instead of being bounced. Overridable via `OPENHUMAN_AUTH_ME_STORE_TIMEOUT_MS`
/// for ops tuning and tests.
-const AUTH_ME_STORE_VALIDATION_BUDGET: Duration = Duration::from_secs(12);
-const AUTH_ME_STORE_VALIDATION_BUDGET_ENV: &str = "OPENHUMAN_AUTH_ME_STORE_TIMEOUT_MS";
+pub(crate) const AUTH_ME_STORE_VALIDATION_BUDGET: Duration = Duration::from_secs(12);
+pub(crate) const AUTH_ME_STORE_VALIDATION_BUDGET_ENV: &str = "OPENHUMAN_AUTH_ME_STORE_TIMEOUT_MS";
/// Whether this dispatch is running under an embedder-hosted core (the library
/// `Harness`) rather than the desktop shell or CLI.
@@ -214,7 +214,7 @@ pub async fn stop_login_gated_services(config: &Config) {
log::info!("[services] all login-gated services stopped");
}
-fn secret_store_for_config(config: &Config) -> SecretStore {
+pub(crate) fn secret_store_for_config(config: &Config) -> SecretStore {
let data_dir = config
.config_path
.parent()
@@ -632,7 +632,7 @@ async fn store_session_inner(
/// Store-time `GET /auth/me` budget resolver. Reads the
/// `OPENHUMAN_AUTH_ME_STORE_TIMEOUT_MS` override (positive integer milliseconds),
/// otherwise the `AUTH_ME_STORE_VALIDATION_BUDGET` default.
-fn auth_me_store_validation_budget() -> Duration {
+pub(crate) fn auth_me_store_validation_budget() -> Duration {
std::env::var(AUTH_ME_STORE_VALIDATION_BUDGET_ENV)
.ok()
.and_then(|raw| raw.trim().parse::<u64>().ok())
@@ -704,7 +704,7 @@ async fn fetch_current_user_for_session_store_inner(
}
}
-fn auth_me_store_failure_is_transient(reason: &str) -> bool {
+pub(crate) fn auth_me_store_failure_is_transient(reason: &str) -> bool {
if let Some(status) = auth_me_failure_status(reason) {
return AUTH_ME_STORE_TRANSIENT_STATUSES.contains(&status);
}
@@ -735,7 +735,7 @@ fn fallback_session_user_for_deferred_validation() -> Value {
json!({ "pendingBackendValidation": true })
}
-fn sanitize_stored_session_user(user: Option<serde_json::Value>) -> Option<serde_json::Value> {
+pub(crate) fn sanitize_stored_session_user(user: Option<serde_json::Value>) -> Option<serde_json::Value> {
match user {
Some(serde_json::Value::Object(map)) if map.is_empty() => None,
Some(serde_json::Value::Null) => None,
@@ -743,7 +743,7 @@ fn sanitize_stored_session_user(user: Option<serde_json::Value>) -> Option<serde
}
}
-fn normalize_local_session_user(user: serde_json::Value, local_user_id: &str) -> serde_json::Value {
+pub(crate) fn normalize_local_session_user(user: serde_json::Value, local_user_id: &str) -> serde_json::Value {
let mut map = match user {
serde_json::Value::Object(map) => map,
other => return other,