mobile-debug-mcp 0.26.4 → 0.27.0

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.
@@ -0,0 +1,253 @@
1
+ # RFC 011.1 — Recovery Contract Types & Runtime Wiring Spec
2
+
3
+ ## 1. Purpose
4
+
5
+ This document defines the typed runtime contract required to implement RFC 011 safely and consistently across:
6
+
7
+ - src/server
8
+ - src/interact
9
+ - shared action/result boundaries
10
+
11
+ It removes ambiguity from RFC 011 by formalising:
12
+ - enums
13
+ - state schemas
14
+ - execution payloads
15
+ - failure propagation format
16
+
17
+ ---
18
+
19
+ ## 2. Design Principle
20
+
21
+ Recovery is not a behaviour description.
22
+
23
+ It is a typed state machine over execution results.
24
+
25
+ All recovery decisions MUST be derivable from structured runtime data.
26
+
27
+ ---
28
+
29
+ ## 3. Core Runtime Types
30
+
31
+ ### 3.1 Failure Class
32
+
33
+ ```ts
34
+ type FailureClass =
35
+ | "TargetResolutionFailure"
36
+ | "ExecutionFailure"
37
+ | "VerificationFailure"
38
+ | "ControlConvergenceFailure"
39
+ | "SemanticMismatchFailure";
40
+ ```
41
+
42
+ ---
43
+
44
+ ### 3.2 Recovery Strategy
45
+
46
+ ```ts
47
+ type RecoveryStrategy =
48
+ | "re_resolve"
49
+ | "alternate_candidate"
50
+ | "state_refresh"
51
+ | "retry_adjustment"
52
+ | "step_back";
53
+ ```
54
+
55
+ ---
56
+
57
+ ### 3.3 Runtime Failure Code
58
+
59
+ ```ts
60
+ type RuntimeFailureCode =
61
+ | "ELEMENT_NOT_FOUND"
62
+ | "STALE_REFERENCE"
63
+ | "AMBIGUOUS_TARGET"
64
+ | "TIMEOUT"
65
+ | "ACTION_REJECTED"
66
+ | "VERIFICATION_FAILED"
67
+ | "EXPECT_STATE_MISMATCH"
68
+ | "CONTROL_CONVERGENCE_FAILED"
69
+ | "SEMANTIC_MISMATCH"
70
+ | "UNKNOWN";
71
+ ```
72
+
73
+ ---
74
+
75
+ ### 3.4 Recovery State
76
+
77
+ ```ts
78
+ interface RecoveryState {
79
+ failure_class: FailureClass;
80
+ runtime_code: RuntimeFailureCode;
81
+
82
+ recovery_strategy?: RecoveryStrategy;
83
+
84
+ recovery_attempts: number;
85
+ max_recovery_attempts: number;
86
+
87
+ retry_depth: number;
88
+ max_retry_depth: number;
89
+
90
+ is_terminal: boolean;
91
+
92
+ // derived from runtime retryable signal
93
+ retry_allowed?: boolean;
94
+ }
95
+ ```
96
+
97
+ ---
98
+
99
+ ## 4. Execution Result Integration (ActionExecutionResult)
100
+
101
+ This RFC does NOT introduce a new execution result type. Instead, it extends the existing runtime ActionExecutionResult / tool response envelope.
102
+
103
+ The recovery contract MUST be attached as an extension field.
104
+
105
+ ```ts
106
+ type ActionExecutionResult = {
107
+ success: boolean;
108
+
109
+ action_type: string;
110
+ target_id?: string;
111
+
112
+ // existing runtime error representation (already present in system)
113
+ failure_code?: RuntimeFailureCode;
114
+
115
+ // existing runtime retry signal
116
+ retryable?: boolean;
117
+
118
+ // RFC 011.1 extension
119
+ recovery?: RecoveryState;
120
+ };
121
+ ```
122
+
123
+ The recovery extension MUST NOT replace or duplicate existing failure_code semantics. Instead, failure_code remains the source input for deriving FailureClass and RecoveryState. RecoveryState is a structured interpretation layer built on top of existing execution results.
124
+
125
+ Existing retryable semantics remain authoritative for whether an action may be directly retried.
126
+
127
+ - retryable answers whether an execution may be retried.
128
+ - RecoveryState defines how recovery proceeds when failure occurs.
129
+
130
+ RecoveryState augments retryability; it does not replace it.
131
+
132
+ ---
133
+
134
+ ## 5. Server → Interact Contract
135
+
136
+ ### 5.1 Server responsibilities
137
+ - map raw runtime errors → RuntimeFailureCode
138
+ - attach initial FailureClass
139
+ - initialise recovery state defaults
140
+
141
+ ### 5.2 Interact responsibilities
142
+ - consume RecoveryState
143
+ - mutate recovery_attempts and retry_depth
144
+ - select RecoveryStrategy
145
+ - enforce bounds
146
+
147
+ Interact is the only layer allowed to mutate recovery state.
148
+
149
+ ---
150
+
151
+ ## 6. Deterministic Mapping Function
152
+
153
+ ```ts
154
+ function mapRuntimeCodeToFailureClass(code: RuntimeFailureCode): FailureClass {
155
+ switch (code) {
156
+ case "ELEMENT_NOT_FOUND":
157
+ case "STALE_REFERENCE":
158
+ case "AMBIGUOUS_TARGET":
159
+ return "TargetResolutionFailure";
160
+
161
+ case "TIMEOUT":
162
+ case "ACTION_REJECTED":
163
+ case "UNKNOWN":
164
+ return "ExecutionFailure";
165
+
166
+ case "VERIFICATION_FAILED":
167
+ case "EXPECT_STATE_MISMATCH":
168
+ return "VerificationFailure";
169
+
170
+ case "CONTROL_CONVERGENCE_FAILED":
171
+ return "ControlConvergenceFailure";
172
+
173
+ case "SEMANTIC_MISMATCH":
174
+ return "SemanticMismatchFailure";
175
+ }
176
+ }
177
+ ```
178
+
179
+ ---
180
+
181
+ ## 7. Step-back Semantics
182
+
183
+ Step-back MUST be implemented as re-entry into resolution + execution pipeline, NOT state rollback.
184
+
185
+ ---
186
+
187
+ ## 8. Budget Enforcement Rules
188
+
189
+ ```ts
190
+ const RECOVERY_LIMITS = {
191
+ max_recovery_attempts: 3,
192
+ max_retry_depth: 3
193
+ };
194
+ ```
195
+
196
+ - MUST increment recovery_attempts per recovery cycle
197
+ - MUST increment retry_depth per re-resolution loop
198
+ - MUST terminate when limits exceeded
199
+
200
+ ### Retryability Gating Rules
201
+
202
+ Recovery strategies MUST honor existing retryable semantics.
203
+
204
+ If retryable=false:
205
+ - direct identical-action retry MUST NOT be selected
206
+ - retry_adjustment MUST NOT be selected
207
+ - re_resolve or alternate_candidate SHOULD be preferred
208
+
209
+ If retryable=true:
210
+ - retry_adjustment MAY be selected subject to recovery budgets
211
+
212
+ This prevents contradiction between runtime execution constraints and recovery policy.
213
+
214
+ ---
215
+
216
+ ## 9. Failure Output Contract
217
+
218
+ ```ts
219
+ interface TerminalFailure {
220
+ failure_class: FailureClass;
221
+ runtime_code: RuntimeFailureCode;
222
+
223
+ resolved_target?: string;
224
+
225
+ recovery_attempts: number;
226
+
227
+ attempted_recovery_strategies: RecoveryStrategy[];
228
+
229
+ final_state: "failed";
230
+ }
231
+ ```
232
+
233
+ ---
234
+
235
+ ## 10. Integration Summary
236
+
237
+ This spec defines the typed contract required for implementing RFC 011 across server and interact layers.
238
+
239
+ ### 10.1 Runtime Wiring Constraint
240
+
241
+ This specification MUST be implemented by extending existing ActionExecutionResult objects in both src/server and src/interact.
242
+
243
+ No new parallel execution envelope is permitted.
244
+
245
+ RecoveryState is an additive field only.
246
+
247
+ Failure interpretation MUST continue to use existing failure_code fields as the source of truth.
248
+
249
+ ---
250
+
251
+ ## 11. Summary
252
+
253
+ This document formalises recovery as a deterministic, typed execution subsystem.
@@ -0,0 +1,203 @@
1
+
2
+
3
+
4
+ # RFC 012 — Action Trace and Execution Observability
5
+
6
+ ## 1. Summary
7
+
8
+ This RFC defines a structured execution trace model for all actions within the MCP runtime. It provides visibility into resolution, execution, verification, stabilization, and recovery stages.
9
+
10
+ The goal is to make system behavior explainable, debuggable, and measurable without altering execution semantics.
11
+
12
+ ---
13
+
14
+ ## 2. Problem Statement
15
+
16
+ As the system has evolved (RFC 005–011), execution has become more reliable but also more opaque due to:
17
+
18
+ - stabilization loops masking transient failures
19
+ - recovery logic retrying actions without visibility
20
+ - multiple execution stages (resolve → execute → verify → stabilize → recover)
21
+
22
+ Current outputs provide final results but lack a structured explanation of how those results were reached.
23
+
24
+ ---
25
+
26
+ ## 3. Goals
27
+
28
+ This RFC introduces an execution trace model that MUST:
29
+
30
+ - provide a step-by-step record of action execution
31
+ - expose resolution, execution, verification, stabilization, and recovery stages
32
+ - remain deterministic and low-overhead
33
+ - be consistent across all tools and handlers
34
+
35
+ ---
36
+
37
+ ## 4. Non-Goals
38
+
39
+ This RFC does NOT define:
40
+
41
+ - external logging systems
42
+ - UI visualization layers
43
+ - distributed tracing infrastructure
44
+
45
+ It is strictly an in-process observability model.
46
+
47
+ ---
48
+
49
+ ## 5. Runtime Surfaces
50
+
51
+ Trace data MUST be emitted from:
52
+
53
+ - src/server (resolution)
54
+ - src/interact (execution and verification)
55
+ - stabilization layer (RFC 010)
56
+ - recovery layer (RFC 011)
57
+
58
+ All action flows MUST produce a trace.
59
+
60
+ ---
61
+
62
+ ## 6. Trace Model
63
+
64
+ ### 6.1 ActionTrace
65
+
66
+ ```ts
67
+ interface ActionTrace {
68
+ action_id: string;
69
+ steps: TraceStep[];
70
+ final_outcome: "success" | "failure";
71
+ attempts: number;
72
+ }
73
+ ```
74
+
75
+ ### 6.2 TraceStep
76
+
77
+ ```ts
78
+ interface TraceStep {
79
+ stage: "resolve" | "execute" | "verify" | "stabilize" | "recover";
80
+ timestamp: number;
81
+ result: "success" | "failure" | "retry";
82
+ metadata?: Record<string, any>;
83
+ }
84
+ ```
85
+
86
+ ---
87
+
88
+ ## 7. Stage Emission Rules
89
+
90
+ ### 7.1 Resolve Stage
91
+
92
+ - emitted by findElementHandler and related resolution logic
93
+ - includes selector, matched element, and confidence (if available)
94
+
95
+ ### 7.2 Execute Stage
96
+
97
+ - emitted by action handlers (tap, type_text, scroll_to_element, etc.)
98
+ - represents the execution attempt
99
+
100
+ ### 7.3 Verify Stage
101
+
102
+ - emitted by expect_* handlers
103
+ - reflects state validation results
104
+
105
+ ### 7.4 Stabilize Stage
106
+
107
+ - emitted by RFC 010 stabilization logic
108
+ - includes stabilization attempts and convergence status
109
+
110
+ ### 7.5 Recover Stage
111
+
112
+ - emitted by RFC 011 recovery logic
113
+ - includes strategy used and retry attempts
114
+
115
+ ### 7.6 Step Emission Timing
116
+
117
+ Each stage MUST emit a TraceStep at the point where its outcome is determined:
118
+
119
+ - resolve: after target selection is finalized
120
+ - execute: after action handler completes (success or failure)
121
+ - verify: after verification result is computed
122
+ - stabilize: after stabilization loop completes (success or failure)
123
+ - recover: after a recovery attempt is decided and executed
124
+
125
+ Each retry or re-attempt MUST emit a separate step.
126
+
127
+ ---
128
+
129
+ ## 8. Deterministic Behavior
130
+
131
+ Trace emission MUST NOT:
132
+
133
+ - alter execution flow
134
+ - introduce timing side effects
135
+ - affect success/failure outcomes
136
+
137
+ It is strictly observational.
138
+
139
+ ---
140
+
141
+ ## 9. Minimal Metadata Contract
142
+
143
+ Implementations SHOULD include where available:
144
+
145
+ - selector or target identifier
146
+ - snapshot identifiers
147
+ - stabilization attempt counts
148
+ - recovery strategy name
149
+
150
+ Metadata MUST remain lightweight.
151
+
152
+ ---
153
+
154
+ ## 10. Integration with Existing RFCs
155
+
156
+ - RFC 006: execution emits execute stage
157
+ - RFC 007: resolution emits resolve stage
158
+ - RFC 010: stabilization emits stabilize stage
159
+ - RFC 011: recovery emits recover stage
160
+
161
+ This RFC unifies these into a single trace model.
162
+
163
+ ---
164
+
165
+ ## 11. Output Behavior
166
+
167
+ Trace MAY be returned as part of action results or stored internally.
168
+
169
+ Example:
170
+
171
+ ```ts
172
+ interface ActionExecutionResult {
173
+ success: boolean;
174
+ failure_code?: string;
175
+ trace?: ActionTrace;
176
+ }
177
+ ```
178
+
179
+ ---
180
+
181
+ ## 12. Failure Analysis
182
+
183
+ Trace data MUST allow identification of:
184
+
185
+ - resolution failures
186
+ - execution failures
187
+ - verification mismatches
188
+ - stabilization convergence issues
189
+ - recovery attempts and outcomes
190
+
191
+ ---
192
+
193
+ ## 13. Success Metrics
194
+
195
+ - improved debuggability of failures
196
+ - reduced need for manual log inspection
197
+ - clearer differentiation between failure types
198
+
199
+ ---
200
+
201
+ ## 14. Summary
202
+
203
+ This RFC introduces a structured trace model that makes action execution transparent and debuggable. It builds on existing RFCs without changing behavior, enabling better diagnostics and future analytics capabilities.
@@ -80,6 +80,17 @@ MUST be returned in this structure:
80
80
  ui_fingerprint_after: string | null,
81
81
  failure_code?: string,
82
82
  retryable?: boolean,
83
+ recovery?: {
84
+ failure_class: string,
85
+ runtime_code: string,
86
+ recovery_strategy?: string,
87
+ recovery_attempts: number,
88
+ max_recovery_attempts: number,
89
+ retry_depth: number,
90
+ max_retry_depth: number,
91
+ is_terminal: boolean,
92
+ retry_allowed?: boolean
93
+ },
83
94
  device?: DeviceInfo,
84
95
  details?: object
85
96
  }
@@ -93,6 +104,7 @@ Rules:
93
104
  - `source_module` identifies where the envelope was produced
94
105
  - fingerprints represent observed pre/post UI state on a best-effort basis
95
106
  - `failure_code` is optional but MUST be used when a structured mapping exists
107
+ - `recovery` MAY be attached to failed actions to carry typed recovery metadata
96
108
 
97
109
  ### 4.4 Allowed Deviations
98
110
 
@@ -244,6 +256,7 @@ Raw layer contents include:
244
256
  - UI hierarchy or accessibility tree
245
257
  - normalized readable element state where exposed by the platform
246
258
  - platform-native identity hints such as stable identifiers, roles, and test tags
259
+ - semantic control metadata when derivable from the raw tree, including `semantic_role`, `supported_actions`, `adjustable`, and `state_shape`
247
260
  - snapshot metadata such as `snapshot_revision` and `captured_at_ms`
