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
docs(cua-driver): document CI and PR split plans
Francesco Bonacci60e16372619c
diff --git a/libs/cua-driver/docs/cross-platform-ci-test-plan.md b/libs/cua-driver/docs/cross-platform-ci-test-plan.mdnew file mode 100644index 0000000000..2dbc1420f8--- /dev/null+++ b/libs/cua-driver/docs/cross-platform-ci-test-plan.md@@ -0,0 +1,286 @@+# Cross-Platform CI and E2E Test Plan++Status: implementation plan, with the source-built unit and manual runner+foundation now landed on the working branch++## Goal++Make the Rust harnesses the source of truth for user behavior on Linux and+Windows. Keep unit tests cheap and OS-scoped. Run desktop end-to-end tests as a+maintainer-controlled gate with the real session each platform requires.++The same Rust scenario should run on both platforms whenever the behavior is+supported. The runner may use different platform APIs, but the scenario ID,+application oracle, and outcome rules should stay the same.++## Test Tiers++### Tier 1: Rust unit and compile checks++Run automatically on pull requests when an affected platform or shared Rust+path changes.++- No desktop session, TCC, RDP, AT-SPI, or Azure credentials.+- Run on `ubuntu-latest` and `windows-latest` in separate jobs.+- Use `cargo test --workspace --all-targets --locked`.+- Run Clippy in the same OS-scoped workflow where its cost remains acceptable.++Shared code changes run both OS jobs. A platform-only change runs one job.++### Tier 2: Fast Linux integration checks++Keep the small Xvfb and AT-SPI checks that do not require a real user desktop.+These checks can remain automatic if their runtime stays short and stable.++They cover protocol setup, capture modes, accessibility reachability, and+desktop-scope contract errors. They do not replace the behavioral harness.++### Tier 3: Maintainer e2e gate++Run the same Rust behavioral matrix against real harness applications.++- Linux: the manual Rust runner for the canonical matrix; Nix X11 and Nix+ Wayland remain supporting compositor checks until the source-built app pilot+ is complete.+- Windows: Azure Windows with an active RDP user session.+- Trigger: `workflow_dispatch` with a commit ref, PR number, and suite.+- Optional nightly and post-merge runs can catch drift without slowing every PR.+- The VM or runner never pushes code.++### Tier 4: Supporting compatibility checks++Keep toolkit and distro checks that cover behavior outside the canonical harness+matrix. These checks should be labeled as supporting coverage and should not+claim that a user workflow passed when they only prove window discovery or a+non-error response.++## Canonical Behavioral Matrix++The Rust test suite owns the scenario list. CI workflows should select a suite,+not duplicate the scenario definitions in YAML or Python.++### Applications++- Electron+- Tauri++### Surfaces++- Accessibility action path+- Pixel-coordinate path++### Delivery modes++- Background+- Foreground++### Scenarios++- Calculator click sequence and result oracle+- Editor type, save, and saved-state oracle+- Enter key and hotkey state oracles+- Nested scroll and scroll-offset oracle+- Child-window creation oracle+- Drag and drop-state oracle+- Focus sentinel and window posture checks++Each result has one of these outcomes:++```text+pass+expected_refusal+known_gap+not_applicable+unexpected_failure+```++An expected refusal must include the structured driver error and capability+reason. A driver response without an external application-state change is not a+pass.++The runner should emit a common result record:++```json+{+ "scenario": "editor_type_and_save",+ "os": "windows",+ "app": "electron",+ "surface": "ax",+ "delivery": "background",+ "outcome": "pass",+ "oracle": "editor_status=saved:exact"+}+```++Platform-specific applications such as WPF and WinUI 3 remain focused Windows+coverage. GTK and Qt remain focused Linux coverage. They supplement the shared+matrix and do not define cross-platform acceptance.++## Linux Structure++Nix remains the Linux desktop test environment. It should build the driver and+repo-local harness applications from source and run the Rust tests against those+outputs. The test should not download a prebuilt application and Linux e2e runs+do not need GIF recording.++Proposed layout:++```text+nix/cua-driver/+ package.nix+ module.nix+ README.md+ lib/+ app-catalog.nix+ artifacts.nix+ atspi-session.nix+ mcp-client.nix+ wayland-session.nix+ x11-session.nix+ checks/+ x11/+ harness-electron.nix+ harness-tauri.nix+ input-cursor-click.nix+ input-parallel-drag.nix+ service-config-persistence.nix+ service-integration.nix+ wayland/+ app-background-read.nix+ input-background-terminal.nix+ input-cursor-click.nix+ input-parallel-drag.nix+ service-integration.nix+```++The current generic `linux-background-gui.nix` should be split. Its read-only+app entries should become supporting checks or be removed after equivalent+canonical harness coverage exists. Its Chromium and Tk write paths should be+retained until the Rust harness covers the same contract.++Use explicit flake check names such as:++```text+cua-driver-linux-x11-harness-electron+cua-driver-linux-x11-harness-tauri+cua-driver-linux-x11-service-config-persistence+cua-driver-linux-wayland-gnome-input-background-terminal+```++Do not put `gif` in a test name. Screenshots, AX trees, structured results, and+driver logs are enough for routine artifacts. Capture a PNG on failure or when+diagnosing a pixel scenario.++The testkit needs test-only path overrides so Nix can use immutable build+outputs:++```text+CUA_TEST_DRIVER_BIN+CUA_TEST_APPS_ROOT+CUA_TEST_WORKSPACE_ROOT+```++Local runs keep their current defaults.++## Windows Structure++Windows uses the same Rust scenarios and repo-local harness source. The Azure VM+builds the applications on demand inside the active RDP session.++Workflow and helper names:++```text+.github/workflows/ci-rust-windows.yml+.github/workflows/e2e-rust-windows.yml+scripts/ci/windows/+ verify-user-session.ps1+ build-harnesses.ps1+ run-rust-e2e.ps1+ collect-artifacts.ps1+```++The Windows e2e workflow now:++1. Check out or sync the requested commit.+2. Confirm that the target process runs in the active RDP user session, not+ Session 0.+3. Build Electron, Tauri, WPF, and WinUI 3 harnesses from source.+4. Build the Rust driver and integration tests.+5. Run the shared behavioral matrix, then Windows-native tests.+6. Collect structured results, UIA trees, screenshots, and driver logs.+7. Leave the VM unable to push or modify the source branch.++The Windows unit workflow runs on `windows-latest` and does not attempt these+desktop steps.++## Workflow Names++Use the distinction between `ci` and `e2e` in the filename and displayed job+name:++```text+CI: Rust Linux unit+CI: Rust Windows unit+CI: Linux fast integration+E2E: Linux Nix X11+E2E: Linux Nix Wayland+E2E: Linux Azure desktop+E2E: Windows Azure RDP+```++The Nix X11 and Wayland workflows should stop running automatically for every+PR update once the maintainer gate is available. Keep manual dispatch, nightly+runs, and post-merge regression runs.++## Legacy Test Migration++Keep an inventory before deleting tests. For each test record its scenario,+oracle, OS, window system, app, and current CI role.++Classify each test as:++- `canonical`: a trusted user-behavior acceptance test.+- `supporting`: useful backend or toolkit coverage.+- `diagnostic`: useful during investigation but not a product gate.+- `retire`: redundant or weaker than a canonical replacement.++Migration order:++1. Add the testkit path overrides and strict fixture preflight.+2. Land the OS-scoped unit checks and the manual desktop runners.+3. Pilot source-built harness packaging inside Nix before moving app builds+ into the Nix sandbox.+4. Add missing scenario coverage before removing an old test.+5. Move weaker tests out of required CI.+6. Delete tests only after the replacement has passed repeatedly on the target+ platform.+7. Update the Nix and workflow READMEs to describe the new ownership.++Do not delete specialized Wayland, MPX, WPF, or WinUI coverage merely because+the shared Electron/Tauri matrix exists. Retain those tests until the shared+matrix covers the behavior they uniquely exercise.++## Acceptance Criteria++- Shared scenario IDs and external oracles are identical on Linux and Windows.+- Shared Rust changes run both unit-test jobs.+- Platform-only changes run only the affected OS unit job.+- Linux e2e builds harness applications from source in the Linux desktop runner;+ a fully sandboxed Nix app-build pilot remains a separate follow-up.+- Windows e2e builds harness applications from source in the Azure VM.+- No Linux e2e test requires GIF recording.+- No canonical test passes on driver success alone.+- Unsupported background behavior produces a structured refusal or remains a+ visible known gap.+- Maintainer e2e runs publish a result table and failure artifacts linked to the+ PR.+- Legacy tests are either classified, upgraded, moved out of required CI, or+ removed with an equivalent canonical replacement.++## Non-Goals++- Do not make Windows use Nix.+- Do not create a second Python behavioral framework.+- Do not download opaque prebuilt desktop fixtures.+- Do not weaken external-state assertions to make a matrix green.+- Do not make Azure or RDP credentials available to untrusted PR code.diff --git a/libs/cua-driver/docs/pr-split-plan.md b/libs/cua-driver/docs/pr-split-plan.mdnew file mode 100644index 0000000000..de2befb665--- /dev/null+++ b/libs/cua-driver/docs/pr-split-plan.md@@ -0,0 +1,298 @@+# Cua-driver PR Split Plan++Status: draft for review++## Decision++Do not merge PR #2135 as one change. It currently contains 204 files and+roughly 11.5k additions/deletions across fixture migration, Rust test+ownership, Windows behavior, Linux/macOS behavior, and CI/Nix architecture.++Keep the current branch as an untouched snapshot while smaller PRs are built+from `main`. The historical commits are useful provenance, but several of them+mix unrelated file families. Cherry-picking those commits wholesale would+reintroduce the same review problem.++## Target PRs++### PR 0: Documentation lockfile housekeeping++Suggested title:++```text+chore(docs): sync pnpm lockfile with pnpm 9+```++Scope:++- `docs/pnpm-lock.yaml`+- Current provenance: `8fee84dd`++This is independent and can merge first. It should not be coupled to desktop+behavior or CI changes.++Acceptance:++- Docs dependency install/check passes.+- No `libs/cua-driver` files change.++### PR 1: Repo-local Rust harness foundation++Suggested title:++```text+test(cua-driver): make repo-local Rust harnesses canonical+```++Purpose: establish where fixtures, Rust integration tests, and runner scripts+live. This PR should make the source tree coherent without changing the+platform input algorithms.++Scope by file family:++- Move `libs/cua-driver/test-harness` content to+ `libs/cua-driver/tests/fixtures`.+- Add the repo-local Electron and Tauri source/build scripts for each host.+- Move the Windows sandbox runner to `tests/runners/windows-sandbox`.+- Add the Rust-only Windows `tests/runners/windows/run-all.ps1` entrypoint.+- Remove the old Python e2e harness and downloaded desktop binaries.+- Port the optional LibreOffice and macOS launch-focus tests to Rust where+ needed, keeping them outside the default run-all path.+- Update path references, `.gitignore` files, fixture READMEs, Rust test README,+ and the small contributor-facing Fumadocs page.+- Include `libs/cua-driver/scripts/sync-vm-worktree.sh` because it belongs to+ the host-owned fixture workflow.++Historical provenance:++- `811ffa6d`, `d44971c`, `98e59d75`, `d9e4311f`, `9ab85981`,+ `5e8759e1`, and `4e1636b9`.++Do not take the platform implementation portions of `a759840b` or+`d01c7a14` into this PR. If a test path needs a behavior change to compile,+make the smallest path-only adjustment and leave the behavioral assertion+change for the relevant behavior PR.++Acceptance:++- No old downloaded Electron/Tauri application is tracked.+- No Python behavioral suite remains under the cua-driver test tree.+- Fixture build scripts pass shell/PowerShell parsing on their native hosts.+- `cargo test -p cua-driver --tests --no-run` passes on macOS, Linux, and+ Windows.+- Staged outputs remain under ignored `rust/test-apps`.+- Optional external-app tests are visibly excluded from the default runner.++### PR 2: Shared Rust behavioral matrix++Suggested title:++```text+test(cua-driver): add shared external-oracle behavior matrix+```++Purpose: make the trusted user-behavior scenarios explicit before wiring them+into expensive CI. The same scenario IDs, fixture DOM, delivery modes, and+external-state oracles should be used on every supported host.++Scope:++- Add `cross_platform_behavior_test.rs`.+- Add/update the shared web fixture and scenario catalog.+- Add only the generic testkit response/tree helpers required by the matrix.+- Keep the matrix ignored by default and runnable through one Rust command.+- Keep assertions based on fresh application state, not driver success alone.++Historical provenance: primarily `ca60e0ba`, but extract only the matrix,+fixture, and generic testkit pieces. The platform algorithm changes from that+commit belong in PRs 3 and 4.++Acceptance:++- Matrix compiles on all three hosts.+- Electron and Tauri are selected from repo-local source-built fixtures.+- Every scenario has an external oracle and a documented outcome rule.+- Missing fixtures are visible as a runner/setup failure on dedicated e2e+ lanes, not a green silent skip.++### PR 3: Windows delivery and interactive UX fixes++Suggested title:++```text+fix(cua-driver): harden Windows delivery and GUI validation+```++Scope:++- Windows Session 0 and interactive-desktop diagnostics.+- Focus sentinel and guard UX behavior.+- Background keyboard/click refusal reporting and preserved actuator causes.+- UIA focus, scroll, WebView2/Tauri, WPF, and WinUI3 behavior changes.+- Windows-specific test assertions and fixture details that validate those+ behaviors.++Historical provenance: Windows portions of `a759840b`, `98e59d75`,+`d01c7a14`, and `ca60e0ba`.++Acceptance:++- Windows unit and compile checks pass on `windows-latest`.+- SSH/Session 0 runs skip GUI-only assertions with an explicit reason.+- An active user-session run passes the guard and native harness suites.+- W1-style background input never reports verified delivery without an+ external state change.+- W8-style unsupported background delivery returns a structured refusal with+ the concrete cause.++### PR 4: Linux delivery fixes++Suggested title:++```text+fix(cua-driver): harden Linux AT-SPI and input delivery+```++Scope:++- Linux AT-SPI reference handling, action delivery, input capability errors,+ and related external-oracle test updates.+- Linux focused tests and strict known-gap assertions.++Historical provenance: Linux portions of `a759840b`, `ca60e0ba`, and+`d848e365`. The VM sync helper from `d848e365` belongs in PR 1, not here.++Acceptance:++- Linux unit and interactive Xvfb/AT-SPI checks pass.+- Known gaps remain strict and visible; no assertion is weakened to fit the+ current driver behavior.+- Linux behavior changes are covered by the shared matrix where the platform+ supports the scenario.++### PR 5: macOS input and capture delivery++Suggested title:++```text+fix(cua-driver): harden macOS input and capture delivery+```++Scope:++- macOS background click, drag, targeted wheel, and accessibility scrolling.+- macOS Swift runtime/build fixes required for Rust test binaries.+- macOS focused tests and strict nested-scroll known-gap assertions.++Historical provenance: macOS portions of `a759840b`, `ca60e0ba`, and+`9c3c719a`, plus the macOS portions of `0447bd52`.++Acceptance:++- macOS default tests and installed-daemon harness checks pass with TCC+ already authorized.+- Electron and Tauri click/drag rows use external application-state oracles.+- The nested web scrolling gap remains strict and visible.++### PR 6: OS-scoped CI and Nix e2e architecture++Suggested title:++```text+ci(cua-driver): add OS-scoped Rust and manual e2e lanes+```++Scope:++- Testkit path overrides and their unit test:+ `CUA_TEST_DRIVER_BIN`, `CUA_TEST_APPS_ROOT`, and+ `CUA_TEST_WORKSPACE_ROOT`.+- Strict fixture preflight for canonical e2e runs.+- Linux and Windows OS-scoped unit workflows.+- Maintainer-dispatched Linux and Windows interactive e2e workflows.+- Source-built Linux Rust check in Nix.+- Nix and workflow READMEs describing canonical versus supporting coverage.+- Move the legacy GUI/toolkit and compositor matrices to maintainer dispatch;+ preserve them as supporting diagnostics.+- Keep new canonical Linux tests free of GIF requirements.++Historical provenance: `eef79f2a` and `0447bd52`, after extracting the Linux+and macOS driver edits from `0447bd52` into PRs 4 and 5.++Acceptance:++- Shared Rust changes trigger both OS unit workflows.+- Platform-specific changes trigger only the relevant OS unit workflow.+- Linux Rust source check passes in Nix.+- Manual Linux e2e builds repo-local fixtures from source.+- Windows e2e verifies an interactive user session and supports an Azure+ active-RDP runner label.+- No VM or GitHub runner can push source changes.+- The PR description says clearly that fully sandboxed Nix Electron/Tauri+ packaging remains a follow-up requiring committed dependency lockfiles.++## Dependency Graph++```mermaid+graph LR+ P0[Docs lockfile] --> Merge+ P1[Repo-local harness foundation] --> P2[Shared Rust behavior matrix]+ P2 --> P3[Windows behavior fixes]+ P2 --> P4[Linux behavior fixes]+ P2 --> P5[macOS behavior fixes]+ P3 --> P6[OS-scoped CI and Nix]+ P4 --> P6+ P5 --> P6+```++PR 0 is independent. PR 6 can technically begin earlier, but merging it last+keeps the required CI contract aligned with the already-merged test and driver+behavior.++## Branching Procedure++1. Freeze PR #2135. Do not add more mixed commits to it.+2. Preserve the current branch as the snapshot containing all work. The+ private `cross-platform-fix-journal.md` stays untracked and must not be+ included in any PR.+3. Create each split branch from `main`, then apply the final file families+ from the snapshot. Use `git diff --find-renames main...HEAD -- <paths>` to+ preserve moves and deletions.+4. Do not cherry-pick `a759840b`, `ca60e0ba`, `d848e365`, or `0447bd52`+ wholesale. Each mixes concerns that belong in different PRs.+5. Cherry-picking `8fee84dd` is safe for PR 0. `eef79f2a` is safe only after+ confirming the old interactive workflow remains compatible with the new CI+ split.+6. Run the acceptance checks for each branch before opening its PR. Keep PR+ descriptions narrowly scoped and list known failures instead of hiding+ them behind broad “cross-platform fixes” language.+7. Open the PRs in dependency order. Stack PR 2 on PR 1 if needed, then+ retarget it to `main` after PR 1 merges. Repeat for later PRs.+8. Close PR #2135 only after the smaller PRs are open and its body links to+ them. Keep the snapshot branch available until all split PRs merge.++## Review and Rollback Rules++- A PR must have one primary reason to change and one obvious owner.+- Fixture moves must be reviewed with rename detection enabled.+- Deleting the Python suite and downloaded binaries is only part of PR 1 when+ the Rust replacement and build scripts are present in the same diff.+- Platform behavior PRs must not change CI trigger policy.+- CI/Nix PRs must not contain opportunistic platform algorithm changes.+- If a split branch cannot compile independently, either add the missing+ foundation to its parent PR or make the dependency explicit; do not silently+ retain unrelated files from PR #2135.+- Revert the smallest PR that caused a regression. The dependency order keeps+ the harness foundation and behavior fixes independently revertible from CI.++## Final State++After all PRs merge, the repository should have:++- Rust harnesses as the canonical behavioral source of truth.+- One shared scenario matrix with platform-specific implementations behind it.+- Cheap OS-scoped unit checks on normal PRs.+- Manual, real-session e2e gates for expensive desktop behavior.+- Nix retained as the Linux environment, with legacy visual checks clearly+ labeled as supporting coverage.+- No opaque downloaded desktop fixture in the canonical test path.