Skip to content

feat(macos): re-identify refs through the element's own accessibility address - #441

Merged
lahfir merged 25 commits into
laf/remove-macos-hostfrom
laf/identity-lean
Nov 2, 2026
Merged

lahfir merged 25 commits into
laf/remove-macos-hostfrom
laf/identity-lean

Conversation

@lahfir

@lahfir lahfir commented Nov 1, 2026 •

Copy link
Copy Markdown
Collaborator
  1. Since fix: remove the macOS command host #414 removed the macOS command host, a ref to a row that gets removed can click the row that moves into its place.
  2. A macOS ref now stores the element's own accessibility address, acts only on that exact element, and returns STALE_REF once it is gone.
  3. Builds on fix: remove the macOS command host #414. Replaces fix: resolve refs only through a unique recorded identity #429. The Linux and Windows rule follows in a stacked PR.
  • Each ref records the address _AXUIElementRemoteTokenCreate gives the element, looked up at runtime. A later command rebuilds that exact element with _AXUIElementCreateWithRemoteToken.
  • A removed element's address dies and is never reused, so it cannot land on a look-alike. A ref with an address never falls back to a search.
  • The address grants nothing: every use still needs the caller's own Accessibility permission (probes/macos/FINDINGS.md M1-11).
#414 this PR
wrong row hit, fixture 1 0
wrong row hit, Finder after a file is deleted 1 0
right twin hit, Chrome identical buttons after rows shift 0 1
refs that resolve, 4 apps 1050 / 1050 1050 / 1050
E2E checks passing 123 129

Speed (ms, native binary)

app get @ref #414 get @ref this PR snapshot #414 snapshot this PR
Finder 32.2 22.0 629 532
TextEdit 30.7 21.8 152 147
Safari 34.2 23.8 585 541
Chrome 33.2 21.9 317 294

lahfir added 13 commits November 1, 2026 00:46
…pture rule

macOS refs now carry a retained object from the accessibility remote-token
calls, looked up at runtime: a ref resolves to that exact element in a later
process, and a dead or mismatched one returns STALE_REF without a search.
Refs without one resolve only when they were unique over complete evidence at
capture and exactly one live element matches the same predicate now; anything
else is refused. Linux paths and Windows runtime ids no longer count as
identity. The in-memory retained session from the removed host is deleted.
…m each landing

The census now reads the observed evidence, so a twin holding an id second-hand or an unread field still counts. A path landing is re-checked against the recorded predicate before it is used, a resolution under a held lease reuses it, and shell-surface refs find their container again.
Tokenless refs already go through the shared capture rule in core, so the macOS path fast path and broad search had no CLI caller left. FFI find now lands its fresh match through the locator anchor on every platform.
Saved refs on Windows resolve through core's capture rule and the locator anchor, and FFI find lands through the anchor too, so the strict path walk, broad search, tie-break and chrome repair tiers were dead. The verified process stamp check moved into an anchor test.
… read

A shallow capture without element tokens now reads the whole window once, counts uniqueness there, and presents its skeleton or subtree cut from that same read, so skeleton anchors and drilled refs can resolve on Linux and Windows. A drill reuses the walk its root resolution performs. Captures whose refs all carry element tokens keep their single walk.
… substitution

macOS ships bash 3.2, which cannot parse a case pattern's closing paren inside $( ), so the assertion failed with a syntax error even though the hint was right.
…rills to their own capture

Pre-dispatch validation compared only a native id, so a recycled Linux path with new text could still take the action. A re-drill compared paths across captures and could prune its own root. Drill depth now counts from the drilled element, and a cut boundary that can never become a ref no longer forces a whole-window read.
The ref churn checks were skipped while a removed row's ref could land on its surviving neighbour. Element tokens fix that, so the checks run again, and the CHANGELOG limitation becomes the fix it now is.
@vercel

vercel Bot commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated
agent-desktop Ignored Ignored Preview, v0 Nov 2, 2026 8:03am UTC

