Scale computer-use 2.0 with open-source drivers, cross-OS sandboxes, and benchmarks for training, evaluation, and data generation.
Rust agentai-agentapplecomputer-usecomputer-use-agentcontainerizationcuadesktop-automationhacktoberfestlumemacosmanusoperatorswiftvirtualizationvirtualization-frameworkwindowswindows-sandbox
fix(cua-driver): stabilize Hyprland agent input
Francesco Bonaccif6be60087b8d
diff --git a/docs/content/docs/reference/cua-driver/platform-support.mdx b/docs/content/docs/reference/cua-driver/platform-support.mdxindex 5db45c614d..54eaeb0de6 100644--- a/docs/content/docs/reference/cua-driver/platform-support.mdx+++ b/docs/content/docs/reference/cua-driver/platform-support.mdx@@ -115,17 +115,22 @@ The initial native application qualification scope is Calc fromexecutable against the expected package path and exact local package metadatabefore each action. Those checks establish eligibility for isolated input, notproof that every application operation works. The plugin requires a live native-surface and the exact compiled default `evdev`/`pc105`/`us` keymap. Variants,-options, remaps, multiple layout groups, Unicode, IME input, arbitrary held-key-streams, and modified pointer gestures are outside the qualified contract. Chromium,-Electron, and XWayland raw background input are also outside this scope.-Semantic AT-SPI actions retain their separate behavior.+surface. Its background seats use a private canonical `evdev`/`pc105`/`us`+keymap, so user options such as Caps Lock remapped to Ctrl or Super do not alter+agent key semantics. A physical keymap transition still cancels existing+authority; a fresh background action may proceed afterward. Multiple agent+layout groups, Unicode, IME input, arbitrary held-key streams, and modified+pointer gestures remain outside the qualified contract. Chromium, Electron,+and XWayland raw background input are also outside this scope. Semantic AT-SPI+actions retain their separate behavior.The explicitly requested foreground route binds an exact native top-levelsurface and intentionally changes primary focus and, for pointer actions,cursor position. It does not restore either. The canonical native harnesscovers defined GTK3, Electron, and Tauri foreground cases; background refusals-never select this route automatically.+never select this route automatically. Foreground pointer-only actions are+independent of the user's keyboard layout. Foreground keyboard actions remain+limited to the canonical physical US keymap and refuse safely under remaps.Bounded instrumented two-seat app proof and an uninstrumented smoke are retainedfrom source `f180e8828b8f31cc153e3c44eaa89a9c13c5bc68`, with an unchangeddiff --git a/libs/cua-driver/hyprland-plugin/packaging/release/USAGE.md b/libs/cua-driver/hyprland-plugin/packaging/release/USAGE.mdindex f7c6737c13..3d56d54661 100644--- a/libs/cua-driver/hyprland-plugin/packaging/release/USAGE.md+++ b/libs/cua-driver/hyprland-plugin/packaging/release/USAGE.md@@ -137,12 +137,16 @@ alone does not prove input availability. Start the matching Driver with`CUA_DRIVER_RS_ENABLE_WAYLAND=1`; its production input protocol is v3 by default.The input path checks exact native application packages: `libreoffice-fresh-26.2.5-3` for Calc and `inkscape 1.4.4-6`. It also requires the canonical-`evdev/pc105/us` keyboard map without variants, remaps, or additional groups.-There are two independent input lanes. A third concurrent owner receives a-lane-busy refusal. Other application versions, Chromium/Electron, and XWayland-are outside this input contract. Use normal Driver snapshots and background-actions, then verify the application result; a delivery acknowledgement is not+26.2.5-3` for Calc and `inkscape 1.4.4-6`. Each background input lane publishes+its own canonical `evdev/pc105/us` keymap, independent of user options such as+Caps Lock remapped to Ctrl or Super. Existing actions are canceled when the+physical keymap changes; start a fresh action after the reload. Foreground+keyboard delivery remains limited to the canonical physical map, while+foreground pointer-only actions are layout-independent. There are two+independent input lanes. A third concurrent owner receives a lane-busy refusal.+Other application versions, Chromium/Electron, and XWayland are outside this+input contract. Use normal Driver snapshots and background actions, then verify+the application result; a delivery acknowledgement is notproof that the intended edit occurred. Do not automatically replay partial orunknown actions. The release's native evidence identifies the qualifiedoperation cells within these limits.diff --git a/libs/cua-driver/hyprland-plugin/protocol/cua-input-v3.md b/libs/cua-driver/hyprland-plugin/protocol/cua-input-v3.mdindex 7c72cbc14a..f9cbfbf0d9 100644--- a/libs/cua-driver/hyprland-plugin/protocol/cua-input-v3.md+++ b/libs/cua-driver/hyprland-plugin/protocol/cua-input-v3.md@@ -64,10 +64,12 @@ The request sequence for every Driver-admitted action is:`TARGET` binds the exact live native top-level surface, generates a fresh token,and grants at most five seconds of steady-clock technical lifetime. It firstretires any unused previous grant. It refuses unavailable desktops, primary-focus on the target's Wayland client, another lane targeting that client, and-unsupported keymaps. A discovered address is an input to attestation, not a-surface lifetime token. Surface unmap, destruction, or replacement invalidates-the binding. Geometry changes increment the revision and refuse stale actions.+focus on the target's Wayland client, and another lane targeting that client.+Background seats always publish a private canonical `evdev`/`pc105`/`us`+keymap, so user layout options and remaps do not alter agent key semantics. A+discovered address is an input to attestation, not a surface lifetime token.+Surface unmap, destruction, or replacement invalidates the binding. Geometry+changes increment the revision and refuse stale actions.The complete operation requests are:@@ -126,6 +128,9 @@ their lanes before either selects a target, without retrying any input.Target replacement, unmap, destruction, geometry change, primary-clientconflict, and desktop/keymap/configuration transitions clear passive focus.+An observed physical keymap transition cancels existing authority, but fresh+background admission after that transition uses the unchanged private agent+keymap.The five-second action grant does not extend to passive focus. These boundariesmay still end focus before a stalled client processes its events; dispatchacknowledgement is not an application-processing fence. Verify the application's@@ -168,8 +173,10 @@ Before taking over primary input, the plugin must refuse held physical keys orbuttons, active grabs, pointer constraints, and drag-and-drop. It requires asingle primary seat binding, excluding its own agent seats by resource identity,and refuses binding or input-resource changes during dispatch. Keyboard delivery-requires neutral primary modifiers and layout group zero; latched or locked-modifiers refuse before activation. Foreground drag+requires the physical keymap to match canonical `evdev`/`pc105`/`us`, with+neutral primary modifiers and layout group zero; remaps, latched or locked+modifiers refuse before activation. Foreground pointer-only actions do not+depend on the physical keyboard layout. Foreground dragcancellation on primary-input and focus transitions remains subject to reviewand native verification; do not infer background isolation from this route.Foreground results use foreground delivery metadata. A drag cancellation afterdiff --git a/libs/cua-driver/hyprland-plugin/src/foreground_route.hpp b/libs/cua-driver/hyprland-plugin/src/foreground_route.hppindex 0b675d335e..c499a05afe 100644--- a/libs/cua-driver/hyprland-plugin/src/foreground_route.hpp+++ b/libs/cua-driver/hyprland-plugin/src/foreground_route.hpp@@ -9,6 +9,16 @@namespace cua::hyprland {enum class InputRoute { unbound, independent, primary_foreground };+struct AgentKeymapConfig {+ std::string_view rules;+ std::string_view model;+ std::string_view layout;+ std::string_view variant;+ std::string_view options;+};++inline constexpr AgentKeymapConfig kAgentKeymap{"evdev", "pc105", "us", "", ""};+enum class ForegroundFailureReason {none, exact_root, primary_binding, peer_conflict, physical_keys, physical_buttons,grab, dnd, constraint, keyboard_focus, pointer_focus, lease, client_dead,@@ -101,6 +111,10 @@ inline bool bind_input_route(InputRoute& bound, InputRoute requested) {return true;}+inline bool input_layout_qualified(InputRoute route, bool keyboard_action, bool primary_layout_qualified) {+ return route != InputRoute::primary_foreground || !keyboard_action || primary_layout_qualified;+}+struct ForegroundGuard {bool exact_root = false;bool primary_binding = true;diff --git a/libs/cua-driver/hyprland-plugin/src/input_experiment.cpp b/libs/cua-driver/hyprland-plugin/src/input_experiment.cppindex fc7e740bb3..bdd1437b7d 100644--- a/libs/cua-driver/hyprland-plugin/src/input_experiment.cpp+++ b/libs/cua-driver/hyprland-plugin/src/input_experiment.cpp@@ -31,6 +31,7 @@#include <openssl/evp.h>#endif#include <sys/random.h>+#include <sys/mman.h>#include <xkbcommon/xkbcommon.h>#include <algorithm>@@ -190,7 +191,7 @@ struct InputExperiment::Impl {wl_global* global = nullptr;OwnedSocketPath socket_path;std::string_view socket_cleanup = "not_bound";- std::string path, epoch = nonce(), keymap_text;+ std::string path, epoch = nonce(), keymap_text, physical_keymap_text;std::vector<unsigned char> public_key;std::vector<std::unique_ptr<Client>> clients;std::vector<std::unique_ptr<Seat>> seats;@@ -213,6 +214,9 @@ struct InputExperiment::Impl {xkb_context* xkb_context_ = nullptr;xkb_keymap* keymap = nullptr;xkb_state* keyboard_state = nullptr;+ xkb_context* physical_xkb_context = nullptr;+ xkb_keymap* physical_keymap = nullptr;+ xkb_state* physical_keyboard_state = nullptr;int keymap_fd = -1;bool retired = false, suspended = true, us_keymap = false, physical_keymap_present = false;WP<IKeyboard> physical_keyboard;@@ -222,6 +226,7 @@ struct InputExperiment::Impl {PrimaryTrace* trace = nullptr;bool foreground_started = false, foreground_activating = false;bool foreground_keyboard_used = false;+ bool foreground_needs_keyboard = false;bool foreground_needs_pointer = false;WP<CWLSurfaceResource> foreground_surface;WP<CWLSeatResource> foreground_seat;@@ -246,7 +251,8 @@ struct InputExperiment::Impl {static bool canonical_us_keymap(xkb_context* context, xkb_keymap* map) {// Compare canonical compiled content, not a layout display name. This// deliberately excludes variants, options, remaps, and multiple groups.- const xkb_rule_names names{"evdev", "pc105", "us", "", ""};+ const xkb_rule_names names{kAgentKeymap.rules.data(), kAgentKeymap.model.data(),+ kAgentKeymap.layout.data(), kAgentKeymap.variant.data(), kAgentKeymap.options.data()};auto* reference = xkb_keymap_new_from_names(context, &names, XKB_KEYMAP_COMPILE_NO_FLAGS);if (!reference) return false;char* actual = xkb_keymap_get_as_string(map, XKB_KEYMAP_FORMAT_TEXT_V1);@@ -255,13 +261,63 @@ struct InputExperiment::Impl {std::free(actual); std::free(expected); xkb_keymap_unref(reference);return matches;}+ static int create_keymap_file(std::string_view text) {+ const auto fd = memfd_create("cua-agent-keymap", MFD_CLOEXEC);+ std::string payload(text);+ payload.push_back('\0');+ if (fd < 0 || ftruncate(fd, static_cast<off_t>(payload.size())) != 0) {+ if (fd >= 0) close(fd);+ throw std::runtime_error("agent keymap file unavailable");+ }+ std::size_t offset = 0;+ while (offset < payload.size()) {+ const auto written = pwrite(fd, payload.data() + offset, payload.size() - offset, static_cast<off_t>(offset));+ if (written < 0 && errno == EINTR) continue;+ if (written <= 0) { close(fd); throw std::runtime_error("agent keymap write failed"); }+ offset += static_cast<std::size_t>(written);+ }+ return fd;+ }+ void initialize_agent_keymap() {+ if (keyboard_state) return;+ const xkb_rule_names names{kAgentKeymap.rules.data(), kAgentKeymap.model.data(),+ kAgentKeymap.layout.data(), kAgentKeymap.variant.data(), kAgentKeymap.options.data()};+ auto* context = xkb_context_new(XKB_CONTEXT_NO_FLAGS);+ auto* map = context ? xkb_keymap_new_from_names(context, &names, XKB_KEYMAP_COMPILE_NO_FLAGS) : nullptr;+ auto* state = map ? xkb_state_new(map) : nullptr;+ char* serialized = map ? xkb_keymap_get_as_string(map, XKB_KEYMAP_FORMAT_TEXT_V1) : nullptr;+ if (!state || !serialized) {+ std::free(serialized);+ if (state) xkb_state_unref(state);+ if (map) xkb_keymap_unref(map);+ if (context) xkb_context_unref(context);+ throw std::runtime_error("agent US keymap unavailable");+ }+ std::string text(serialized);+ std::free(serialized);+ int fd = -1;+ try {+ fd = create_keymap_file(text);+ } catch (...) {+ xkb_state_unref(state);+ xkb_keymap_unref(map);+ xkb_context_unref(context);+ throw;+ }+ xkb_context_ = context;+ keymap = map;+ keyboard_state = state;+ keymap_text = std::move(text);+ keymap_fd = fd;+ }bool layout_qualified() const {if (!kProduction) return true;const auto keyboard = g_pSeatManager->m_keyboard.lock();- return physical_keymap_present && us_keymap && keyboard_state && keyboard &&- keyboard->m_xkbKeymapV1FD.get() >= 0 && keyboard->m_xkbKeymapV1String == keymap_text;+ return physical_keymap_present && us_keymap && physical_keyboard_state && keyboard &&+ keyboard->m_xkbKeymapV1FD.get() >= 0 && keyboard->m_xkbKeymapV1String == physical_keymap_text;}void sync_keymap() {+ initialize_agent_keymap();const auto keyboard = g_pSeatManager->m_keyboard.lock();if (physical_keyboard != keyboard) {if (physical_keymap_present) desktop_transition();@@ -278,36 +334,26 @@ struct InputExperiment::Impl {return;}physical_keymap_present = true;- if (keyboard_state && keymap_text == keyboard->m_xkbKeymapV1String) return;- // Prepare a complete replacement before retiring the old independent- // state. Keep our own fd: primary keyboard replacement must not leave- // later seat bindings referring to a closed compositor fd.+ if (physical_keyboard_state && physical_keymap_text == keyboard->m_xkbKeymapV1String) return;+ // Foreground keyboard delivery uses the primary seat. Keep a separate+ // compiled state for it; the background seats retain their fixed US map.auto* context = xkb_context_new(XKB_CONTEXT_NO_FLAGS);auto* map = context ? xkb_keymap_new_from_string(context, keyboard->m_xkbKeymapV1String.c_str(),XKB_KEYMAP_FORMAT_TEXT_V1, XKB_KEYMAP_COMPILE_NO_FLAGS) : nullptr;auto* state = map ? xkb_state_new(map) : nullptr;- const auto fd = fcntl(keyboard->m_xkbKeymapV1FD.get(), F_DUPFD_CLOEXEC, 0);- if (!state || fd < 0) {- if (fd >= 0) close(fd);+ if (!state) {if (state) xkb_state_unref(state);if (map) xkb_keymap_unref(map);if (context) xkb_context_unref(context);- throw std::runtime_error("independent XKB state unavailable");+ throw std::runtime_error("primary XKB state unavailable");}desktop_transition();- if (keyboard_state) xkb_state_unref(keyboard_state);- if (keymap) xkb_keymap_unref(keymap);- if (xkb_context_) xkb_context_unref(xkb_context_);- if (keymap_fd >= 0) close(keymap_fd);- keyboard_state = state; keymap = map; xkb_context_ = context; keymap_fd = fd;+ if (physical_keyboard_state) xkb_state_unref(physical_keyboard_state);+ if (physical_keymap) xkb_keymap_unref(physical_keymap);+ if (physical_xkb_context) xkb_context_unref(physical_xkb_context);+ physical_keyboard_state = state; physical_keymap = map; physical_xkb_context = context;us_keymap = !kProduction || canonical_us_keymap(context, map);- keymap_text = keyboard->m_xkbKeymapV1String;- for (auto& k : keyboards)- if (!k->dead && k->wl->resource())- k->wl->sendKeymap(WL_KEYBOARD_KEYMAP_FORMAT_XKB_V1, keymap_fd, keymap_text.size() + 1);- for (auto& seat : seats)- if (!seat->dead && seat->wl->resource())- seat->wl->sendCapabilities(static_cast<wl_seat_capability>(WL_SEAT_CAPABILITY_POINTER | WL_SEAT_CAPABILITY_KEYBOARD));+ physical_keymap_text = keyboard->m_xkbKeymapV1String;}void start() {sync_keymap();@@ -390,6 +436,9 @@ struct InputExperiment::Impl {if (keyboard_state) xkb_state_unref(keyboard_state);if (keymap) xkb_keymap_unref(keymap);if (xkb_context_) xkb_context_unref(xkb_context_);+ if (physical_keyboard_state) xkb_state_unref(physical_keyboard_state);+ if (physical_keymap) xkb_keymap_unref(physical_keymap);+ if (physical_xkb_context) xkb_context_unref(physical_xkb_context);if (keymap_fd >= 0) close(keymap_fd);}std::uint32_t serial() const { return wl_display_next_serial(g_pCompositor->m_wlDisplay); }@@ -573,6 +622,8 @@ struct InputExperiment::Impl {held_keys.clear();if (keyboard_state) xkb_state_unref(keyboard_state);keyboard_state = keymap ? xkb_state_new(keymap) : nullptr;+ if (physical_keyboard_state) xkb_state_unref(physical_keyboard_state);+ physical_keyboard_state = physical_keymap ? xkb_state_new(physical_keymap) : nullptr;}void retire_grant() {lease = nullptr; capabilities = 0; grant.reset(); expires = {};@@ -786,7 +837,8 @@ struct InputExperiment::Impl {if (lease != &c) throw ForegroundFailure{ForegroundFailureReason::lease};if (c.dead) throw ForegroundFailure{ForegroundFailureReason::client_dead};if (!available()) throw ForegroundFailure{ForegroundFailureReason::session_unavailable};- if (!layout_qualified()) throw ForegroundFailure{ForegroundFailureReason::unsupported_layout};+ if (!input_layout_qualified(c.route, foreground_needs_keyboard, layout_qualified()))+ throw ForegroundFailure{ForegroundFailureReason::unsupported_layout};if (Clock::now() >= expires) throw ForegroundFailure{ForegroundFailureReason::lease_expired};const auto failure = foreground_guard(c).dispatch_failure(foreground_needs_pointer);if (failure != ForegroundFailureReason::none) throw ForegroundFailure{failure};@@ -813,14 +865,15 @@ struct InputExperiment::Impl {foreground_pointers.clear(); foreground_keyboards.clear(); foreground_surface.reset(); foreground_seat.reset();foreground_started = false;foreground_keyboard_used = false;+ foreground_needs_keyboard = false;}void start_foreground(Client& c, double x, double y, bool needs_pointer, bool needs_keyboard) {const auto root = c.surface.lock();const auto physical = g_pSeatManager->m_keyboard.lock();const auto failure = foreground_guard(c).activation_failure();if (failure != ForegroundFailureReason::none) throw ForegroundFailure{failure};- if (!physical) throw ForegroundFailure{ForegroundFailureReason::physical_keyboard};- if (!keyboard_state) throw ForegroundFailure{ForegroundFailureReason::keyboard_state};+ if (needs_keyboard && !physical) throw ForegroundFailure{ForegroundFailureReason::physical_keyboard};+ if (needs_keyboard && !physical_keyboard_state) throw ForegroundFailure{ForegroundFailureReason::keyboard_state};if (needs_pointer && !g_pSeatManager->m_mouse) throw ForegroundFailure{ForegroundFailureReason::physical_pointer};const Vector2D local{x + c.geometry[0] - c.geometry[4], y + c.geometry[1] - c.geometry[5]};if (needs_pointer && (!point(c, x, y) || root->at(local, true).first != root)) throw ForegroundFailure{ForegroundFailureReason::pointer_target};@@ -830,23 +883,28 @@ struct InputExperiment::Impl {for (const auto& p : seat->m_pointers) if (p && p->good()) foreground_pointers.push_back(p);for (const auto& k : seat->m_keyboards) if (k && k->good()) foreground_keyboards.push_back(k);if (needs_pointer && foreground_pointers.empty()) throw ForegroundFailure{ForegroundFailureReason::pointer_resources};- if (foreground_keyboards.empty()) throw ForegroundFailure{ForegroundFailureReason::keyboard_resources};- foreground_modifiers = {physical->m_modifiersState.depressed, physical->m_modifiersState.latched,- physical->m_modifiersState.locked, physical->m_modifiersState.group};- for (const auto& kb : g_pInputManager->m_keyboards) {- if (!kb->m_enabled || !kb->shareStates() || (kb->isVirtual() && g_pInputManager->shouldIgnoreVirtualKeyboard(kb))) continue;- foreground_modifiers[0] |= kb->m_modifiersState.depressed;- foreground_modifiers[1] |= kb->m_modifiersState.latched;- foreground_modifiers[2] |= kb->m_modifiersState.locked;- }+ if (needs_keyboard && foreground_keyboards.empty())+ throw ForegroundFailure{ForegroundFailureReason::keyboard_resources};+ foreground_modifiers = {};if (needs_keyboard) {+ foreground_modifiers = {physical->m_modifiersState.depressed, physical->m_modifiersState.latched,+ physical->m_modifiersState.locked, physical->m_modifiersState.group};+ for (const auto& kb : g_pInputManager->m_keyboards) {+ if (!kb->m_enabled || !kb->shareStates() ||+ (kb->isVirtual() && g_pInputManager->shouldIgnoreVirtualKeyboard(kb))) continue;+ foreground_modifiers[0] |= kb->m_modifiersState.depressed;+ foreground_modifiers[1] |= kb->m_modifiersState.latched;+ foreground_modifiers[2] |= kb->m_modifiersState.locked;+ }const auto modifier_failure = foreground_key_modifier_failure(foreground_modifiers);if (modifier_failure != ForegroundFailureReason::none) throw ForegroundFailure{modifier_failure};+ xkb_state_update_mask(physical_keyboard_state, foreground_modifiers[0], foreground_modifiers[1],+ foreground_modifiers[2], 0, 0, foreground_modifiers[3]);}- xkb_state_update_mask(keyboard_state, foreground_modifiers[0], foreground_modifiers[1], foreground_modifiers[2], 0, 0, foreground_modifiers[3]);foreground_surface = root;foreground_seat = seat;foreground_needs_pointer = needs_pointer;+ foreground_needs_keyboard = needs_keyboard;c.foreground_attempted = true;foreground_started = true;foreground_activating = true;@@ -894,15 +952,15 @@ struct InputExperiment::Impl {void foreground_key(Client& c, std::uint32_t code, bool pressed) {require_foreground(c);foreground_keyboard_used = true;- xkb_state_update_key(keyboard_state, code + 8, pressed ? XKB_KEY_DOWN : XKB_KEY_UP);+ xkb_state_update_key(physical_keyboard_state, code + 8, pressed ? XKB_KEY_DOWN : XKB_KEY_UP);if (pressed) held_keys.push_back(code); else std::erase(held_keys, code);for (const auto& weak : foreground_keyboards) {const auto k = weak.lock(); if (!k || !k->good()) throw ForegroundFailure{ForegroundFailureReason::keyboard_resources};k->sendKey(event_ms(), code, pressed ? WL_KEYBOARD_KEY_STATE_PRESSED : WL_KEYBOARD_KEY_STATE_RELEASED);- k->sendMods(xkb_state_serialize_mods(keyboard_state, XKB_STATE_MODS_DEPRESSED),- xkb_state_serialize_mods(keyboard_state, XKB_STATE_MODS_LATCHED),- xkb_state_serialize_mods(keyboard_state, XKB_STATE_MODS_LOCKED),- xkb_state_serialize_layout(keyboard_state, XKB_STATE_LAYOUT_EFFECTIVE));+ k->sendMods(xkb_state_serialize_mods(physical_keyboard_state, XKB_STATE_MODS_DEPRESSED),+ xkb_state_serialize_mods(physical_keyboard_state, XKB_STATE_MODS_LATCHED),+ xkb_state_serialize_mods(physical_keyboard_state, XKB_STATE_MODS_LOCKED),+ xkb_state_serialize_layout(physical_keyboard_state, XKB_STATE_LAYOUT_EFFECTIVE));}}bool pointer_enter(Client& c, double x, double y) {@@ -942,8 +1000,8 @@ struct InputExperiment::Impl {held_button = pressed ? value : 0;}bool keyboard_enter(Client& c) {- const auto root = c.surface.lock(); const auto physical = g_pSeatManager->m_keyboard.lock();- if (!root || !physical || physical->m_xkbKeymapV1String != keymap_text || !keyboard_state) return false;+ const auto root = c.surface.lock();+ if (!root || !keyboard_state) return false;unsigned count = 0;for (auto& k : keyboards) {if (k->dead || !k->wl->resource() || k->wl->client() != root->client()) continue;@@ -1030,7 +1088,7 @@ struct InputExperiment::Impl {if (kProduction && (!InputGrant::single_operation(requested_cap) ||(requested_cap == 16 && route != InputRoute::primary_foreground))) { invalidate(c); send(c, refusal("unsupported")); return; }if (kProduction && !available()) { invalidate(c, false); send(c, refusal("session_unavailable")); return; }- if (!layout_qualified()) { invalidate(c, false); send(c, refusal("unsupported_layout")); return; }+ if (!input_layout_qualified(route, requested_cap == 2, layout_qualified())) { invalidate(c, false); send(c, refusal("unsupported_layout")); return; }const auto pid = number(f[1]); const auto address = number(f[2], 16);PHLWINDOW window;for (const auto& w : Desktop::windowState()->windows())@@ -1090,7 +1148,7 @@ struct InputExperiment::Impl {if (c.token.empty() || f[2] != c.token || !refresh(c)) { send(c, refusal("stale_target")); return; }if (number(f[3]) != c.revision) { if (kProduction) revoke("stale_geometry"); send(c, refusal("stale_geometry")); return; }if (!available()) { revoke("session_unavailable", true); send(c, refusal("session_unavailable")); return; }- if (!layout_qualified()) { revoke("unsupported_layout", true); send(c, refusal("unsupported_layout")); return; }+ if (!input_layout_qualified(c.route, cap == 2, layout_qualified())) { revoke("unsupported_layout", true); send(c, refusal("unsupported_layout")); return; }if (lease && Clock::now() >= expires) revoke("lease_expired");if (drag) { send(c, refusal("lease_busy")); return; }if (lease != &c || !(capabilities & cap) || (kProduction && !grant.permits(cap, Clock::now()))) {@@ -1225,9 +1283,11 @@ struct InputExperiment::Impl {}void guard_targets() {if (lease) {+ const bool keyboard_action = (capabilities & 2) != 0 || foreground_needs_keyboard;if (lease->dead) revoke("disconnected", true);else if (Clock::now() >= expires) revoke("lease_expired");- else if (!available() || !layout_qualified()) revoke("cancelled", true);+ else if (!available() || !input_layout_qualified(lease->route, keyboard_action, layout_qualified()))+ revoke("cancelled", true);else if (!refresh(*lease) || primary_conflict(*lease) || agent_conflict(*lease) ||(drag && !drag->geometry.matches(lease->revision))) revoke("cancelled");}diff --git a/libs/cua-driver/hyprland-plugin/tests/desktop_fault_policy_fixture.cpp b/libs/cua-driver/hyprland-plugin/tests/desktop_fault_policy_fixture.cppindex 45c48efa69..7e613140ad 100644--- a/libs/cua-driver/hyprland-plugin/tests/desktop_fault_policy_fixture.cpp+++ b/libs/cua-driver/hyprland-plugin/tests/desktop_fault_policy_fixture.cpp@@ -1,6 +1,7 @@// Used by desktop_fault_policy_test.py, which inserts actual production bodies.// Transport effects are counted here; native protocol/app behavior is separate.#include "drag_geometry.hpp"+#include "foreground_route.hpp"#include "input_grant.hpp"#include "passive_pointer_target.hpp"@@ -25,6 +26,7 @@ struct Client {std::weak_ptr<Window> window;std::weak_ptr<Surface> surface;uint64_t approved_deadline = 42, revision = 1;+ InputRoute route = InputRoute::independent;};struct Pointer {bool dead = false, resource_live = true;@@ -34,8 +36,6 @@ struct Pointer {};struct Drag { Client* client; DragGeometry geometry{1}; };struct Trace { void mark(const char*, unsigned) {} };-enum class ForegroundFailureReason { none };-struct ForegroundFailure { ForegroundFailureReason reason; };void wl_event_source_remove(void*) {}int close(int) { return 0; }std::string refusal(std::string_view reason) { return std::string(reason); }@@ -48,7 +48,7 @@ struct Lane {static constexpr bool kProduction = true;bool suspended = false, session = true, layout = true, target_live = true;bool primary_busy = false, peer_busy = false, refresh_ok = true;- bool foreground_started = false, keyboard_focus = true;+ bool foreground_started = false, foreground_needs_keyboard = false, keyboard_focus = true;unsigned lane = 0, held_button = 272, releases = 0, leaves = 0;uint64_t capabilities = 8, desktop_generation = 1;Trace* trace = nullptr;@@ -97,6 +97,13 @@ struct Lane {}void leave_keyboard() { held_keys.clear(); keyboard_focus = false; }void cleanup_socket() {}+ void make_layout_sensitive() {+ lease->route = InputRoute::primary_foreground;+ capabilities = 2;+ foreground_needs_keyboard = true;+ grant.arm(2, Clock::now());+ expires = grant.deadline();+ }// PRODUCTION_METHODSvoid check_inert(bool retained = true) const {check(!lease && !drag && !held_button && held_keys.empty() && !keyboard_focus &&@@ -122,7 +129,7 @@ int main() {for (bool session_fault : {true, false}) {for (int path = 0; path < 3; ++path) {Lane l;- if (session_fault) l.session = false; else l.layout = false;+ if (session_fault) l.session = false; else { l.layout = false; l.make_layout_sensitive(); }if (path == 0) l.guard_targets();if (path == 1) l.target_refusal(*l.lease);if (path == 2) l.action_refusal(*l.lease);diff --git a/libs/cua-driver/hyprland-plugin/tests/desktop_fault_policy_test.py b/libs/cua-driver/hyprland-plugin/tests/desktop_fault_policy_test.pyindex 68ca6c882b..abb52972de 100644--- a/libs/cua-driver/hyprland-plugin/tests/desktop_fault_policy_test.py+++ b/libs/cua-driver/hyprland-plugin/tests/desktop_fault_policy_test.py@@ -35,10 +35,12 @@ def fixture(source):):block = source.split(start, 1)[1].split(end, 1)[0]refusals = [line.strip() for line in block.splitlines()- if 'if (' in line and ('!available()' in line or '!layout_qualified()' in line)]+ if 'if (' in line and ('!available()' in line or '!input_layout_qualified(' in line)]if len(refusals) != 2:raise AssertionError(f'production refusal branches not found: {label}')- methods += '\nvoid ' + label + '(Client& c) {\n' + '\n'.join(refusals) + '\n}'+ setup = ('const auto requested_cap = capabilities; const auto route = c.route;\n'+ if label == 'target_refusal' else 'const auto cap = capabilities;\n')+ methods += '\nvoid ' + label + '(Client& c) {\n' + setup + '\n'.join(refusals) + '\n}'return (ROOT / 'tests/desktop_fault_policy_fixture.cpp').read_text().replace('// PRODUCTION_METHODS', methods)diff --git a/libs/cua-driver/hyprland-plugin/tests/foreground_route_test.cpp b/libs/cua-driver/hyprland-plugin/tests/foreground_route_test.cppindex bdac3d3740..d3351362d9 100644--- a/libs/cua-driver/hyprland-plugin/tests/foreground_route_test.cpp+++ b/libs/cua-driver/hyprland-plugin/tests/foreground_route_test.cpp@@ -117,6 +117,21 @@ int main() {route = InputRoute::independent;check(!bind_input_route(route, InputRoute::primary_foreground));+ // Background input uses the agent seat's private keymap. The primary+ // layout matters only for foreground keyboard delivery.+ for (const bool primary_layout : {false, true}) {+ check(input_layout_qualified(InputRoute::independent, false, primary_layout));+ check(input_layout_qualified(InputRoute::independent, true, primary_layout));+ check(input_layout_qualified(InputRoute::primary_foreground, false, primary_layout));+ }+ check(!input_layout_qualified(InputRoute::primary_foreground, true, false));+ check(input_layout_qualified(InputRoute::primary_foreground, true, true));+ check(kAgentKeymap.rules == "evdev");+ check(kAgentKeymap.model == "pc105");+ check(kAgentKeymap.layout == "us");+ check(kAgentKeymap.variant.empty());+ check(kAgentKeymap.options.empty());+ForegroundGuard guard{.exact_root = true};check(guard.can_activate());check(!guard.can_dispatch());diff --git a/libs/cua-driver/hyprland-plugin/tests/production_desktop_fault_proof.py b/libs/cua-driver/hyprland-plugin/tests/production_desktop_fault_proof.pyindex 206e4631c5..b591ab8760 100644--- a/libs/cua-driver/hyprland-plugin/tests/production_desktop_fault_proof.py+++ b/libs/cua-driver/hyprland-plugin/tests/production_desktop_fault_proof.py@@ -18,12 +18,13 @@ Config suspension disconnects the trace transport. Restore the fixture, reconnecwithout TRACE_START, and require unchanged trace history with cancellation andowned release BEFORE restoration. Normal Driver snapshots and one NEW actionthen prove recovery. No replay, signing, module swap, automatic wake or unlock.-Keymap uses the separate exact KEYMAP_US include, changes only to KEYMAP_DE,-and restores the same original US map. Exact option readback, compositor lane-generation changes and the compiled-map-gated unsupported_layout refusal from-a fresh normal Driver action prove invalidation; no keymap hash is exposed.-The keymap fixture has a fixed 30-second restoration watchdog to cover the-fresh-runtime refusal and both app snapshots; config-disable keeps 12 seconds.+Keymap uses the separate exact KEYMAP_US include, changes only the physical+layout, and restores the same original US map. Exact option readback and+compositor lane generation changes prove invalidation. Fresh background input+under a user remap is covered separately because the agent seats now keep a+private canonical US map; this fault harness still proves cancellation and+restoration of work active during the physical transition. The keymap fixture+has a fixed 30-second restoration watchdog; config-disable keeps 12 seconds.Watchdog restoration, stale grounding, or readback crossing either deadlinestill fails the episode. Neither duration is a product cancellation limit.DPMS and lock are deliberately unsupported here. Portable tests prepare@@ -64,26 +65,28 @@ import production_pointer_grounding as pointer_groundingKEYMAP_US = 'hl.config({input = {kb_rules = "evdev", kb_model = "pc105", kb_layout = "us", kb_variant = "", kb_options = "", kb_file = ""}})\n'-KEYMAP_DE = 'hl.config({input = {kb_rules = "evdev", kb_model = "pc105", kb_layout = "de", kb_variant = "", kb_options = "", kb_file = ""}})\n'+KEYMAP_CAPS_CTRL = 'hl.config({input = {kb_rules = "evdev", kb_model = "pc105", kb_layout = "us", kb_variant = "", kb_options = "ctrl:nocaps", kb_file = ""}})\n'+KEYMAP_CAPS_SUPER = 'hl.config({input = {kb_rules = "evdev", kb_model = "pc105", kb_layout = "us", kb_variant = "", kb_options = "caps:super", kb_file = ""}})\n'+KEYMAP_REMAPS = {'caps_to_ctrl': KEYMAP_CAPS_CTRL, 'caps_to_super': KEYMAP_CAPS_SUPER}WATCHDOG_SECONDS = {'config_disable': 12, 'keymap': 30}def fixed_bytes(kind):assert kind in ('config_disable', 'keymap'), 'unsupported desktop fault'- return (ENABLED, DISABLED) if kind == 'config_disable' else (KEYMAP_US, KEYMAP_DE)+ return (ENABLED, DISABLED) if kind == 'config_disable' else (KEYMAP_US, KEYMAP_CAPS_CTRL)def keymap_options(instance, restored):- expected = {'kb_rules': 'evdev', 'kb_model': 'pc105', 'kb_layout': 'us' if restored else 'de',- 'kb_variant': '', 'kb_options': '', 'kb_file': ''}+ expected = {'kb_rules': 'evdev', 'kb_model': 'pc105', 'kb_layout': 'us',+ 'kb_variant': '', 'kb_options': '' if restored else 'ctrl:nocaps', 'kb_file': ''}replies = {key: json.loads(_hypr(instance, '-j', 'getoption', 'input:' + key)) for key in expected}verify_keymap_options(replies, restored)return repliesdef verify_keymap_options(replies, restored):- expected = {'kb_rules': 'evdev', 'kb_model': 'pc105', 'kb_layout': 'us' if restored else 'de',- 'kb_variant': '', 'kb_options': '', 'kb_file': ''}+ expected = {'kb_rules': 'evdev', 'kb_model': 'pc105', 'kb_layout': 'us',+ 'kb_variant': '', 'kb_options': '' if restored else 'ctrl:nocaps', 'kb_file': ''}assert set(replies) == set(expected), 'incomplete keymap option readback'for key, value in expected.items():assert replies[key].get('option') == 'input:' + key and replies[key].get('str') == value, \@@ -708,21 +711,26 @@ def verify_fault(boundary, record, restoration, action):verify_keymap_options(restoration['keymap_options'], True)assert record['keymap_before'] == restoration['keymap_options'], 'original map options not restored'verify_keymap_transition(record['gate_status'], record['after'], policy, record['lane'])- refusal = record['wrong_layout']- assert pointer_cleanup(refusal) == policy, 'refusal changed pointer cleanup contract'- if policy == 'retained_inert':- assert refusal['lane'] == record['lane'] and refusal['target'] == record['target'] and refusal['bounds'] == record['bounds']- verify_retained_inert(record['after'], refusal['before'], record['lane'])- assert refusal['closure']['observed_ns'] < restoration['started_ns'], 'probe not closed before restoration'- verify_layout_refusal(refusal)- after, before_refusal = keymap_lanes(record['after']), keymap_lanes(refusal['before'])- for lane in after:- assert all(after[lane][key] == before_refusal[lane][key] for key in ('epoch', 'desktop_generation', 'dispatches')), \- 'keymap state changed before fresh refusal'- trace_interval(record['prefix'], refusal['trace_before'])- trace_interval(refusal['trace_after'], boundary)- assert record['acknowledged_ns'] <= refusal['prepared_ns'] <= refusal['observed_ns'] < restoration['started_ns']- verify_keymap_transition(refusal['after'], restoration['status'], policy, record['lane'])+ # Preserve validation of archived pre-private-keymap evidence without+ # requiring or producing a fresh unsupported-layout probe today.+ if 'wrong_layout' in record:+ refusal = record['wrong_layout']+ assert pointer_cleanup(refusal) == policy, 'refusal changed pointer cleanup contract'+ if policy == 'retained_inert':+ assert refusal['lane'] == record['lane'] and refusal['target'] == record['target'] and refusal['bounds'] == record['bounds']+ verify_retained_inert(record['after'], refusal['before'], record['lane'])+ assert refusal['closure']['observed_ns'] < restoration['started_ns'], 'probe not closed before restoration'+ verify_layout_refusal(refusal)+ after, before_refusal = keymap_lanes(record['after']), keymap_lanes(refusal['before'])+ for lane in after:+ assert all(after[lane][key] == before_refusal[lane][key] for key in ('epoch', 'desktop_generation', 'dispatches')), \+ 'keymap state changed before fresh refusal'+ trace_interval(record['prefix'], refusal['trace_before'])+ trace_interval(refusal['trace_after'], boundary)+ assert record['acknowledged_ns'] <= refusal['prepared_ns'] <= refusal['observed_ns'] < restoration['started_ns']+ verify_keymap_transition(refusal['after'], restoration['status'], policy, record['lane'])+ else:+ verify_keymap_transition(record['after'], restoration['status'], policy, record['lane'])if policy == 'retained_inert':gate = keymap_lanes(record['gate_status'])initial = idle_lanes(record['before'])@@ -745,8 +753,8 @@ def verify_fault(boundary, record, restoration, action):isolation = verify_cancelled(boundary, record, restoration['started_ns'])result = {'result': 'verified', 'outcome': fault_outcome(action), 'continuous_isolation': isolation,'synthetic_cleanup': 'verified', 'saved_document_effect': 'unproven'}- if record['kind'] == 'keymap':- result['wrong_layout'] = verify_layout_refusal(record['wrong_layout'])+ if record['kind'] == 'keymap' and 'wrong_layout' in record:+ result['legacy_wrong_layout'] = verify_layout_refusal(record['wrong_layout'])if policy == 'retained_inert':result['pointer_cleanup'] = {'policy': policy, 'presence_continuity': 'verified','grounded_target_identity': 'verified', 'wayland_surface_identity': 'not_exposed'}@@ -826,12 +834,6 @@ def run(args):save('keymap-cancelled-prefix.json', cancelled)verify_cancelled(cancelled, fault.record, time.monotonic_ns())close_owned(clients[0])- clients.append(launch('wrong-layout'))- fault.record['wrong_layout'] = refuse_new_action(- clients[-1], observer, clients[0], spec, plan['recovery']['pointer_stage'],- trace, fault.config, guard, save)- close_owned(clients[-1])- save('fault.json', fault.record)restoration = fault.restore()save('restoration.json', restoration)trace.close()diff --git a/libs/cua-driver/hyprland-plugin/tests/production_desktop_fault_proof_test.py b/libs/cua-driver/hyprland-plugin/tests/production_desktop_fault_proof_test.pyindex 7b96627c8e..ff69ffbc7c 100644--- a/libs/cua-driver/hyprland-plugin/tests/production_desktop_fault_proof_test.py+++ b/libs/cua-driver/hyprland-plugin/tests/production_desktop_fault_proof_test.py@@ -49,8 +49,8 @@ def restoration():def options(restored=True):- values = {'kb_rules': 'evdev', 'kb_model': 'pc105', 'kb_layout': 'us' if restored else 'de',- 'kb_variant': '', 'kb_options': '', 'kb_file': ''}+ values = {'kb_rules': 'evdev', 'kb_model': 'pc105', 'kb_layout': 'us',+ 'kb_variant': '', 'kb_options': '' if restored else 'ctrl:nocaps', 'kb_file': ''}return {key: {'option': 'input:' + key, 'str': value, 'set': True} for key, value in values.items()}@@ -73,7 +73,7 @@ def layout_refusal():def keymap_record():- return {**record(), 'kind': 'keymap', 'config': {'sha256': proof.digest(proof.KEYMAP_DE.encode())},+ return {**record(), 'kind': 'keymap', 'config': {'sha256': proof.digest(proof.KEYMAP_CAPS_CTRL.encode())},'before': keymap_status(1), 'gate_status': keymap_status(1), 'after': keymap_status(2),'keymap_before': options(), 'keymap_after': options(False), 'wrong_layout': layout_refusal()}@@ -483,6 +483,18 @@ class MotionGateTests(unittest.TestCase):class KeymapTests(unittest.TestCase):+ def test_supported_user_remap_fixtures_keep_us_layout_and_change_only_options(self):+ self.assertEqual(set(proof.KEYMAP_REMAPS), {'caps_to_ctrl', 'caps_to_super'})+ self.assertIn('kb_layout = "us"', proof.KEYMAP_CAPS_CTRL)+ self.assertIn('kb_options = "ctrl:nocaps"', proof.KEYMAP_CAPS_CTRL)+ self.assertIn('kb_layout = "us"', proof.KEYMAP_CAPS_SUPER)+ self.assertIn('kb_options = "caps:super"', proof.KEYMAP_CAPS_SUPER)+ for fixture in proof.KEYMAP_REMAPS.values():+ self.assertIn('kb_rules = "evdev"', fixture)+ self.assertIn('kb_model = "pc105"', fixture)+ self.assertIn('kb_variant = ""', fixture)+ self.assertIn('kb_file = ""', fixture)+def test_idle_baseline_allows_only_unreserved_inert_hover_on_either_lane(self):for lane in (0, 1):passive = keymap_status(1)@@ -532,7 +544,7 @@ class KeymapTests(unittest.TestCase):def test_keymap_plan_requires_its_own_exact_include(self):proof.validate_plan(plan('keymap'))for kind, data in (('keymap', proof.ENABLED), ('config_disable', proof.KEYMAP_US),- ('keymap', proof.KEYMAP_DE), ('keymap', proof.KEYMAP_US + '-- extra\n')):+ ('keymap', proof.KEYMAP_CAPS_CTRL), ('keymap', proof.KEYMAP_US + '-- extra\n')):candidate = plan(kind)candidate['config']['sha256'] = proof.digest(data.encode())with self.subTest(kind=kind, data=data), self.assertRaises(AssertionError):@@ -811,7 +823,7 @@ class SafetyTests(unittest.TestCase):stack.enter_context(patch.object(proof, '_reload', side_effect=TimeoutError('lost') if failure == 'reload' else lambda *_: keymap_status(3)))readback = stack.enter_context(patch.object(proof, 'keymap_options', return_value=options()))proof._replace(config, False)- self.assertEqual(Path(config['path']).read_bytes(), proof.KEYMAP_DE.encode())+ self.assertEqual(Path(config['path']).read_bytes(), proof.KEYMAP_CAPS_CTRL.encode())if failure == 'unrelated':Path(config['path']).write_bytes(proof.DISABLED.encode())if failure == 'wrong_stage':@@ -1054,7 +1066,7 @@ class SafetyTests(unittest.TestCase):stack.enter_context(patch.object(proof.time, 'monotonic_ns', side_effect=[5, 6, 7]))replace = stack.enter_context(patch.object(proof, '_replace', side_effect=lambda *_args, **kwargs: kwargs['before_replace']()))stack.enter_context(patch.object(proof, '_reload', return_value=keymap_status(1 if failure == 'not_compiled' else 2)))- stack.enter_context(patch.object(proof, 'file_identity', return_value={'sha256': proof.digest(proof.KEYMAP_DE.encode())}))+ stack.enter_context(patch.object(proof, 'file_identity', return_value={'sha256': proof.digest(proof.KEYMAP_CAPS_CTRL.encode())}))if failure:with self.assertRaises(AssertionError):fault.inject(Mock(), trace(ACTIVE[:1]), Mock(done=Mock(return_value=False)), Mock())@@ -1105,7 +1117,7 @@ class RunnerTests(unittest.TestCase):def test_reconnect_without_reset_restore_before_snapshot_and_new_action(self):cases = [(kind, failure, 'cleared') for kind in ('config_disable', 'keymap') for failure in (None, 'inject', 'restore', 'recovery')]- cases += [('keymap', 'refusal', 'cleared'), ('keymap', 'cancel', 'cleared')]+ cases += [('keymap', 'cancel', 'cleared')]cases += [(kind, failure, 'retained_inert') for kind in ('config_disable', 'keymap')for failure in (None, 'recovery', 'snapshot_leave')]for kind, failure, policy in cases:@@ -1139,10 +1151,10 @@ class RunnerTests(unittest.TestCase):fault.restore.side_effect = restorestack.enter_context(patch.object(proof, 'ConfigFault', return_value=fault))stack.enter_context(patch.object(proof, 'provenance', return_value={'files': {}}))- agent, observer, fresh, refused = client(100), client(101), client(102), client(103)+ agent, observer, fresh = client(100), client(101), client(102)agent.tool.return_value = {}observer.tool.return_value = {'structuredContent': {'screen_width': 1920, 'screen_height': 1080}}- stack.enter_context(patch.object(proof, 'DirectMCP', side_effect=[agent, observer, refused, fresh] if kind == 'keymap' else [agent, observer, fresh]))+ stack.enter_context(patch.object(proof, 'DirectMCP', side_effect=[agent, observer, fresh]))def snapshot(*_args, **_kwargs):order.append('snapshot')return target_snapshot('snapshot-' + str(len(order)), runtime=101, observed_ns=14_000_000)@@ -1176,13 +1188,6 @@ class RunnerTests(unittest.TestCase):observations = [cancelled, observed, cancelled, last]second = Mock(hello={'protocol': 3}, collect=Mock(side_effect=observations))stack.enter_context(patch.object(proof, 'connect_trace', side_effect=[first, second]))- def refuse(*args):- order.append('refusal')- self.assertEqual(agent.process.poll(), 0)- if failure == 'refusal':- raise AssertionError('wrong layout did not refuse')- return fault_record['wrong_layout'] if policy == 'retained_inert' else layout_refusal()- probe = stack.enter_context(patch.object(proof, 'refuse_new_action', side_effect=refuse))def recover(*args):order.append('recovery')if failure == 'recovery':@@ -1198,15 +1203,10 @@ class RunnerTests(unittest.TestCase):self.assertFalse(any(call.args == ('TRACE_START',) for call in second.exchange.call_args_list))self.assertEqual(agent.process.poll(), 0)self.assertEqual(observer.process.poll(), 0)- if failure not in ('inject', 'restore', 'refusal', 'cancel', 'snapshot_leave'):+ if failure not in ('inject', 'restore', 'cancel', 'snapshot_leave'):self.assertLess(order.index('restore'), len(order) - 1 - order[::-1].index('snapshot'))self.assertLess(order.index('restore'), order.index('recovery'))self.assertTrue((args.evidence / 'pre-recovery-prefix.json').is_file())- if kind == 'keymap' and failure not in ('inject', 'cancel'):- self.assertLess(order.index('refusal'), order.index('restore'))- self.assertEqual(refused.process.poll(), 0)- if kind == 'config_disable' or failure in ('inject', 'cancel'):- probe.assert_not_called()if policy == 'retained_inert' and failure != 'snapshot_leave':self.assertEqual(fault.record['target_before']['snapshot_id'], 'prepared')self.assertEqual(fault.record['target_after']['pid'], candidate['agents'][0]['target']['pid'])diff --git a/libs/cua-driver/rust/Skills/cua-driver/LINUX.md b/libs/cua-driver/rust/Skills/cua-driver/LINUX.mdindex 5a84eb0024..8ed986968d 100644--- a/libs/cua-driver/rust/Skills/cua-driver/LINUX.md+++ b/libs/cua-driver/rust/Skills/cua-driver/LINUX.md@@ -277,12 +277,14 @@ identity refuses. Package eligibility does not certify every LibreOfficeapplication or operation.The plugin separately binds the exact live native surface and checks geometry,-desktop availability, primary-client and other-lane conflicts, and the compiled-default `evdev`/`pc105`/`us` keymap. The candidate excludes variants, options,-remaps, multiple layout groups, missing keyboards, Unicode, IME input,-arbitrary held-key streams, and modified pointer gestures. Chromium, Electron,-and XWayland raw background input are outside this scope. AT-SPI routes retain-their separate behavior.+desktop availability, and primary-client and other-lane conflicts. Each+background lane publishes a private canonical `evdev`/`pc105`/`us` keymap, so+user options such as Caps Lock remapped to Ctrl or Super do not alter agent key+semantics. A physical keymap transition cancels existing authority; use a fresh+action afterward. Multiple agent layout groups, Unicode, IME input, arbitrary+held-key streams, and modified pointer gestures remain outside this scope.+Chromium, Electron, and XWayland raw background input are outside this scope.+AT-SPI routes retain their separate behavior.Two compositor seats, `Cua-Agent` and `Cua-Agent-2`, persist across configurationdisable/re-enable. Each connection claims one lane, and each admitted action@@ -302,7 +304,9 @@ native harness covers defined GTK3, Electron, and Tauri foreground cases. It refheld physical input, grabs, constraints, drag-and-drop, ambiguous primary seatbindings, and non-neutral keyboard modifiers. Background refusal never selectsthis route automatically. Driver expands bounded ASCII text under the exact-US keymap; Unicode and IME remain outside its raw-input scope.+US keymap; Unicode and IME remain outside its raw-input scope. Foreground+pointer-only actions are layout-independent, but foreground keyboard actions+still require the canonical physical US map.The retained bounded app evidence at source`f180e8828b8f31cc153e3c44eaa89a9c13c5bc68` includes instrumented Calc/Inkscape@@ -354,7 +358,7 @@ ask the user.|---|---|---|| X11/Openbox | AT-SPI trees and actions, foreground pointer and keyboard input, window and desktop capture, and video | Raw background delivery remains toolkit-specific; unsupported shapes refuse || Sway/wlroots | AT-SPI, native discovery, full-display and cropped-window screencopy, foreground input, semantic background actions, and video | Raw background pointer and keyboard input remains focus-bound |-| Hyprland/Omarchy | Experimental source candidate with separate discovery-foundation and bounded two-seat app evidence | Default plugin is discovery-only; raw background v3 qualification is limited to the exact native Calc/Inkscape packages and plain US keymap; complete native harness and release acceptance are separate gates |+| Hyprland/Omarchy | Experimental source candidate with separate discovery-foundation and bounded two-seat app evidence | Default plugin is discovery-only; raw background v3 qualification is limited to the exact native Calc/Inkscape packages and a private agent US keymap; user Caps-to-Ctrl/Super remaps do not alter agent semantics; complete native harness and release acceptance are separate gates || GNOME/Mutter | AT-SPI, WinRects geometry and activation, capture, and portal/libei foreground input | Requires the helper and portal grant; portal video parity remains open || KDE/KWin | AT-SPI and generic discovery where exposed | Target-specific activation and behavioral coverage remain experimental || Nested `cua-compositor` | Versioned direct per-surface input, native GTK 31/31, capture/scope 5/5, and partial Electron coverage | The complete shared matrix remains experimental; do not infer standard-Wayland support |diff --git a/libs/cua-driver/rust/crates/platform-linux/src/wayland/hyprland_input.rs b/libs/cua-driver/rust/crates/platform-linux/src/wayland/hyprland_input.rsindex 9aa784c2ad..f84fc313b5 100644--- a/libs/cua-driver/rust/crates/platform-linux/src/wayland/hyprland_input.rs+++ b/libs/cua-driver/rust/crates/platform-linux/src/wayland/hyprland_input.rs@@ -15,6 +15,7 @@ use serde_json::{json, Value};const TIMEOUT: Duration = Duration::from_secs(3);const CANCELLATION_POLL: Duration = Duration::from_millis(25);+const TEXT_ACTION_GAP: Duration = Duration::from_millis(25);const MAX_PACKET: usize = 2048;const MAX_LANES: usize = 2;const MAX_STALE_GEOMETRY_RETRIES: usize = 1;@@ -1200,14 +1201,23 @@ fn execute_text_actions(mut dispatch: impl FnMut(Action) -> Result<Value>,) -> Result<Value> {let mut delivered = 0u32;- for action in actions {+ let action_count = actions.len();+ for (index, action) in actions.into_iter().enumerate() {match dispatch(action) {Ok(mut reply) if reply["ok"] == false => {reply["effect"] = json!(if delivered > 0 { "partial" } else { "none" });reply["delivery"] = json!({"mode":route.mode(),"delivered_count":delivered});return Ok(reply);}- Ok(_) => delivered += 1,+ Ok(_) => {+ delivered += 1;+ // The compositor acknowledgement is not a client-processing+ // fence. Give the target event loop a bounded turn before the+ // next character so native GTK clients do not drop a burst.+ if index + 1 < action_count {+ std::thread::sleep(TEXT_ACTION_GAP);+ }+ }Err(error) => {if let Some(unknown) = error.downcast_ref::<DispatchUnknown>() {return Err(unknown_dispatch(@@ -1426,6 +1436,19 @@ mod tests {}}+ #[test]+ fn text_dispatch_paces_acknowledged_keys() {+ let started = Instant::now();+ let result = execute_text_actions(+ text_actions("abc").unwrap(),+ DeliveryRoute::Background,+ |_| Ok(json!({"ok":true})),+ )+ .unwrap();+ assert_eq!(result["delivery"]["delivered_count"], 3);+ assert!(started.elapsed() >= TEXT_ACTION_GAP + TEXT_ACTION_GAP);+ }+#[test]fn background_text_binds_each_key_to_the_exact_target() {reset_test_attestations();diff --git a/libs/cua-driver/tests/fixtures/shared/web/index.html b/libs/cua-driver/tests/fixtures/shared/web/index.htmlindex 5df42346c2..1e32fa497d 100644--- a/libs/cua-driver/tests/fixtures/shared/web/index.html+++ b/libs/cua-driver/tests/fixtures/shared/web/index.html@@ -143,6 +143,14 @@</div></fieldset>+ <fieldset>+ <legend>child_window</legend>+ <div class="row">+ <button id="btn-open-child-window" data-cua-id="btn-open-child-window">Open child window</button>+ <span class="mirror" id="lbl-child-window-state" data-cua-id="lbl-child-window-state">child_windows=0</span>+ </div>+ </fieldset>+<fieldset><legend>checkable_controls</legend><div class="row">@@ -181,13 +189,6 @@<h3 id="section-target" data-cua-id="section-target">SECTION_TARGET_MARKER_v1</h3></fieldset>- <fieldset>- <legend>child_window</legend>- <div class="row">- <button id="btn-open-child-window" data-cua-id="btn-open-child-window">Open child window</button>- <span class="mirror" id="lbl-child-window-state" data-cua-id="lbl-child-window-state">child_windows=0</span>- </div>- </fieldset></main><script>diff --git a/libs/cua-driver/tests/fixtures/shared/web/journal.test.cjs b/libs/cua-driver/tests/fixtures/shared/web/journal.test.cjsindex 2d51ad78a1..5e402185ad 100644--- a/libs/cua-driver/tests/fixtures/shared/web/journal.test.cjs+++ b/libs/cua-driver/tests/fixtures/shared/web/journal.test.cjs@@ -4,6 +4,28 @@ const { join } = require('node:path');const { test } = require('node:test');const { runInNewContext } = require('node:vm');+test('pixel-addressed controls stay within the first three grid rows', () => {+ const html = readFileSync(join(__dirname, 'index.html'), 'utf8');+ assert.match(html, /grid-template-columns:\s*repeat\(3,/);++ const gridStart = html.indexOf('<main class="harness-grid">');+ assert.notEqual(gridStart, -1, 'shared fixture grid exists');+ for (const id of [+ 'txt-input',+ 'keyboard-input',+ 'drag-source',+ 'drop-target',+ 'scroll-tall',+ 'click-target',+ 'btn-open-child-window',+ ]) {+ const control = html.indexOf(`id="${id}"`, gridStart);+ assert.notEqual(control, -1, `${id} exists in the shared fixture grid`);+ const fieldsetCount = (html.slice(gridStart, control).match(/<fieldset>/g) || []).length;+ assert.ok(fieldsetCount <= 9, `${id} moved below the third grid row`);+ }+});+test('journal samples live scroll geometry without an event or DOM mutation', () => {const html = readFileSync(join(__dirname, 'index.html'), 'utf8');const source = html.match(/\(function startFixtureJournal\(\) \{[\s\S]*?\n \}\)\(\);/);