dsh-windows-parallel-mcp 0.1.5 → 0.1.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -4,6 +4,52 @@ Dates are the registry `time` values for each version, not git commit dates —
4
4
  when someone typed, a publish time records when a version became installable, and only the second
5
5
  one is a promise to anyone installing it.
6
6
 
7
+ ## 0.1.6 — 2026-11-21
8
+
9
+ Two failures that shared one refusal code are split — because the reader's next step differs.
10
+
11
+ **The defect.** Everything door-less came back `unreachable`. Two of its causes are opposites: a
12
+ tree that was never populated (the application has UI Automation off — measured on this desktop:
13
+ uTools walks to zero content elements on three in-place reads spanning 2.2 s and never grows one),
14
+ and a probe that threw (the tree could not be measured at all). The probe's own diagnostic was
15
+ already being produced and then wasted: `uiaErr` reached the result object only as a reason-string
16
+ suffix that nothing branched on — 0.1.5's point-probe work found it as dead data. A caller reading
17
+ `unreachable` could not tell "pick another target" from "make the app enable accessibility" from
18
+ "read the exception".
19
+
20
+ **Fixed**
21
+ - **`uia_tree_empty`** — the walked tree holds **zero content elements**. The criterion is
22
+ structural, not numeric: Pane/Group/Image/Text/Thumb/Separator/TitleBar are the window's own
23
+ shell; anything else (Button, Edit, Document, Custom) is something an application chose to
24
+ expose. Count alone lies — an a11y-off Chromium window still exposes one
25
+ `Chrome_RenderWidgetHostHWND` shell pane, and the same uTools window measured raw=0 and raw=1
26
+ the same day depending on its own state while content stayed 0 throughout. The reason states
27
+ the observation, not an exclusive cause: a provider that answers nothing (a hung pump) reads as
28
+ empty too, instantly, without throwing — that second cause is documented, not hidden.
29
+ - **`uia_probe_failed`** — the probe threw before it could measure; no conclusion about the
30
+ target is licensed. The exception text rides the reason as `[uia: …]`. Measured: WM_CLOSE
31
+ landing 40 ms into the call (between the `IsWindow` check and `FromHandle`) returns this code
32
+ with the original exception text, not `unreachable`. Probe failure outranks tree-empty — a
33
+ measurement that threw cannot also certify emptiness — and a usable door outranks both.
34
+ - **The refusal reason carries the probe's context for all three codes**: which point was probed
35
+ and what it found there, plus the exception when one exists. A diagnosis with the evidence
36
+ redacted is not a diagnosis.
37
+
38
+ **Also**
39
+ - The reverse assertion about Chromium's "lazy" accessibility is written where the next reader
40
+ will trip over it (`scripts/chromium-a11y-flag.mjs` conclusion, README's measurement section):
41
+ the same window re-read in place three times (+0/+700/+1500 ms) never grew content, an a11y-on
42
+ tree answers completely on the first query — so the engine does NOT re-query with a deadline
43
+ and no retry exists anywhere. The instrument ships:
44
+ `scripts/uia-tree-content.ps1` reads the same two counters with the same shell-type table the
45
+ engine decides on.
46
+
47
+ Measured instances behind every claim above: real-window end-to-end refusals for all three codes
48
+ (`uia_tree_empty` via both the scan and the point path on uTools; `unreachable` on a tree-alive
49
+ window; `uia_probe_failed` on a mid-probe destroy), decision-table arms for each new branch and
50
+ its precedence, and `refusals-test` 11 passed with 2 codes still declared uncovered
51
+ (`action_failed`, `restore_failed`).
52
+
7
53
  ## 0.1.5 — 2026-11-21
8
54
 
9
55
  A click that acted on the wrong control, and returned `ok:true` while doing it.
package/README.md CHANGED
@@ -1,11 +1,14 @@
1
1
  # dsh-windows-parallel-mcp
2
2
 
3
- > **0.1.3 — the proof now says who reported the success, not just that you were undisturbed.** The
4
- > name was reserved earlier under a weaker claim (see [CHANGELOG.md](CHANGELOG.md)); the claim below
5
- > is the measured one. 0.1.1 is 0.1.0's behaviour with a corrected packaging chain; 0.1.2 added the
6
- > runtime proof chain (`proof=` verdict and `proofDimensions`, measured against the desktop around
7
- > your own call); 0.1.3 adds the second half — `effect=` — and lets it enter the judgment, so a call
8
- > that accomplished nothing can no longer read as `proof=pass`.
3
+ > **0.1.6 — a refusal now says which world it saw.** `unreachable` used to cover two failures with
4
+ > different fixes: a tree that holds no content at all (the application has UI Automation off;
5
+ > nothing to re-query for — which is why the engine never retries) is now `uia_tree_empty`, and a
6
+ > probe that threw before it could measure (no conclusion about the target is licensed; the
7
+ > exception text rides the reason) is now `uia_probe_failed`. 0.1.5 made a click act on the point
8
+ > it names; 0.1.3 added `effect=` — who reported the success — and let it enter the judgment, so a
9
+ > call that accomplished nothing can no longer read as `proof=pass`; 0.1.2 added the proof chain
10
+ > (`proof=`, `proofDimensions`, measured against the desktop around your own call); 0.1.1 is
11
+ > 0.1.0's behaviour with a corrected packaging chain. Full history: [CHANGELOG.md](CHANGELOG.md).
9
12
 
10
13
  A DSH plugin that lets an agent drive **its own** Windows windows without moving your cursor. Where
11
14
  a window accepts a window message, you never lose focus at all. Where it only exposes UI Automation,
@@ -62,8 +65,8 @@ silently claims the documented key works. `overlay=true` in settings controls th
62
65
  flag itself is engine-side and refuses actions with `paused`.
63
66
 
64
67
  Refusals are a normal result, not an error: `no_hwnd`, `paused`, `elevated_target`, `unreachable`,
65
- `terminal_no_door`, `needs_facts`, `action_failed`, `restore_failed`. Each carries a reason and a
66
- next step — see [docs/refusals.md](docs/refusals.md).
68
+ `uia_tree_empty`, `uia_probe_failed`, `terminal_no_door`, `needs_facts`, `action_failed`,
69
+ `restore_failed`. Each carries a reason and a next step — see [docs/refusals.md](docs/refusals.md).
67
70
 
68
71
  **Every real click carries its own disturbance proof.** `click` returns a `proof=pass|inconclusive|…`
69
72
  verdict plus a `proofDimensions` field (cursor / foreground / focus). Around your call the engine
@@ -156,6 +159,17 @@ goal statement did not survive it. Kept here rather than quietly dropped:
156
159
  UIA `Invoke` was foreground-neutral in 0 of 12 rounds — the earlier 6/6 and 12/12 were measured
157
160
  under a construction that first took the foreground away. The flash tier is a fuse, not a promise
158
161
  of disturbance.
162
+ - **An empty accessibility tree is a switch, not a delay.** The alternative reading — Chromium
163
+ activates renderer accessibility on demand, so the tree might be merely slow — was tested, not
164
+ assumed away: the same window was re-read in place three times (+0/+700/+1500 ms,
165
+ `scripts/uia-tree-content.ps1`). uTools read **0/0/0** descendants, zero interactive content
166
+ elements every time (one earlier peek the same day saw a single `Chrome Legacy Window` shell
167
+ pane appear, content still 0); DSH on the same desktop read a real tree on the **first** query
168
+ (514 at census time, 1019 raw / 85 content on re-read). Nothing ever trickled in. So the
169
+ engine refuses with `uia_tree_empty` and does **not** poll — there is nothing to wait for — and
170
+ the actual switch is a launch-time state (`--force-renderer-accessibility`) the engine cannot
171
+ impose on a browser the user already has open. `unreachable` is the other world: the tree is
172
+ alive and offers nothing at the named point or element.
159
173
 
160
174
  `elevated_target` is measured live: the engine compares the target's integrity RID against its own
161
175
  and refuses before acting (verified on an elevated Task Manager; 19 medium windows, zero
package/docs/refusals.md CHANGED
@@ -19,22 +19,24 @@ R2′ 把「拒绝」当成本产品的**正常结果**(`engine.ps1` 首段注
19
19
 
20
20
  | 层 | 出处 | 数量 | 语义 |
21
21
  |---|---|---|---|
22
- | 决定层 | `src/engine/decide.ps1` 的 `$WpmRefusals` | 6 | 动作**在执行之前**被合法否决,目标本身没被碰过 |
22
+ | 决定层 | `src/engine/decide.ps1` 的 `$WpmRefusals` | 8 | 动作**在执行之前**被合法否决,目标本身没被碰过 |
23
23
  | 运行时失败层 | `src/engine/engine.ps1` 执行/回还段 | 2 | 决定说「能做」,做的过程中通道炸了或回还没成 |
24
24
 
25
- 混在一起会让人以为「8 个码都是设计好的分支」,实际后 2 个是**兜底**:它们出现就意味着
25
+ 混在一起会让人以为「10 个码都是设计好的分支」,实际后 2 个是**兜底**:它们出现就意味着
26
26
  引擎的判断与实际能力不一致,属于需要调查的信号,不该被当成正常分支来轮询。
27
27
 
28
- ## 决定层(6 码)
28
+ ## 决定层(8 码)
29
29
 
30
30
  | 码 | 触发条件(代码位置) | 语义 | 下一步动作 | 实测状态 |
31
31
  |---|---|---|---|---|
32
- | `no_hwnd` | `engine.ps1:109`(hwnd 不是活窗口)/`decide.ps1:73`(未给 hwnd) | 没有可用目标 | 先调 `wpm_windows` 拿 hwnd,再重试;不要用屏幕坐标猜 | **REAL** — `test/refusals-test.ps1` R1:`hwnd=1` 直接返回该码 |
33
- | `paused` | `decide.ps1:69`(`$script:WpmPaused`) | 所有者按了暂停 | 停手。这是**服务端**拒绝,不是提示层建议;不要换目标绕过 | **REAL** — R2:真实桌面上把 paused 打开,`status` 返回该码 |
34
- | `elevated_target` | `decide.ps1:77`(`facts.elevatedTarget`);flag 由 `win.ps1` 的 `WpmWin::IsElevatedTarget` 实测置真 | 目标完整性级别更高,当前进程写不进去 | 让所有者用非提权方式重开该程序;不要提权重试 | **REAL** — 2026-11-20 `test/integrity-probe.ps1`:桌面上任务管理器(0x3000 high)被识别,`Get-WpmFacts` → `elevatedTarget=True`,决策 `refuse/elevated_target`;其余 19 个 medium 窗零误判 |
35
- | `unreachable` | `decide.ps1:111`(测过:无消息门、无可用 pattern);运行时窄路 `engine.ps1:150,159,165,185,195` | 目标没有任何可在不注入物理输入的前提下使用的门 | 换目标;或让目标暴露可寻址子窗(原生 Win32/WinForms) | **REAL** — R3:WinForms 目标按名字取控件 → 消息门被抑制、WinForms 无 pattern → 该码 |
36
- | `terminal_no_door` | `decide.ps1:84`(family=terminal 且两门皆无) | 终端文字面既不暴露子 HWND,也没有 Document 元素 | 换目标(浏览器地址栏/记事本等),终端不在可驱动面内 | **SIMULATED** — 判定层注入。真实终端窗实测刻意推迟,理由见下 |
37
- | `needs_facts` | `decide.ps1:65,107` | 调用方没给这个目标的实测事实 | 先测量再决定。**拒绝,而不是默认走安静档** | **REAL(表级)** — 引擎内不可达:`facts` 恒被测量,本码只在表被单独使用时出现 |
32
+ | `no_hwnd` | `engine.ps1:180`(hwnd 不是活窗口)/`decide.ps1:85`(未给 hwnd) | 没有可用目标 | 先调 `wpm_windows` 拿 hwnd,再重试;不要用屏幕坐标猜 | **REAL** — `test/refusals-test.ps1` R1:`hwnd=1` 直接返回该码 |
33
+ | `paused` | `decide.ps1:79`(`[WpmCtl]::Paused`) | 所有者按了暂停 | 停手。这是**服务端**拒绝,不是提示层建议;不要换目标绕过 | **REAL** — R2:真实桌面上把 paused 打开,`status` 返回该码 |
34
+ | `elevated_target` | `decide.ps1:89`(`facts.elevatedTarget`);flag 由 `win.ps1` 的 `WpmWin::IsElevatedTarget` 实测置真 | 目标完整性级别更高,当前进程写不进去 | 让所有者用非提权方式重开该程序;不要提权重试 | **REAL** — 2026-11-20 `test/integrity-probe.ps1`:桌面上任务管理器(0x3000 high)被识别,`Get-WpmFacts` → `elevatedTarget=True`,决策 `refuse/elevated_target`;其余 19 个 medium 窗零误判 |
35
+ | `unreachable` | `decide.ps1:143`(测过:无消息门、无可用 pattern,**且树里有内容**);运行时窄路 `engine.ps1:246,255,261,275,281,291` | 树是活的、点也认了,但那个点/那个名字上没有任何可用 pattern——「换一处或换目标」的世界 | 换目标、换坐标或换元素名;或让目标暴露可寻址子窗(原生 Win32/WinForms) | **REAL** — R3:WinForms 目标按名字取控件 → 消息门被抑制、WinForms 无 pattern → 该码 |
36
+ | `uia_tree_empty` | `decide.ps1:140`(`facts.uiaTreeEmpty`,由 `win.ps1` 的 `Test-WpmUiaTreeHasContent` 实测:树内 **0 个内容元素**) | 树里只剩壳,一个可驱动的内容元素都没有。**主成因**(2026-11-21 普查实测):应用侧没开无障碍(uTools:raw=1/1/1、其中 0 个可交互元素,三连读全等;同日普查测得 raw=0/0/0——壳来去,内容从不出现)。**已知第二成因**(同轮挂泵靶窗实测):泵挂死的应用对 WM_GETOBJECT 不作答,UIA 立即回 0 个元素——同一观察,成因不同 | 让应用以开启无障碍的方式重启(Chromium:`--force-renderer-accessibility`,启动期开关);或换目标。若目标同时处于「未响应」状态,先等应用恢复。**不要重试轮询**——三次原位重查证明等不出内容 | **REAL** — 2026-11-21 对 uTools 真窗实测引擎端到端返回该码(扫描与点两条路);对照 DSH 同桌首读即出真树(普查 514、复测 1019) |
37
+ | `uia_probe_failed` | `decide.ps1:136`(`facts.uiaProbeFailed`,即探针 `uiaErr` 非空) | 探针本身抛了异常(元素在测量中途被销毁等),**树测没测成**——对目标下任何结论都无凭据 | 读 reason 里 `[uia: …]` 段的异常原文再判断;不要把它当成「目标不可达」的证据,也不要自动重试 | **REAL** — 2026-11-21 探针异常实例:WM_CLOSE 于调用后 40ms 落进探针(`IsWindow` 已过、`FromHandle` 抛「无法识别的错误」),返回该码且 reason 带 `[uia: …]` 异常原文 |
38
+ | `terminal_no_door` | `decide.ps1:96`(family=terminal 且两门皆无) | 终端文字面既不暴露子 HWND,也没有 Document 元素 | 换目标(浏览器地址栏/记事本等),终端不在可驱动面内 | **SIMULATED** — 判定层注入。真实终端窗实测刻意推迟,理由见下 |
39
+ | `needs_facts` | `decide.ps1:77,119` | 调用方没给这个目标的实测事实 | 先测量再决定。**拒绝,而不是默认走安静档** | **REAL(表级)** — 引擎内不可达:`facts` 恒被测量,本码只在表被单独使用时出现 |
38
40
 
39
41
  ## 运行时失败层(2 码)
40
42
 
@@ -57,6 +59,14 @@ R2′ 把「拒绝」当成本产品的**正常结果**(`engine.ps1` 首段注
57
59
  3. **`terminal_no_door` 只有判定层实测。** 本轮不拉真实终端窗口,是因为 `findings.md:311-316` 记录过一次
58
60
  `wt --headless` 残留 Error 弹窗事故(单实例转发 + 弹窗归属真实宿主,`Stop-Process` 够不到)。
59
61
  真实证据是覆盖率普查:`findings-G0-VERDICT.md` 的 `uap-framed` 30 窗 0 门。
62
+ 4. **`uia_probe_failed` 的可执行用例只有判定层一条**(schema 里 `click-uia-probe-failed`,decision 模式)。
63
+ 引擎级用例需要「探针必然抛异常」的稳定构造,本轮拿到了**真样本**但没固化成可复跑用例:构造是
64
+ 「引擎调用开始后 N ms,由一个原生 OS 线程向靶窗投递 WM_CLOSE」(销毁落在 `IsWindow` 与
65
+ `FromHandle` 之间的窗口里);2026-11-21 扫描 40ms 一档即命中(reason 带 `[uia: …FromHandle…
66
+ 无法识别的错误…]`)。它是竞态:延迟档位选错就落到 `no_hwnd`(先销毁)或 `unreachable`
67
+ (后销毁),而「只销毁控件不销毁窗体」和「泵挂死」两个变体都会被逐元素的内部 catch 吞掉、
68
+ 读成 `uia_tree_empty` 而不是抛错——所以做成 schema 可执行用例需要一个能精确中断跨进程 COM
69
+ 的靶窗,留给后续轮次。
60
70
 
61
71
  ## 与工具 schema 的关系
62
72
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-windows-parallel-mcp",
3
- "version": "0.1.5",
3
+ "version": "0.1.6",
4
4
  "publishConfig": {
5
5
  "access": "public",
6
6
  "tag": "latest"
@@ -8,10 +8,15 @@
8
8
  # them, and it is kept free of IO so a wrong verdict cannot hide behind a passing desktop.
9
9
  #
10
10
  # THE FACTS IT CONSUMES, and where each came from:
11
- # messageDoor -- 17/57 live windows expose a classic child door (neutral-coverage-census)
12
- # hasPattern -- WPF/UWP/Chromium expose UIA patterns; WinForms exposes none (probe-winform)
13
- # cursor cost -- zero in every channel (channel-raise-matrix, 0 px across 24 rounds)
14
- # focus cost -- message door 0/6 raise; UIA pattern 6/6 and 12/12 raise
11
+ # messageDoor -- 17/57 live windows expose a classic child door (neutral-coverage-census)
12
+ # hasPattern -- WPF/UWP/Chromium expose UIA patterns; WinForms exposes none (probe-winform)
13
+ # uiaTreeEmpty -- an a11y-off Chromium window walks to ZERO content elements and never grows
14
+ # one under re-query (uTools 1/1/1 raw, 0/0/0 content, 2026-11-21; census read
15
+ # 0/0/0 the same day) -- scripts/uia-tree-content.ps1 re-measures it
16
+ # uiaProbeFailed-- the probe's own exception, carried out of win.ps1 as a boolean so the code
17
+ # selection never parses message text
18
+ # cursor cost -- zero in every channel (channel-raise-matrix, 0 px across 24 rounds)
19
+ # focus cost -- message door 0/6 raise; UIA pattern 6/6 and 12/12 raise
15
20
  # Each fact is a measurement, not a guess. A fact that was never measured is NOT allowed to
16
21
  # default to the flattering branch: missing facts refuse, they do not assume quiet.
17
22
 
@@ -24,6 +29,8 @@ $script:WpmRefusals = @{
24
29
  paused = 'owner paused input; server-side refusal, not a prompt-level hint'
25
30
  elevated_target = 'target runs at a higher integrity level; a non-elevated process cannot write to it'
26
31
  unreachable = 'no message door and no usable UIA pattern; this target cannot be driven without physical input'
32
+ uia_tree_empty = 'the accessibility tree holds no content element at all: no pattern can ever appear here, and re-querying has nothing to wait for'
33
+ uia_probe_failed = 'the accessibility probe itself threw before it could measure this target; whether a usable pattern exists was never learned'
27
34
  terminal_no_door = 'terminal text surface exposes no child HWND and no Document element'
28
35
  needs_facts = 'the caller supplied no measured facts for this target; refusing instead of assuming quiet'
29
36
  }
@@ -40,12 +47,15 @@ function New-WpmFacts {
40
47
  [bool]$HasPattern = $false,
41
48
  [string]$PatternKind = 'none', # invoke | value | toggle | selectionitem | legacy | none
42
49
  [string]$Action = 'click', # click | type | key | scroll
43
- [bool]$FactsMeasured = $false
50
+ [bool]$FactsMeasured = $false,
51
+ [bool]$UiaTreeEmpty = $false, # the walked tree contained zero content elements (win.ps1 Test-WpmUiaTreeHasContent)
52
+ [bool]$UiaProbeFailed = $false # the UIA probe threw; uiaErr carries the exception text (win.ps1)
44
53
  )
45
54
  return @{
46
55
  hwnd = $Hwnd; paused = $Paused; elevatedTarget = $ElevatedTarget; family = $Family
47
56
  messageDoor = $MessageDoor; hasPattern = $HasPattern; patternKind = $PatternKind
48
57
  action = $Action; factsMeasured = $FactsMeasured
58
+ uiaTreeEmpty = $UiaTreeEmpty; uiaProbeFailed = $UiaProbeFailed
49
59
  }
50
60
  }
51
61
 
@@ -108,6 +118,27 @@ function Get-WpmChannelDecision {
108
118
  return @{ channel = 'refuse'; tier = 'none'; needsRestore = $false
109
119
  refusal = 'needs_facts'; reason = $script:WpmRefusals.needs_facts }
110
120
  }
121
+
122
+ # THREE WORLDS USED TO SHARE ONE CODE ('unreachable'), and they have different fixes, which is
123
+ # why they stopped sharing it (2026-11-21: 0.1.5's point-probe fix exposed uiaErr arriving here
124
+ # as dead data; the census the same day exposed the tree split). A tree with NO content element
125
+ # needs the APPLICATION to enable accessibility -- launch-time for Chromium
126
+ # (--force-renderer-accessibility); re-querying cannot help, which is exactly why no retry or
127
+ # polling exists anywhere in this engine. A probe that THREW means the measurement itself
128
+ # failed, so no conclusion about the target is licensed -- the exception text rides the reason
129
+ # (engine.ps1 appends it), and the caller reads it instead of guessing. The plain door-less
130
+ # case with a live tree means 'pick another target or point'. Probe failure outranks
131
+ # tree-empty: a measurement that threw cannot also certify emptiness. And a usable door still
132
+ # outranks every diagnosis -- these branches only replace the terminal refusal, never a
133
+ # working channel.
134
+ if ($Facts.uiaProbeFailed) {
135
+ return @{ channel = 'refuse'; tier = 'none'; needsRestore = $false
136
+ refusal = 'uia_probe_failed'; reason = $script:WpmRefusals.uia_probe_failed }
137
+ }
138
+ if ($Facts.uiaTreeEmpty) {
139
+ return @{ channel = 'refuse'; tier = 'none'; needsRestore = $false
140
+ refusal = 'uia_tree_empty'; reason = $script:WpmRefusals.uia_tree_empty }
141
+ }
111
142
  return @{ channel = 'refuse'; tier = 'none'; needsRestore = $false
112
143
  refusal = 'unreachable'; reason = $script:WpmRefusals.unreachable }
113
144
  }
@@ -199,8 +199,12 @@ function Invoke-WpmAction {
199
199
  # A refusal that says only 'unreachable' makes the reader guess which of two very different
200
200
  # things happened. When the point probe ran, it knows: the point is outside the target, or the
201
201
  # element there has no pattern, or the tree could not be walked at all. Carry that out -- a
202
- # refusal is a normal product outcome and its reason is the product (R3.2).
203
- if ($decision.refusal -eq 'unreachable' -and $probe.uiaReason) {
202
+ # refusal is a normal product outcome and its reason is the product (R3.2). The split codes
203
+ # (uia_probe_failed / uia_tree_empty, decide.ps1) need the same context, so the point reason
204
+ # rides on all of them; the probe's exception text always follows when it exists, because a
205
+ # uia_probe_failed refusal whose reason hides the exception is a diagnosis with the evidence
206
+ # redacted.
207
+ if ($decision.refusal -in @('unreachable', 'uia_probe_failed', 'uia_tree_empty') -and $probe.uiaReason) {
204
208
  $result.reason = "$($decision.reason) -- at that point: $($probe.uiaReason)"
205
209
  }
206
210
  if ($probe.uiaErr) { $result.reason = "$($result.reason) [uia: $($probe.uiaErr)]" }
@@ -437,6 +437,47 @@ function Get-WpmUiaCached {
437
437
  return $script:WpmUia
438
438
  }
439
439
 
440
+ function Test-WpmUiaTreeHasContent([IntPtr]$Hwnd, [int]$MaxElements = 200) {
441
+ <#
442
+ Does this target's accessibility tree contain ANY content element, or is it shell only?
443
+ Returns $true when at least one element carries a content control type, $false when the
444
+ walked tree is only structural chrome, and $false when the walk itself cannot run (a walk
445
+ that failed must not be reported as "measured empty" -- the caller distinguishes that world
446
+ through the probe error, not through this answer).
447
+
448
+ WHY CONTENT, NOT COUNT. "The tree is empty" cannot mean Count == 0: a Chromium window with
449
+ renderer accessibility off still exposes ONE shell element -- the Chrome_RenderWidgetHostHWND
450
+ pane ("Chrome Legacy Window") -- so uTools measures raw=1 while carrying zero drivable
451
+ content, and the same window measured raw=0 earlier the same day depending on its own state.
452
+ What never changed across every re-read was the CONTENT count: 0 for the a11y-off window,
453
+ hundreds for the a11y-on ones (DSH 514 at census time, 1019 later; ZCode 497). The stable
454
+ boundary is structural, not numeric: shell types (Pane/Group/Image/Text/Thumb/Separator/
455
+ TitleBar) are the window's own chrome; anything else -- Button, Edit, Document, Custom --
456
+ is something an application chose to expose. Custom counts as content deliberately: it may
457
+ be undrivable, but calling it "empty" would claim the app has a11y off, and a wrong
458
+ uia_tree_empty is a worse lie than an honest unreachable.
459
+
460
+ Measured on 2026-11-21 (see scripts/uia-tree-content.ps1, which reads the same two counters
461
+ with the same shell list). This is also why NO retry/polling exists for a tree that answers
462
+ empty: three in-place reads over 2.2s produced zero content elements every time -- there is
463
+ nothing to wait for. The switch is launch-time: --force-renderer-accessibility.
464
+ #>
465
+ try {
466
+ $rootEl = [System.Windows.Automation.AutomationElement]::FromHandle($Hwnd)
467
+ $all = $rootEl.FindAll([System.Windows.Automation.TreeScope]::Descendants,
468
+ [System.Windows.Automation.Condition]::TrueCondition)
469
+ $n = [Math]::Min($all.Count, $MaxElements)
470
+ for ($i = 0; $i -lt $n; $i++) {
471
+ $t = ''
472
+ try { $t = $all[$i].Current.ControlType.ProgrammaticName -replace 'ControlType\.', '' } catch { continue }
473
+ if (@('Pane', 'Group', 'Image', 'Text', 'Thumb', 'Separator', 'TitleBar') -notcontains $t) { return $true }
474
+ }
475
+ return $false
476
+ } catch {
477
+ return $false
478
+ }
479
+ }
480
+
440
481
  function Get-WpmFamily([IntPtr]$Hwnd, [string]$Cls) {
441
482
  # Family decides which door is even possible, so it is measured from the class name rather than
442
483
  # guessed from the title: a title is the user's text, a class is the toolkit's identity.
@@ -577,6 +618,7 @@ function Get-WpmFacts {
577
618
  $uiaElement = $null
578
619
  $uiaErr = ''
579
620
  $uiaReason = ''
621
+ $scanProbed = $false
580
622
 
581
623
  # A CLICK WITH COORDINATES IS RESOLVED AT THE POINT, never by tree order. See
582
624
  # Resolve-WpmUiaElementAtPoint for what went wrong before this: the first descendant carrying a
@@ -595,6 +637,7 @@ function Get-WpmFacts {
595
637
  $uiaElement = $pr.element
596
638
  }
597
639
  } elseif ($doorKinds.Count -eq 0 -or $ElementName) {
640
+ $scanProbed = $true
598
641
  try {
599
642
  $root = [System.Windows.Automation.AutomationElement]::FromHandle($Hwnd)
600
643
  $cond = New-Object System.Windows.Automation.PropertyCondition(
@@ -629,6 +672,18 @@ function Get-WpmFacts {
629
672
  }
630
673
  }
631
674
 
675
+ # EMPTY TREE vs PATTERN-LESS CONTENT, measured rather than folded into one word. When the UIA
676
+ # probe ran and found nothing usable, two different worlds produce the same hasPattern=false:
677
+ # a tree that was never populated (the app has a11y off -- uTools walks to one shell Pane and
678
+ # zero content elements, and no amount of re-querying changes that), and a tree that is alive
679
+ # but offers nothing at the named point or element (ZCode/DSH walk to hundreds of elements).
680
+ # They get different refusal codes (decide.ps1), so this measurement runs only when the probe
681
+ # actually ran -- never to decorate a target whose message door already decided the route.
682
+ $uiaTreeEmpty = $false
683
+ if (-not $hasPattern -and ($pointResolved -or $scanProbed)) {
684
+ $uiaTreeEmpty = -not (Test-WpmUiaTreeHasContent $Hwnd)
685
+ }
686
+
632
687
  # Elevation is now measured, not assumed. WpmWin::IsElevatedTarget compares the target's
633
688
  # integrity RID against ours; a failure to read either side returns false rather than guessing,
634
689
  # because guessing 'elevated' would refuse every window whose handle read failed. The flag is
@@ -640,7 +695,8 @@ function Get-WpmFacts {
640
695
 
641
696
  $facts = New-WpmFacts -Hwnd ($Hwnd.ToInt64().ToString()) -Family $fam `
642
697
  -MessageDoor ($doorKinds.Count -gt 0) -HasPattern $hasPattern -PatternKind $patKind `
643
- -Action $Action -FactsMeasured $true -ElevatedTarget $elevated
698
+ -Action $Action -FactsMeasured $true -ElevatedTarget $elevated `
699
+ -UiaTreeEmpty $uiaTreeEmpty -UiaProbeFailed ($uiaErr -ne '')
644
700
 
645
701
  return @{
646
702
  facts = $facts
@@ -656,6 +712,11 @@ function Get-WpmFacts {
656
712
  # whose tree cannot be walked at all reached the caller as the same sentence: 'no message door
657
713
  # and no usable UIA pattern'. Two different worlds, one string -- and the fixes differ.
658
714
  uiaReason = $uiaReason
715
+ # The two booleans that decide.ps1 splits 'unreachable' on travel INSIDE $facts, built through
716
+ # the typed constructor above -- deliberately NOT duplicated here. A second copy of a measured
717
+ # value in the same return object is the two-copies-drift bug this repo keeps meeting; the
718
+ # first live-instance run of this very change caught exactly that shape (facts said False
719
+ # while the raw measurement said True, because the constructor call had not been extended).
659
720
  pointResolved = $pointResolved
660
721
  pid = [WpmWin]::PidOf($Hwnd)
661
722
  }
@@ -37,7 +37,9 @@
37
37
  { "code": "no_hwnd", "layer": "decision", "summary": "no usable target window handle" },
38
38
  { "code": "paused", "layer": "decision", "summary": "the owner paused input; server-side refusal" },
39
39
  { "code": "elevated_target", "layer": "decision", "summary": "target runs at a higher integrity level" },
40
- { "code": "unreachable", "layer": "decision", "summary": "no message door and no usable UIA pattern" },
40
+ { "code": "unreachable", "layer": "decision", "summary": "no message door and no usable UIA pattern; the tree is alive but offers nothing at the named point or element" },
41
+ { "code": "uia_tree_empty", "layer": "decision", "summary": "the accessibility tree holds no content element at all; in every measured instance the cause is the application having UI Automation disabled, which only a launch-time switch changes" },
42
+ { "code": "uia_probe_failed", "layer": "decision", "summary": "the accessibility probe threw before it could measure this target; the exception text rides the reason" },
41
43
  { "code": "terminal_no_door", "layer": "decision", "summary": "terminal text surface exposes neither a child window nor a document element" },
42
44
  { "code": "needs_facts", "layer": "decision", "summary": "the caller supplied no measured facts for this target" },
43
45
  { "code": "action_failed", "layer": "runtime", "summary": "the chosen channel threw while acting", "uncoveredReason": "needs a target whose channel reliably throws; not constructed this round (docs/refusals.md, gap 2)" },
@@ -74,7 +76,7 @@
74
76
  "required": ["hwnd", "x", "y"],
75
77
  "additionalProperties": false
76
78
  },
77
- "refusals": ["no_hwnd", "paused", "elevated_target", "unreachable", "terminal_no_door", "action_failed", "restore_failed"]
79
+ "refusals": ["no_hwnd", "paused", "elevated_target", "unreachable", "uia_tree_empty", "uia_probe_failed", "terminal_no_door", "action_failed", "restore_failed"]
78
80
  },
79
81
  {
80
82
  "name": "wpm_type",
@@ -93,7 +95,7 @@
93
95
  "required": ["hwnd", "text"],
94
96
  "additionalProperties": false
95
97
  },
96
- "refusals": ["no_hwnd", "paused", "elevated_target", "unreachable", "terminal_no_door", "action_failed", "restore_failed"]
98
+ "refusals": ["no_hwnd", "paused", "elevated_target", "unreachable", "uia_tree_empty", "uia_probe_failed", "terminal_no_door", "action_failed", "restore_failed"]
97
99
  },
98
100
  {
99
101
  "name": "wpm_focus",
@@ -110,7 +112,7 @@
110
112
  "required": ["hwnd", "elementName"],
111
113
  "additionalProperties": false
112
114
  },
113
- "refusals": ["no_hwnd", "paused", "elevated_target", "unreachable", "terminal_no_door", "action_failed", "restore_failed"]
115
+ "refusals": ["no_hwnd", "paused", "elevated_target", "unreachable", "uia_tree_empty", "uia_probe_failed", "terminal_no_door", "action_failed", "restore_failed"]
114
116
  },
115
117
  {
116
118
  "name": "wpm_status",
@@ -177,6 +179,22 @@
177
179
  "expect": "terminal_no_door",
178
180
  "note": "Decision-table instance only. A real terminal window is not launched in this run because findings.md:311-316 records a leftover-dialog accident on this host; the real evidence is the coverage census."
179
181
  },
182
+ {
183
+ "id": "click-uia-tree-empty",
184
+ "mode": "decision",
185
+ "tool": "wpm_click",
186
+ "facts": { "hwnd": "$liveHwnd", "family": "chromium", "uiaTreeEmpty": true },
187
+ "expect": "uia_tree_empty",
188
+ "note": "Decision-table instance of the 2026-11-21 census: a Chromium window with renderer accessibility off walks to a tree with ZERO content elements (uTools measured one Chrome Legacy Window shell Pane, 0 interactive elements, identical across three in-place reads). Distinct from unreachable because the fix differs: nothing a re-query can find -- the app must relaunch with a11y on (--force-renderer-accessibility) or a different target must be picked. Real instance: scripts/uia-tree-content.ps1 plus a live engine call against uTools."
189
+ },
190
+ {
191
+ "id": "click-uia-probe-failed",
192
+ "mode": "decision",
193
+ "tool": "wpm_click",
194
+ "facts": { "hwnd": "$liveHwnd", "uiaProbeFailed": true },
195
+ "expect": "uia_probe_failed",
196
+ "note": "Decision-table instance. The UIA probe threw between the IsWindow check and the tree walk (element destroyed under the probe), so door measurement is impossible and no conclusion about the target is licensed. The engine appends the exception text to the reason as [uia: ...]. Before this code existed a thrown probe and a genuinely pattern-less target shared 'unreachable', and uiaErr arrived here as dead data."
197
+ },
180
198
  {
181
199
  "id": "needs-facts",
182
200
  "mode": "decision",