mobile-debug-mcp 0.29.0 → 0.30.1
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/AGENTS.md +13 -0
- package/README.md +44 -21
- package/dist/interact/index.js +359 -46
- package/dist/observe/index.js +1 -0
- package/dist/observe/snapshot-metadata.js +62 -1
- package/dist/server/tool-definitions.js +8 -3
- package/dist/server/tool-handlers.js +4 -2
- package/dist/server-core.js +1 -1
- package/docs/CHANGELOG.md +11 -0
- package/docs/ROADMAP.md +18 -7
- package/docs/rfcs/013-wait-and-synchronization-reliability.md +870 -0
- package/docs/rfcs/014-actionability-resolution.md +394 -0
- package/docs/specs/mcp-tooling-spec-v1.md +28 -0
- package/docs/tools/interact.md +6 -0
- package/package.json +1 -1
- package/src/interact/index.ts +444 -45
- package/src/observe/index.ts +1 -0
- package/src/observe/snapshot-metadata.ts +69 -2
- package/src/server/tool-definitions.ts +8 -3
- package/src/server/tool-handlers.ts +4 -2
- package/src/server-core.ts +1 -1
- package/src/types.ts +24 -0
- package/test/unit/interact/adjust_control.test.ts +104 -0
- package/test/unit/interact/subtree_collection.test.ts +24 -0
- package/test/unit/interact/tap_element.test.ts +71 -0
- package/test/unit/interact/wait_for_ui_change.test.ts +189 -45
- package/test/unit/observe/snapshot_metadata.test.ts +67 -0
|
@@ -0,0 +1,870 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
# RFC 013 — Wait and Synchronization Reliability
|
|
4
|
+
|
|
5
|
+
## Status
|
|
6
|
+
|
|
7
|
+
Draft
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
# 1. Summary
|
|
12
|
+
|
|
13
|
+
This RFC introduces deterministic synchronization primitives and snapshot freshness semantics for mobile-debug-mcp.
|
|
14
|
+
|
|
15
|
+
The goal is to reduce premature action execution, stale-state reasoning, retry amplification, and sequencing instability when interacting with asynchronous mobile UI frameworks.
|
|
16
|
+
|
|
17
|
+
The RFC defines:
|
|
18
|
+
|
|
19
|
+
- UI synchronization principles
|
|
20
|
+
- Wait lifecycle semantics
|
|
21
|
+
- Snapshot freshness metadata
|
|
22
|
+
- Convergence and stabilization behavior
|
|
23
|
+
- Synchronization guardrails for agents
|
|
24
|
+
- Incremental synchronization foundations
|
|
25
|
+
|
|
26
|
+
These capabilities are intended to improve reliability across:
|
|
27
|
+
|
|
28
|
+
- Android Views
|
|
29
|
+
- Jetpack Compose
|
|
30
|
+
- UIKit
|
|
31
|
+
- SwiftUI
|
|
32
|
+
|
|
33
|
+
---
|
|
34
|
+
|
|
35
|
+
# Relationship to Existing Synchronization Contracts
|
|
36
|
+
|
|
37
|
+
This RFC extends and clarifies the synchronization semantics introduced in RFC003 and the currently shipped synchronization tooling.
|
|
38
|
+
|
|
39
|
+
RFC013 is additive rather than a full replacement.
|
|
40
|
+
|
|
41
|
+
Where conflicts exist between:
|
|
42
|
+
|
|
43
|
+
- historical documentation
|
|
44
|
+
- illustrative examples in earlier RFCs
|
|
45
|
+
- implementation behavior
|
|
46
|
+
|
|
47
|
+
The shipped implementation contract remains the source of truth until RFC013 reaches accepted status and corresponding implementation updates are merged.
|
|
48
|
+
|
|
49
|
+
This RFC specifically standardizes:
|
|
50
|
+
|
|
51
|
+
- synchronization terminology
|
|
52
|
+
- convergence semantics
|
|
53
|
+
- snapshot freshness semantics
|
|
54
|
+
- synchronization lifecycle behavior
|
|
55
|
+
- future incremental synchronization direction
|
|
56
|
+
|
|
57
|
+
It does not invalidate existing synchronization tooling.
|
|
58
|
+
|
|
59
|
+
---
|
|
60
|
+
|
|
61
|
+
# 2. Problem Statement
|
|
62
|
+
|
|
63
|
+
Current interaction flows rely heavily on immediate post-action reasoning against potentially transient UI state.
|
|
64
|
+
|
|
65
|
+
Observed failure modes include:
|
|
66
|
+
|
|
67
|
+
- Actions executing before navigation or recomposition completes
|
|
68
|
+
- Agents reasoning against stale hierarchy snapshots
|
|
69
|
+
- Retry loops caused by transient loading states
|
|
70
|
+
- Network activity incorrectly treated as readiness confirmation
|
|
71
|
+
- In-place UI mutations not being detected reliably
|
|
72
|
+
- Async Compose recomposition causing unstable interaction timing
|
|
73
|
+
- Sequential actions being executed without convergence verification
|
|
74
|
+
|
|
75
|
+
Example failure pattern:
|
|
76
|
+
|
|
77
|
+
```text
|
|
78
|
+
Tap login button
|
|
79
|
+
→ hierarchy partially updates
|
|
80
|
+
→ next action executes immediately
|
|
81
|
+
→ target element not yet available
|
|
82
|
+
→ retry loop begins
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
The current model does not provide a deterministic definition of:
|
|
86
|
+
|
|
87
|
+
- when the UI has changed
|
|
88
|
+
- when the UI is stable
|
|
89
|
+
- whether a snapshot is fresh
|
|
90
|
+
- whether synchronization has converged
|
|
91
|
+
|
|
92
|
+
This RFC introduces explicit synchronization semantics to address those gaps.
|
|
93
|
+
|
|
94
|
+
---
|
|
95
|
+
|
|
96
|
+
# 3. Goals
|
|
97
|
+
|
|
98
|
+
The system should:
|
|
99
|
+
|
|
100
|
+
- Make UI state transitions observable and waitable
|
|
101
|
+
- Reduce premature action execution
|
|
102
|
+
- Improve deterministic sequencing behavior
|
|
103
|
+
- Reduce retry amplification
|
|
104
|
+
- Support asynchronous UI frameworks reliably
|
|
105
|
+
- Improve snapshot freshness awareness
|
|
106
|
+
- Enable token-efficient synchronization strategies
|
|
107
|
+
- Provide explicit synchronization lifecycle semantics
|
|
108
|
+
|
|
109
|
+
---
|
|
110
|
+
|
|
111
|
+
# 4. Non-Goals
|
|
112
|
+
|
|
113
|
+
This RFC does not attempt to:
|
|
114
|
+
|
|
115
|
+
- Implement autonomous recovery planning
|
|
116
|
+
- Infer app-specific business loading semantics
|
|
117
|
+
- Guarantee backend or network completion
|
|
118
|
+
- Replace explicit verification primitives
|
|
119
|
+
- Eliminate all timing-related failures
|
|
120
|
+
- Perform animation introspection beyond observable hierarchy state
|
|
121
|
+
- Solve all synchronization issues at the protocol level alone
|
|
122
|
+
|
|
123
|
+
---
|
|
124
|
+
|
|
125
|
+
# 5. Design Principles
|
|
126
|
+
|
|
127
|
+
## 5.1 UI-First Synchronization
|
|
128
|
+
|
|
129
|
+
Observable UI convergence is the primary synchronization signal.
|
|
130
|
+
|
|
131
|
+
The system should prefer:
|
|
132
|
+
|
|
133
|
+
- hierarchy changes
|
|
134
|
+
- visibility changes
|
|
135
|
+
- enabled-state changes
|
|
136
|
+
- navigation transitions
|
|
137
|
+
|
|
138
|
+
over indirect signals such as:
|
|
139
|
+
|
|
140
|
+
- network activity
|
|
141
|
+
- logs
|
|
142
|
+
- timing assumptions
|
|
143
|
+
|
|
144
|
+
---
|
|
145
|
+
|
|
146
|
+
## 5.2 Verification Over Inference
|
|
147
|
+
|
|
148
|
+
Synchronization should confirm observable state transitions rather than infer readiness heuristically whenever possible.
|
|
149
|
+
|
|
150
|
+
Preferred flow:
|
|
151
|
+
|
|
152
|
+
```text
|
|
153
|
+
action
|
|
154
|
+
→ wait
|
|
155
|
+
→ verify
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
Avoid:
|
|
159
|
+
|
|
160
|
+
```text
|
|
161
|
+
action
|
|
162
|
+
→ immediate follow-up action
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
---
|
|
166
|
+
|
|
167
|
+
## 5.3 Bounded Convergence
|
|
168
|
+
|
|
169
|
+
All synchronization operations must terminate deterministically.
|
|
170
|
+
|
|
171
|
+
Every wait operation must:
|
|
172
|
+
|
|
173
|
+
- have a timeout
|
|
174
|
+
- expose completion reason
|
|
175
|
+
- avoid infinite polling loops
|
|
176
|
+
- expose partial convergence information when possible
|
|
177
|
+
|
|
178
|
+
---
|
|
179
|
+
|
|
180
|
+
## 5.4 Snapshot Freshness Awareness
|
|
181
|
+
|
|
182
|
+
Agents should understand whether observations are:
|
|
183
|
+
|
|
184
|
+
- current
|
|
185
|
+
- stale
|
|
186
|
+
- transient
|
|
187
|
+
- stable
|
|
188
|
+
|
|
189
|
+
Snapshot freshness must be explicit rather than inferred.
|
|
190
|
+
|
|
191
|
+
---
|
|
192
|
+
|
|
193
|
+
## 5.5 Explicit Sequencing
|
|
194
|
+
|
|
195
|
+
Synchronization should encourage predictable execution ordering.
|
|
196
|
+
|
|
197
|
+
Preferred execution model:
|
|
198
|
+
|
|
199
|
+
```text
|
|
200
|
+
perform action
|
|
201
|
+
→ observe mutation
|
|
202
|
+
→ wait for convergence
|
|
203
|
+
→ verify state
|
|
204
|
+
→ continue
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
---
|
|
208
|
+
|
|
209
|
+
# 6. Definitions
|
|
210
|
+
|
|
211
|
+
## Fresh
|
|
212
|
+
|
|
213
|
+
A snapshot is considered fresh when:
|
|
214
|
+
|
|
215
|
+
- its `snapshot_revision` matches the latest observed hierarchy revision
|
|
216
|
+
- its `captured_at_ms` timestamp is newer than the most recent qualifying hierarchy mutation observed by the synchronization operation
|
|
217
|
+
|
|
218
|
+
Freshness is computed by the synchronization subsystem.
|
|
219
|
+
|
|
220
|
+
Freshness is advisory rather than absolute because additional hierarchy mutation may occur immediately after snapshot capture.
|
|
221
|
+
|
|
222
|
+
---
|
|
223
|
+
|
|
224
|
+
## Stale
|
|
225
|
+
|
|
226
|
+
A snapshot is considered stale when:
|
|
227
|
+
|
|
228
|
+
- a newer hierarchy revision exists
|
|
229
|
+
- the synchronization subsystem has observed additional qualifying hierarchy mutation after the snapshot was captured
|
|
230
|
+
|
|
231
|
+
---
|
|
232
|
+
|
|
233
|
+
## Transient
|
|
234
|
+
|
|
235
|
+
A hierarchy state is transient when qualifying hierarchy mutations are still occurring within the stabilization window.
|
|
236
|
+
|
|
237
|
+
Transient state maps to:
|
|
238
|
+
|
|
239
|
+
```text
|
|
240
|
+
stability_state = transient
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
---
|
|
244
|
+
|
|
245
|
+
## Stable
|
|
246
|
+
|
|
247
|
+
A hierarchy state is stable when:
|
|
248
|
+
|
|
249
|
+
- no qualifying hierarchy mutations occur within the stabilization window
|
|
250
|
+
- convergence conditions have been satisfied
|
|
251
|
+
|
|
252
|
+
Stable state maps to:
|
|
253
|
+
|
|
254
|
+
```text
|
|
255
|
+
stability_state = stable
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
---
|
|
259
|
+
|
|
260
|
+
## Converged
|
|
261
|
+
|
|
262
|
+
A synchronization state in which:
|
|
263
|
+
|
|
264
|
+
- required conditions are satisfied
|
|
265
|
+
- no additional qualifying hierarchy mutations occur within the stabilization window
|
|
266
|
+
- the returned snapshot is considered fresh at the time of emission
|
|
267
|
+
|
|
268
|
+
---
|
|
269
|
+
|
|
270
|
+
# 7. Proposed Capabilities
|
|
271
|
+
|
|
272
|
+
## 7.1 wait_for_ui_change
|
|
273
|
+
|
|
274
|
+
Introduces an explicit synchronization primitive that waits for observable hierarchy mutation.
|
|
275
|
+
|
|
276
|
+
### Current Shipped Contract
|
|
277
|
+
|
|
278
|
+
The current implementation exposes synchronization through the interaction layer using:
|
|
279
|
+
|
|
280
|
+
```json
|
|
281
|
+
wait_for_ui_change({
|
|
282
|
+
platform?: "android" | "ios",
|
|
283
|
+
deviceId?: string,
|
|
284
|
+
timeout_ms?: number,
|
|
285
|
+
stability_window_ms?: number,
|
|
286
|
+
expected_change?: string,
|
|
287
|
+
scope?: "screen" | "subtree",
|
|
288
|
+
target?: string
|
|
289
|
+
})
|
|
290
|
+
```
|
|
291
|
+
|
|
292
|
+
`scope=subtree` requires a target `element_id` and narrows synchronization to the resolved element subtree.
|
|
293
|
+
|
|
294
|
+
### Semantics
|
|
295
|
+
|
|
296
|
+
The operation:
|
|
297
|
+
|
|
298
|
+
1. Captures the current hierarchy revision
|
|
299
|
+
2. Waits for qualifying hierarchy mutation
|
|
300
|
+
3. Waits for stabilization convergence
|
|
301
|
+
4. Returns synchronization metadata
|
|
302
|
+
|
|
303
|
+
### Completion Conditions
|
|
304
|
+
|
|
305
|
+
The operation succeeds when:
|
|
306
|
+
|
|
307
|
+
- a qualifying hierarchy mutation occurs
|
|
308
|
+
- stabilization completes before timeout
|
|
309
|
+
|
|
310
|
+
The operation fails when:
|
|
311
|
+
|
|
312
|
+
- timeout expires
|
|
313
|
+
- hierarchy becomes unavailable
|
|
314
|
+
- target subtree becomes invalid
|
|
315
|
+
|
|
316
|
+
### Synchronization-Relevant Mutation Rules
|
|
317
|
+
|
|
318
|
+
The current implementation treats synchronization-relevant mutations as observable hierarchy changes that may affect interaction correctness or verification behavior.
|
|
319
|
+
|
|
320
|
+
Examples include:
|
|
321
|
+
|
|
322
|
+
- element addition or removal
|
|
323
|
+
- visibility changes
|
|
324
|
+
- enabled-state changes
|
|
325
|
+
- navigation transitions
|
|
326
|
+
- text or content-description changes
|
|
327
|
+
- subtree structure mutation
|
|
328
|
+
- semantic accessibility tree mutation
|
|
329
|
+
|
|
330
|
+
The implementation may ignore mutations considered non-meaningful for synchronization purposes.
|
|
331
|
+
|
|
332
|
+
Examples may include:
|
|
333
|
+
|
|
334
|
+
- animation frame updates
|
|
335
|
+
- layout-only jitter
|
|
336
|
+
- opacity-only visual transitions
|
|
337
|
+
- non-semantic rendering updates
|
|
338
|
+
|
|
339
|
+
Mutation qualification behavior is currently implementation-defined.
|
|
340
|
+
|
|
341
|
+
### Normative Default Mutation Classification Rules
|
|
342
|
+
|
|
343
|
+
The implementation MUST treat the following as synchronization-relevant mutations:
|
|
344
|
+
|
|
345
|
+
- element addition or removal
|
|
346
|
+
- visibility changes
|
|
347
|
+
- enabled-state changes
|
|
348
|
+
- navigation transitions
|
|
349
|
+
- text or content-description changes
|
|
350
|
+
- subtree structure mutation
|
|
351
|
+
- semantic accessibility tree mutation
|
|
352
|
+
|
|
353
|
+
The implementation MUST NOT treat the following as synchronization-relevant mutations:
|
|
354
|
+
|
|
355
|
+
- animation frame updates
|
|
356
|
+
- layout-only jitter
|
|
357
|
+
- opacity-only visual transitions
|
|
358
|
+
- non-semantic rendering updates
|
|
359
|
+
|
|
360
|
+
If a mutation affects interaction semantics or element accessibility identity, it SHOULD be treated as synchronization-relevant.
|
|
361
|
+
|
|
362
|
+
Future protocol revisions may standardize semantic diff classification.
|
|
363
|
+
|
|
364
|
+
### Response Example
|
|
365
|
+
|
|
366
|
+
```json
|
|
367
|
+
{
|
|
368
|
+
"status": "success",
|
|
369
|
+
"snapshot_revision": 42,
|
|
370
|
+
"change_detected": true,
|
|
371
|
+
"stabilized": true,
|
|
372
|
+
"elapsed_ms": 842
|
|
373
|
+
}
|
|
374
|
+
```
|
|
375
|
+
|
|
376
|
+
### Normative Field Definitions
|
|
377
|
+
|
|
378
|
+
| Field | Status | Description |
|
|
379
|
+
|---|---|---|
|
|
380
|
+
| `platform` | optional | Target platform identifier |
|
|
381
|
+
| `deviceId` | optional | Device session identifier |
|
|
382
|
+
| `timeout_ms` | optional | Maximum synchronization duration |
|
|
383
|
+
| `stability_window_ms` | optional | Required stabilization duration before convergence |
|
|
384
|
+
| `expected_change` | optional | Advisory description of expected UI mutation |
|
|
385
|
+
| `scope` | proposed | Future subtree or screen scoping |
|
|
386
|
+
| `target` | proposed | Future scoped synchronization target |
|
|
387
|
+
|
|
388
|
+
---
|
|
389
|
+
|
|
390
|
+
## 7.1.1 Stabilization Execution Model (Normative)
|
|
391
|
+
|
|
392
|
+
This section defines the required execution semantics for stabilization. Implementations MAY differ internally, but MUST conform to the observable behavior defined here.
|
|
393
|
+
|
|
394
|
+
### 1. Core Rule
|
|
395
|
+
|
|
396
|
+
Stabilization is defined as:
|
|
397
|
+
|
|
398
|
+
> a continuous period of `stability_window_ms` during which no synchronization-relevant mutation occurs.
|
|
399
|
+
|
|
400
|
+
A snapshot is considered **stable only when this condition is satisfied continuously for the full window duration**.
|
|
401
|
+
|
|
402
|
+
---
|
|
403
|
+
|
|
404
|
+
### 2. Window Behavior (Reset Semantics)
|
|
405
|
+
|
|
406
|
+
The stabilization window:
|
|
407
|
+
|
|
408
|
+
- MUST reset whenever a synchronization-relevant mutation is observed
|
|
409
|
+
- MUST be measured from the **most recent qualifying mutation timestamp**
|
|
410
|
+
|
|
411
|
+
This implies:
|
|
412
|
+
|
|
413
|
+
```text
|
|
414
|
+
mutation → reset window → wait full window → check again
|
|
415
|
+
```
|
|
416
|
+
|
|
417
|
+
There is no accumulation of partial stability.
|
|
418
|
+
|
|
419
|
+
---
|
|
420
|
+
|
|
421
|
+
### 3. Coalescing Model
|
|
422
|
+
|
|
423
|
+
Multiple mutations occurring within the stabilization window:
|
|
424
|
+
|
|
425
|
+
- MUST be treated as a single continuous instability period
|
|
426
|
+
- MUST NOT trigger separate stabilization evaluations
|
|
427
|
+
|
|
428
|
+
Effectively:
|
|
429
|
+
|
|
430
|
+
> stabilization evaluates *quiescence*, not individual events
|
|
431
|
+
|
|
432
|
+
---
|
|
433
|
+
|
|
434
|
+
### 4. Completion Condition
|
|
435
|
+
|
|
436
|
+
Stabilization is complete only when:
|
|
437
|
+
|
|
438
|
+
- no synchronization-relevant mutation has occurred for a full `stability_window_ms`
|
|
439
|
+
- at least one snapshot is captured at the end of that window without new mutation
|
|
440
|
+
|
|
441
|
+
This guarantees convergence is based on observed inactivity, not prediction.
|
|
442
|
+
|
|
443
|
+
---
|
|
444
|
+
|
|
445
|
+
### 5. Emission Semantics
|
|
446
|
+
|
|
447
|
+
Implementations:
|
|
448
|
+
|
|
449
|
+
- MAY emit intermediate “transient” or “stabilizing” states internally
|
|
450
|
+
- MUST NOT report `stable` until the completion condition is satisfied
|
|
451
|
+
- MUST ensure `stable` implies a fully satisfied stabilization window
|
|
452
|
+
|
|
453
|
+
---
|
|
454
|
+
|
|
455
|
+
### 6. Timeout Interaction
|
|
456
|
+
|
|
457
|
+
If a timeout occurs:
|
|
458
|
+
|
|
459
|
+
- stabilization MUST abort
|
|
460
|
+
- partial convergence MUST NOT be reported as `stable`
|
|
461
|
+
- last observed state MAY be returned with `stabilizing` or equivalent status
|
|
462
|
+
|
|
463
|
+
---
|
|
464
|
+
|
|
465
|
+
### 7. Determinism Requirement
|
|
466
|
+
|
|
467
|
+
Given identical sequences of:
|
|
468
|
+
|
|
469
|
+
- mutations
|
|
470
|
+
- timing
|
|
471
|
+
- `stability_window_ms`
|
|
472
|
+
|
|
473
|
+
the stabilization outcome MUST be deterministic.
|
|
474
|
+
|
|
475
|
+
---
|
|
476
|
+
|
|
477
|
+
## 7.2 Snapshot Revision Metadata
|
|
478
|
+
|
|
479
|
+
Snapshots should expose explicit freshness metadata.
|
|
480
|
+
|
|
481
|
+
Example:
|
|
482
|
+
|
|
483
|
+
```json
|
|
484
|
+
{
|
|
485
|
+
"snapshot_revision": 42,
|
|
486
|
+
"captured_at_ms": 1716738123,
|
|
487
|
+
"loading_state": {
|
|
488
|
+
"active": false,
|
|
489
|
+
"signal": "none",
|
|
490
|
+
"source": "system"
|
|
491
|
+
}
|
|
492
|
+
}
|
|
493
|
+
```
|
|
494
|
+
|
|
495
|
+
### Current Shipped Metadata
|
|
496
|
+
|
|
497
|
+
The current implementation exposes:
|
|
498
|
+
|
|
499
|
+
- `snapshot_revision`
|
|
500
|
+
- `captured_at_ms`
|
|
501
|
+
- advisory `loading_state`
|
|
502
|
+
- `scope` and `target` on wait responses
|
|
503
|
+
- `stability_state` and scoped `change_summary` on wait responses
|
|
504
|
+
|
|
505
|
+
The `loading_state` field is currently an advisory structured object rather than a simple enum value.
|
|
506
|
+
|
|
507
|
+
Wait responses also include a `snapshot_freshness_ms` age value so callers can reason about freshness without inferring it from revision numbers alone.
|
|
508
|
+
|
|
509
|
+
### Requirements
|
|
510
|
+
|
|
511
|
+
- revisions must be monotonically increasing
|
|
512
|
+
- revisions must increment on qualifying hierarchy mutation
|
|
513
|
+
- stale snapshots must be detectable
|
|
514
|
+
- stability state must be explicit
|
|
515
|
+
|
|
516
|
+
### Proposed Stability States
|
|
517
|
+
|
|
518
|
+
The shipped implementation emits `transient` while a wait is still converging and `stable` once the stabilization window has completed.
|
|
519
|
+
|
|
520
|
+
---
|
|
521
|
+
|
|
522
|
+
## 7.3 Loading State Detection
|
|
523
|
+
|
|
524
|
+
The system should expose structured loading semantics when observable.
|
|
525
|
+
|
|
526
|
+
Examples:
|
|
527
|
+
|
|
528
|
+
- progress indicators
|
|
529
|
+
- loading spinners
|
|
530
|
+
- disabled submission states
|
|
531
|
+
- visible loading overlays
|
|
532
|
+
- navigation transition indicators
|
|
533
|
+
|
|
534
|
+
### Important Constraint
|
|
535
|
+
|
|
536
|
+
Loading detection is advisory.
|
|
537
|
+
|
|
538
|
+
It must not be treated as authoritative proof of application readiness.
|
|
539
|
+
|
|
540
|
+
UI convergence remains the primary synchronization signal.
|
|
541
|
+
|
|
542
|
+
---
|
|
543
|
+
|
|
544
|
+
## 7.4 Focused Snapshot Scoping
|
|
545
|
+
|
|
546
|
+
Large hierarchies create latency and token-efficiency problems.
|
|
547
|
+
|
|
548
|
+
The protocol should support scoped synchronization.
|
|
549
|
+
|
|
550
|
+
Examples:
|
|
551
|
+
|
|
552
|
+
- subtree snapshots
|
|
553
|
+
- target-local snapshots
|
|
554
|
+
- focused diff regions
|
|
555
|
+
|
|
556
|
+
### Goals
|
|
557
|
+
|
|
558
|
+
- reduce payload size
|
|
559
|
+
- reduce reasoning complexity
|
|
560
|
+
- improve synchronization latency
|
|
561
|
+
- improve Compose hierarchy handling
|
|
562
|
+
|
|
563
|
+
The shipped runtime exposes scope-aware waits and snapshot delta summaries on UI tree and debug snapshot responses to keep this signal lightweight.
|
|
564
|
+
|
|
565
|
+
---
|
|
566
|
+
|
|
567
|
+
## 7.5 Incremental Snapshot Delivery
|
|
568
|
+
|
|
569
|
+
The protocol should support incremental hierarchy updates.
|
|
570
|
+
|
|
571
|
+
Example capabilities:
|
|
572
|
+
|
|
573
|
+
- structural diffs
|
|
574
|
+
- subtree invalidation
|
|
575
|
+
- partial hierarchy refreshes
|
|
576
|
+
- revision patch delivery
|
|
577
|
+
|
|
578
|
+
The shipped runtime currently exposes revision-aware `snapshot_delta` metadata rather than transport-level patch payloads.
|
|
579
|
+
|
|
580
|
+
### Dependency
|
|
581
|
+
|
|
582
|
+
Incremental synchronization depends on stable element identity semantics.
|
|
583
|
+
|
|
584
|
+
This capability therefore depends on the richer element identity RFC.
|
|
585
|
+
|
|
586
|
+
---
|
|
587
|
+
|
|
588
|
+
# 8. Synchronization Lifecycle Model
|
|
589
|
+
|
|
590
|
+
Synchronization should follow a consistent lifecycle.
|
|
591
|
+
|
|
592
|
+
```text
|
|
593
|
+
Action Executed
|
|
594
|
+
↓
|
|
595
|
+
Transient UI Mutation
|
|
596
|
+
↓
|
|
597
|
+
Hierarchy Revision Changes
|
|
598
|
+
↓
|
|
599
|
+
Optional Loading State
|
|
600
|
+
↓
|
|
601
|
+
Convergence Detection
|
|
602
|
+
↓
|
|
603
|
+
Stable Snapshot Available
|
|
604
|
+
↓
|
|
605
|
+
Verification Phase
|
|
606
|
+
```
|
|
607
|
+
|
|
608
|
+
This lifecycle is intended to standardize synchronization expectations across tools and agents.
|
|
609
|
+
|
|
610
|
+
---
|
|
611
|
+
|
|
612
|
+
# 9. Agent Guidance and Guardrails
|
|
613
|
+
|
|
614
|
+
## Preferred Flow
|
|
615
|
+
|
|
616
|
+
```text
|
|
617
|
+
perform_action
|
|
618
|
+
→ wait_for_ui_change
|
|
619
|
+
→ verify_expected_state
|
|
620
|
+
```
|
|
621
|
+
|
|
622
|
+
---
|
|
623
|
+
|
|
624
|
+
## Avoid
|
|
625
|
+
|
|
626
|
+
```text
|
|
627
|
+
perform_action
|
|
628
|
+
→ immediate_follow_up_action
|
|
629
|
+
```
|
|
630
|
+
|
|
631
|
+
---
|
|
632
|
+
|
|
633
|
+
## Network and Log Signals
|
|
634
|
+
|
|
635
|
+
Network activity and logs may be used for diagnostics.
|
|
636
|
+
|
|
637
|
+
They should not be treated as primary synchronization signals unless explicitly required for a workflow.
|
|
638
|
+
|
|
639
|
+
---
|
|
640
|
+
|
|
641
|
+
## Retry Behavior
|
|
642
|
+
|
|
643
|
+
Retries should occur only after:
|
|
644
|
+
|
|
645
|
+
- synchronization failure
|
|
646
|
+
- verification failure
|
|
647
|
+
- explicit timeout
|
|
648
|
+
|
|
649
|
+
Retries should not replace synchronization primitives.
|
|
650
|
+
|
|
651
|
+
---
|
|
652
|
+
|
|
653
|
+
# 10. Failure Modes
|
|
654
|
+
|
|
655
|
+
## Infinite Animations
|
|
656
|
+
|
|
657
|
+
Continuous animations may prevent convergence.
|
|
658
|
+
|
|
659
|
+
Mitigation:
|
|
660
|
+
|
|
661
|
+
- scoped synchronization
|
|
662
|
+
- stabilization thresholds
|
|
663
|
+
- ignore-list heuristics
|
|
664
|
+
|
|
665
|
+
---
|
|
666
|
+
|
|
667
|
+
## Background Recomposition Churn
|
|
668
|
+
|
|
669
|
+
Compose and SwiftUI may produce frequent transient hierarchy mutations.
|
|
670
|
+
|
|
671
|
+
Mitigation:
|
|
672
|
+
|
|
673
|
+
- stabilization windows
|
|
674
|
+
- semantic diff filtering
|
|
675
|
+
- subtree scoping
|
|
676
|
+
|
|
677
|
+
---
|
|
678
|
+
|
|
679
|
+
## Ephemeral UI Elements
|
|
680
|
+
|
|
681
|
+
Examples:
|
|
682
|
+
|
|
683
|
+
- toasts
|
|
684
|
+
- snackbars
|
|
685
|
+
- temporary overlays
|
|
686
|
+
|
|
687
|
+
Mitigation:
|
|
688
|
+
|
|
689
|
+
- bounded stabilization windows
|
|
690
|
+
- semantic significance filtering
|
|
691
|
+
|
|
692
|
+
---
|
|
693
|
+
|
|
694
|
+
## Delayed Navigation Transitions
|
|
695
|
+
|
|
696
|
+
Navigation may begin after asynchronous work.
|
|
697
|
+
|
|
698
|
+
Mitigation:
|
|
699
|
+
|
|
700
|
+
- longer synchronization windows
|
|
701
|
+
- explicit verification after wait completion
|
|
702
|
+
|
|
703
|
+
---
|
|
704
|
+
|
|
705
|
+
## Stale Cached Snapshots
|
|
706
|
+
|
|
707
|
+
Agents may reason against outdated hierarchy state.
|
|
708
|
+
|
|
709
|
+
Mitigation:
|
|
710
|
+
|
|
711
|
+
- explicit revision metadata
|
|
712
|
+
- freshness checks
|
|
713
|
+
- revision-aware synchronization
|
|
714
|
+
|
|
715
|
+
---
|
|
716
|
+
|
|
717
|
+
# 11. Platform Considerations
|
|
718
|
+
|
|
719
|
+
## Android Views
|
|
720
|
+
|
|
721
|
+
Traditional view hierarchies are comparatively stable but may still experience delayed transitions and asynchronous rendering.
|
|
722
|
+
|
|
723
|
+
---
|
|
724
|
+
|
|
725
|
+
## Jetpack Compose
|
|
726
|
+
|
|
727
|
+
Compose introduces:
|
|
728
|
+
|
|
729
|
+
- recomposition churn
|
|
730
|
+
- transient hierarchy instability
|
|
731
|
+
- frequent semantic tree mutation
|
|
732
|
+
|
|
733
|
+
Compose synchronization should prefer:
|
|
734
|
+
|
|
735
|
+
- semantic stability
|
|
736
|
+
- subtree scoping
|
|
737
|
+
- stabilization windows
|
|
738
|
+
|
|
739
|
+
---
|
|
740
|
+
|
|
741
|
+
## UIKit
|
|
742
|
+
|
|
743
|
+
UIKit transitions are generally deterministic but may include animation timing gaps.
|
|
744
|
+
|
|
745
|
+
Synchronization should prioritize observable hierarchy completion rather than transition timing assumptions.
|
|
746
|
+
|
|
747
|
+
---
|
|
748
|
+
|
|
749
|
+
## SwiftUI
|
|
750
|
+
|
|
751
|
+
SwiftUI shares several synchronization challenges with Compose:
|
|
752
|
+
|
|
753
|
+
- transient updates
|
|
754
|
+
- declarative rendering churn
|
|
755
|
+
- delayed state propagation
|
|
756
|
+
|
|
757
|
+
Stabilization windows are especially important.
|
|
758
|
+
|
|
759
|
+
---
|
|
760
|
+
|
|
761
|
+
# 12. Telemetry and Metrics
|
|
762
|
+
|
|
763
|
+
The implementation should track:
|
|
764
|
+
|
|
765
|
+
- synchronization success rate
|
|
766
|
+
- premature action reduction
|
|
767
|
+
- retry reduction rate
|
|
768
|
+
- stale snapshot detection frequency
|
|
769
|
+
- average stabilization duration
|
|
770
|
+
- hierarchy diff frequency
|
|
771
|
+
- synchronization timeout frequency
|
|
772
|
+
|
|
773
|
+
These metrics should be used to tune convergence heuristics.
|
|
774
|
+
|
|
775
|
+
---
|
|
776
|
+
|
|
777
|
+
# 13. Rollout Strategy
|
|
778
|
+
|
|
779
|
+
## Phase 1
|
|
780
|
+
|
|
781
|
+
Introduce:
|
|
782
|
+
|
|
783
|
+
- snapshot revision metadata
|
|
784
|
+
- basic wait_for_ui_change
|
|
785
|
+
- stabilization windows
|
|
786
|
+
|
|
787
|
+
---
|
|
788
|
+
|
|
789
|
+
## Phase 2
|
|
790
|
+
|
|
791
|
+
Introduce:
|
|
792
|
+
|
|
793
|
+
- loading state detection
|
|
794
|
+
- convergence heuristics
|
|
795
|
+
- scoped synchronization
|
|
796
|
+
|
|
797
|
+
---
|
|
798
|
+
|
|
799
|
+
## Phase 3
|
|
800
|
+
|
|
801
|
+
Introduce:
|
|
802
|
+
|
|
803
|
+
- incremental snapshot delivery
|
|
804
|
+
- diff-based synchronization
|
|
805
|
+
- subtree invalidation
|
|
806
|
+
|
|
807
|
+
The runtime now exposes scoped diff summaries for waits, but full partial-hierarchy patch delivery remains a future protocol extension.
|
|
808
|
+
|
|
809
|
+
---
|
|
810
|
+
|
|
811
|
+
## Phase 4
|
|
812
|
+
|
|
813
|
+
Introduce:
|
|
814
|
+
|
|
815
|
+
- advanced convergence tuning
|
|
816
|
+
- platform-specific optimization
|
|
817
|
+
- adaptive stabilization heuristics
|
|
818
|
+
|
|
819
|
+
---
|
|
820
|
+
|
|
821
|
+
# 14. Design Closure
|
|
822
|
+
|
|
823
|
+
This specification is fully defined and implementation-ready.
|
|
824
|
+
|
|
825
|
+
All previously listed open questions have been resolved within normative sections 7.x and 7.1.1.
|
|
826
|
+
|
|
827
|
+
No runtime behavior is delegated to interpretation.
|
|
828
|
+
|
|
829
|
+
Future changes require a new RFC or explicit versioned amendment.
|
|
830
|
+
|
|
831
|
+
The following areas are fully specified:
|
|
832
|
+
|
|
833
|
+
- implicit vs explicit execution model (explicit only)
|
|
834
|
+
- mutation classification (normative rules defined in 7.1)
|
|
835
|
+
- stabilization semantics (7.1.1)
|
|
836
|
+
- diff semantics (structural + semantic accessibility only)
|
|
837
|
+
- default synchronization scope (screen)
|
|
838
|
+
|
|
839
|
+
# 15. Dependencies
|
|
840
|
+
|
|
841
|
+
## Depends On
|
|
842
|
+
|
|
843
|
+
- Stronger State Verification
|
|
844
|
+
- Richer Element Identity
|
|
845
|
+
|
|
846
|
+
---
|
|
847
|
+
|
|
848
|
+
## Strengthens
|
|
849
|
+
|
|
850
|
+
- Actionability Resolution
|
|
851
|
+
- Compose and Custom Control Semantics
|
|
852
|
+
- Incremental Snapshot Systems
|
|
853
|
+
- Advanced Trace Correlation
|
|
854
|
+
- Retry Reduction Initiatives
|
|
855
|
+
|
|
856
|
+
---
|
|
857
|
+
|
|
858
|
+
# 16. Conclusion
|
|
859
|
+
|
|
860
|
+
Reliable synchronization is foundational to deterministic mobile automation.
|
|
861
|
+
|
|
862
|
+
This RFC introduces explicit synchronization semantics that:
|
|
863
|
+
|
|
864
|
+
- reduce premature execution
|
|
865
|
+
- improve snapshot freshness awareness
|
|
866
|
+
- provide deterministic convergence behavior
|
|
867
|
+
- establish consistent sequencing expectations
|
|
868
|
+
- create a foundation for incremental synchronization capabilities
|
|
869
|
+
|
|
870
|
+
These changes are intended to improve reliability, reduce retries, and make agent behavior substantially more predictable across asynchronous mobile UI frameworks.
|