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
test(e2e): backfill coverage for migration guard, prompt order, redirects, privacy sheet\n\nAn audit of six PRs merged in the last week found none with e2e coverage of\nwhat they changed. Three shipped tests their authors reasonably believed were\nsufficient: #5799 added 62 lines to `tests/json_rpc_e2e.rs` that are a\ndeterminism fix for a different test; #5821's four unit tests exercise an\nextracted pure helper and would pass if `build_system_prompt` stopped calling\nit; #5939's two tests are vitest, not an e2e lane.\n\nAdded, each driving the changed path and asserting the changed behaviour:\n\n- #5799 `json_rpc_migrate_hermes_refuses_null_driver_without_naming_openclaw`.\n Drives the Hermes migration RPC into a configured null driver and asserts the\n refusal, that it no longer hard-codes "OpenClaw" in a message both migrations\n raise, and that the source workspace really is byte-identical afterwards.\n The third arm #5799 added is unreachable with modules on and stays with its\n gates-off unit test; the doc comment says so rather than faking it.\n\n- #5821 two tests on the real `Agent::build_system_prompt`, asserting the\n tool-policy boundary does not open the prompt and that it is the prompt's\n final block — the property a prefix cache keys on, and the one a revert to\n prepending destroys.\n\n- #5939 two cases on `/webhooks`, asserting the query and the fragment survive\n BOTH redirect hops. They assert the final destination, so a fix to only the\n first hop still fails them.\n\n- #5845 a new spec opening the privacy sheet, which no e2e had ever done.\n\nAlso flips `BUG: /skills?tab=channels drops the tab`, which pinned pre-fix\nbehaviour with the note "Flip the two assertions below when that lands". It\nlanded in 786d7ba76 (#5924), four hours before that spec was last touched, so\nthe test asserts the opposite of shipped behaviour.\n
M3gA-Mind7eabdb52f2a6
diff --git a/app/test/playwright/specs/connections-tab-deeplinks.spec.ts b/app/test/playwright/specs/connections-tab-deeplinks.spec.tsindex f4a5e89f9d..684c9533bc 100644--- a/app/test/playwright/specs/connections-tab-deeplinks.spec.ts+++ b/app/test/playwright/specs/connections-tab-deeplinks.spec.ts@@ -21,6 +21,12 @@ import {* `ForwardSearch`, which copies `search` and `hash` onto the destination; the* `?tab=` tests below assert that forwarding rather than the old defect.*+ * `/webhooks` forwards the same way but in TWO hops — via+ * `/settings/integrations`, which is itself a redirect (#5939). Both hops used+ * a bare `<Navigate>`, so a fix to only the first would have handed the query+ * to the second and had it dropped there; the `/webhooks` tests below assert+ * the FINAL destination for that reason.+ ** NOTE ON SCOPE: nothing here opens the Composio tab. Doing so downloads the* `tinyconnectors` module from a GitHub release, and a failed download is* terminal for the core process — which takes the rest of the file with it.@@ -226,6 +232,42 @@ test.describe('Connections — the /skills back-compat redirect', () => {await expectSelectedTab(page, 'welcome');});+ test('/webhooks?tab= survives BOTH hops of its redirect', async ({ page }) => {+ // #5939 (closes #5908). `/webhooks` is a TWO-hop redirect:+ //+ // /webhooks -> /settings/integrations (AppRoutes.tsx:239)+ // /settings/integrations -> /connections (settingsRouteElements.tsx:130)+ //+ // Both hops used a bare `<Navigate>`, so fixing only the first would have+ // handed the query to hop two and had it dropped there instead. That is why+ // this asserts the FINAL destination rather than the intermediate one — a+ // half-fix passes an assertion on `/settings/integrations` and still loses+ // the deep link the user actually followed.+ await openRoute(page, 'pw-webhooks-tab-keep', '/webhooks?tab=channels', '/connections');+ await expect.poll(() => currentHash(page), { timeout: 15_000 }).toContain('/connections');++ expect(await currentHash(page)).toContain('tab=channels');+ await expectSelectedTab(page, 'channels');+ });++ test('/webhooks carries the fragment through as well as the query', async ({ page }) => {+ // `ForwardSearch` copies `hash` alongside `search`. Under HashRouter the+ // fragment is the part after a SECOND `#`, so this also pins that the two+ // are not conflated — a redirect that forwarded only `search` would land on+ // the right tab and still drop the anchor.+ await openRoute(+ page,+ 'pw-webhooks-fragment-keep',+ '/webhooks?tab=channels#delivery-3',+ '/connections'+ );+ await expect.poll(() => currentHash(page), { timeout: 15_000 }).toContain('/connections');++ const hash = await currentHash(page);+ expect(hash).toContain('tab=channels');+ expect(hash).toContain('#delivery-3');+ });+test('/channels keeps working, because its redirect names the tab explicitly', async ({page,}) => {diff --git a/app/test/playwright/specs/privacy-what-leaves-sheet.spec.ts b/app/test/playwright/specs/privacy-what-leaves-sheet.spec.tsnew file mode 100644index 0000000000..523a3b7e59--- /dev/null+++ b/app/test/playwright/specs/privacy-what-leaves-sheet.spec.ts@@ -0,0 +1,106 @@+import { expect, type Page, test } from '@playwright/test';++import { bootAuthenticatedPage, callCoreRpc, waitForAppReady } from '../helpers/core-rpc';++/**+ * The "what leaves my computer" sheet, driven in a real browser.+ *+ * #5845 re-based this sheet from a hand-rolled portal onto the shared Radix+ * dialog (`components/ui/Dialog.tsx`), and no e2e lane ever opened it.+ *+ * A note on why that gap was invisible: `settings-channels-permissions.spec.ts`+ * asserts `getByText('What leaves your computer')` and reads as if it covers+ * this. It does not. That string is `privacy.whatLeavesComputer` (`en.ts:1389`),+ * a static label on the privacy panel. The sheet's trigger is+ * `privacy.whatLeaves.link.label` = 'What leaves my computer?' (`en.ts:4801`)+ * and its own headline is `WHAT_LEAVES_HEADLINE` (`whatLeavesItems.ts:30`).+ * Three different strings; only the panel label was ever asserted.+ *+ * WHAT IS AND IS NOT NEW HERE. The pre-#5845 sheet already rendered+ * `role="dialog"` with `aria-modal`, already closed on Escape (a `document`+ * keydown listener) and already closed on an overlay click (a full-bleed+ * `<button>`). Those three are *preserved* behaviour, not new, and a test+ * asserting only them would pass against the old component too. The one thing+ * the rewrite genuinely added is `aria-describedby` -> the subhead: the old+ * markup rendered that paragraph with no id and never referenced it, so a+ * screen reader announced the title alone. Every test below therefore asserts+ * the description wiring alongside whatever else it drives, so that each one+ * fails if the rewrite is reverted rather than merely re-passing.+ *+ * The sheet is reachable from exactly one place — `WelcomeStep.tsx:28`, the+ * onboarding welcome step — so these boot into onboarding rather than settings.+ */++const HEADLINE = 'Local by default. Cloud when you ask.';+const SUBHEAD = "For full transparency, here's exactly what does, and when.";+const TRIGGER = 'What leaves my computer?';++async function bootIntoOnboardingWelcome(page: Page, userId: string): Promise<void> {+ await bootAuthenticatedPage(page, userId, '/home');+ await callCoreRpc('openhuman.config_set_onboarding_completed', { value: false });+ await page.goto('/#/onboarding/welcome');+ await waitForAppReady(page);+ await expect+ .poll(async () => page.evaluate(() => window.location.hash), { timeout: 20_000 })+ .toMatch(/^#\/onboarding/);+ await expect(page.getByTestId('onboarding-welcome-step')).toBeVisible({ timeout: 20_000 });+}++const sheet = (page: Page) => page.getByRole('dialog');++/**+ * Open the sheet and assert the wiring #5845 introduced.+ *+ * The `aria-describedby` assertion lives here, in the shared open step, so it+ * guards every test in the file rather than only the one that names it.+ */+async function openSheetAndAssertDescribed(page: Page): Promise<void> {+ await expect(sheet(page)).toHaveCount(0);+ await page.getByRole('button', { name: TRIGGER }).click();+ await expect(sheet(page)).toBeVisible({ timeout: 10_000 });++ const describedBy = await sheet(page).getAttribute('aria-describedby');+ expect(+ describedBy,+ 'the rewrite wired the dialog to its subhead; the hand-rolled sheet gave that paragraph no id at all'+ ).toBe('what-leaves-description');+ await expect(page.locator('#what-leaves-description')).toHaveText(SUBHEAD);+}++test.describe('Privacy — the "what leaves my computer" sheet', () => {+ test('opens as a described dialog carrying the honest list', async ({ page }) => {+ await bootIntoOnboardingWelcome(page, 'pw-what-leaves-open');+ await openSheetAndAssertDescribed(page);++ await expect(sheet(page)).toContainText(HEADLINE);++ // The three items are the point of the sheet — a dialog that renders its+ // chrome but drops its content would otherwise satisfy the assertions above.+ await expect(sheet(page)).toContainText('Cloud AI Inference');+ await expect(sheet(page)).toContainText('Third-party integrations');+ await expect(sheet(page)).toContainText('Crash Reports & Usage Data (opt-out)');+ });++ test('Escape closes it and returns the user to the step', async ({ page }) => {+ await bootIntoOnboardingWelcome(page, 'pw-what-leaves-escape');+ await openSheetAndAssertDescribed(page);++ // Preserved behaviour, not new — but it now belongs to Radix rather than a+ // hand-registered `document` listener, which is exactly the kind of thing a+ // library swap loses quietly.+ await page.keyboard.press('Escape');+ await expect(sheet(page)).toHaveCount(0, { timeout: 10_000 });+ await expect(page.getByTestId('onboarding-welcome-step')).toBeVisible();+ });++ test('clicking the overlay outside the panel closes it', async ({ page }) => {+ await bootIntoOnboardingWelcome(page, 'pw-what-leaves-outside');+ await openSheetAndAssertDescribed(page);++ // Top-left of the viewport is overlay, never panel: the content is centred+ // and capped at `max-w-lg`.+ await page.mouse.click(5, 5);+ await expect(sheet(page)).toHaveCount(0, { timeout: 10_000 });+ await expect(page.getByTestId('onboarding-welcome-step')).toBeVisible();+ });+});diff --git a/tests/json_rpc_e2e.rs b/tests/json_rpc_e2e.rsindex cb9018fa25..0a71ca1310 100644--- a/tests/json_rpc_e2e.rs+++ b/tests/json_rpc_e2e.rs@@ -14663,3 +14663,145 @@ async fn json_rpc_flows_strict_create_still_refuses_prose_prompt_without_messagerpc_join.abort();api_join.abort();}++// ---------------------------------------------------------------------------+// Migration import guard: refusing the null memory driver (#5799)+// ---------------------------------------------------------------------------++/// An apply-mode migration into a null memory driver must REFUSE, and the+/// refusal must not name the wrong product.+///+/// The guard exists because every write into a null driver is discarded, so an+/// import that reports "migrated N entries" having written none is silent data+/// loss of the worst kind: the user may delete the source workspace on the+/// strength of that report and have nothing left to re-run against.+///+/// #5799 rewrote the refusal. The half reachable in a modules-on build — which+/// is every build this lane runs — is the headline: it used to read "refusing to+/// import **OpenClaw** memory into the null driver" and was raised verbatim by+/// `migrate_hermes` too, telling a Hermes user about a product they were not+/// migrating. That is what this drives: the Hermes RPC, asserting the refusal+/// does not say "OpenClaw".+///+/// Not covered here, and deliberately: the third arm #5799 added, which names a+/// modules-off *build* rather than the user's config. `binding::module_provider`+/// only substitutes the null provider under `#[cfg(not(feature = "modules"))]`+/// (`memory/binding.rs:406-415`); with modules on it always answers+/// `DriverClass::Module`, so that arm is unreachable from this binary. It is+/// asserted by the gates-off unit test+/// `migration_helpers::ops_tests::apply_refuses_and_names_the_build_when_no_memory_module_is_compiled_in`.+#[tokio::test]+async fn json_rpc_migrate_hermes_refuses_null_driver_without_naming_openclaw() {+ let _env_lock = json_rpc_e2e_env_lock();+ let tmp = tempdir().expect("tempdir");+ let home = tmp.path();+ let openhuman_home = home.join(".openhuman");++ // `Config::workspace_dir` is `#[serde(skip)]` (`config/schema/types_part_01.rs:78`),+ // so it cannot be set from config.toml — the workspace comes from the+ // `OPENHUMAN_WORKSPACE` env overlay, which is what this sets. A `workspace_dir`+ // key in the TOML would be silently inert, and the migration's+ // self-migration guard compares against whatever the overlay resolved.+ let workspace = home.join("workspace");+ std::fs::create_dir_all(&workspace).expect("mkdir workspace");++ let _home_guard = EnvVarGuard::set_to_path("HOME", home);+ let _workspace_guard = EnvVarGuard::set_to_path("OPENHUMAN_WORKSPACE", &workspace);+ let _backend_url_guard = EnvVarGuard::unset("BACKEND_URL");+ let _vite_backend_guard = EnvVarGuard::unset("VITE_BACKEND_URL");++ let (mock_addr, mock_join) = serve_on_ephemeral(mock_upstream_router()).await;+ let mock_origin = format!("http://{}", mock_addr);++ // `driver = "null"` is the one route to a null-classed binding that a+ // modules-on build can take: `admit` returns the configured id, and the id+ // *is* the null driver, so the binding reports class Null with no fallback.+ let cfg = format!(+ r#"api_url = "{mock_origin}"+default_model = "e2e-mock-model"+default_temperature = 0.7+chat_onboarding_completed = true++[secrets]+encrypt = false++[subsystems.memory]+driver = "null"+"#+ );+ std::fs::create_dir_all(&openhuman_home).expect("mkdir openhuman");+ std::fs::write(openhuman_home.join("config.toml"), &cfg).expect("write config");+ std::fs::create_dir_all(openhuman_home.join("users").join("local")).expect("mkdir users/local");+ std::fs::write(+ openhuman_home+ .join("users")+ .join("local")+ .join("config.toml"),+ &cfg,+ )+ .expect("write user config");+ let _: openhuman_core::openhuman::config::Config =+ toml::from_str(&cfg).expect("config toml must match Config schema");++ // A Hermes source with something real to lose. `MEMORY.md` is the first of+ // `hermes_file_mappings()`, so the import has an entry to write and the+ // refusal has to come from the guard rather than from an empty plan.+ let source = home.join("hermes-src");+ std::fs::create_dir_all(&source).expect("mkdir hermes source");+ let source_memory = source.join("MEMORY.md");+ std::fs::write(&source_memory, "# Note\nwould be lost").expect("write hermes MEMORY.md");++ let (rpc_addr, rpc_join) = serve_on_ephemeral(build_core_http_router(false)).await;+ let rpc_base = format!("http://{}", rpc_addr);+ tokio::time::sleep(Duration::from_millis(100)).await;++ let response = post_json_rpc(+ &rpc_base,+ 7310,+ "openhuman.migrate_hermes",+ json!({+ "source_workspace": source.to_string_lossy(),+ "dry_run": false,+ }),+ )+ .await;++ // The refusal may surface as a JSON-RPC error or as an error payload+ // depending on how the controller maps it; take whichever carries text so+ // the assertions below are about the message, not the envelope.+ let message = response+ .get("error")+ .and_then(|e| e.get("message"))+ .and_then(Value::as_str)+ .map(str::to_string)+ .unwrap_or_else(|| response.to_string());++ assert!(+ message.contains("null driver"),+ "apply into a null memory driver must be refused by the guard; got: {message}"+ );+ assert!(+ !message.contains("OpenClaw"),+ "the Hermes migration must not blame OpenClaw — #5799 dropped the \+ hard-coded product name from a message both migrations raise; got: {message}"+ );+ assert!(+ message.contains("the source workspace is untouched"),+ "the refusal must still promise the source survived; got: {message}"+ );++ // The promise in that sentence, checked rather than taken on trust.+ assert!(+ source_memory.exists(),+ "the refusal promised the source workspace was untouched, but {} is gone",+ source_memory.display()+ );+ assert_eq!(+ std::fs::read_to_string(&source_memory).expect("read source memory"),+ "# Note\nwould be lost",+ "the source workspace must be byte-identical after a refused import"+ );++ mock_join.abort();+ rpc_join.abort();+}diff --git a/tests/raw_coverage/agent_prompts_subagent_raw_coverage_e2e.rs b/tests/raw_coverage/agent_prompts_subagent_raw_coverage_e2e.rsindex 09b642189d..74012a40c1 100644--- a/tests/raw_coverage/agent_prompts_subagent_raw_coverage_e2e.rs+++ b/tests/raw_coverage/agent_prompts_subagent_raw_coverage_e2e.rs@@ -617,3 +617,124 @@ async fn run_subagent_surfaces_provider_errors_and_can_be_cancelled() -> Result<Ok(())}++/// The tool-policy boundary is APPENDED to the system prompt, not prepended+/// (#5821, closes #5704).+///+/// Every line of that block is session-scoped — agent id, channel, entry point,+/// risk level, the allowed-tool list — so putting it first moves the prompt's+/// first diverging byte to offset 0 and costs the inference backend's automatic+/// prefix cache everything behind it. Prepending also replaced each agent's+/// opening persona line with a constant heading.+///+/// This drives the real `Agent::build_system_prompt`, which is the gap it exists+/// to close. The four tests #5821 shipped+/// (`turn::context::tool_policy_boundary_placement_tests`) exercise the+/// extracted pure helper `append_tool_policy_boundary` and would all still pass+/// if `build_system_prompt` stopped calling it; the one existing test that does+/// go through the builder,+/// `turn_tests_part_01_tests::system_prompt_includes_tool_policy_boundary`,+/// asserts the boundary is PRESENT and says nothing about where — it passes+/// unchanged under the old prepend.+#[test]+fn system_prompt_appends_the_tool_policy_boundary_after_the_body() {+ // A visible-name set narrower than the tool set is what gives the policy+ // session something to restrict, which is what makes the block render at+ // all. With no restrictions there is no boundary and nothing to place.+ // A tempdir workspace keeps the AGENTS.md layers `build_system_prompt`+ // loads out of the picture, so the prompt is a function of the builder+ // arguments and nothing on the developer's disk.+ let workspace = tempfile::tempdir().expect("temp workspace");+ let agent = Agent::builder()+ .tools(vec![tool("echo"), tool("write_notes")])+ .chat_model(ScriptedModel::new(vec![]))+ .memory(Arc::new(StubMemory))+ .tool_dispatcher(Box::new(NativeToolDispatcher))+ .visible_tool_names(HashSet::from(["echo".to_string()]))+ .config(AgentConfig::default())+ .workspace_dir(workspace.path().to_path_buf())+ .build()+ .expect("complete builder should succeed");++ let prompt = agent+ .build_system_prompt(LearnedContextData::default())+ .expect("system prompt builds");++ let boundary_at = prompt+ .find("## Tool Policy Boundary")+ .expect("a restricted tool set must render the boundary block");++ assert!(+ boundary_at > 0,+ "the boundary must not open the prompt — prepending it moves the first \+ diverging byte to offset 0 and defeats the backend's prefix cache \+ (#5704). Prompt begins: {:?}",+ prompt.chars().take(160).collect::<String>()+ );+ assert!(+ !prompt.starts_with("## Tool Policy Boundary"),+ "prepending replaced every agent's opening line with a constant heading"+ );++ // Position stated against something concrete rather than "not zero": the+ // boundary must come after the body the builder assembled, not merely after+ // some byte of it.+ let body_end = prompt[..boundary_at].trim_end();+ assert!(+ !body_end.is_empty(),+ "there must be prompt body BEFORE the boundary; got only: {prompt:?}"+ );+ assert!(+ prompt[boundary_at..].contains("Allowed tools: echo"),+ "the appended block must still carry the policy detail: {}",+ &prompt[boundary_at..]+ );+}++/// The placement's actual payoff, stated exactly: the boundary block is the+/// LAST thing in the prompt, so everything stable precedes it.+///+/// That is the property a prefix cache keys on — the varying bytes are at the+/// tail, not the head — and it is the one a revert to prepending destroys+/// outright: under prepend the block is the prompt's first line and the stable+/// body starts after it.+///+/// `render_tool_policy_boundary` (`tools/agent_policy/prompt.rs:8-47`) emits+/// `- Restricted tools: N omitted by policy` last whenever anything is+/// restricted, so asserting the prompt ENDS with that line pins the whole block+/// to the tail rather than merely somewhere after offset 0.+#[test]+fn the_tool_policy_boundary_is_the_last_block_in_the_prompt() {+ let workspace = tempfile::tempdir().expect("temp workspace");+ let agent = Agent::builder()+ .tools(vec![tool("echo"), tool("write_notes")])+ .chat_model(ScriptedModel::new(vec![]))+ .memory(Arc::new(StubMemory))+ .tool_dispatcher(Box::new(NativeToolDispatcher))+ .visible_tool_names(HashSet::from(["echo".to_string()]))+ .config(AgentConfig::default())+ .workspace_dir(workspace.path().to_path_buf())+ .build()+ .expect("complete builder should succeed");++ let prompt = agent+ .build_system_prompt(LearnedContextData::default())+ .expect("system prompt builds");++ assert!(+ prompt+ .trim_end()+ .ends_with("- Restricted tools: 1 omitted by policy"),+ "the boundary block must be the prompt's final block — prepending puts \+ it first and leaves the stable body trailing it (#5704). Prompt ends: {:?}",+ prompt+ .trim_end()+ .chars()+ .rev()+ .take(200)+ .collect::<Vec<_>>()+ .into_iter()+ .rev()+ .collect::<String>()+ );+}