… the lease for final pointer checks

Interval typing reused one handle after the first keystroke, so a replacement element could take the rest of the text; each keystroke now repeats the live identity check under its lease. Final hover and drag checks dropped the held lease and could wait on it again, and a tokenless drill skipped the depth validation every other snapshot runs.
@lahfir
lahfir requested review from Railly and ctate November 1, 2026 09:57
… came from

find materialized every tokenless ref with unique_at_capture false, so a unique match could not be used on Linux or Windows. It now runs the same census over its own observation when that observation is a complete whole-window read.
… Windows, prove rooted find refs

Linux menu refs scope a tokenless entry to the open popup instead of refusing it, and tests that relied on an AT-SPI path as identity now refuse replacements through the predicate. Windows anchors land by position and leave identity to core's full-predicate check. A tokenless find --root evaluates over the whole-window read its root resolution performs, so its refs carry that read's capture proof.
@vercel-internal-security-reviewer

Copy link
Copy Markdown

Security review details

…andings in FFI find, popup-bound menu refs

Every tokenless ref is now proven by its own recorded predicate over the whole-window read it was published from, at snapshot, drill, find and hydration alike. FFI find re-identifies a landed handle before publishing it. A Linux menu ref keeps its popup binding through positional landing and is refused without it.
…e exhaustive check, align docs

The exact-entry FFI calls now always refuse, so the ABI major moves to 7 and the docs say so. Capture proof and tokenless resolution share one ObservedTree::is_exhaustive check, LivePredicate moves to its own file, and AGENTS.md, the CHANGELOG, the Linux skill and the Windows twin E2E leg describe the capture rule as shipped.
…dentified

A boundary container is offered as a drill anchor only when it carries an element token or the capture proof found it once, so twins and unread windows no longer hand out anchors that fail when drilled.
The Linux and Windows capture rule moves to a stacked follow-up. This leaves the macOS element-address resolution on top of the existing resolvers, with the core and the other platforms as they were before this branch.
@lahfir lahfir changed the title feat(identity): resolve refs through element addresses and a capture rule feat(macos): re-identify refs through the element's own accessibility address Nov 1, 2026
@lahfir
lahfir added this pull request to stack #444 November 1, 2026 11:44
@lahfir
lahfir merged commit b4926b5 into main Nov 2, 2026
24 checks passed
lahfir added a commit that referenced this pull request Nov 2, 2026
lucamaraschi added a commit to lucamaraschi/agent-desktop that referenced this pull request Nov 3, 2026
Main removed the macOS command host (vercel-labs#414) and re-identifies tokenless
refs through a capture rule (vercel-labs#441, vercel-labs#442).

- Every command is now its own process on macOS too, so the policy layer
  drops the host forwarding of AGENT_DESKTOP_POLICY_DIR, reads it
  directly, and the one-shot checkpoint test runs on macOS as well.
- A ref action now finds the ref's app and window before it reads the
  element, so the policy scenario desk lists each seeded ref's app and
  window and counts the element read at observe_tree.
- The live window_at_point grid test accepts the owner's name over
  another user's window when the hit test can read that owner's identity
  (root's loginwindow), as well as the refusal.
lucamaraschi added a commit to lucamaraschi/agent-desktop that referenced this pull request Nov 4, 2026
Main removed the macOS command host (vercel-labs#414) and re-identifies tokenless
refs through a capture rule (vercel-labs#441, vercel-labs#442).

- Every command is now its own process on macOS too, so the policy layer
  drops the host forwarding of AGENT_DESKTOP_POLICY_DIR, reads it
  directly, and the one-shot checkpoint test runs on macOS as well.
- A ref action now finds the ref's app and window before it reads the
  element, so the policy scenario desk lists each seeded ref's app and
  window and counts the element read at observe_tree.
- The live window_at_point grid test accepts the owner's name over
  another user's window when the hit test can read that owner's identity
  (root's loginwindow), as well as the refusal.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants