mobile-debug-mcp 0.33.0 → 0.35.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.
Files changed (448) hide show
  1. package/.agents/skills/mcp-builder/SKILL.md +44 -64
  2. package/.agents/skills/mcp-builder/references/build-flags.md +44 -43
  3. package/.agents/skills/mcp-builder/references/diagnostics-schema.md +4 -1
  4. package/.agents/skills/mcp-builder/references/toolchain-details.md +49 -62
  5. package/.agents/skills/spec-review/references/spec-review-checklist.md +7 -0
  6. package/.agents/skills/test-authoring/SKILL.md +7 -6
  7. package/.agents/skills/test-authoring/references/repo-test-layout.md +3 -1
  8. package/.agents/skills/test-authoring/references/test-authoring-workflow.md +16 -7
  9. package/.agents/skills/test-authoring/references/test-quality-checklist.md +2 -1
  10. package/.github/copilot-instructions.md +14 -36
  11. package/.github/workflows/ci.yml +23 -2
  12. package/AGENTS.md +12 -3
  13. package/CONTRIBUTING.md +79 -0
  14. package/README.md +158 -124
  15. package/agent-plugin/.claude-plugin/plugin.json +2 -2
  16. package/agent-plugin/.codex-plugin/plugin.json +1 -1
  17. package/agent-plugin/.cursor-plugin/plugin.json +2 -2
  18. package/agent-plugin/.mcp.json +1 -1
  19. package/agent-plugin/README.md +20 -6
  20. package/agent-plugin/mcp.json +1 -1
  21. package/agent-plugin/plugin.json +1 -1
  22. package/agent-plugin/skills/mobile-debug-mcp/SKILL.md +113 -4
  23. package/dist/contracts/execution-controls.js +24 -0
  24. package/dist/contracts/selector.js +8 -0
  25. package/dist/contracts/target.js +15 -0
  26. package/dist/contracts/ui.js +1 -0
  27. package/dist/debugger/android.js +79 -0
  28. package/dist/debugger/diagnostics.js +54 -0
  29. package/dist/debugger/guard.js +30 -0
  30. package/dist/debugger/protocol.js +33 -0
  31. package/dist/debugger/sessions.js +304 -0
  32. package/dist/debugger/worker.js +176 -0
  33. package/dist/interact/adjustment/adjustment-context.js +41 -0
  34. package/dist/interact/adjustment/adjustment-gestures.js +55 -0
  35. package/dist/interact/adjustment/adjustment-plan.js +18 -0
  36. package/dist/interact/adjustment/adjustment-resolution.js +127 -0
  37. package/dist/interact/adjustment/adjustment-result.js +19 -0
  38. package/dist/interact/adjustment/adjustment-semantic.js +64 -0
  39. package/dist/interact/adjustment/adjustment-verification.js +35 -0
  40. package/dist/interact/adjustment/adjustment.js +52 -0
  41. package/dist/interact/adjustment/control-geometry.js +87 -0
  42. package/dist/interact/adjustment/control-values.js +136 -0
  43. package/dist/interact/adjustment/slider-labels.js +84 -0
  44. package/dist/interact/assertions/screen-assertion.js +37 -0
  45. package/dist/interact/assertions/state-assertion-context.js +35 -0
  46. package/dist/interact/assertions/state-assertion.js +76 -0
  47. package/dist/interact/assertions/state-comparison.js +141 -0
  48. package/dist/interact/assertions/visibility-assertion.js +34 -0
  49. package/dist/interact/conditional-action.js +12 -7
  50. package/dist/interact/index.js +65 -3074
  51. package/dist/interact/input-service.js +1 -0
  52. package/dist/interact/interaction-trace.js +21 -0
  53. package/dist/interact/model.js +1 -0
  54. package/dist/interact/observation.js +1 -0
  55. package/dist/interact/targeting/candidate-ancestor.js +58 -0
  56. package/dist/interact/targeting/candidate-result.js +23 -0
  57. package/dist/interact/targeting/candidate-scoring.js +50 -0
  58. package/dist/interact/targeting/element-helpers.js +216 -0
  59. package/dist/interact/targeting/find-element.js +65 -0
  60. package/dist/interact/targeting/nearby-control.js +56 -0
  61. package/dist/interact/targeting/resolved-elements.js +21 -0
  62. package/dist/interact/targeting/tap-target.js +17 -0
  63. package/dist/interact/targeting/target-scope.js +104 -0
  64. package/dist/interact/waits/legacy-log-wait.js +38 -0
  65. package/dist/interact/waits/legacy-wait-observations.js +103 -0
  66. package/dist/interact/waits/legacy-wait-state.js +34 -0
  67. package/dist/interact/waits/legacy-wait.js +48 -0
  68. package/dist/interact/waits/screen-wait.js +49 -0
  69. package/dist/interact/waits/ui-change-helpers.js +157 -0
  70. package/dist/interact/waits/ui-change-state.js +18 -0
  71. package/dist/interact/waits/ui-change-wait.js +77 -0
  72. package/dist/interact/waits/ui-wait-condition.js +56 -0
  73. package/dist/interact/waits/ui-wait-state.js +38 -0
  74. package/dist/interact/waits/ui-wait.js +106 -0
  75. package/dist/manage/android.js +55 -51
  76. package/dist/manage/index.js +38 -75
  77. package/dist/manage/ios/build-types.js +1 -0
  78. package/dist/manage/ios/build.js +210 -0
  79. package/dist/manage/ios/project-discovery.js +29 -0
  80. package/dist/manage/ios/scheme.js +18 -0
  81. package/dist/manage/ios.js +42 -256
  82. package/dist/observe/android/context.js +1 -0
  83. package/dist/observe/android/current-screen.js +55 -0
  84. package/dist/observe/android/fingerprint.js +13 -0
  85. package/dist/observe/android/log-stream.js +132 -0
  86. package/dist/observe/android/logs.js +107 -0
  87. package/dist/observe/android/screenshot.js +70 -0
  88. package/dist/observe/android/ui-tree.js +107 -0
  89. package/dist/observe/android.js +16 -520
  90. package/dist/observe/evidence.js +122 -76
  91. package/dist/observe/index.js +16 -263
  92. package/dist/observe/ios/context.js +16 -0
  93. package/dist/observe/ios/fingerprint.js +12 -0
  94. package/dist/observe/ios/log-stream.js +105 -0
  95. package/dist/observe/ios/logs.js +168 -0
  96. package/dist/observe/ios/screenshot.js +22 -0
  97. package/dist/observe/ios/ui-elements.js +241 -0
  98. package/dist/observe/ios/ui-tree.js +137 -0
  99. package/dist/observe/ios.js +17 -715
  100. package/dist/observe/logs/model.js +1 -0
  101. package/dist/{network → observe/network}/index.js +2 -2
  102. package/dist/observe/readiness-service.js +13 -2
  103. package/dist/observe/readiness.js +44 -18
  104. package/dist/observe/screenshot-encoding.js +41 -0
  105. package/dist/observe/snapshot-collection.js +79 -0
  106. package/dist/observe/snapshot-logs.js +30 -0
  107. package/dist/observe/snapshot-metadata.js +43 -31
  108. package/dist/observe/snapshot-semantic.js +115 -0
  109. package/dist/observe/system-trace-android.js +135 -0
  110. package/dist/observe/system-trace.js +294 -0
  111. package/dist/runtime/action-results.js +270 -0
  112. package/dist/runtime/clock.js +4 -0
  113. package/dist/server/common.js +1 -256
  114. package/dist/server/definitions/assert.js +162 -0
  115. package/dist/server/definitions/diagnostic.js +118 -0
  116. package/dist/server/definitions/input.js +274 -0
  117. package/dist/server/definitions/manage.js +194 -0
  118. package/dist/server/definitions/observe.js +149 -0
  119. package/dist/server/definitions/target.js +138 -0
  120. package/dist/server/definitions/wait.js +105 -0
  121. package/dist/server/handlers/action-execution.js +163 -0
  122. package/dist/server/handlers/correlation.js +23 -0
  123. package/dist/server/handlers/debugger-handlers.js +48 -0
  124. package/dist/server/handlers/debugger-response.js +9 -0
  125. package/dist/server/handlers/diagnostic.js +69 -0
  126. package/dist/server/handlers/handler-types.js +1 -0
  127. package/dist/server/handlers/input.js +154 -0
  128. package/dist/server/handlers/interact.js +113 -0
  129. package/dist/server/handlers/journey-assertions.js +35 -0
  130. package/dist/server/handlers/journey.js +147 -0
  131. package/dist/server/handlers/manage.js +119 -0
  132. package/dist/server/handlers/observe.js +95 -0
  133. package/dist/server/handlers/payload.js +4 -0
  134. package/dist/server/handlers/tool-handlers.js +160 -0
  135. package/dist/server/schemas/condition-schema.js +2 -0
  136. package/dist/server/schemas/debugger-schema.js +47 -0
  137. package/dist/server/{journey-schema.js → schemas/journey-schema.js} +8 -22
  138. package/dist/server/schemas/system-trace-schema.js +17 -0
  139. package/dist/server/tool-definitions.js +62 -1134
  140. package/dist/server-core.js +4 -4
  141. package/dist/server.js +34 -0
  142. package/dist/system/android-status.js +101 -0
  143. package/dist/system/android.js +37 -27
  144. package/dist/system/index.js +13 -438
  145. package/dist/system/ios-status.js +132 -0
  146. package/dist/system/ios.js +11 -8
  147. package/dist/system/model.js +1 -0
  148. package/dist/system/probes.js +105 -0
  149. package/dist/system/status-summary.js +43 -0
  150. package/dist/system/unsupported-status.js +52 -0
  151. package/dist/utils/android/commands.js +89 -0
  152. package/dist/utils/android/gradle.js +139 -0
  153. package/dist/utils/android/logs.js +103 -0
  154. package/dist/utils/android/ui-tree.js +233 -0
  155. package/dist/utils/android/utils.js +6 -564
  156. package/dist/utils/cli/idb/idb-helper.js +4 -6
  157. package/dist/utils/cli/idb/install-idb.js +13 -9
  158. package/dist/utils/cli/ios/preflight-ios.js +42 -38
  159. package/dist/utils/exec.js +2 -0
  160. package/dist/utils/ios/utils.js +45 -46
  161. package/dist/utils/java.js +75 -57
  162. package/dist/utils/operation-budget.js +2 -0
  163. package/dist/utils/resolve-device.js +6 -2
  164. package/dist/utils/ui/index.js +26 -26
  165. package/docs/CHANGELOG.md +48 -0
  166. package/docs/README.md +38 -0
  167. package/docs/benchmarks/README.md +18 -0
  168. package/docs/benchmarks/interaction-latency/README.md +14 -0
  169. package/docs/benchmarks/interaction-latency/final.md +4 -1
  170. package/docs/benchmarks/interaction-latency/ios-validation.md +2 -0
  171. package/docs/benchmarks/ui-tree-performance/README.md +24 -16
  172. package/docs/benchmarks/ui-tree-performance/comparison.md +11 -10
  173. package/docs/code-structure.md +118 -0
  174. package/docs/specs/001-state-verification/spec.md +16 -14
  175. package/docs/specs/002-richer-element-identity/spec.md +12 -10
  176. package/docs/specs/003-wait-and-synchronization-reliability/spec.md +12 -10
  177. package/docs/specs/004-action-verification-routing/spec.md +3 -3
  178. package/docs/specs/005-unified-action-execution-and-verification-model/spec.md +2 -0
  179. package/docs/specs/006-runtime-action-instrumentation-and-binding-layer/spec.md +2 -0
  180. package/docs/specs/007-actionability-resolution-and-executable-target-selection/spec.md +3 -1
  181. package/docs/specs/008-adjustable-control-support-and-semantic-value-manipulation/spec.md +3 -4
  182. package/docs/specs/009-semantic-control-modeling-for-custom-and-composite-controls/spec.md +2 -0
  183. package/docs/specs/010-verification-stabilization-and-temporal-convergence/spec.md +2 -2
  184. package/docs/specs/011-recovery-and-replanning-for-failed-or-ambiguous-interaction-flows/spec.md +2 -2
  185. package/docs/specs/011.1-recovery-contract-types-and-runtime-wiring-spec/spec.md +2 -0
  186. package/docs/specs/012-action-trace-and-xecution-observability/spec.md +2 -3
  187. package/docs/specs/013-wait-and-synchronization-reliability/spec.md +19 -19
  188. package/docs/specs/014-actionability-resolution/spec.md +20 -18
  189. package/docs/specs/015-adjustable-control-support/spec.md +17 -15
  190. package/docs/specs/016-environment-tools/spec.md +20 -20
  191. package/docs/specs/018-interaction-latency-and-batched-journeys/spec.md +2 -0
  192. package/docs/specs/019-ui-tree-observation-performance/spec.md +3 -1
  193. package/docs/specs/020-conditional-actions/intent.md +5 -3
  194. package/docs/specs/020-conditional-actions/plan.md +8 -9
  195. package/docs/specs/020-conditional-actions/spec.md +4 -2
  196. package/docs/specs/021-app-readiness-signals/intent.md +4 -2
  197. package/docs/specs/021-app-readiness-signals/plan.md +7 -6
  198. package/docs/specs/021-app-readiness-signals/spec.md +3 -1
  199. package/docs/specs/022-correlated-evidence/intent.md +4 -4
  200. package/docs/specs/022-correlated-evidence/plan.md +10 -11
  201. package/docs/specs/022-correlated-evidence/spec.md +3 -1
  202. package/docs/specs/023-android-system-traces/device-evidence.json +38 -0
  203. package/docs/specs/023-android-system-traces/emulator-recheck.json +38 -0
  204. package/docs/specs/023-android-system-traces/intent.md +41 -0
  205. package/docs/specs/023-android-system-traces/plan.md +115 -0
  206. package/docs/specs/023-android-system-traces/spec.md +122 -0
  207. package/docs/specs/024-android-heap-dump-capture/intent.md +41 -0
  208. package/docs/specs/025-android-runtime-debugger/intent.md +41 -0
  209. package/docs/specs/025-android-runtime-debugger/plan.md +106 -0
  210. package/docs/specs/025-android-runtime-debugger/spec.md +183 -0
  211. package/docs/specs/026-code-structure-and-quality-gates/health-plan.md +88 -0
  212. package/docs/specs/026-code-structure-and-quality-gates/intent.md +47 -0
  213. package/docs/specs/026-code-structure-and-quality-gates/plan.md +191 -0
  214. package/docs/specs/026-code-structure-and-quality-gates/spec.md +138 -0
  215. package/docs/specs/026-code-structure-and-quality-gates/verification-final.json +200 -0
  216. package/docs/specs/026-code-structure-and-quality-gates/verification-thin-facade.json +154 -0
  217. package/docs/specs/026-code-structure-and-quality-gates/verification.json +136 -0
  218. package/docs/specs/027-debugger-failure-diagnostics/intent.md +43 -0
  219. package/docs/specs/027-debugger-failure-diagnostics/plan.md +86 -0
  220. package/docs/specs/027-debugger-failure-diagnostics/spec.md +133 -0
  221. package/docs/specs/028-compact-debugger-responses/intent.md +41 -0
  222. package/docs/specs/028-compact-debugger-responses/plan.md +112 -0
  223. package/docs/specs/028-compact-debugger-responses/spec.md +108 -0
  224. package/docs/specs/029-kotlin-locals-validation/report.md +119 -0
  225. package/docs/specs/030-android-coroutine-validation/evidence.json +475 -0
  226. package/docs/specs/030-android-coroutine-validation/intent.md +47 -0
  227. package/docs/specs/030-android-coroutine-validation/plan.md +147 -0
  228. package/docs/specs/030-android-coroutine-validation/report.md +240 -0
  229. package/docs/specs/030-android-coroutine-validation/spec.md +107 -0
  230. package/docs/tools/TOOLS.md +31 -16
  231. package/docs/tools/{evidence.md → correlated-evidence.md} +14 -3
  232. package/docs/tools/debugger.md +180 -0
  233. package/docs/tools/interact.md +42 -20
  234. package/docs/tools/manage.md +25 -44
  235. package/docs/tools/observe.md +64 -25
  236. package/docs/tools/system-traces.md +134 -0
  237. package/docs/tools/system.md +12 -5
  238. package/package.json +11 -8
  239. package/scripts/architecture-graph.mjs +69 -0
  240. package/scripts/check-architecture.mjs +47 -0
  241. package/scripts/code-quality-baseline.json +1 -0
  242. package/scripts/code-quality.mjs +161 -0
  243. package/src/contracts/execution-controls.ts +26 -0
  244. package/src/contracts/selector.ts +17 -0
  245. package/src/contracts/target.ts +19 -0
  246. package/src/contracts/ui.ts +94 -0
  247. package/src/debugger/android.ts +66 -0
  248. package/src/debugger/diagnostics.ts +43 -0
  249. package/src/debugger/guard.ts +31 -0
  250. package/src/debugger/java/DebuggerWorker.java +166 -0
  251. package/src/debugger/protocol.ts +37 -0
  252. package/src/debugger/sessions.ts +327 -0
  253. package/src/debugger/worker.ts +135 -0
  254. package/src/interact/adjustment/adjustment-context.ts +83 -0
  255. package/src/interact/adjustment/adjustment-gestures.ts +48 -0
  256. package/src/interact/adjustment/adjustment-plan.ts +23 -0
  257. package/src/interact/adjustment/adjustment-resolution.ts +104 -0
  258. package/src/interact/adjustment/adjustment-result.ts +34 -0
  259. package/src/interact/adjustment/adjustment-semantic.ts +53 -0
  260. package/src/interact/adjustment/adjustment-verification.ts +60 -0
  261. package/src/interact/adjustment/adjustment.ts +49 -0
  262. package/src/interact/adjustment/control-geometry.ts +120 -0
  263. package/src/interact/adjustment/control-values.ts +141 -0
  264. package/src/interact/adjustment/slider-labels.ts +84 -0
  265. package/src/interact/assertions/screen-assertion.ts +39 -0
  266. package/src/interact/assertions/state-assertion-context.ts +48 -0
  267. package/src/interact/assertions/state-assertion.ts +64 -0
  268. package/src/interact/assertions/state-comparison.ts +168 -0
  269. package/src/interact/assertions/visibility-assertion.ts +41 -0
  270. package/src/interact/conditional-action.ts +18 -12
  271. package/src/interact/index.ts +76 -3491
  272. package/src/interact/input-service.ts +11 -0
  273. package/src/interact/interaction-trace.ts +36 -0
  274. package/src/interact/model.ts +109 -0
  275. package/src/interact/observation.ts +7 -0
  276. package/src/interact/targeting/candidate-ancestor.ts +49 -0
  277. package/src/interact/targeting/candidate-result.ts +24 -0
  278. package/src/interact/targeting/candidate-scoring.ts +42 -0
  279. package/src/interact/targeting/element-helpers.ts +243 -0
  280. package/src/interact/targeting/find-element.ts +47 -0
  281. package/src/interact/targeting/nearby-control.ts +46 -0
  282. package/src/interact/targeting/resolved-elements.ts +20 -0
  283. package/src/interact/targeting/tap-target.ts +22 -0
  284. package/src/interact/targeting/target-scope.ts +121 -0
  285. package/src/interact/waits/legacy-log-wait.ts +30 -0
  286. package/src/interact/waits/legacy-wait-observations.ts +55 -0
  287. package/src/interact/waits/legacy-wait-state.ts +48 -0
  288. package/src/interact/waits/legacy-wait.ts +34 -0
  289. package/src/interact/waits/screen-wait.ts +37 -0
  290. package/src/interact/waits/ui-change-helpers.ts +184 -0
  291. package/src/interact/waits/ui-change-state.ts +26 -0
  292. package/src/interact/waits/ui-change-wait.ts +59 -0
  293. package/src/interact/waits/ui-wait-condition.ts +52 -0
  294. package/src/interact/waits/ui-wait-state.ts +55 -0
  295. package/src/interact/waits/ui-wait.ts +84 -0
  296. package/src/manage/android.ts +56 -50
  297. package/src/manage/index.ts +63 -93
  298. package/src/manage/ios/build-types.ts +14 -0
  299. package/src/manage/ios/build.ts +230 -0
  300. package/src/manage/ios/project-discovery.ts +26 -0
  301. package/src/manage/ios/scheme.ts +16 -0
  302. package/src/manage/ios.ts +65 -298
  303. package/src/observe/android/context.ts +1 -0
  304. package/src/observe/android/current-screen.ts +63 -0
  305. package/src/observe/android/fingerprint.ts +13 -0
  306. package/src/observe/android/log-stream.ts +127 -0
  307. package/src/observe/android/logs.ts +110 -0
  308. package/src/observe/android/screenshot.ts +79 -0
  309. package/src/observe/android/ui-tree.ts +113 -0
  310. package/src/observe/android.ts +17 -531
  311. package/src/observe/evidence.ts +130 -71
  312. package/src/observe/index.ts +24 -286
  313. package/src/observe/ios/context.ts +22 -0
  314. package/src/observe/ios/fingerprint.ts +12 -0
  315. package/src/observe/ios/log-stream.ts +103 -0
  316. package/src/observe/ios/logs.ts +179 -0
  317. package/src/observe/ios/screenshot.ts +26 -0
  318. package/src/observe/ios/ui-elements.ts +266 -0
  319. package/src/observe/ios/ui-tree.ts +143 -0
  320. package/src/observe/ios.ts +18 -749
  321. package/src/observe/logs/model.ts +11 -0
  322. package/src/{network → observe/network}/index.ts +2 -2
  323. package/src/observe/readiness-service.ts +10 -3
  324. package/src/observe/readiness.ts +49 -22
  325. package/src/observe/screenshot-encoding.ts +32 -0
  326. package/src/observe/snapshot-collection.ts +69 -0
  327. package/src/observe/snapshot-logs.ts +26 -0
  328. package/src/observe/snapshot-metadata.ts +51 -31
  329. package/src/observe/snapshot-semantic.ts +153 -0
  330. package/src/observe/system-trace-android.ts +133 -0
  331. package/src/observe/system-trace.ts +227 -0
  332. package/src/runtime/action-results.ts +376 -0
  333. package/src/runtime/clock.ts +9 -0
  334. package/src/server/common.ts +9 -359
  335. package/src/server/definitions/assert.ts +164 -0
  336. package/src/server/definitions/diagnostic.ts +120 -0
  337. package/src/server/definitions/input.ts +276 -0
  338. package/src/server/definitions/manage.ts +196 -0
  339. package/src/server/definitions/observe.ts +151 -0
  340. package/src/server/definitions/target.ts +140 -0
  341. package/src/server/definitions/wait.ts +107 -0
  342. package/src/server/handlers/action-execution.ts +164 -0
  343. package/src/server/handlers/correlation.ts +20 -0
  344. package/src/server/handlers/debugger-handlers.ts +39 -0
  345. package/src/server/handlers/debugger-response.ts +7 -0
  346. package/src/server/handlers/diagnostic.ts +79 -0
  347. package/src/server/handlers/handler-types.ts +7 -0
  348. package/src/server/handlers/input.ts +173 -0
  349. package/src/server/handlers/interact.ts +135 -0
  350. package/src/server/handlers/journey-assertions.ts +39 -0
  351. package/src/server/handlers/journey.ts +132 -0
  352. package/src/server/handlers/manage.ts +141 -0
  353. package/src/server/handlers/observe.ts +116 -0
  354. package/src/server/handlers/payload.ts +36 -0
  355. package/src/server/handlers/tool-handlers.ts +159 -0
  356. package/src/server/schemas/condition-schema.ts +2 -0
  357. package/src/server/schemas/debugger-schema.ts +43 -0
  358. package/src/server/{journey-schema.ts → schemas/journey-schema.ts} +8 -22
  359. package/src/server/schemas/system-trace-schema.ts +17 -0
  360. package/src/server/tool-definitions.ts +69 -1140
  361. package/src/server-core.ts +4 -4
  362. package/src/server.ts +25 -1
  363. package/src/system/android-status.ts +124 -0
  364. package/src/system/android.ts +33 -21
  365. package/src/system/index.ts +21 -523
  366. package/src/system/ios-status.ts +147 -0
  367. package/src/system/ios.ts +14 -10
  368. package/src/system/model.ts +41 -0
  369. package/src/system/probes.ts +114 -0
  370. package/src/system/status-summary.ts +47 -0
  371. package/src/system/unsupported-status.ts +55 -0
  372. package/src/types.ts +16 -106
  373. package/src/utils/android/commands.ts +81 -0
  374. package/src/utils/android/gradle.ts +132 -0
  375. package/src/utils/android/logs.ts +103 -0
  376. package/src/utils/android/ui-tree.ts +239 -0
  377. package/src/utils/android/utils.ts +16 -556
  378. package/src/utils/cli/idb/check-idb.ts +4 -4
  379. package/src/utils/cli/idb/idb-helper.ts +6 -8
  380. package/src/utils/cli/idb/install-idb.ts +15 -9
  381. package/src/utils/cli/ios/preflight-ios.ts +39 -31
  382. package/src/utils/cli/ios/run-ios-ui-tree-tap.ts +4 -4
  383. package/src/utils/exec.ts +2 -0
  384. package/src/utils/ios/utils.ts +57 -61
  385. package/src/utils/java.ts +71 -51
  386. package/src/utils/operation-budget.ts +2 -0
  387. package/src/utils/resolve-device.ts +11 -6
  388. package/src/utils/ui/index.ts +28 -28
  389. package/test/device/automated/debugger/coroutine-lifecycle.ts +27 -0
  390. package/test/device/automated/debugger/coroutine-support.ts +140 -0
  391. package/test/device/automated/debugger/coroutine.android.test.ts +169 -0
  392. package/test/device/automated/debugger/kotlin.android.test.ts +127 -0
  393. package/test/device/automated/debugger/runtime.android.test.ts +219 -0
  394. package/test/device/automated/interact/interaction.android.test.ts +56 -0
  395. package/test/device/automated/observe/system-trace.smoke.ts +104 -0
  396. package/test/device/manual/interact/modul8_selector_tap.manual.ts +1 -1
  397. package/test/fixtures/contracts/tool-definitions.json +3536 -0
  398. package/test/fixtures/coroutine-app/MainActivity.kt +100 -0
  399. package/test/fixtures/coroutine-app/README.md +48 -0
  400. package/test/fixtures/coroutine-app/build.ts +35 -0
  401. package/test/fixtures/debugger-app/MainActivity.java +67 -0
  402. package/test/fixtures/debugger-app/MainActivity.kt +32 -0
  403. package/test/fixtures/debugger-app/NoLocals.java +7 -0
  404. package/test/fixtures/debugger-app/README.md +65 -0
  405. package/test/fixtures/debugger-app/build.ts +39 -0
  406. package/test/fixtures/latency-journey-app/README.md +2 -0
  407. package/test/fixtures/readiness-app/README.md +2 -0
  408. package/test/helpers/perfetto.ts +59 -0
  409. package/test/unit/debugger/coroutine-lifecycle.test.ts +43 -0
  410. package/test/unit/debugger/diagnostic-sessions.test.ts +67 -0
  411. package/test/unit/debugger/diagnostics.test.ts +80 -0
  412. package/test/unit/debugger/guards.test.ts +50 -0
  413. package/test/unit/debugger/native.test.ts +33 -0
  414. package/test/unit/debugger/preparation.test.ts +32 -0
  415. package/test/unit/debugger/protocol.test.ts +15 -0
  416. package/test/unit/debugger/sessions.test.ts +83 -0
  417. package/test/unit/interact/adjustment_service.test.ts +42 -0
  418. package/test/unit/interact/adjustment_verification.test.ts +35 -0
  419. package/test/unit/interact/clock_dependencies.test.ts +63 -0
  420. package/test/unit/interact/element_helpers.test.ts +19 -0
  421. package/test/unit/interact/legacy_wait_service.test.ts +17 -0
  422. package/test/unit/interact/state_comparison.test.ts +20 -0
  423. package/test/unit/interact/target_scope.test.ts +35 -0
  424. package/test/unit/network/get_network_activity.test.ts +1 -1
  425. package/test/unit/observe/readiness.test.ts +3 -1
  426. package/test/unit/observe/screenshot-encoding.test.ts +30 -0
  427. package/test/unit/observe/snapshot-logs.test.ts +14 -0
  428. package/test/unit/observe/system-trace-android.test.ts +52 -0
  429. package/test/unit/observe/system-trace.test.ts +166 -0
  430. package/test/unit/quality/architecture.test.ts +60 -0
  431. package/test/unit/quality/code-quality.test.ts +58 -0
  432. package/test/unit/quality/interaction_boundaries.test.ts +24 -0
  433. package/test/unit/server/conditional_actions.test.ts +1 -1
  434. package/test/unit/server/conditional_schema.test.ts +2 -2
  435. package/test/unit/server/debugger-response.test.ts +63 -0
  436. package/test/unit/server/system-trace.test.ts +64 -0
  437. package/test/unit/server/tool_definitions_parity.test.ts +8 -0
  438. package/dist/server/tool-handlers.js +0 -893
  439. package/docs/ROADMAP.md +0 -646
  440. package/docs/benchmarks/ui-tree-performance/bridge-probe.json +0 -29
  441. package/docs/benchmarks/ui-tree-performance/initial-baseline.json +0 -59560
  442. package/docs/specs/baseline-spec-v0.md +0 -312
  443. package/docs/specs/mcp-tooling-spec-v1.md +0 -446
  444. package/src/server/tool-handlers.ts +0 -923
  445. /package/dist/{server/condition-schema.js → contracts/condition.js} +0 -0
  446. /package/dist/server/{readiness-schema.js → schemas/readiness-schema.js} +0 -0
  447. /package/src/{server/condition-schema.ts → contracts/condition.ts} +0 -0
  448. /package/src/server/{readiness-schema.ts → schemas/readiness-schema.ts} +0 -0
@@ -1,8 +1,10 @@
1
1
  # Plan: conditional actions
2
2
 
3
+ [Design and evidence](../../README.md#design-and-evidence) · [Tool reference](../../tools/TOOLS.md) · [Intent](intent.md) · [Specification](spec.md)
4
+
3
5
  Date: 2026-10-29. Status: complete — implementation and required verification passed.
4
6
  Intent: [intent.md](intent.md). Specification: [spec.md](spec.md).
5
- Both approved by the originator's separate “yes” replies in this conversation;
7
+ Both approved by the originator's separate “yes” replies during design review;
6
8
  the latest approval authorises implementation of spec 020.
7
9
 
8
10
  ## Implementation sequence
@@ -98,18 +100,16 @@ minimum is >=18; CI's Node 18 run has not been executed locally).
98
100
  All elements contribute to revision checks beyond the bounded delta history.
99
101
  - `npm run sync:agent-plugin`: PASS; no generated manifest differences.
100
102
  - Final `npm run verify`: PASS (lint, build, 59 unit-test files, plugin consistency).
101
- Log: `/tmp/mobile-debug-conditional-verify-final.log`.
102
103
  - Initial `npm run test:device`: FAIL at iOS UI-tree smoke (`Invalid UI tree resolution`) while the original simulator was booting.
103
104
  Android screenshot/log/tree wrappers passed. iOS screenshot wrapper passed;
104
105
  the iOS log wrapper also reported pass but its underlying log retrieval printed
105
106
  `getpwuid_r` / unavailable log-store errors, so this is not evidence of usable
106
107
  iOS logs. These wrappers use automatic device selection; focused tests below
107
- pin their simulator explicitly. Full log: `/tmp/mobile-debug-conditional-device-suite.log`.
108
+ pin their simulator explicitly.
108
109
 
109
110
  - Final `npm run test:device`: PASS after the replacement iPhone 17 Pro finished
110
111
  booting. All six Android/iOS screenshot, log, and tree smoke wrappers passed,
111
- without the earlier iOS log-store diagnostics. Log:
112
- `/tmp/mobile-debug-conditional-device-suite-final.log`.
112
+ without the earlier iOS log-store diagnostics.
113
113
  - Final documentation relative-link checks and `git diff --check`: PASS.
114
114
  - Final lint after the device helper's selector/start-state correction: PASS.
115
115
 
@@ -138,7 +138,7 @@ Starting state: system Settings root, with Network & internet visible.
138
138
  | Journey stop, compact | Successful wait for Internet, conditional back tap with root expectation, later tap | Earlier wait passed, guarded step failed with fresh tree, later step `not_run`; destination remained | PASS |
139
139
  | Journey stop, debug | Same sequence in debug mode | Same stop and preserved evidence | PASS |
140
140
 
141
- Full structured evidence: `/tmp/mobile-debug-conditional-android.json`.
141
+ The temporary raw output was not retained in the repository; results are summarised here.
142
142
  The five scenarios were rerun successfully against the final built server after
143
143
  the compact-error and metadata-validity fixes and the helper selector correction.
144
144
  The helper is reproducible and requires a deliberately prepared safe system
@@ -175,7 +175,7 @@ Starting state: Settings root with General visible, About absent.
175
175
  | Journey stop, compact | Successful wait for About, stale conditional tap on `resource_id: BackButton`, later back tap | Wait passed; condition failed; later step `not_run`; General remained visible | PASS |
176
176
  | Journey stop, debug | Same sequence in debug mode | Same stop and fresh condition evidence | PASS |
177
177
 
178
- Structured evidence: `/tmp/mobile-debug-conditional-ios.json`.
178
+ The temporary raw output was not retained in the repository; results are summarised here.
179
179
  An initial helper attempt selected the application container sharing the Settings
180
180
  label and correctly stopped with `ELEMENT_NOT_INTERACTABLE` / `not_checked`;
181
181
  this was not counted as a conditional-journey pass. The helper now prefers the
@@ -210,5 +210,4 @@ Limits: live simulator checks cover conditional taps and journey stops; conditio
210
210
  swipes and Android typing/back use production-adapter tests with fake native
211
211
  tools. Physical devices were not used for mutation checks. UI normalization, the observation-to-OS-input race, and concurrent external
212
212
  input remain explicit spec limits. No mutation testing was performed. No tests
213
- or validation rules were weakened. Existing uncommitted process/skill relocation
214
- work was preserved. No package was published and nothing was committed/pushed.
213
+ or validation rules were weakened. No published-package verification was performed.
@@ -1,8 +1,10 @@
1
1
  # Spec 020: conditional actions
2
2
 
3
+ [Design and evidence](../../README.md#design-and-evidence) · [Tool reference](../../tools/TOOLS.md) · [Intent](intent.md) · [Plan and verification](plan.md)
4
+
3
5
  Date: 2026-10-29.
4
6
  Status: approved — implementation authorised.
5
- Intent: [intent.md](intent.md), approved in the current conversation by the
7
+ Intent: [intent.md](intent.md), approved during design review by the
6
8
  originator's “yes” in response to the captured intent.
7
9
 
8
10
  ## Outcome
@@ -296,6 +298,6 @@ separately. Record exact test routes and cleanup in the implementation plan.
296
298
 
297
299
  ## Approval
298
300
 
299
- Approved by the originator on 2026-10-29 in the current conversation: “yes”,
301
+ Approved by the originator on 2026-10-29 during design review: “yes”,
300
302
  in direct response to the linked complete spec and the listed first-version
301
303
  scope. Implementation is authorised within that scope.
@@ -1,6 +1,8 @@
1
1
  # Intent: app readiness signals
2
2
 
3
- Originator: repository maintainer (current conversation).
3
+ [Design and evidence](../../README.md#design-and-evidence) · [Tool reference](../../tools/TOOLS.md) · [Specification](spec.md) · [Plan and verification](plan.md)
4
+
5
+ Originator: repository maintainer (design review).
4
6
  Date: 2026-10-29. Status: approved.
5
7
  Source: [GitHub issue #65: App readiness signals](https://github.com/clivejefferies/mobile-debug-tools/issues/65), roadmap priority 2 of 9.
6
8
 
@@ -37,4 +39,4 @@ unsupported signals, API placement, and how long observations remain current.
37
39
  ## Approval
38
40
 
39
41
  Approved on 2026-10-29 by the originator’s “yes” in direct response to the
40
- complete intent summary and linked artifact in this conversation.
42
+ complete intent summary and linked artifact during design review.
@@ -1,8 +1,10 @@
1
1
  # Plan: app readiness signals
2
2
 
3
+ [Design and evidence](../../README.md#design-and-evidence) · [Tool reference](../../tools/TOOLS.md) · [Intent](intent.md) · [Specification](spec.md)
4
+
3
5
  Date: 2026-10-29. Status: complete — implementation and required verification passed.
4
- [Intent](intent.md) and [spec](spec.md) separately approved in this conversation;
5
- “yep” authorises implementation of spec 021. Preserve existing uncommitted work.
6
+ [Intent](intent.md) and [spec](spec.md) separately approved during design review;
7
+ “yep” authorises implementation of spec 021.
6
8
 
7
9
  ## Implementation
8
10
 
@@ -47,8 +49,8 @@ Node v23.11.0. This is local evidence, not a published package or Node 18 CI run
47
49
  | --- | --- |
48
50
  | Classifier, schemas, opt-in waits | PASS: state precedence, monotonic stability, invalid/error continuity, no extra predicate reads, explicit unsupported states, timeout uncertainty |
49
51
  | Production Android/iOS observation adapters with fake binaries | PASS: two-sample stability, native loaders, timeout child closure, and killing a hung iOS metadata probe; simulated error evidence |
50
- | Maintainer checks | PASS: final `npm run verify` (lint, build, 62 unit-test files, plugin consistency); `/tmp/mobile-readiness-verify-complete.log` |
51
- | Existing `npm run test:device` | PASS: all six Android/iOS screenshot, log, and tree smoke wrappers; `/tmp/mobile-readiness-device-suite.log` |
52
+ | Maintainer checks | PASS: final `npm run verify` (lint, build, 62 unit-test files, plugin consistency) |
53
+ | Existing `npm run test:device` | PASS: all six Android/iOS screenshot, log, and tree smoke wrappers |
52
54
  | Native fixture journeys through built MCP stdio | PASS: six on each simulator; evidence linked below |
53
55
 
54
56
  Focused device commands (each builds, installs, and uninstalls its own offline
@@ -78,8 +80,7 @@ starts a 12-second loader while Ready stays visible; completion displays Done.
78
80
  All twelve device scenarios passed. Both fixture apps were uninstalled, build
79
81
  folders removed, Android’s original foreground app restored, and iOS returned
80
82
  to Home. No settings, permissions, accounts, or production app data were changed.
81
- Structured evidence: `/tmp/mobile-readiness-android.json` and
82
- `/tmp/mobile-readiness-ios.json`.
83
+ Temporary raw outputs were not retained in the repository; results are summarised here.
83
84
 
84
85
  Review covered classification/normalization, schema parity, serialization,
85
86
  request-local state, ancestor budgets, native acquisition and cleanup, existing
@@ -1,8 +1,10 @@
1
1
  # Spec 021: app readiness signals
2
2
 
3
+ [Design and evidence](../../README.md#design-and-evidence) · [Tool reference](../../tools/TOOLS.md) · [Intent](intent.md) · [Plan and verification](plan.md)
4
+
3
5
  Date: 2026-10-29. Status: approved — implementation authorised.
4
6
  Source: [issue #65](https://github.com/clivejefferies/mobile-debug-tools/issues/65).
5
- [Intent](intent.md) approved by the originator’s “yes” in this conversation.
7
+ [Intent](intent.md) approved by the originator’s “yes” during design review.
6
8
 
7
9
  ## Behaviour and scope
8
10
 
@@ -1,6 +1,8 @@
1
1
  # Intent: correlated evidence
2
2
 
3
- Originator: repository maintainer (current conversation).
3
+ [Design and evidence](../../README.md#design-and-evidence) · [Tool reference](../../tools/TOOLS.md) · [Specification](spec.md) · [Plan and verification](plan.md)
4
+
5
+ Originator: repository maintainer (design review).
4
6
  Date: 2026-10-29. Status: approved.
5
7
  Source: [issue #66](https://github.com/clivejefferies/mobile-debug-tools/issues/66), roadmap priority 3 of 9.
6
8
 
@@ -32,6 +34,4 @@ handling, building on existing helpers.
32
34
 
33
35
  ## Approval
34
36
 
35
- The maintainer’s “yes” on 2026-10-29 approved the complete linked intent in this
36
- conversation. This shorter version preserves that scope; specification approval
37
- remains pending.
37
+ The maintainer’s “yes” on 2026-10-29 approved the complete linked intent during design review. See the linked specification for its separate approval record.
@@ -1,7 +1,9 @@
1
1
  # Plan: correlated evidence
2
2
 
3
+ [Design and evidence](../../README.md#design-and-evidence) · [Tool reference](../../tools/TOOLS.md) · [Intent](intent.md) · [Specification](spec.md)
4
+
3
5
  Authorisation: [intent](intent.md), then [spec](spec.md), explicitly approved by
4
- “yes” and “approve” respectively in this conversation on 2026-10-29.
6
+ “yes” and “approve” respectively during design review on 2026-10-29.
5
7
 
6
8
  ## Implementation
7
9
 
@@ -42,8 +44,8 @@ Use fresh device discovery. Exercise disabled/partial snapshot and invalid
42
44
  reference without changing app data. Record pass/fail/blocked/unrun plus metadata
43
45
  in this directory; avoid saving screenshot/log contents. Restore changed settings,
44
46
  stop only owned streams, and remove temporary test data. No settings change is
45
- needed. Android log healthcheck was degraded: targeted read is the next check;
46
- if unavailable, record its concrete error and verify metadata failure behaviour.
47
+ needed. The initial Android log healthcheck was degraded; the targeted read
48
+ subsequently passed, as recorded below.
47
49
  iOS physical-device coverage is outside existing simulator support.
48
50
 
49
51
  ## Results
@@ -77,10 +79,8 @@ contains no capture content; later Modul8 testing below records selector limits.
77
79
  - Physical-device correlation, installed/published-package verification: **unrun**.
78
80
  No release or deployment was requested.
79
81
 
80
- Validation logs for this local run: `/tmp/mobile-debug-correlated-verify.log` and
81
- `/tmp/mobile-debug-correlated-device.log`. The `tsx` CLI requires local IPC blocked
82
- by the sandbox; required npm checks ran with approved escalation. Focused checks
83
- also passed via `node --import tsx` without that socket.
82
+ Required npm checks passed with local IPC enabled. Focused checks also passed
83
+ via `node --import tsx`.
84
84
 
85
85
  ## Modul8 follow-up verification — 2026-10-30
86
86
 
@@ -146,8 +146,7 @@ conditional dispatch guards intact. Preserve unrelated correlated-evidence work.
146
146
  Modul8 and semantically confirmed the original Subscription screen. No app data
147
147
  or device settings changed; temporary cleanup client removed.
148
148
  - Historical failures in `modul8-evidence.json` are retained as before-fix evidence;
149
- this repair supersedes their unresolved-selector status. Validation logs:
150
- `/tmp/mobile-debug-selector-fix-verify.log`, `/tmp/mobile-debug-selector-fix-device.log`.
149
+ this repair supersedes their unresolved-selector status.
151
150
 
152
151
  ## Remaining readiness test flake — 2026-10-30
153
152
 
@@ -166,6 +165,6 @@ restored in `finally`. No production timing or readiness behaviour changed.
166
165
  - Focused check: Node 23 pass; 25 separate Node 18.20.8 test-process runs pass.
167
166
  - Full Node 18 maintainer verification with unavailable native defaults: **pass**
168
167
  (65 unit files, lint, build, agent-plugin consistency). Changed whitespace and
169
- local document links also pass; log: `/tmp/mobile-debug-readiness-clock-verify.log`.
168
+ local document links also pass.
170
169
  - Native device suite not repeated for this test-only change; prior runtime
171
- device results remain applicable. GitHub CI requires pushing this local repair.
170
+ device results remain applicable. Hosted CI was not rerun for this repair at the time of this record.
@@ -1,9 +1,11 @@
1
1
  # Specification: correlated evidence
2
2
 
3
+ [Design and evidence](../../README.md#design-and-evidence) · [Tool reference](../../tools/TOOLS.md) · [Intent](intent.md) · [Plan and verification](plan.md)
4
+
3
5
  Date: 2026-10-29. Status: approved.
4
6
  Source: [issue #66](https://github.com/clivejefferies/mobile-debug-tools/issues/66).
5
7
  [Intent](intent.md) approved by “yes”; this specification approved by the
6
- maintainer’s “approve” on 2026-10-29 in this conversation.
8
+ maintainer’s “approve” on 2026-10-29 during design review.
7
9
 
8
10
  ## Scope and association
9
11
 
@@ -0,0 +1,38 @@
1
+ {
2
+ "status": "PASS",
3
+ "build_sha256": "f59ec5112751295517ce3fd6fafe78e06ca009f30ecfcc560c872bfbf1cf86ee",
4
+ "runtime": "v23.11.0",
5
+ "server": {
6
+ "name": "mobile-debug-mcp",
7
+ "version": "0.33.0"
8
+ },
9
+ "device": "emulator-5554",
10
+ "osVersion": "16",
11
+ "starting_state": "System Settings fixture",
12
+ "journey": "start Settings, assert baseline Settings-owned resource visible in UI tree; explicit trace association",
13
+ "trace_id": "7a0bdca9-f64f-4c4f-b204-5c9b7527c2c6",
14
+ "correlation_id": "6622a71c-e556-4e27-b228-1eb0328f0637",
15
+ "phases": {
16
+ "capture_started_at_ms": 1793359970395,
17
+ "capture_completed_at_ms": 1793359976096
18
+ },
19
+ "artifact_bytes": 870332,
20
+ "content": {
21
+ "packets": 227,
22
+ "ftrace_bundles": 210,
23
+ "events": 19833,
24
+ "compact_sched_bundles": 210,
25
+ "validation": "local protobuf structure, trace config duration and timestamped ftrace/compact scheduler content; not full Perfetto analysis"
26
+ },
27
+ "durationContent": {
28
+ "packets": 51,
29
+ "ftrace_bundles": 35,
30
+ "events": 4596,
31
+ "compact_sched_bundles": 35,
32
+ "validation": "local protobuf structure, trace config duration and timestamped ftrace/compact scheduler content; not full Perfetto analysis"
33
+ },
34
+ "cancel": "PASS",
35
+ "expired_journey": "PASS",
36
+ "active_shutdown": "PASS",
37
+ "cleanup": "Device capture files removed; test host artifacts removed in finally. No settings or app data changed. Settings remains foreground."
38
+ }
@@ -0,0 +1,38 @@
1
+ {
2
+ "status": "PASS",
3
+ "build_sha256": "f59ec5112751295517ce3fd6fafe78e06ca009f30ecfcc560c872bfbf1cf86ee",
4
+ "runtime": "v23.11.0",
5
+ "server": {
6
+ "name": "mobile-debug-mcp",
7
+ "version": "0.33.0"
8
+ },
9
+ "device": "emulator-5554",
10
+ "osVersion": "16",
11
+ "starting_state": "System Settings fixture",
12
+ "journey": "start Settings, assert baseline Settings-owned resource visible in UI tree; explicit trace association",
13
+ "trace_id": "af7507e9-90ee-48e1-af43-f81bf3a66840",
14
+ "correlation_id": "dfe3e3ae-54f1-4c7a-afad-0c5ee76ede12",
15
+ "phases": {
16
+ "capture_started_at_ms": 1793360613568,
17
+ "capture_completed_at_ms": 1793360619070
18
+ },
19
+ "artifact_bytes": 996053,
20
+ "content": {
21
+ "packets": 230,
22
+ "ftrace_bundles": 213,
23
+ "events": 23054,
24
+ "compact_sched_bundles": 213,
25
+ "validation": "local protobuf structure, trace config duration and timestamped ftrace/compact scheduler content; not full Perfetto analysis"
26
+ },
27
+ "durationContent": {
28
+ "packets": 54,
29
+ "ftrace_bundles": 36,
30
+ "events": 3094,
31
+ "compact_sched_bundles": 36,
32
+ "validation": "local protobuf structure, trace config duration and timestamped ftrace/compact scheduler content; not full Perfetto analysis"
33
+ },
34
+ "cancel": "PASS",
35
+ "expired_journey": "PASS",
36
+ "active_shutdown": "PASS",
37
+ "cleanup": "Device capture files removed; test host artifacts removed in finally. No settings or app data changed. Settings remains foreground."
38
+ }
@@ -0,0 +1,41 @@
1
+ # Intent: Android system traces
2
+
3
+ [Design and evidence](../../README.md#design-and-evidence) · [Tool reference](../../tools/TOOLS.md) · [Specification](spec.md) · [Plan and verification](plan.md)
4
+
5
+ Originator: repository maintainer, through GitHub roadmap issue #67.
6
+ Date: 2026-10-30. Status: approved.
7
+ Source: [issue #67](https://github.com/clivejefferies/mobile-debug-tools/issues/67), roadmap priority 4 of 9.
8
+
9
+ ## Problem and outcome
10
+
11
+ MCP clients investigating slow or frozen Android interactions need system-level
12
+ performance evidence alongside existing journey and observation evidence.
13
+ The server currently has no system-trace capture capability.
14
+
15
+ Enable clients to start a bounded Android system trace, run an existing journey,
16
+ stop capture, and obtain a local Perfetto artifact with device, capture timing,
17
+ and correlation metadata. Detect available profiling capabilities explicitly and
18
+ report unsupported environments, failures, cancellation, and cleanup outcomes.
19
+
20
+ ## Scope and success criteria
21
+
22
+ - Android capture around existing journeys, reusing established device targeting
23
+ and correlated-evidence conventions.
24
+ - Optional profiling tooling with explicit capability and prerequisite reporting.
25
+ - Local artifact handling and bounded capture/resource ownership.
26
+ - Successful start/stop and artifact retrieval on a supported Android fixture.
27
+ - Explicit failure/cancellation outcomes and cleanup of session-owned resources.
28
+
29
+ ## Exclusions and open decisions
30
+
31
+ Exclude iOS tracing, runtime debugging, heap dumps, automatic performance diagnosis,
32
+ and changes to journey interaction semantics. Do not upload trace contents.
33
+
34
+ Specification must establish the supported backend/tooling, tool contracts,
35
+ capture limits/configuration, concurrent-session rules, cancellation/recovery,
36
+ artifact retention, privacy handling, and verification prerequisites. The issue's
37
+ Android CLI integration is provisional and requires investigation.
38
+
39
+ ## Approval
40
+
41
+ The maintainer approved the complete captured intent with “yes” during design review on 2026-10-30. See the linked specification for its separate approval record.
@@ -0,0 +1,115 @@
1
+ # Plan: Android system traces
2
+
3
+ [Design and evidence](../../README.md#design-and-evidence) · [Tool reference](../../tools/TOOLS.md) · [Intent](intent.md) · [Specification](spec.md)
4
+
5
+ Authorised by [intent](intent.md) (“yes”) and [specification](spec.md)
6
+ (“looks good”, followed by “great”), 2026-10-30 during design review.
7
+
8
+ ## Implementation
9
+
10
+ - [x] Implement ADB capability/capture adapter with PID identity and bounded files.
11
+ - [x] Implement serialised sessions, deadlines, retries, retention and shutdown.
12
+ - [x] Register strict schemas/tools, link journeys and propagate trace evidence.
13
+ - [x] Add regression/device tests and align README/tool docs/changelog.
14
+ - [x] Review ownership/failure/concurrency/contracts; run verification below.
15
+
16
+ Use existing device resolver, ADB path helper, execution helper and async-local
17
+ evidence context. Node >=18; CI uses Node 18 and local runtime is recorded below.
18
+ No installation, publishing, commit or push is required. Android CLI absent;
19
+ ADB/Perfetto available on emulator-5554 API 36. Inspect trace content with a local
20
+ parser or Perfetto UI; missing viewer/parser blocks artifact-format proof, not
21
+ implementation. Avoid downloading tooling without need.
22
+
23
+ ## Verification
24
+
25
+ | Criteria | Evidence |
26
+ | --- | --- |
27
+ | 1 capability/no side effects | Fake adapter/ADB tests, strict runtime/registration schemas, iOS rejection. |
28
+ | 2 artifact/correlation | Updated stdio server: emulator start, Settings journey, stop, nonempty bounded artifact and Perfetto content inspection. |
29
+ | 3 lifecycle/isolation | Deterministic injected adapter/clock tests: duration, cancel, repeated controls, contention, stale IDs, reused PID, concurrent devices. |
30
+ | 4 failures/cleanup | Tests: missing tool/service, start/stop/pull timeout, disconnect, partial transfer, shutdown and mismatch without journey dispatch; real cancel/expiry. |
31
+ | 5 compatibility | Existing unit/device suites and additive schema/serialization assertions. |
32
+
33
+ Commands: `node --import tsx test/unit/observe/system-trace.test.ts`,
34
+ `node --import tsx test/unit/server/system-trace.test.ts`, `npm run verify`,
35
+ `npm run test:device`. Local verify adds plugin checks beyond CI; CI device
36
+ workflow is manual and Android API 30, local suite additionally requires iOS.
37
+
38
+ Device smoke: fresh discovery, explicit Android emulator, rebuilt 0.33.0 stdio
39
+ server. Start in Settings; capture a start_app Settings journey; assert identifiers,
40
+ state, artifact size and cleanup. Repeat cancellation, duration expiry and invalid
41
+ journey reference. Inspect resulting Perfetto packets; save metadata only in this
42
+ directory. Remove test-owned host artifacts; no app data/settings changes. State
43
+ pass/fail/blocked/unrun, build hash, device and gaps. Physical-device capture and
44
+ installed/published package remain separate from emulator evidence.
45
+
46
+ ## Results
47
+
48
+ Implementation and focused review completed on 2026-10-30, based on
49
+ `a74238b`. The results below cover the local build, not a published package.
50
+
51
+ - Local runtime: Node 23.11.0 / npm 10.9.2. CI's Node 18 runtime remains **unrun**
52
+ locally; the final CI workflow was not invoked. Existing CI uses Node 18 and
53
+ manual Android API 30 integration; local device evidence uses API 36.
54
+ - Focused session, Android adapter and tool/journey contract checks: **pass**.
55
+ Cover strict input/error flags, unsupported iOS/no dispatch, missing native
56
+ prerequisites, bounded capture, successful transfer permissions, cancellation,
57
+ automatic duration completion, failed/empty/oversized/partial transfers,
58
+ stop/start timeouts, unavailable devices, retry, PID reuse, naturally exiting
59
+ processes, simultaneous control calls, parallel devices, active shutdown,
60
+ shutdown racing start, metadata expiry/eviction and trace evidence isolation.
61
+ - `npm run verify`: **pass** on the final code (68 unit files, lint, TypeScript
62
+ build, plugin consistency). The tsx CLI requires local IPC
63
+ blocked by the sandbox, so the required command ran with approved escalation.
64
+ - `npm run test:device`: **pass** on the final runtime code, eight smoke files.
65
+ Existing Android/iOS screenshot, tree, log and correlation checks pass; correlation
66
+ pins emulator-5554 and iPhone 17 Pro simulator
67
+ F9243BAF-62A8-4990-8A99-17F527F56FDA (iOS 26.4). The six older platform smokes use
68
+ automatic targeting and do not all identify the selected device.
69
+ - Focused updated stdio-server trace journeys: **pass** on Android 16
70
+ emulator-5554, local package 0.33.0. Final combined runtime hash:
71
+ `f59ec5112751295517ce3fd6fafe78e06ca009f30ecfcc560c872bfbf1cf86ee`.
72
+ Fresh Settings baseline, traced launch and semantic assertion of a visible
73
+ Settings-owned resource, matching trace/journey/step IDs, local artifact,
74
+ idempotent stop, inactive reference rejection, cancellation, 1,001 ms duration
75
+ expiry, and closing another server during active capture all pass.
76
+ - Artifact format/content: **pass** using the local protobuf decoder: complete
77
+ Trace.packet boundaries, embedded requested duration, timestamped ftrace events
78
+ and compact scheduler bundles. Final full-suite artifact: 870,332 bytes,
79
+ 227 packets, 19,833 timestamped events and 210 compact scheduler bundles.
80
+ This is structural/content evidence, not full Perfetto UI/SQL analysis.
81
+ - Device metadata is in [device-evidence.json](device-evidence.json), without
82
+ trace contents, UI text, screenshots or logs. Test-owned device/host capture
83
+ artifacts are removed. No device settings or app data changed; Settings remains
84
+ foreground. Final device-directory inspection confirms no test trace files
85
+ remain. The first shutdown regression test's bounded leftover file was
86
+ removed individually after confirming its process had exited.
87
+ - Review corrected stdin-end cleanup (the SDK does not emit transport close on
88
+ stdin EOF), process-exit races around identity reads/SIGTERM, error flags for
89
+ unsupported action-control fields, and conservative journey coverage when
90
+ capture state becomes unavailable. Unreadable/reused live identity still fails
91
+ closed. No outstanding findings in the implemented scope.
92
+ - The initial extra UI assertion expected a Settings title, but Settings resumed
93
+ Network & internet. The smoke now establishes a fresh Settings-owned resource
94
+ baseline and proves that element is visible during the journey. No assertion
95
+ was removed, and no fixture settings were changed.
96
+ - Physical Android capture, actual unplug/disconnect and hard-crash recovery:
97
+ **unrun**; deterministic adapter/session failure coverage passes. iOS tracing is
98
+ explicitly unsupported, with rejection tested. Installed/published-package and
99
+ full trace-analysis verification remain **unrun**.
100
+
101
+ Changed documentation links, evidence JSON and whitespace checks pass.
102
+
103
+ ## Emulator recheck — 2026-10-30
104
+
105
+ User requested a fresh emulator test. Rebuilt with `npm run build` (**pass**),
106
+ then ran `SYSTEM_TRACE_EVIDENCE_PATH=docs/specs/023-android-system-traces/emulator-recheck.json node --import tsx test/device/automated/observe/system-trace.smoke.ts`
107
+ on emulator-5554, Android 16, local stdio server 0.33.0, same runtime hash as above.
108
+ **Pass:** fresh Settings UI baseline, traced launch and semantic visibility
109
+ assertion, correlated IDs, nonempty Perfetto artifact with timestamped kernel and
110
+ scheduler content, repeated stop, inactive reference rejection, cancellation,
111
+ 1,001 ms expiry, and active-capture server shutdown cleanup. Artifact: 996,053
112
+ bytes, 230 packets, 23,054 timestamped ftrace events. Test-owned host/device trace
113
+ files removed; no settings or app data changed. Settings remains foreground.
114
+ Metadata: [emulator-recheck.json](emulator-recheck.json). Full Perfetto analysis,
115
+ physical devices and failure-by-unplug were not part of this recheck.
@@ -0,0 +1,122 @@
1
+ # Specification: Android system traces
2
+
3
+ [Design and evidence](../../README.md#design-and-evidence) · [Tool reference](../../tools/TOOLS.md) · [Intent](intent.md) · [Plan and verification](plan.md)
4
+
5
+ Date: 2026-10-30. Status: approved.
6
+ Source: [issue #67](https://github.com/clivejefferies/mobile-debug-tools/issues/67).
7
+ [Intent](intent.md) approved by the maintainer’s “yes” during design review.
8
+ Specification approved by “looks good” followed by “great” on 2026-10-30.
9
+
10
+ ## Backend and boundaries
11
+
12
+ Use the device’s Perfetto CLI through existing ADB discovery/execution helpers.
13
+ Require Android API 29+, authorised ADB, supported background-wait options,
14
+ tracing services, and writable trace storage. Probe capabilities without starting
15
+ capture. No SDK installation, root, external downloads, Android CLI dependency,
16
+ or fallback to legacy systrace. iOS returns unsupported before side effects.
17
+ Android CLI is absent locally; official Android documentation supports direct
18
+ ADB capture. Analysis skills/SQL and trace interpretation remain out of scope.
19
+
20
+ ## Tools and schemas
21
+
22
+ All objects reject unknown fields. IDs are opaque server-generated UUIDs.
23
+
24
+ - `get_system_trace_capabilities({platform, deviceId?})`: resolve one device;
25
+ return supported/backend, resolved device, prerequisites, limitations, reasons.
26
+ - `start_system_trace({platform, deviceId?, durationMs?})`: integer duration
27
+ 1,000–120,000, default 30,000. Return recording session only after Perfetto’s
28
+ data-source-start acknowledgement; otherwise return failure and cleanup result.
29
+ - `get_system_trace_status({traceId})`: reconcile owned process/deadline and return
30
+ current state; finalise automatically completed capture when queried.
31
+ - `stop_system_trace({traceId})`: gracefully stop, retrieve and finalise artifact.
32
+ - `cancel_system_trace({traceId})`: stop and discard owned device/partial local
33
+ files; return cancelled plus cleanup outcome. Completed artifacts are retained.
34
+
35
+ Trace ID determines the pinned device; control calls cannot redirect it. Unknown,
36
+ expired, or previous-server IDs return `TRACE_NOT_FOUND`. One recording per device,
37
+ maximum four server-wide; reject excess with `TRACE_BUSY`. Concurrent operations
38
+ on one session serialise; repeated terminal operations return the stored outcome.
39
+ Retain at most 100 terminal records for 10 minutes; expiry never deletes completed
40
+ artifacts. Starting/active records are not evicted.
41
+
42
+ Responses use JSON text with `trace_id`, `session_id`, `device`, `backend: perfetto`,
43
+ `state` (starting/recording/stopping/completed/cancelled/failed), `reason`,
44
+ `capture_started_at_ms`, `capture_completed_at_ms`, `completion_reason`
45
+ (requested/duration_limit/cancelled/error), `artifact`, `cleanup`, and
46
+ `correlation_ids`. Unreached values are null. Artifact is null or contains absolute
47
+ `path`, `format: perfetto`, and `size_bytes`. Cleanup reports pending/complete/failed
48
+ and remaining owned resources. Errors retain known session metadata, use MCP
49
+ `isError`, and distinguish INVALID_ARGUMENT, UNSUPPORTED_PLATFORM,
50
+ TRACE_UNSUPPORTED, TRACE_BUSY, TRACE_NOT_FOUND, TRACE_START_FAILED,
51
+ TRACE_STOP_FAILED, TRACE_ARTIFACT_FAILED, ACTION_TIMEOUT, and TRACE_CANCELLED.
52
+ Capability queries with unsupported prerequisites are normal supported:false results.
53
+
54
+ ## Capture and lifecycle
55
+
56
+ Use a fixed scheduling/input/rendering preset (sched, freq, idle, am, wm, gfx,
57
+ view, input), 16 MiB ring buffer, and maximum output 32 MiB. Report enabled sources
58
+ and unavailable categories; unavailable required sched/input categories reject
59
+ start. No arbitrary config, package wildcard annotations, heap, screenshots, or
60
+ logcat data sources. This is device-wide evidence, not app-private capture.
61
+
62
+ Generate unique device paths under `/data/misc/perfetto-traces/`. Start with
63
+ background-wait and device-side duration limit. Record PID and process identity;
64
+ before SIGTERM validate both identity and unique output path. Never kill by process
65
+ name or signal a reused/unverified PID. Poll boundedly for termination before pull;
66
+ uncertain stop yields failure, never a successful artifact. Allow 35 seconds for
67
+ start acknowledgement, 10 for stop, and 30 for pull; subprocesses must terminate
68
+ on deadlines. Failed cleanup is explicit and retryable through control calls.
69
+
70
+ A server timer stops/finalises at duration; device duration also bounds capture
71
+ if the server dies. Normal shutdown attempts owned cleanup within 10 seconds;
72
+ crash recovery is not promised. A crash may leave its uniquely named device file
73
+ for manual removal; no restart-wide sweep. Host subprocess termination alone is
74
+ never reported as stopping device capture.
75
+
76
+ Pull into a unique server-created temporary directory with restrictive permissions;
77
+ rename only after successful transfer and nonempty size <=32 MiB. Return paths,
78
+ never binary/base64 contents. Remove owned device files after verified pull, retain
79
+ local artifacts for user-managed deletion. Pull failure retains bounded device
80
+ output for retry; cancelled partial files are removed. No upload or telemetry.
81
+
82
+ ## Journey and evidence association
83
+
84
+ Add optional `systemTraceId` to `run_journey`. Validate active same-server,
85
+ same-device recording before any journey input; mismatch/inactive ID fails without
86
+ executing steps. Preserve existing journey semantics and correlation IDs. It is
87
+ explicit bracketing: start, run journey, stop; journeys do not own trace lifetime.
88
+ A failed journey leaves capture available for stop/cancel or duration expiry.
89
+
90
+ Extend evidence `trace_context` for explicitly linked journey/step observations:
91
+ `supported:true`, `trace_id`, `markers:[]`. Otherwise preserve the existing
92
+ unsupported/null context. Record linked journey correlation IDs in trace metadata;
93
+ report capture ending during a journey as partial coverage. No injected device
94
+ markers, clock synchronisation, causal claims, or inferred associations. Host UTC
95
+ intervals and monotonic duration do not claim alignment with device trace clocks.
96
+
97
+ ## Acceptance and verification
98
+
99
+ 1. Capability detection and invalid arguments cause no recording side effects.
100
+ 2. Emulator start → existing Settings journey → stop produces a nonempty local
101
+ Perfetto artifact and matching trace/journey evidence IDs; inspect with an
102
+ available trace parser/viewer before claiming valid Perfetto content.
103
+ 3. Duration completion, explicit cancel, repeated controls, same-device contention,
104
+ concurrent devices, stale IDs, PID reuse and cleanup failures have deterministic tests.
105
+ 4. Test missing tools/services, start/stop/pull timeout, device disconnect, partial
106
+ transfer, shutdown, and journey mismatch; report real-device gaps explicitly.
107
+ 5. Existing clients without tracing retain contracts. Run maintainer verification,
108
+ automated device suite, and focused updated-server trace journeys.
109
+
110
+ Affected: new observe/session adapter, tool registration/validation/handlers,
111
+ journey schema/execution, evidence context/types, lifecycle shutdown, tests,
112
+ README/tool docs/changelog. Main risks: platform source availability, process
113
+ ownership races, finalisation correctness, storage/privacy, and absent parser.
114
+
115
+ Baseline: local package 0.33.0; emulator-5554 Android API 36 exposes Perfetto
116
+ background-wait, bounded output, and graceful PID-stop options. Pixel 9 Pro is
117
+ also connected but untested. ADB inspection passed after sandbox escalation;
118
+ no capture or new behaviour has been verified. Physical-device and iOS tests
119
+ remain unrun. Approval of this complete specification authorises implementation.
120
+
121
+ Sources: [Android Perfetto CLI](https://developer.android.com/tools/perfetto),
122
+ [Perfetto background capture](https://perfetto.dev/docs/learning-more/tracing-in-background).
@@ -0,0 +1,41 @@
1
+ # Intent: Android heap dump capture
2
+
3
+ [Design and evidence](../../README.md#design-and-evidence) · [Tool reference](../../tools/TOOLS.md)
4
+
5
+ Originator: clivejefferies, through GitHub roadmap issue #69 and maintainer design review.
6
+ Date: 2026-10-30. Status: parked; intent not approved.
7
+ Source: [issue #69](https://github.com/clivejefferies/mobile-debug-tools/issues/69), roadmap priority 6 of 9.
8
+
9
+ ## Problem and outcome
10
+
11
+ MCP clients investigating Android memory growth and out-of-memory failures need
12
+ a heap dump they can inspect with external analysis tools. Provide capture of a
13
+ supported running Android app's heap and return a local artifact with device,
14
+ app, capture-time, and artifact-path metadata.
15
+
16
+ ## Scope and success criteria
17
+
18
+ - Capture and retrieve an Android heap dump for an explicitly targeted app/process.
19
+ - Report device, app/process identity, capture timing, and the local artifact path.
20
+ - Detect unsupported configurations and report failed, cancelled, and timed-out
21
+ captures clearly.
22
+ - Bound capture work and clean up capture-owned temporary resources.
23
+ - Verify successful artifact retrieval on a supported Android fixture, alongside
24
+ meaningful failure and cleanup checks.
25
+
26
+ ## Exclusions and open decisions
27
+
28
+ Exclude iOS capture, deep heap analysis, leak diagnosis, automatic uploads, and
29
+ changes to app behaviour or permissions to enable capture.
30
+
31
+ Specification must resolve supported app/device configurations, capture backend
32
+ (including whether optional Android CLI tooling is useful), process selection,
33
+ tool contracts, limits, cancellation, concurrency, artifact retention, privacy,
34
+ and device-verification prerequisites. Heap contents can include sensitive app
35
+ data; capture and artifact handling must make their ownership explicit.
36
+
37
+ ## Approval
38
+
39
+ The user switched to Android runtime debugger work before approving this intent.
40
+ Heap capture remains parked pending explicit agreement on the complete intent. No specification or
41
+ implementation approval is recorded.