Skip to content

Engine: a control relabelled in place (same handle, Save to Delete) passes the stale-point guard #298

Closed

Description

@SSFSKIM

Problem

#296's stale-point guard can't see one case: a surviving element relabelled in place. For example, an app keeps the same AXButton but changes its title from Save to Delete between the screenshot and the click. The handle is the same element, its frame still contains the point, and the hit is the same element, so the guard passes, and the click lands on what is now Delete.

The guard can't refuse on a changed title of the same handle. If it did, it would refuse every button whose own label ticks (a counter in the label, a timer), which #296's false-positive spike measured as correct passes. That spike: https://github.com/SSFSKIM/cua/actions/runs/42179036967 and https://github.com/SSFSKIM/cua/actions/runs/42180641939, kit probe/296-hosted.

The design session ruled it a stated limit of #296, with an A/B cell showing the pass (1ea561bc 0c0b70f0).

Intent

Find a signal that separates a relabel that changes the control's meaning (Save to Delete) from a label that changes as content (Like (12) to Like (13), a ticking timer), without refusing the latter. Candidates:

  • the change's shape (digits only, against words);
  • AXIdentifier or a DOM id where present;
  • the role description or the action list changing.

Measure before building.

Constraints

Success criteria

Activity

  1. added
    enhancement
    status:ready-for-implementer
    priority:P3
    on Nov 6, 2026
  2. SSFSKIM commented on Nov 6, 2026

    @SSFSKIM
    OwnerAuthor

    The design session clarified this on 2026-11-06 (1ea561bc 2db3ba75): the blind spot covers containers too. A truncated container checked by #296's guard counts as the observed one on its live handle while its re-read frame still holds the point, and its title is not compared. So a container relabelled in place while keeping its handle passes, just as any node does. Without that rule, a page title that gains a notification count would refuse every click into the budget-cut part of a large page. Any rule this ticket arrives at should cover both cases.

  3. SSFSKIM commented on Nov 9, 2026

    @SSFSKIM
    OwnerAuthor

    #298 measured: a word rule on the label separates a relabel from a content change. Structural attributes don't.

    Measurement only. Nothing was built: the rule would live in StalePoint.swift, and its build is sequenced after #330.

    Finding. In Chrome for Testing, Safari and AppKit, a control relabelled in place keeps its AX handle in every case measured: 82 cells (35 Chrome, 34 Safari, 13 AppKit), 12 to 18 repetitions each on 6 hosted runners. Nothing structural moves with the label unless the page moves it itself. AXDOMIdentifier, the DOM class list, AXIdentifier, the role, role description and action list, and AXHelp each have zero false positives. But each caught only the cell where the page deliberately changed that attribute, and none of them moved on the canonical Save -> Delete (a text change). So no structural signal exists. The signal is the label's words.

    The rule that works: compare the recorded label's words with the label read now, after setting aside every number together with the words that follow it up to the next punctuation mark. It refuses all 33 meaning cells measured, including a dialog container and the text inside links and clickable divs, and every state flip that changes the label. It passes every content change measured: #296's ticking labels, counts, plurals, relative times, "Inbox (3)", "Notifications, 3 new", and tab, window, web-area and group titles gaining "(3)". Replayed over #296's own false-positive spike, it refuses 0 of the 132 cells that #296 passed on a kept handle. Its one live false positive is a same-meaning translation ("Save" -> "Guardar"). Its structural misses are labels that differ only by a number ("Order #1234" -> "Order #1235").

    A second finding came out of measuring the deepest node. For a link or a clickable div, #296's guard records the AXStaticText inside the control, and that node's words are in AXValue, which neither the record nor the re-created match compares. So the blind spot is wider than this ticket says. A framework-style text update (nodeValue) keeps the text's handle with new words. A same-width replacement re-creates it, and #296 matches the new one anyway. Both pass Save -> Delete today. Separately, #296 already refuses a link whose text is replaced with a width change, even when only the content changed ("Inbox" -> "Inbox (3)"); see limit 6.

    Runs

    Branch probe/298-measure (kit scripts/probe-298/: measure.mjs, tool.swift, app.swift, analyze.mjs, replay-296.mjs; workflow .github/workflows/probe-298.yml). No engine and no click. A standalone AX tool holds each cell's handle and reads every candidate attribute in one batched request at three moments: the "observation"; 1 s later with nothing changed, to show the drift a ticking label makes on its own; and "click time", 5 s after the observation and 3 s after the page or app changed every cell at once. Each read also hit-tests the observed centre, and when the deepest node's handle is gone the tool runs #296's re-created search on it. macOS 26.7.2, Chrome for Testing 156.0.8078.80, Safari 27.2.

    Each run used 2 runners x 3 repetitions per surface. Every cell was found and every change was applied on all 6 runners, and the repetitions agree cell by cell.

    Cells x signals

    C = Chrome for Testing, S = Safari, N = AppKit. "Same handle" counts the handle still alive at click time (and, on the page, still the element its locator finds). R = refuses, · = passes. digits: refuse when the label differs once digit runs are masked. kept: refuse when a word of the old label is gone from the new one (a word counts as kept if some new word starts with it). proposed: refuse when the words differ after setting aside each number and the words that follow it up to the next punctuation mark; window and web area exempt. structural: which of AXDOMIdentifier, class list, AXIdentifier, role/description/actions, AXValue, AXHelp changed.

    cell truth surfaces, same handle label at observation -> click structural change digits kept proposed
    tick (#296's ticking label) content C S N 18/18 "Elapsed 11.6 s" -> "Elapsed 17.2 s" none · · ·
    nextto (#296's counter beside a button) content C S 18/18 "Next to" unchanged none · · ·
    like content C S N 18/18 "Like (12)" -> "Like (13)" none · · ·
    items content C S N 18/18 "1 item" -> "2 items" none R · ·
    reltime (link) content C S 18/18 "1 minute ago" -> "2 minutes ago" none R · · (see deepest node)
    inbox (link) content C S 18/18 "Inbox" -> "Inbox (3)" none R · · (see deepest node)
    notif (aria-label) content C S 18/18 "Notifications" -> "Notifications, 3 new" none R · ·
    tab (Chrome's tab button) content C 18/18 "probe298 page" -> "(3) probe298 page" none R · ·
    region, labelledby (groups) content C S 18/18 "Inbox" -> "Inbox (3)" none R · ·
    window, web area content C S N 18/18 "probe298 page" -> "(3) probe298 page" none R · · (exempt; passes anyway)
    loc same meaning C S 18/18 "Save" -> "Guardar" none R R R
    follow, play, more flip C S N 18/18 "Follow" -> "Following", "Play" -> "Pause", "Show more" -> "Show less" none R R only for play and more R
    saved flip C S 18/18 "Save" -> "Saved" none R · R
    followp (aria-pressed) flip C S 18/18 "Follow" -> "Following" S AXValue 0 -> 1; C none (AXValue "" both) R · R
    toggle (AppKit on/off) flip N 18/18 "Follow" unchanged (alternateTitle not exposed) AXValue 0 -> 1 · · ·
    save, saveid (DOM id kept), btnnv, spanbtn meaning C S 18/18 (btnnv, spanbtn 12/12) "Save" -> "Delete" none R R R
    saveidchg meaning C S 18/18 "Save" -> "Delete" AXDOMIdentifier save-2 -> delete-2 R R R
    saveclass meaning C S 18/18 "Save" -> "Delete" class primary -> danger R R R
    savearia (aria-label, title attribute) meaning C S 18/18 "Save" -> "Delete" AXHelp Save -> Delete R R R
    popup (aria-haspopup added) meaning C S 18/18 "Save" -> "Delete" C: AXButton -> AXPopUpButton on the same handle; S none R R R
    deleteall meaning C S N 18/18 "Delete" -> "Delete all" none R · R
    relabel (#296's limit ii), noid, alabel (AXDescription) meaning N 18/18 "Save" -> "Delete" none R R R
    save-2 meaning N 18/18 "Save" -> "Delete" AXIdentifier save-2 -> delete-2 R R R
    dialog (container) meaning C S 18/18 "Save changes?" -> "Delete file?" none R R R
    divbtn (clickable div) meaning C S 12/12 the group has no label; its text "Save" -> "Delete" none see deepest node R on the text

    The deepest node at the point, which is what #296's record takes. Chrome and Safari flatten a button's text into the button, but a link's or a clickable div's text is its own AXStaticText, whose words are only in AXValue. Each row is 12/12 on 4 runners.

    cell truth text at observation -> click its handle #296 today proposed
    linknv (nodeValue) content "Inbox" -> "Inbox (3)" kept kept pass
    linksavenv (nodeValue) meaning "Save" -> "Delete" kept kept refuse
    divbtn (nodeValue) meaning "Save" -> "Delete" kept kept refuse
    divtick (nodeValue, ticking) content "Elapsed 10.7 s" -> "Elapsed 16.3 s" kept kept pass
    linkmono (textContent, same width) meaning "Save" -> "Send" re-created within 2 pt kept (re-created) refuse (re-created path)
    linklike (textContent, same width) content "Like (12)" -> "Like (13)" re-created kept (re-created) pass
    linksave (textContent) meaning "Save" -> "Delete" gone, nearest 8 pt refused (nodeGone) refused
    inbox, reltime (textContent) content "Inbox" -> "Inbox (3)", "1 minute ago" -> "2 minutes ago" gone, nearest 20 and 6 pt refused (nodeGone), a false positive of #296 today unchanged

    Each candidate's false positives and misses

    Live counts are measured cells. The corpus is 50 label pairs beyond the live cells, judged by the strings alone; that is sound because every live cell showed the label delivered verbatim on the kept handle (the corpus table is in analyze.mjs's output).

    • Any label change (the rule Engine: refuse a coordinate click whose screenshot target has moved or been replaced (stale-point guard) #296 rejected): refuses every content cell, including Engine: refuse a coordinate click whose screenshot target has moved or been replaced (stale-point guard) #296's ticking labels.
    • Digits only: passes Engine: refuse a coordinate click whose screenshot target has moved or been replaced (stale-point guard) #296's cells but refuses 23 measured content or same-meaning cells ("1 item" -> "2 items", "Inbox (3)", "Notifications, 3 new", every title gaining "(3)"). Corpus: 20 false positives.
    • Words kept (subtractive: additions never refuse): live false positive "Guardar"; live miss "Delete" -> "Delete all". It passes the stem-keeping flips (Follow -> Following, Save -> Saved). Corpus misses include "Allow" -> "Don't Allow" and "Continue" -> "Continue and pay $9.99"; corpus false positives "1 reply" -> "2 replies", "Starts in 1 minute" -> "Starts in 59 seconds", Russian plurals.
    • Words beside numbers set aside (proposed): live false positive "Guardar" only; live misses none; every label-changing flip refused. Corpus false positives (6): "just now" -> "1 minute ago"; "Today" -> "Yesterday"; "No notifications" -> "3 notifications"; two document-title flashes (the window and web-area exemption covers them, except on Chrome's tab button); "Guardar". Corpus misses (3): "Order #1234" -> "Order #1235", "Nov 8 standup" -> "Nov 9 standup", "Delete 1 file" -> "Delete 3 files".
    • Setting aside only the one word after a number: the same, plus a false positive on "1 new message" -> "2 new messages".
    • AXDOMIdentifier, class list, AXIdentifier, role/description/actions, AXHelp: zero false positives; each caught only the cell built to change it, so every Save -> Delete without that deliberate change is missed. The walk does not read AXDOMIdentifier at all (Fetch.swift's observedAttributes).
    • AXValue: catches a toggle's flip where the label stays (AppKit on/off; Safari aria-pressed). Chrome exposes no value for aria-pressed. It misses every relabel.

    Proposal

    Build one rule, relabelled (refuses), in StalePoint.swift, after #330.

    The label. A node's label is its title if non-empty, else its description, else its value when the node is an AXStaticText. A label's words are its lowercased letter runs after taking out every number (a digit run with internal ., , or :) together with the letter words that follow it up to the next punctuation mark.

    Same-handle check (new). When the recorded node is found by its own handle and its frame still holds the point, refuse relabelled when the recorded role is neither AXWindow nor AXWebArea, both labels are non-empty, and the recorded label's words differ from the words of the label read now.

    Re-created path. Extend stalePointLabelsAgree: when neither side has a title or description and both have an AXStaticText value, the values must have the same words. Titles and descriptions keep exact equality, as amendment 0c0b70f0 set it.

    Containers are covered by the same rule: a group, region or dialog gaining a count passes; a dialog changing meaning refuses. Document titles are exempt, because they flash and gain tab-state suffixes ("Ann messaged you", "- Audio playing"); #316's otherWebArea already guards the document's identity.

    Reuse and cost. ScreenshotNode already keeps title and description; it gains the value for AXStaticText only, which the walk already reads (ElementData.value), so the cost is memory only. At click time, StalePointReads already has title and description closures (the re-created search's); it gains value, and the handle path makes those 2 to 3 reads on one element. In this spike a batched read of 17 attributes on one element took 0.18 ms median, 1.4 ms p99 and 5.2 ms max over 1,368 reads in the three apps. The rule is pure string logic over the closures, so it can be unit-tested on the fake tree.

    Cells for the build's A/B (scripts/probe-298/measure.mjs's page and app carry them all). Must refuse: save, btnnv, linksavenv, divbtn, linkmono, savearia, deleteall, dialog (C, S); relabel (#296's limit ii, which flips from kept to refused), alabel, noid (N); follow and play (C, S, N). Must pass: #296's ticking label at 1, 5 and 20 s (C, S, N), counter/nextto, like, items, notif, linknv, divtick, linklike; Chrome's tab gaining "(3)", region, labelledby; window and web-area titles gaining "(3)". Plus #296's final A/B set unchanged.

    Limits (to state in the Decision Log):

    1. A label that differs only by a number passes: an index-keyed list recycling a row ("Order #1234" -> "Order #1235", "Item 9" -> "Item 10", "Nov 8" -> "Nov 9"), or a count of what the action applies to ("Delete 1 file" -> "Delete 3 files"). Any rule that passes counters passes these.
    2. Content whose words roll without a number refuses: "just now" -> "1 minute ago", "Today" -> "Yesterday", "No items" -> "1 item". Such a label rolls at most once a minute, so this is rare within one screenshot-to-click gap.
    3. A translation in place refuses ("Save" -> "Guardar").
    4. Document titles are not compared. Chrome's tab button carries the document title and is a control, so a flashing title refuses a click on that tab; exempting the AXTabButton subrole is an option.
    5. A toggle whose label stays the same passes: AppKit's alternateTitle isn't exposed, and Chrome's aria-pressed has no AXValue. Comparing a checkbox's AXValue would catch the AppKit and Safari cases; it is left out because a checkbox's value can legitimately be the thing that changed.
    6. This rule doesn't touch an existing false positive of Engine: refuse a coordinate click whose screenshot target has moved or been replaced (stale-point guard) #296: a link whose text is replaced (textContent) with a width change is refused as nodeGone, even for content ("Inbox" -> "Inbox (3)", "1 minute ago" -> "2 minutes ago"; 12/12 on Chrome and Safari). Engine: refuse a coordinate click whose screenshot target has moved or been replaced (stale-point guard) #296's spike had no link whose label changed. This is worth its own ticket: the re-created search could accept a text frame that grows from the same origin when its words agree by this rule.

    Sminos-Session: cursor235#b93055dd (cua on macbook)

  4. SSFSKIM commented on Nov 9, 2026

    @SSFSKIM
    OwnerAuthor

    Ruling (design session 1ea561bc, 31a62775)

    Sminos-Session: cursor235#b93055dd (cua on macbook)

  5. 10 remaining items

  6. added
    status:in-review
    and removed
    status:in-progress
    on Nov 10, 2026
  7. SSFSKIM commented on Nov 10, 2026

    @SSFSKIM
    OwnerAuthor

    [board] in-review: PR #355 open, gates accepted 1ea561bc:569

  8. removed
    status:in-review
    on Nov 10, 2026
  9. SSFSKIM commented on Nov 10, 2026

    @SSFSKIM
    OwnerAuthor

    [board] done: Landed via PR #355 (0.27.24)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementpriority:P3

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions