Skip to content

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

chore: remove obsolete subconscious triggers and agentbox e2e tests\n\nThe subconscious triggers Playwright spec, the agentbox end-to-end test, and the subconscious full-stack e2e test along with their fixture files have been removed. These tests were tied to a deprecated subconscious triggers pipeline and an agentbox feature that is no longer maintained, and keeping them would cause confusion and maintenance burden.\n\nAuto-committed-on: dragonfly\n

Steven Enamakelaf4148d369f6
diff --git a/app/test/playwright/specs/subconscious-triggers.spec.ts b/app/test/playwright/specs/subconscious-triggers.spec.ts
deleted file mode 100644
index a8922fc29b..0000000000
--- a/app/test/playwright/specs/subconscious-triggers.spec.ts
+++ /dev/null
@@ -1,92 +0,0 @@
-import { expect, type Page, test } from '@playwright/test';
-
-import { bootAuthenticatedPage, callCoreRpc, waitForAppReady } from '../helpers/core-rpc';
-
-const USER_ID = 'pw-subconscious-triggers';
-const BRAIN_SUBCONSCIOUS = '/brain?tab=subconscious';
-
-/** Reset the trigger pipeline to a known disabled baseline (config-driven). */
-async function resetTriggersDisabled(): Promise<void> {
- await callCoreRpc('openhuman.heartbeat_settings_set', {
- triggers_enabled: false,
- subconscious_mode: 'off',
- max_promotions_per_hour: 30,
- });
-}
-
-async function openPanel(page: Page): Promise<void> {
- await bootAuthenticatedPage(page, USER_ID, BRAIN_SUBCONSCIOUS);
- await waitForAppReady(page);
- await expect(page.getByTestId('subconscious-triggers-panel')).toBeVisible({ timeout: 20_000 });
- // Status resolves once the first poll returns.
- await expect(page.getByTestId('subconscious-triggers-status')).toBeVisible({ timeout: 20_000 });
-}
-
-test.describe('Brain — Subconscious Triggers panel', () => {
- test.beforeEach(async () => {
- await resetTriggersDisabled();
- });
-
- test('renders the status rows with the disabled baseline', async ({ page }) => {
- await openPanel(page);
-
- // Pipeline shows disabled + the activation hint, orchestrator stopped-by-config.
- await expect(page.getByTestId('row-pipeline')).toContainText(/Disabled/i);
- await expect(page.getByTestId('subconscious-triggers-disabled-hint')).toBeVisible();
-
- // Structural rows are present.
- await expect(page.getByTestId('row-mode')).toBeVisible();
- await expect(page.getByTestId('row-promotions')).toContainText('30');
- await expect(page.getByTestId('row-queue')).toBeVisible();
- // Reserved thread ids surface verbatim from the core.
- await expect(page.getByTestId('row-orchestrator-thread')).toContainText(
- 'subconscious:orchestrator'
- );
- await expect(page.getByTestId('row-user-thread')).toContainText('subconscious:user');
- });
-
- test('enabling the pipeline flips it to event-driven and starts the orchestrator', async ({
- page,
- }) => {
- await openPanel(page);
- await expect(page.getByTestId('row-pipeline')).toContainText(/Disabled/i);
-
- // Toggle on → core enables triggers + event_driven mode and bootstraps.
- await page.getByTestId('subconscious-triggers-toggle').click();
-
- await expect(page.getByTestId('row-pipeline')).toContainText(/Enabled/i, { timeout: 20_000 });
- await expect(page.getByTestId('row-mode')).toContainText('event_driven');
- await expect(page.getByTestId('row-orchestrator')).toContainText(/Running/i, {
- timeout: 20_000,
- });
- // Once running, the queue depth is a number (0 when idle), not the em-dash.
- await expect(page.getByTestId('row-queue')).not.toContainText('—');
- // The toggle now offers the inverse action and the hint is gone.
- await expect(page.getByTestId('subconscious-triggers-toggle')).toContainText(/Disable/i);
- await expect(page.getByTestId('subconscious-triggers-disabled-hint')).toHaveCount(0);
- });
-
- test('disabling the pipeline returns it to disabled', async ({ page }) => {
- await openPanel(page);
-
- // Enable first.
- await page.getByTestId('subconscious-triggers-toggle').click();
- await expect(page.getByTestId('row-pipeline')).toContainText(/Enabled/i, { timeout: 20_000 });
-
- // Then disable.
- await page.getByTestId('subconscious-triggers-toggle').click();
- await expect(page.getByTestId('row-pipeline')).toContainText(/Disabled/i, { timeout: 20_000 });
- await expect(page.getByTestId('subconscious-triggers-toggle')).toContainText(/Enable/i);
- });
-
- test('refresh re-fetches without error', async ({ page }) => {
- await openPanel(page);
-
- await page.getByTestId('subconscious-triggers-refresh').click();
-
- // Still showing status, no error surfaced.
- await expect(page.getByTestId('subconscious-triggers-status')).toBeVisible();
- await expect(page.getByTestId('subconscious-triggers-error')).toHaveCount(0);
- await expect(page.getByTestId('row-pipeline')).toBeVisible();
- });
-});
diff --git a/tests/agentbox_e2e.rs b/tests/agentbox_e2e.rs
deleted file mode 100644
index a8524337b6..0000000000
--- a/tests/agentbox_e2e.rs
+++ /dev/null
@@ -1,316 +0,0 @@
-//! End-to-end test for the AgentBox marketplace adapter (#3620).
-//!
-//! Boots the real `openhuman-core` binary with `OPENHUMAN_AGENTBOX_MODE=1`
-//! pointed at an in-process OpenAI-compatible wiremock provider (filling the
-//! `GMI_MAAS_*` env contract that `agentbox::env` consumes at startup),
-//! submits `POST /run`, then polls `GET /jobs/{job_id}` until terminal.
-//!
-//! Mirrors the binary-launch pattern in
-//! `tests/memory_tree_sync_deep_raw_coverage_e2e.rs` (uses
-//! `env!("CARGO_BIN_EXE_openhuman-core")`) and the wiremock provider pattern
-//! in `tests/inference_provider_e2e.rs`.
-//!
-//! ## Why `#[ignore]`
-//!
-//! The AgentBox `/run` invoker (`agentbox::invoker::CoreAgentInvoker`) drives
-//! the **live agent runtime** through the web-channel pipeline
-//! (`web_chat::start_chat`). End-to-end completion against a
-//! freshly-bootstrapped tempdir workspace requires:
-//!
-//! 1. A logged-in user session on disk — `start_chat` and several upstream
-//! stages (prompt-injection guard, multimodal config, memory) call into
-//! `Config::load_or_init` and the auth store. A fresh empty workspace
-//! has no session, so the agent runtime currently returns a `chat_error`
-//! before the inference provider is ever consulted.
-//! 2. Most domain services bootstrapped by `bootstrap_core_runtime` to be
-//! mockable from outside the process (memory store, embeddings,
-//! heartbeat, etc.). Several of those make outbound calls today that the
-//! OpenAI-compat mock can't intercept.
-//! 3. A way to seed `config.toml` so `register_gmi_provider_if_present`
-//! keeps its writes from racing against the agent runtime's own first
-//! `Config::load_or_init`.
-//!
-//! Un-ignoring this test requires either:
-//! - a public test-harness hook to seed a fake logged-in session into the
-//! workspace before `serve` starts (see `e2e-test-support` feature gate
-//! used by the desktop E2E build for `openhuman.test_reset`), OR
-//! - a `OPENHUMAN_AGENTBOX_TEST_STUB_INVOKER=1` opt-in in
-//! `core::jsonrpc::build_core_http_router` that swaps `CoreAgentInvoker`
-//! for a deterministic stub that echoes the request back without
-//! touching the agent runtime.
-//!
-//! Until then, Task 14's Docker smoke step in the deployment runbook
-//! (`gitbooks/developing/agentbox-deployment.md`) covers manual end-to-end
-//! validation against the real GMI MaaS endpoint.
-//!
-//! The test below is wired up correctly otherwise: it spawns the binary,
-//! waits for `/health`, drives `/run` + `/jobs/{id}`, and tears the child
-//! down via a Drop guard even on assertion failure.
-
-#![cfg(not(target_os = "windows"))]
-
-use std::io::Read;
-use std::net::TcpListener;
-use std::process::{Child, Command, Stdio};
-use std::time::{Duration, Instant};
-
-use serde_json::Value;
-use tempfile::TempDir;
-use wiremock::matchers::{method, path};
-use wiremock::{Mock, MockServer, ResponseTemplate};
-
-/// RAII guard that kills the spawned core process on drop, so the test
-/// cleans up correctly on assertion failure as well as success.
-struct ChildGuard {
- child: Option<Child>,
-}
-
-impl ChildGuard {
- fn new(child: Child) -> Self {
- Self { child: Some(child) }
- }
-}
-
-impl Drop for ChildGuard {
- fn drop(&mut self) {
- if let Some(mut child) = self.child.take() {
- let _ = child.kill();
- // Drain stderr so we surface it on failure. Bounded read so a
- // chatty child can't hang the test runner.
- if let Some(err) = child.stderr.take() {
- let mut buf = Vec::with_capacity(8 * 1024);
- let _ = err.take(64 * 1024).read_to_end(&mut buf);
- if !buf.is_empty() {
- eprintln!(
- "[agentbox_e2e] child stderr (truncated):\n{}",
- String::from_utf8_lossy(&buf)
- );
- }
- }
- let _ = child.wait();
- }
- }
-}
-
-/// Reserve a TCP port the OS considers free *right now* and immediately drop
-/// the listener so the spawned core process can bind it. There is a small
-/// race window between drop and re-bind, but `pick_listen_port_for_host`
-/// inside the core will fall back to a nearby port on conflict, so this is
-/// only a best-effort hint.
-fn reserve_port() -> u16 {
- let listener = TcpListener::bind("127.0.0.1:0").expect("bind ephemeral");
- let port = listener
- .local_addr()
- .expect("local_addr on ephemeral bind")
- .port();
- drop(listener);
- port
-}
-
-fn spawn_core_with_agentbox(port: u16, workspace: &std::path::Path, gmi_base_url: &str) -> Child {
- Command::new(env!("CARGO_BIN_EXE_openhuman-core"))
- .arg("serve")
- .arg("--jsonrpc-only")
- .env("OPENHUMAN_AGENTBOX_MODE", "1")
- .env("OPENHUMAN_CORE_PORT", port.to_string())
- .env("OPENHUMAN_CORE_HOST", "127.0.0.1")
- .env("OPENHUMAN_WORKSPACE", workspace)
- // Token only matters for authed endpoints; /run and /jobs/* bypass auth.
- .env("OPENHUMAN_CORE_TOKEN", "agentbox-e2e-token")
- .env("OPENHUMAN_KEYRING_BACKEND", "file")
- // Wire the GMI MaaS bridge at startup so the agent runtime would
- // route inference through our wiremock stub.
- .env("GMI_MAAS_BASE_URL", gmi_base_url)
- .env("GMI_MAAS_API_KEY", "test-key")
- .env("GMI_MODELS", "stub-model")
- // Keep noise down; bump to debug locally when investigating.
- .env(
- "RUST_LOG",
- "warn,openhuman_core::openhuman::agent::agentbox=info",
- )
- .stdout(Stdio::piped())
- .stderr(Stdio::piped())
- .spawn()
- .expect("spawn openhuman-core")
-}
-
-async fn wait_health(port: u16, deadline: Duration) -> Result<(), String> {
- let client = reqwest::Client::builder()
- .timeout(Duration::from_secs(2))
- .build()
- .map_err(|e| e.to_string())?;
- let url = format!("http://127.0.0.1:{port}/health");
- let started = Instant::now();
- let mut last_err: Option<String> = None;
- while started.elapsed() < deadline {
- match client.get(&url).send().await {
- Ok(r) if r.status().is_success() => return Ok(()),
- Ok(r) => last_err = Some(format!("status={}", r.status())),
- Err(e) => last_err = Some(e.to_string()),
- }
- tokio::time::sleep(Duration::from_millis(200)).await;
- }
- Err(format!(
- "core /health did not become ready in {:?}: last_err={:?}",
- deadline, last_err
- ))
-}
-
-fn openai_chat_response(content: &str) -> Value {
- serde_json::json!({
- "id": "chatcmpl-agentbox-e2e",
- "object": "chat.completion",
- "created": 1_700_000_000_u64,
- "model": "stub-model",
- "choices": [{
- "index": 0,
- "message": { "role": "assistant", "content": content },
- "finish_reason": "stop"
- }],
- "usage": { "prompt_tokens": 1, "completion_tokens": 1, "total_tokens": 2 }
- })
-}
-
-async fn start_openai_compat_mock() -> MockServer {
- let server = MockServer::start().await;
-
- Mock::given(method("POST"))
- .and(path("/v1/chat/completions"))
- .respond_with(ResponseTemplate::new(200).set_body_json(openai_chat_response("stub-reply")))
- .mount(&server)
- .await;
-
- Mock::given(method("GET"))
- .and(path("/v1/models"))
- .respond_with(ResponseTemplate::new(200).set_body_json(serde_json::json!({
- "data": [{"id": "stub-model", "object": "model"}],
- "object": "list"
- })))
- .mount(&server)
- .await;
-
- server
-}
-
-/// End-to-end: spawn `openhuman-core serve` with `OPENHUMAN_AGENTBOX_MODE=1`
-/// pointed at an in-process OpenAI-compat mock, drive `POST /run` then poll
-/// `GET /jobs/{id}` until terminal, and assert a non-empty completion.
-///
-/// **Currently `#[ignore]`d** — see the module-level docstring. The Docker
-/// smoke step in `gitbooks/developing/agentbox-deployment.md` covers manual
-/// end-to-end validation against the real GMI MaaS endpoint until the
-/// runtime exposes a test stub for the invoker (see TODO below).
-///
-/// TODO(#3620): un-ignore once one of these lands:
-/// 1. An `e2e-test-support`-gated env var
-/// `OPENHUMAN_AGENTBOX_TEST_STUB_INVOKER=1` that swaps
-/// `agentbox::invoker::CoreAgentInvoker` for a deterministic echo stub
-/// in `core::jsonrpc::build_core_http_router`, OR
-/// 2. A reusable test fixture that seeds a logged-in session +
-/// pre-rendered `config.toml` into `OPENHUMAN_WORKSPACE` so the real
-/// agent runtime can complete a turn against the wiremock provider
-/// from a cold-start binary.
-#[ignore = "TODO(#3620): needs a test-stub invoker or a seeded-session fixture; see module docs"]
-#[tokio::test]
-async fn agentbox_run_then_poll_completes() {
- let workspace: TempDir = tempfile::tempdir().expect("workspace tempdir");
-
- // 1. Stand up the OpenAI-compat mock first so GMI_MAAS_BASE_URL is real
- // by the time the core boots.
- let mock = start_openai_compat_mock().await;
- let gmi_base_url = mock.uri();
-
- // 2. Pick a port (unusual range; the binary will fall back if it
- // collides between reservation and re-bind).
- let port = {
- let p = reserve_port();
- if p < 17788 {
- 17788
- } else {
- p
- }
- };
-
- // 3. Spawn the binary under a Drop guard so the child is reaped on
- // every code path (panic, assertion failure, early return).
- let guard = ChildGuard::new(spawn_core_with_agentbox(
- port,
- workspace.path(),
- &gmi_base_url,
- ));
-
- // 4. Wait for /health to become ready (~10s bounded).
- wait_health(port, Duration::from_secs(10))
- .await
- .expect("core /health should become ready within 10s");
-
- // 5. Submit a run.
- let client = reqwest::Client::builder()
- .timeout(Duration::from_secs(10))
- .build()
- .expect("build reqwest client");
- let run_url = format!("http://127.0.0.1:{port}/run");
- let resp = client
- .post(&run_url)
- .json(&serde_json::json!({ "payload": { "message": "hello" } }))
- .send()
- .await
- .expect("POST /run");
- assert_eq!(resp.status().as_u16(), 202, "POST /run should return 202");
- let body: Value = resp.json().await.expect("parse /run JSON");
- let job_id = body
- .get("job_id")
- .and_then(Value::as_str)
- .expect("/run response should include job_id")
- .to_string();
- assert!(!job_id.is_empty(), "job_id should be non-empty");
-
- // 6. Poll the job until terminal (~25s bounded, 250ms cadence).
- let jobs_url = format!("http://127.0.0.1:{port}/jobs/{job_id}");
- let deadline = Instant::now() + Duration::from_secs(25);
- let mut last_view: Option<Value> = None;
- while Instant::now() < deadline {
- let r = client.get(&jobs_url).send().await.expect("GET /jobs/{id}");
- assert_eq!(
- r.status().as_u16(),
- 200,
- "GET /jobs/{{id}} should return 200"
- );
- let view: Value = r.json().await.expect("parse /jobs JSON");
- let status = view
- .get("status")
- .and_then(Value::as_str)
- .unwrap_or("")
- .to_string();
- if status == "completed" || status == "failed" {
- last_view = Some(view);
- break;
- }
- last_view = Some(view);
- tokio::time::sleep(Duration::from_millis(250)).await;
- }
-
- let view = last_view.expect("at least one /jobs poll should have returned a body");
- let status = view
- .get("status")
- .and_then(Value::as_str)
- .unwrap_or("")
- .to_string();
- assert_eq!(
- status, "completed",
- "job should reach completed; last view: {view}"
- );
- let message = view
- .pointer("/result/message")
- .and_then(Value::as_str)
- .unwrap_or("");
- assert!(
- !message.is_empty(),
- "completed job should have a non-empty result.message; got view: {view}"
- );
-
- // 7. Drop the guard explicitly so the child is reaped before the test
- // returns. (Lexical drop would do the same; this is just explicit
- // documentation of intent.)
- drop(guard);
-}
diff --git a/tests/fixtures/subconscious/README.md b/tests/fixtures/subconscious/README.md
deleted file mode 100644
index 8e2441b3a8..0000000000
--- a/tests/fixtures/subconscious/README.md
+++ /dev/null
@@ -1,35 +0,0 @@
-# Subconscious Loop Test Fixtures
-
-Two temporal sets simulating state changes between ticks.
-
-## Tick 1 (initial state)
-
-- `tick1_gmail.txt` — 3 emails: deadline reminder (April 3), CI notification (routine), meeting invite
-- `tick1_notion.txt` — Project tracker: 3 threads (memory=in progress, skills=blocked, ingestion=complete)
-- `heartbeat.md` — 3 periodic tasks
-
-### Expected tick 1 behavior
-
-- **Escalate**: Deadline reminder (April 3) — actionable, time-sensitive
-- **Noop**: CI notification — routine, no action needed
-- **Noop or act**: Meeting invite — informational, could store to memory
-- **Noop**: Notion tracker — no urgent changes
-- Decision log should record the deadline escalation with source doc ID
-
-## Tick 2 (state change — 6 hours later)
-
-- `tick2_gmail.txt` — 2 new emails: deadline MOVED UP to April 2 (urgent), skills unblocked
-- `tick2_notion.txt` — Tracker updated: Thread 2 unblocked, deadline decision changed
-
-### Expected tick 2 behavior
-
-- **Skip**: Original deadline email (tick1) — already surfaced in tick 1
-- **Escalate**: New deadline-moved email — different doc, more urgent (tomorrow!)
-- **Act**: Skills unblocked email — store to memory, update known state
-- **Act or escalate**: Notion tracker change — Thread 2 status changed, deadline decision changed
-- Decision log should NOT re-surface the original deadline
-
-## Tick 3 (no new data)
-
-- No new fixtures ingested
-- **Expected**: Noop — delta is empty, skip inference entirely
diff --git a/tests/fixtures/subconscious/heartbeat.md b/tests/fixtures/subconscious/heartbeat.md
deleted file mode 100644
index 5abec37f3c..0000000000
--- a/tests/fixtures/subconscious/heartbeat.md
+++ /dev/null
@@ -1,5 +0,0 @@
-# Periodic Tasks
-
-- Check for deadline changes in project tracker
-- Review new emails for urgent items
-- Monitor skills runtime health
diff --git a/tests/fixtures/subconscious/tick1_gmail.txt b/tests/fixtures/subconscious/tick1_gmail.txt
deleted file mode 100644
index 0827c90c51..0000000000
--- a/tests/fixtures/subconscious/tick1_gmail.txt
+++ /dev/null
@@ -1,47 +0,0 @@
-Subject: Re: API contract deadline reminder
-Date: 2026-04-01 09:30:00
-
-Hi Sanil,
-
-Quick reminder — the API contract review is due by April 3. Please make sure the
-final RPC method names and response envelope strategy are documented before then.
-
-Ravi has already finished the core memory domain work. Asha is wrapping up the
-ingestion evaluation fixtures.
-
-Let me know if you need more time, but Steven wants this locked by Thursday.
-
-Best,
-Ravi
-
----
-
-Subject: [tinyhumansai/openhuman] CI passed on main
-Date: 2026-04-01 10:15:00
-
-All checks passed on commit abc1234 — build, typecheck, lint.
-No action required.
-
----
-
-Subject: Team sync — Wednesday 2pm
-Date: 2026-04-01 11:00:00
-
-Hey Sanil,
-
-Scheduling a team sync for Wednesday April 2 at 2pm IST.
-Agenda:
-- Memory layer status update
-- Ingestion quality review
-- Skills runtime isolation discussion
-
-Please confirm your availability.
-
-Asha
diff --git a/tests/fixtures/subconscious/tick1_notion.txt b/tests/fixtures/subconscious/tick1_notion.txt
deleted file mode 100644
index df7bf5add2..0000000000
--- a/tests/fixtures/subconscious/tick1_notion.txt
+++ /dev/null
@@ -1,48 +0,0 @@
-# Q1 Delivery Tracker
-
-Workspace: tinyhumans / engineering
-Owner: Sanil Jain
-Last edited: 2026-04-01
-Status: In Progress
-
-## Active Threads
-
-### Thread 1: Memory Layer
-Owner: Sanil Jain
-Status: In Progress
-Due date: 2026-04-15
-Deliverables:
-- Stable document storage
-- Graph query and recall
-- Controller registry migration
-
-### Thread 2: Skills Runtime
-Owner: Ravi Kumar
-Status: Blocked
-Due date: 2026-04-10
-Deliverables:
-- Per-skill QuickJS isolation
-- OAuth credential refresh
-- Webhook routing
-
-Blocker: Waiting on credential exchange API from backend team.
-
-### Thread 3: Ingestion Quality
-Owner: Asha Mehta
-Status: Complete
-Due date: 2026-03-26
-Deliverables:
-- Gmail fixture evaluation
-- Notion fixture evaluation
-- GLiNER entity extraction baseline
-
-## Decisions
-
-- JSON-RPC retained as transport for desktop core
-- Namespace is the primary storage scope key
-- Controller registry pattern adopted for all RPC domains
-
-## Team Preferences
-
-- Sanil prefers core-first delivery over UI-first delivery
-- Ravi prefers strict ownership boundaries for parallel agents
diff --git a/tests/fixtures/subconscious/tick2_gmail.txt b/tests/fixtures/subconscious/tick2_gmail.txt
deleted file mode 100644
index 2518a4f14c..0000000000
--- a/tests/fixtures/subconscious/tick2_gmail.txt
+++ /dev/null
@@ -1,32 +0,0 @@
-Subject: URGENT: API contract deadline moved to tomorrow
-Date: 2026-04-01 16:00:00
-
-Sanil,
-
-Change of plans — the API contract review has been moved up to April 2 (tomorrow).
-The investor demo is now scheduled for April 4 instead of April 7, so we need
-everything locked a day earlier.
-
-Please prioritize this over other work today. Let me know if there are blockers.
-
-Steven
-
----
-
-Subject: Skills runtime — credential fix landed
-Date: 2026-04-01 17:30:00
-
-Sanil,
-
-Good news — the backend team deployed the credential exchange fix.
-OAuth token refresh should now work for Gmail and Notion skills.
-I've unblocked Thread 2 and updated the tracker.
-
-The skills runtime isolation work can resume now.
-
-Ravi
diff --git a/tests/fixtures/subconscious/tick2_notion.txt b/tests/fixtures/subconscious/tick2_notion.txt
deleted file mode 100644
index 46aa4b5bd4..0000000000
--- a/tests/fixtures/subconscious/tick2_notion.txt
+++ /dev/null
@@ -1,49 +0,0 @@
-# Q1 Delivery Tracker
-
-Workspace: tinyhumans / engineering
-Owner: Sanil Jain
-Last edited: 2026-04-01
-Status: In Progress
-
-## Active Threads
-
-### Thread 1: Memory Layer
-Owner: Sanil Jain
-Status: In Progress
-Due date: 2026-04-15
-Deliverables:
-- Stable document storage
-- Graph query and recall
-- Controller registry migration
-
-### Thread 2: Skills Runtime
-Owner: Ravi Kumar
-Status: In Progress
-Due date: 2026-04-10
-Deliverables:
-- Per-skill QuickJS isolation
-- OAuth credential refresh
-- Webhook routing
-
-Note: Unblocked — credential exchange API deployed by backend team.
-
-### Thread 3: Ingestion Quality
-Owner: Asha Mehta
-Status: Complete
-Due date: 2026-03-26
-Deliverables:
-- Gmail fixture evaluation
-- Notion fixture evaluation
-- GLiNER entity extraction baseline
-
-## Decisions
-
-- JSON-RPC retained as transport for desktop core
-- Namespace is the primary storage scope key
-- Controller registry pattern adopted for all RPC domains
-- API contract deadline moved to April 2 (was April 3)
-
-## Team Preferences
-
-- Sanil prefers core-first delivery over UI-first delivery
-- Ravi prefers strict ownership boundaries for parallel agents
diff --git a/tests/subconscious_fullstack_e2e.rs b/tests/subconscious_fullstack_e2e.rs
deleted file mode 100644
index 257bdf04ac..0000000000
--- a/tests/subconscious_fullstack_e2e.rs
+++ /dev/null
@@ -1,424 +0,0 @@
-//! Fully hermetic FULL-STACK e2e: the REAL gate + REAL long-lived session
-//! run against a **mocked LLM model** — no network, no Ollama, no real model
-//! anywhere (cloud and local model funnels are both overridden).
-//!
-//! Unlike `subconscious_conversation_e2e.rs` (which injects scripted Gate /
-//! SessionExecutor *above* the model), this test mocks at the crate model
-//! layer, so the production code paths run for real:
-//! - `GatePass::evaluate` → `agent::triage::run_triage` → real model
-//! funnel → mock → real triage parse → real promote/drop mapping.
-//! - `LongLivedSession::process_promoted` → `Agent::from_config` (the real
-//! orchestrator agent + tool loop) → mock → real reserved-thread persistence.
-//!
-//! The mock is installed via the factory's `test_provider_override` seam,
-//! which both model funnels consult first.
-//!
-//! Gated on the off-by-default `e2e-test-support` feature (the seam is only
-//! compiled then). Run with:
-//! `RUST_MIN_STACK=16777216 cargo test --features e2e-test-support --test subconscious_fullstack_e2e -- --nocapture`
-#![cfg(feature = "e2e-test-support")]
-
-use std::sync::{Arc, Mutex as StdMutex, OnceLock};
-
-use async_trait::async_trait;
-
-use openhuman_core::core::bus::BUS;
-use openhuman_core::core::events::DomainEvent;
-use openhuman_core::openhuman::agent::harness::AgentDefinitionRegistry;
-use openhuman_core::openhuman::config::schema::SubconsciousMode;
-use openhuman_core::openhuman::inference::provider::factory::test_provider_override;
-use openhuman_core::openhuman::subconscious::triggers::{normalize, GatePass};
-use openhuman_core::openhuman::subconscious::LongLivedSession;
-use tinyagents::harness::message::AssistantMessage;
-use tinyagents::harness::model::{ChatModel, ModelProfile, ModelRequest, ModelResponse};
-use tinyagents::harness::tool::ToolCall;
-
-// ─────────────────────────────────────────────────────────────────────────────
-// Mock LLM model — deterministic, content-routed, no network.
-// ─────────────────────────────────────────────────────────────────────────────
-
-/// Records every prompt the mock saw, and answers deterministically:
-/// - triage turns (recognised by the triage envelope markers) → a JSON
-/// decision (drop for cron, escalate otherwise);
-/// - any other turn (the session/orchestrator agent) → a plain final reply.
-struct MockLlm {
- seen: StdMutex<Vec<String>>,
- /// When set, the orchestrator turn emits a real `spawn_subagent` tool
- /// call so the harness runs an actual sub-agent (native tool mode).
- spawn: bool,
- profile: ModelProfile,
-}
-
-const SUBAGENT_MARKER: &str = "SUBAGENT_TASK";
-const RESEARCHER_FINDINGS: &str = "Researcher findings: Q3 numbers look healthy.";
-
-impl MockLlm {
- fn new() -> Arc<Self> {
- let mut profile = ModelProfile::default();
- profile.tool_calling = false;
- Arc::new(Self {
- seen: StdMutex::new(Vec::new()),
- spawn: false,
- profile,
- })
- }
- fn with_spawning() -> Arc<Self> {
- let mut profile = ModelProfile::default();
- profile.tool_calling = true;
- profile.parallel_tool_calls = true;
- Arc::new(Self {
- seen: StdMutex::new(Vec::new()),
- spawn: true,
- profile,
- })
- }
-
- fn triage_decision(&self, joined: &str) -> String {
- let drop = joined.contains("\"source\": \"cron\"")
- || joined.contains("\"source\":\"cron\"")
- || joined.to_lowercase().contains("ignore me");
- if drop {
- "{\"action\":\"drop\",\"reason\":\"mock: routine noise\"}".to_string()
- } else {
- "{\"action\":\"escalate\",\"target_agent\":\"orchestrator\",\
- \"prompt\":\"handle this\",\"reason\":\"mock: actionable\"}"
- .to_string()
- }
- }
-
- fn respond(&self, joined: &str) -> ModelResponse {
- self.seen.lock().unwrap().push(joined.to_string());
- let is_triage = joined.contains("DISPLAY_LABEL:") && joined.contains("PAYLOAD:");
-
- let text = if is_triage {
- self.triage_decision(joined)
- } else if joined.contains(RESEARCHER_FINDINGS) {
- // Orchestrator's follow-up turn after the sub-agent returned →
- // merge + finish. Checked BEFORE the marker because turn-2's
- // history echoes the tool-call arguments (which carry the marker).
- "Mock orchestrator merged the sub-agent findings.".to_string()
- } else if joined.contains(SUBAGENT_MARKER) {
- // The spawned researcher sub-agent's own turn → return findings,
- // no further tool calls (prevents recursive spawning).
- RESEARCHER_FINDINGS.to_string()
- } else if self.spawn {
- // Orchestrator's first turn → delegate via a real spawn_subagent
- // tool call.
- return ModelResponse {
- message: AssistantMessage {
- id: None,
- content: Vec::new(),
- tool_calls: vec![ToolCall::new(
- "call-1",
- "spawn_subagent",
- serde_json::json!({
- "agent_id": "researcher",
- "prompt": format!("{SUBAGENT_MARKER}: investigate the Q3 numbers"),
- }),
- )],
- usage: None,
- },
- usage: None,
- finish_reason: Some("tool_calls".to_string()),
- raw: None,
- resolved_model: None,
- continue_turn: None,
- served_from_cache: false,
- };
- } else {
- "Mock orchestrator handled the promoted trigger.".to_string()
- };
-
- ModelResponse::assistant(text)
- }
-
- fn triage_turns(&self) -> usize {
- self.seen
- .lock()
- .unwrap()
- .iter()
- .filter(|p| p.contains("DISPLAY_LABEL:") && p.contains("PAYLOAD:"))
- .count()
- }
-
- fn saw(&self, needle: &str) -> bool {
- self.seen.lock().unwrap().iter().any(|p| p.contains(needle))
- }
-}
-
-#[async_trait]
-impl ChatModel<()> for MockLlm {
- fn profile(&self) -> Option<&ModelProfile> {
- Some(&self.profile)
- }
-
- async fn invoke(
- &self,
- _state: &(),
- request: ModelRequest,
- ) -> tinyagents::Result<ModelResponse> {
- let joined = request
- .messages
- .iter()
- .map(|message| message.text())
- .collect::<Vec<_>>()
- .join("\n");
- Ok(self.respond(&joined))
- }
-}
-
-// ─────────────────────────────────────────────────────────────────────────────
-// Hermetic harness: temp HOME + config + globals + installed mock model.
-// ─────────────────────────────────────────────────────────────────────────────
-
-/// Serializes these tests: they mutate process-global env + install a
-/// process-global model override.
-fn serial() -> std::sync::MutexGuard<'static, ()> {
- static LOCK: OnceLock<StdMutex<()>> = OnceLock::new();
- LOCK.get_or_init(|| StdMutex::new(()))
- .lock()
- .unwrap_or_else(|p| p.into_inner())
-}
-
-struct EnvGuard {
- key: &'static str,
- old: Option<String>,
-}
-impl EnvGuard {
- fn set(key: &'static str, val: &str) -> Self {
- let old = std::env::var(key).ok();
- std::env::set_var(key, val);
- Self { key, old }
- }
- fn unset(key: &'static str) -> Self {
- let old = std::env::var(key).ok();
- std::env::remove_var(key);
- Self { key, old }
- }
-}
-impl Drop for EnvGuard {
- fn drop(&mut self) {
- match &self.old {
- Some(v) => std::env::set_var(self.key, v),
- None => std::env::remove_var(self.key),
- }
- }
-}
-
-struct Harness {
- workspace: std::path::PathBuf,
- mock: Arc<MockLlm>,
- _install: test_provider_override::InstallGuard,
- _home: EnvGuard,
- _ws: EnvGuard,
- _keyring: EnvGuard,
- _tmp: tempfile::TempDir,
-}
-
-fn write_config(openhuman_dir: &std::path::Path) {
- // api_url is never dialed — the model override intercepts creation
- // before any URL is used — but config must parse and disable local AI so
- // nothing reaches Ollama either.
- let cfg = r#"api_url = "http://127.0.0.1:9"
-default_model = "mock-model"
-default_temperature = 0.2
-chat_onboarding_completed = true
-
-[secrets]
-encrypt = false
-
-[local_ai]
-enabled = false
-runtime_enabled = false
-"#;
- let write = |dir: &std::path::Path| {
- std::fs::create_dir_all(dir).expect("mkdir");
- std::fs::write(dir.join("config.toml"), cfg).expect("write config");
- };
- write(openhuman_dir);
- write(&openhuman_dir.join("users").join("local"));
- // Sanity: the config must match the schema.
- let _: openhuman_core::openhuman::config::Config = toml::from_str(cfg).expect("config schema");
-}
-
-fn harness() -> Harness {
- harness_with(MockLlm::new())
-}
-
-fn harness_spawning() -> Harness {
- harness_with(MockLlm::with_spawning())
-}
-
-fn harness_with(mock: Arc<MockLlm>) -> Harness {
- let tmp = tempfile::tempdir().expect("tempdir");
- let home = tmp.path().to_path_buf();
- let openhuman_dir = home.join(".openhuman");
- write_config(&openhuman_dir);
- let workspace = home.join("workspace");
- std::fs::create_dir_all(&workspace).expect("mkdir ws");
-
- let home_guard = EnvGuard::set("HOME", home.to_str().unwrap());
- let ws_guard = EnvGuard::set("OPENHUMAN_WORKSPACE", workspace.to_str().unwrap());
- let keyring_guard = EnvGuard::set("OPENHUMAN_KEYRING_BACKEND", "file");
-
- // Globals the real pipeline needs.
- openhuman_core::core::bus::init().await.expect("bus init");
- openhuman_core::openhuman::agent::bus::register_agent_handlers();
- let _ = AgentDefinitionRegistry::init_global_builtins();
-
- // Install the mock LLM — both model funnels consult this first.
- let install = test_provider_override::install_model(mock.clone());
-
- Harness {
- workspace,
- mock,
- _install: install,
- _home: home_guard,
- _ws: ws_guard,
- _keyring: keyring_guard,
- _tmp: tmp,
- }
-}
-
-fn human_event(message: &str) -> DomainEvent {
- DomainEvent::ChannelInboundMessage {
- event_name: "msg".into(),
- channel: "slack".into(),
- message: message.into(),
- sender: Some("U1".into()),
- reply_target: Some("dm".into()),
- thread_ts: Some("t1".into()),
- raw_data: serde_json::Value::Null,
- }
-}
-
-fn cron_event() -> DomainEvent {
- DomainEvent::CronJobTriggered {
- job_id: "nightly".into(),
- job_name: "nightly recap".into(),
- job_type: "agent".into(),
- }
-}
-
-// ─────────────────────────────────────────────────────────────────────────────
-// Gate (real triage pipeline) over the mock — promote vs drop.
-// ─────────────────────────────────────────────────────────────────────────────
-
-#[tokio::test]
-async fn fullstack_gate_promotes_human_message_via_real_triage() {
- let _s = serial();
- let h = harness();
- let gate = GatePass::new(100);
-
- let trigger = normalize(&human_event("can you help with the Q3 plan?"), 1.0).unwrap();
- let decision = gate.evaluate(&trigger, 1.0).await;
-
- println!("\n[fullstack] human trigger gate decision: {decision:?}");
- assert!(
- decision.is_promote(),
- "real triage (mock-backed) should promote an actionable human message; got {decision:?}"
- );
- assert!(h.mock.triage_turns() >= 1, "the real triage LLM path ran");
-}
-
-#[tokio::test]
-async fn fullstack_gate_drops_cron_noise_via_real_triage() {
- let _s = serial();
- let h = harness();
- let gate = GatePass::new(100);
-
- let trigger = normalize(&cron_event(), 1.0).unwrap();
- let decision = gate.evaluate(&trigger, 1.0).await;
-
- println!("[fullstack] cron trigger gate decision: {decision:?}");
- assert!(
- !decision.is_promote(),
- "routine cron noise should be dropped"
- );
- assert!(h.mock.triage_turns() >= 1);
-}
-
-// ─────────────────────────────────────────────────────────────────────────────
-// Session (real orchestrator agent + tool loop) over the mock.
-// ─────────────────────────────────────────────────────────────────────────────
-
-#[tokio::test]
-async fn fullstack_session_runs_real_agent_and_persists() {
- let _s = serial();
- let h = harness();
-
- let session = LongLivedSession::with_thread(
- h.workspace.clone(),
- SubconsciousMode::Aggressive,
- "subconscious:orchestrator".into(),
- );
-
- let outcome = session
- .process_promoted("[user/slack] Please look into the Q3 numbers.", false)
- .await;
-
- println!("[fullstack] session outcome: {outcome:?}");
- let outcome = outcome.expect("real agent turn (mock-backed) should succeed");
- assert!(
- outcome.response.contains("Mock orchestrator"),
- "session returned the mock agent's reply: {}",
- outcome.response
- );
-
- // Real reserved-thread persistence: the user turn + agent reply landed.
- let msgs = tinycortex::memory::conversations::get_messages(
- h.workspace.clone(),
- "subconscious:orchestrator",
- )
- .expect("read reserved thread");
- let senders: Vec<&str> = msgs.iter().map(|m| m.sender.as_str()).collect();
- assert!(
- senders.contains(&"user"),
- "user turn persisted: {senders:?}"
- );
- assert!(
- senders.contains(&"agent"),
- "agent reply persisted: {senders:?}"
- );
-}
-
-// ─────────────────────────────────────────────────────────────────────────────
-// Full chain: human → subconscious session → REAL sub-agent → back → human.
-// The mock makes the orchestrator emit a real `spawn_subagent` tool call, so
-// the harness runs an actual researcher sub-agent (inheriting the mock
-// model), whose output is merged by the orchestrator's follow-up turn.
-// ─────────────────────────────────────────────────────────────────────────────
-
-#[tokio::test]
-async fn fullstack_session_spawns_real_subagent_and_merges() {
- let _s = serial();
- let h = harness_spawning();
-
- let session = LongLivedSession::with_thread(
- h.workspace.clone(),
- SubconsciousMode::Aggressive,
- "subconscious:orchestrator".into(),
- );
-
- let outcome = session
- .process_promoted("[user/slack] Please research the Q3 numbers.", false)
- .await;
-
- println!("[fullstack] spawn outcome: {outcome:?}");
- let outcome = outcome.expect("orchestrator turn with a real sub-agent should succeed");
-
- // The orchestrator delegated and a REAL researcher sub-agent ran (its turn
- // carried our SUBAGENT_TASK marker), and its findings flowed back into the
- // session result — the full human → subconscious → sub-agent → back chain,
- // all production code, mock-backed model.
- assert!(
- h.mock.saw(SUBAGENT_MARKER),
- "the real harness ran the spawned researcher sub-agent"
- );
- assert!(
- outcome.response.contains("Researcher findings")
- || outcome.response.contains("merged the sub-agent findings"),
- "the sub-agent's output flowed back to the session: {}",
- outcome.response
- );
-}