Computer use CLI for AI agents
Rust accessibilityaccessibility-apiai-agentsautomationclicomputer-usecomputer-use-agentcomputer-use-agentsdesktop-automationmacosmcprust
docs: synchronize windows native repair verification
Lahfir9a78c447f912
diff --git a/docs/phases.md b/docs/phases.mdindex 80415819a..478cd4725 100644--- a/docs/phases.md+++ b/docs/phases.md@@ -1380,7 +1380,7 @@ System tray interaction is built from scratch here.- Full-branch multi-agent review — the whole assembled branch, not only this sub-phase's own diff- **Make `cursor-overlay` tell its caller the truth on Windows.** Today `cursor-overlay enable` returns `ok: true` and renders nothing: `update_cursor_overlay` has no Windows override, and both call sites discard the adapter's answer — `src/dispatch/cursor_overlay.rs` logs a `tracing::warn!` and falls through to success, and `crates/core/src/cursor_overlay/submit.rs` does the same. A Windows-only adapter override returning `not_supported()` therefore changes nothing observable; §2.13 deliberately did not add one. **This gate owns only the honesty half — making the command report what the adapter answered. Rendering the overlay on Windows is §2.16's, which implements against whatever response shape this gate defines.** The candidate fix is to carry the adapter's answer into the response as a machine-readable field (a `rendered: false` on the success envelope) so the tool reports reality in the channel its caller actually reads — with the caveat that this changes a cross-platform command's response shape, which is a contract decision this gate is allowed to make. Two accepted risks inherited from §2.13's npm work are decided alongside, not rediscovered: (1) the install path's checksum verification is same-origin (`checksums.txt` comes from the same release as the tarball) and no consumer verifies the Sigstore provenance the release produces — surfacing `gh attestation verify` to manual-download users was the cheap half; (2) `optionalDependencies` per-platform packages were rejected on scope rather than merit, leaving `npm install --ignore-scripts` a permanent loud failure on every platform. Measured at 2.13's dogfood on npm 12.0.1 (node 24.18): that release's new install-scripts allowlist blocks the postinstall even with `--allow-scripts=agent-desktop` passed, so the wrapper's loud binary-not-found failure is increasingly the first thing a Windows user sees; the wrapper already names the cause, but this gate should weigh publishing the allowScripts configuration in the README before Phase 2 closes- **Decide whether a shell surface's returned handle is rootable, or the `--surface` round trip is the contract.** `open-system-surface` returns `w-<hwnd>` identities, and `snapshot --window-id` refuses them `WINDOW_NOT_FOUND` — measured live at the dogfood for the promoted tray toolbar's handle — because the window inventory deliberately excludes shell windows (KTD1's correct behaviour); the shell round trip routes through `snapshot --surface <kind>` while the exit criteria's "an identity `snapshot --window` consumes" reads only through that path. What closes it: either `snapshot --window-id` roots shell handles through the shell-surface resolver, or the contract states that shell identities are surface-kind-scoped and the identity wording is corrected beside it. **Evidence:** dogfood 2026-08-28 leg 2; KTD1-- **The two live E2E legs that fail identically at this branch's merge-base are a known limit, listed in step 11 of the promotion checklist.** `headed-double-click` (actionability preflight `hit_test` occluded 5/5 on an unattended desktop) and `interaction-scroll-to-visibility` (scroll-to `ACTION_FAILED`) fail the same way when this sub-phase's diff is stashed, so neither is introduced here. The dogfood independently observed the occlusion half live: a tray-click preflight's 5/5 occluded hit-tests named the driving console's own window as the occluder. The runner a re-baseline relied on was retired (`635f24e1`) and the live suite runs locally, where the occluder is the operator's console window. **Evidence:** merge-base stash run; dogfood 2026-08-28 leg 2; `635f24e1`+- **The local native gate passes `headed-double-click` and `interaction-scroll-to-visibility`.** The click fixture counts physical mouse releases once; a double-click must not satisfy its triple-click target. Scroll verification uses the native client viewport, contains targets that fit, and uses vertical `SetScrollPercent` to avoid page-step oscillation. The full native suite passed 110 checks with zero failures and five absent-Chromium skips. Evidence: `tests/e2e-windows/InteractionHeaded.ps1`, `tests/e2e-windows/scenarios/Interaction.ps1`, `crates/windows/src/actions/scroll_ladder_tests.rs`.- **`agent-desktop-windows` is not built for non-Windows targets, and that is the decision rather than an oversight.** Nothing links the crate on a Linux target: the binary and the FFI crate declare their platform crates under `[target.'cfg(target_os = "windows")'.dependencies]`, so a Linux build never compiles `agent-desktop-windows`. What is gated in its place is core's platform neutrality — `agent-desktop-core` cross-compiles to `x86_64-unknown-linux-gnu` and `x86_64-pc-windows-msvc`, and `cargo tree -p agent-desktop-core` proves core carries no platform crate. Those are the invariants that matter, and both hold. Repairing the non-Windows build instead needs `#[cfg(not(target_os = "windows"))]` stubs across roughly twenty files that no lane executes — the exact shape `docs/solutions/best-practices/never-ship-platform-code-that-ci-cannot-execute.md` records the repository paying for once. This gate's scope offered a lane **or** a recorded exclusion with its reason; this is that exclusion. **Evidence:** `docs/solutions/best-practices/never-ship-platform-code-that-ci-cannot-execute.md`- **The A26-13 nameless-leaf classification is taken, and both rows are closed.** A30-2 (`c9aed40e`) produced it through the product's own stack with `--include-bounds`: a Chromium host answers 3 nameless leaves split 1 positive-area to 2 zero-extent, and a Win32 host answers 29 nameless leaves split 14 positive-area to 15 zero-extent, with no nameless leaf lacking bounds. A nameless positive-area content leaf exists, so R20's dependency is real. The Chromium sample was thin (19 refs against A24-11's 262-ref content precondition), so the classification is settled and the density is not. The zero-identity resolution fix (A24-11's half) is live-verified, and A26-13 and A24-11 are closed. **Evidence:** A30-2, A26-13, A24-11, A28-3, A1-5, A1-6- **The three ledger rows this gate owns are closed here, by measurement.** `A27-2` recorded a child enumeration that could not see a window the product's identical call did see, and deliberately handed the cause to a reproduction rather than asserting one. `A28-4` and `A28-5` are that reproduction: three `ToolbarWindow32` windows sit under `Shell_TrayWnd`, two of them collapsed zero-extent placeholders whose automation elements genuinely have no children, and the shipped class chain stopped one hop short and resolved one of the placeholders. All three rows are **closed** by adding the missing `SysPager` hop, after which `--surface system-tray` returns three refs and a click on one is delivered. The descend-the-taskbar-tree approach an earlier attempt built is **disposed of** as unnecessary and removed, and the claim that it improved the overflow surface is corrected in the rows themselves - overflow already read five refs without it.@@ -1425,7 +1425,7 @@ System tray interaction is built from scratch here.**Settled contract (decided here, so the next platform inherits answers rather than questions).**-- **`offscreen` means one thing and is measured at two fidelities, and that is ratified rather than normalized.** The token means *no part of the element is presently rendered within the visible region of its container*. macOS approximates that geometrically against the window rectangle, because it has no other source — no macOS element publishes `AXOffscreen`. Windows reads the provider's per-element value, which additionally sees scroll-viewport clipping that no window-disjointness test can reproduce (A18-1 measured a list item flipping the value over a 40px scroll). Normalizing was attempted twice on paper and rejected on measurement: Windows has no window rectangle to compute against — `resolve_states` receives no rectangles and the crate has no `window_bounds` concept — and `IsOffscreen` additionally feeds the actionability visibility gate, `scroll_ladder` and `scroll_into_view`, so dropping it would stop a below-fold target failing that gate. **A14-8's ban binds both adapters: a container's value is never propagated to its subtree.**+- **`offscreen` means no part of an element is rendered within its container's visible region.** Windows combines the provider flag with minimized-owner and ancestor-scroll-viewport clipping checks; WinForms can report offscreen descendants as on-screen. Native HWND viewports use client bounds, excluding title bars and scrollbars; HWND-less containers use provider bounds. macOS approximates visibility against window geometry because AX exposes no `AXOffscreen`. Neither adapter propagates a container's offscreen flag to its subtree. Evidence: `crates/windows/src/tree/minimized.rs`, `crates/windows/src/tree/walker_source.rs`, `tests/e2e-windows/scenarios/Interaction.ps1`.- **The role does not diverge; only the state token did, and Windows now produces it.** `crates/macos/src/tree/roles.rs` maps `AXSwitch`/`AXToggle` to `switch`, so a genuine switch is `switch` on both adapters and there was never a role divergence to settle. What Windows lacked was `pressed`, and it had the information all along: `LegacyIAccessibleState` is already in the walk set and already read. A `button` carrying `STATE_SYSTEM_PRESSED` now emits `pressed`. `button_role`'s reclassification of toggle-capable buttons to `switch` is untouched and correct — measurement found it accurate on every control that reached it, and the toolbar toggle button that was missing `pressed` advertises no `TogglePattern` at all.- **Dangerous-shortcut matching answers by one rule on both adapters: the pressed modifiers must be a superset of a listed entry's.** An enumeration cannot cover a variant nobody listed. macOS's `BLOCKED` list is deliberately **not** edited — two entries become redundant under the rule and keeping them makes the change monotonic, so nothing blocked before can become unblocked regardless of whether the redundancy argument holds.- **`type`, `press --app` and the `launch` identifier are ratified divergences, because Windows cannot reach macOS's behaviour rather than choosing not to.** UIA exposes no insert-at-selection, so strict-headless `type` returns `POLICY_DENIED` where macOS writes `AXSelectedText`. `SendInput` has no per-pid targeting, so Windows has no semantic accelerator path and no headless delivery to a background target — **and a third arm is documented with them: a non-interactive *caller* (a service, scheduled task or CI job) reaches a foreground-gated target no more reliably than a background target does.** Windows `launch` identifiers stay path-or-system-image against macOS's display-name-or-bundle-id. Each is documented per-platform with its floor rather than papered over.@@ -1603,9 +1603,9 @@ branch**, not a series of sub-phase merges, and it closed Phase 2.one probe run on a Chromium host.- `A21-2`: the live `ERROR_ELEVATION_REQUIRED` (740) launch effect. The rigcannot manufacture the boundary (A27-4, A30-3).- - The live e2e legs `headed-double-click` and `interaction-scroll-to-visibility`.- They fail identically at the merge base because the occluder is the operator's- console window, and the live suite is local-only.+ - The local live E2E gate includes `headed-double-click` and+ `interaction-scroll-to-visibility`; both pass after the native viewport,+ scroll-targeting and physical click-counter repairs described in §2.15.- The multi-agent race budget `LISTING_RACE_ATTEMPTS = 5` is kept as is. A24-14measured the race at 30 of 30 iterations at Medium integrity, and thedistribution of attempts needed was not measured.diff --git a/docs/plans/2026-08-07-001-feat-windows-semantic-action-tier-plan.md b/docs/plans/2026-08-07-001-feat-windows-semantic-action-tier-plan.mdindex 19c118974..ac9afd922 100644--- a/docs/plans/2026-08-07-001-feat-windows-semantic-action-tier-plan.md+++ b/docs/plans/2026-08-07-001-feat-windows-semantic-action-tier-plan.md@@ -104,7 +104,7 @@ Evidence:11. `TypeText`/`PressKey`/`DoubleClick`/`TripleClick`/`RightClick` → `AdapterError::not_supported("<capability>")` naming the missing machinery (key synthesis; multi-click; physical context-menu click) — `PLATFORM_NOT_SUPPORTED`, the honest cross-cutting-DoD arm, discriminable by message (the 2.6 dogfood J2 rule). `RightClick` is physical-only on Windows: UIA has no context-menu pattern, so no semantic rung can exist.12. `KeyDown`/`KeyUp`/`Hover`/`Drag` → macOS's rejection verbatim (`ActionNotSupported`, "requires adapter-level handling, not element action", `dispatch.rs:184-193`).13. Null handle (the `press` path) → `PressKey` reports the missing key-synthesis capability as in arm 11; every other variant → the crate's `invalid_native_handle` error. Checked before the downcast so the honest arm is reachable.-- KTD5. **The ancestor ladder is macOS's algorithm with 2.6's visibility predicate.** On `ScrollTo`, rung 1 is the shipped `ScrollItemPattern` spine unchanged; when the gate says unavailable, or the invoke completes with geometry unchanged, rung 2 runs (this replaces 2.6's terminal `scroll_into_view_unsupported`/not-delivered arms exactly where a scrollable ancestor exists — no ancestor → those arms remain): up to 10 iterations (`MAX_ANCESTOR_SCROLLS`, macOS `scroll_into_view.rs:35-60`); per iteration, compute the scroll direction from the target's fresh bounds against the nearest `ScrollPattern`-available ancestor's viewport bounds (vertical before horizontal, before-edge before after-edge — macOS `direction_for_visibility` parity; the ancestor walk reuses `walker_source::nearest_scroll_viewport`, deadline-checked per step); `ScrollPattern.scroll` one `SmallIncrement` on that ancestor through the classifier; direction resolves to none → visible: at iteration 0 `SatisfiedNoDelivery`, later `DeliveredVerified`; exhausted → `ACTION_FAILED` with `delivered_unverified` (real scrolls fired; macOS parity). Visibility is 2.6's shipped predicate — `IsOffscreen` false, positive-area bounds, and the viewport-intersection term, because A18-2 measured provider rects unclipped by their viewport; a full-rect test would claim verified on a below-the-fold straddler. The 2.6 KTD6 disposition divergence (`not_delivered` where macOS reported `delivered_unverified` after real ancestor scrolling) closes itself: once the ladder scrolls, the exhausted arm reports macOS's disposition.+- KTD5. **The ancestor ladder is macOS's algorithm with 2.6's visibility predicate.** On `ScrollTo`, rung 1 is the shipped `ScrollItemPattern` spine unchanged; when the gate says unavailable, or the invoke completes with geometry unchanged, rung 2 runs (this replaces 2.6's terminal `scroll_into_view_unsupported`/not-delivered arms exactly where a scrollable ancestor exists — no ancestor → those arms remain): up to 10 iterations (`MAX_ANCESTOR_SCROLLS`, macOS `scroll_into_view.rs:35-60`); per iteration, compute the scroll direction from the target's fresh bounds against the nearest `ScrollPattern`-available ancestor's viewport bounds (vertical before horizontal, before-edge before after-edge — macOS `direction_for_visibility` parity; the ancestor walk reuses `walker_source::nearest_scroll_viewport`, deadline-checked per step); one classified semantic scroll write on that ancestor: vertical `SetScrollPercent` centers the target using fresh viewport bounds and view size; horizontal scrolling uses `LargeIncrement`/`LargeDecrement`; direction resolves to none → visible: at iteration 0 `SatisfiedNoDelivery`, later `DeliveredVerified`; exhausted → `ACTION_FAILED` with `delivered_unverified` (real scrolls fired; macOS parity). Visibility requires `IsOffscreen` false and positive-area bounds. A target that fits must be contained by the native client viewport; an oversized target must intersect it. `scroll_ladder_tests.rs` and the local native E2E scroll leg verify that unclipped provider rectangles cannot prove visibility for a small clipped target. The 2.6 KTD6 disposition divergence (`not_delivered` where macOS reported `delivered_unverified` after real ancestor scrolling) closes itself: once the ladder scrolls, the exhausted arm reports macOS's disposition.- KTD6. **Verification is a per-action re-read, and a completed observation outranks the classifier.** Post-write verification (all within the lease deadline, macOS analogs cited): Toggle/Check/Uncheck → `ToggleState` re-read; SetValue → pattern value re-read equals the requested string exactly (via the KTD7 gate); RangeValue → value re-read equals the parsed number, with U1 recording provider rounding before an epsilon is invented; Expand/Collapse → `ExpandCollapseState` re-read; Select → `is_selected`/container-value re-read; Scroll/ScrollTo → geometry (2.6's spine); Click/Invoke rungs → no state to re-read, `verified: false`. Re-reads go through fresh reads, never a value retained from before the write (A3-2's re-acquire discipline). Post-state: for `Toggle`/`Check`/`Uncheck`/`SetValue`/`Clear`/`Expand`/`Collapse`, after any delivery and inside budget, read the full `ElementState` through the existing live-read machinery (secure withholding inherited from `ElementProperties`) and attach it — macOS `post_state.rs` parity, including its action table (pointer/scroll/focus actions attach none). Any post-delivery read failure — including A14-9's succeeding-empty corpse shape and its environment-divergent CI twin — maps through an `after_delivery` wrapper to `delivered_unverified`, never `not_delivered`, never a bare read error. Precedence rule, pinned: where an action's delivery is judged by geometric observation (the scroll family), a completed observation's verdict overrides the classifier's disposition — bounds unchanged across a completed observation is `not_delivered` even when the invoke's HRESULT was transport-uncertain; the classifier supplies code, message, and `platform_detail`. Where no geometric observation exists (Invoke, Toggle, value writes), the classifier's disposition stands.- KTD7. **Secure fields: never read the secret, never claim what was not observed.** `ValuePattern.SetValue` into an `IsPassword` element proceeds under the same headless policy as any field (KTD10, `docs/phases.md:1108`), and then diverges from macOS deliberately: macOS skips the readback and reports the write trusted (`chain_verify.rs:60` returns `true` for secure fields — a `verified: true` no observation backs); §2.7's own contract says no step claims an effect it did not observe (`docs/phases.md:1105`), so Windows reports `verified: None` and the result stays `delivered_unverified`. Mechanics: every value-verification re-read routes through one helper that checks the element's `IsPassword` tri-state first — `Known(false)` reads and compares; `Known(true)` skips the read entirely; `Unknown` fails toward withholding (skips the read, `verified: None`) per the tri-state learning's asymmetric-cost rule — and a scan pins that `UIValuePattern::get_value`/`UIRangeValuePattern::get_value` appear nowhere in `actions/` outside that helper. Error echoes carry `value_chars` counts, never text (the trace-reachable-messages convention); post-state flows through `ElementProperties`, whose `IsPassword` gate already withholds value-bearing fields fail-closed (`element_properties.rs:64-88`). Core's `Clear` postcondition compares a withheld (absent) value — vacuously passing on secure fields — which is the honest reading: emptiness of a secret is itself withheld.- KTD8. **Placement, scan governance, and the preamble discipline.** New modules under `crates/windows/src/actions/`, mirroring the real macOS layout (the chain-family shape, not `CLAUDE.md`'s stale `activate.rs` listing — U10 corrects the map): `dispatch.rs` (the match), `chain.rs` (engine + step recording), `mutation.rs` (+ `mutation_tests.rs` — the classifier and its per-arm pins), `value_write.rs` (SetValue/Clear/RangeValue + the KTD7 gate), `toggle_state.rs` (Toggle/Check/Uncheck), `disclosure.rs` (Expand/Collapse), `select.rs`, `scroll.rs` (`Action::Scroll`), `scroll_ladder.rs` (KTD5 rung 2, sibling of the existing `scroll_into_view.rs`), `focus.rs` (KTD4.10), `post_state.rs` — each with a `*_tests.rs` sibling, each under the 400-line cap from birth (the tightest neighbors are `properties.rs` at 348 and `live_read.rs` at 351 — new code goes in new files, not those). Entry preamble in every path, in order: null-handle arm (KTD4.13), `uia_element` downcast, `ensure_budget(lease.deadline())`, `corroborate_verified_process` before the first write and again around post-write reads (the 2.6 precedent — a write against a corpse must not report observation-judged outcomes). Scan governance: `hit_test_scan_tests.rs`'s `PATTERN_ALLOWLIST` becomes a slice covering exactly the `actions/` files that invoke patterns, its covers-a-live-call-site tripwire generalizes to every entry, and the write-path ban (`scroll_into_view_tests.rs:211-231`'s shape — the three read-classifier names never appear) generalizes to one test scanning every mutation file; `get_pattern` stays banned everywhere else, `tree/` included. The advertise↔dispatch consistency of R2 is its own test: every capability `resolve_actions` can emit maps to a chain whose first gate can accept it. Test-double mechanism, stated because no COM mock exists or is wanted: the engine's rungs and gated reads are injected closures (KTD3's design), which is also the unit-test seam — call-count and outcome pins drive pure chain/dispatch logic with counting closures, the `scroll_into_view_judged_for` injected-observe precedent (`actions/scroll_into_view.rs:105-139`); live whole-pipeline coverage rides the crate's `tree/fixture.rs` harness, extended with the control shapes these chains need (checkbox incl. tri-state, slider, combobox, scrollable list) — as a sibling module, because `fixture_window.rs` sits at 393 of 400 lines.diff --git a/docs/plans/2026-08-30-001-feat-windows-2-15-hardening-integration-review-plan.md b/docs/plans/2026-08-30-001-feat-windows-2-15-hardening-integration-review-plan.mdindex 2a72629c1..7cf5f464b 100644--- a/docs/plans/2026-08-30-001-feat-windows-2-15-hardening-integration-review-plan.md+++ b/docs/plans/2026-08-30-001-feat-windows-2-15-hardening-integration-review-plan.md@@ -522,7 +522,7 @@ Each unit carries a **landing target** per KTD2: `2.15.0` (which merges first),- **Landing target:** none. This unit does not run.- **Requirements:** R21, R22 — dispositioned, not met.-- **Why:** U11 existed to run the full gate on U10's runner and to re-baseline `headed-double-click` and `interaction-scroll-to-visibility` against it. With no runner and no CI lane, there is nothing to run it on. The two legs' underlying facts are unchanged and are recorded rather than lost: **both fail identically when this branch's diff is stashed**, so neither is introduced here, and the dogfood independently observed the occlusion half live — a tray-click preflight's hit-tests were occluded by the driving console's own window, which is the operator's console rather than anything the harness controls.+- **Why:** U11 depended on U10's runner; that CI lane is absent. The local native gate is the executable replacement. It now passes `headed-double-click` and `interaction-scroll-to-visibility` after repairing native client-viewport measurement, vertical scroll oscillation and the fixture's physical click counter. The full local run passed 110 checks, failed none and skipped five absent-Chromium checks. Evidence: `tests/e2e-windows/InteractionHeaded.ps1`, `tests/e2e-windows/scenarios/Interaction.ps1`, `crates/windows/src/actions/scroll_ladder_tests.rs`.- **What travels, and to whom:** the harness repair itself — staging an occluder the harness owns, reusing `FixtureOcclusion.cs`'s existing `open-occluder`/`close-occluder`, `LibEnvelope.psm1`'s `Assert-EnvelopeCheckOccluder` and the present-then-closed pairing `scenarios/Acceptance.ps1` already exercises — is **not** owed to a later sub-phase, because the local run is now the gate and the repair belongs with whoever next runs it. It is written into §2.16's inherited-findings list alongside the five e2e legs that pass regardless of what they observe, since those are the same file family and the same reviewer's evidence.- **Verification:** none. A unit that does not run carries no test expectation; the disposition is what it is verified against.### U12. Audits, hunk index and the performance baseline