248
261
  - `loading_state` when a reliable loading signal is detectable
249
262
  - screenshot when available
@@ -292,6 +305,27 @@ Semantic output MUST NOT replace classification or verification.
292
305
 
293
306
  Classification remains a supplementary, post-action interpretation mechanism.
294
307
 
308
+ ### 9.4 Semantic Control Metadata
309
+
310
+ When present, semantic control metadata MAY include:
311
+
312
+ ```ts
313
+ {
314
+ semantic_role?: 'slider' | 'stepper' | 'dropdown' | 'segmented_control' | 'custom_adjustable' | 'composite_control' | null,
315
+ supported_actions?: string[] | null,
316
+ adjustable?: boolean | null,
317
+ state_shape?: 'continuous' | 'discrete' | 'semantic' | null
318
+ }
319
+ ```
320
+
321
+ Rules:
322
+
323
+ - semantic control metadata is derived and best-effort
324
+ - raw platform roles and state remain authoritative on conflict
325
+ - `adjustable` MAY be inferred from platform traits when no known role matches
326
+ - `state_shape` MUST respect known control roles before value-based heuristics
327
+ - `supported_actions` are hints only and MUST NOT be treated as guaranteed executable actions
328
+
295
329
  ## 10. Classification
296
330
 
297
331
  Tool: `classify_action_outcome`
@@ -395,6 +395,16 @@ Failure response:
395
395
  "success": false,
396
396
  "failure_code": "STALE_REFERENCE",
397
397
  "retryable": true,
398
+ "recovery": {
399
+ "failure_class": "TargetResolutionFailure",
400
+ "runtime_code": "STALE_REFERENCE",
401
+ "recovery_attempts": 0,
402
+ "max_recovery_attempts": 3,
403
+ "retry_depth": 0,
404
+ "max_retry_depth": 3,
405
+ "is_terminal": false,
406
+ "retry_allowed": true
407
+ },
398
408
  "ui_fingerprint_before": "fp_before",
399
409
  "ui_fingerprint_after": "fp_before"
400
410
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mobile-debug-mcp",
3
- "version": "0.26.4",
3
+ "version": "0.27.0",
4
4
  "description": "MCP server for mobile app debugging (Android + iOS), with focus on security and reliability",
5
5
  "type": "module",
6
6
  "bin": {