Skip to content

Commit b2b8694

Browse files
committed
fix(ios-runner): charge device and log evidence to the attempt that produced it
Review round on the readiness work (#2683): - Drain the runner's queued log appends before drawing a log boundary, so bytes an earlier command has not finished writing cannot be read as this command's. The boundary is now one object (`RunnerLogAttempt`) with no log-path-only shape, and every call site reads through it. - Treat an uncorroborated `ddiServicesAvailable: false` as unreadable rather than as a developer-disk-image obstacle: the services only answer while the tunnel is up and the phone is booted. A disabled toggle keeps its answer regardless, since it already explains the image. - Publish each remedy once: the device report carries the wording `core/devicectl.ts` owns, and the preflight reads it instead of wordings its own. - Bound the readiness probe by the startup budget and its signal, and abort after the read if the caller gave up. - Probe the device before the host's developer-tools setting, so a device and a Mac that are both wrong publish the reason the caller can act on. - Mask the identity fields in the committed device payload and give the mask a test.
1 parent 47c20bb commit b2b8694

16 files changed

Lines changed: 670 additions & 192 deletions

‎.device-evidence/CHECKLIST.md‎

Lines changed: 37 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -106,12 +106,20 @@ xcodebuild -version
106106
```
107107

108108
Expected: `{"developerModeStatus":"enabled","ddiServicesAvailable":true}` on a healthy device, plus
109-
the Xcode version. `packages/platform-apple/src/core/__tests__/fixtures/ios-device-info-details.json`
110-
holds this payload with its device identifiers, hostnames and capture path masked, and
111-
`packages/platform-apple/src/runner/__tests__/runner-startup-failure-fixtures.ts` records the two
112-
state pairings as `tool-error-shape`. Paste the raw values so both can move to `captured`. Also
113-
record the `tunnelState` and `tunnelIPAddress` from the same file, which is the transport data the
114-
parser reads.
109+
the Xcode version. Also record `bootState` and `tunnelState` from the same file: those two are what
110+
make a `ddiServicesAvailable: false` an answer at all rather than a device that was not listening.
111+
112+
`packages/platform-apple/src/core/__tests__/fixtures/ios-device-info-details.json` holds this payload
113+
and `packages/platform-apple/src/runner/__tests__/runner-startup-failure-fixtures.ts` records the two
114+
state pairings, both at `invented-shape` until this capture moves them to `captured`. Paste the raw
115+
values rather than a summary.
116+
117+
The committed payload is masked, and the mask is a rule with a test, not a one-time edit:
118+
`hardwareProperties.serialNumber` and `deviceProperties.bootedSnapshotName` carry `MASKED`,
119+
`hardwareProperties.ecid` is `0`, and `connectionProperties.tunnelIPAddress` is a documentation-only
120+
`fd00:` address. Everything the reader consumes — the toggle, the image, `bootState`, `tunnelState`,
121+
OS build — stays verbatim. If you refresh this capture, apply the same mask in both the `result`
122+
block and the mirrored `properties` block, and leave the states alone.
115123

116124
### 2. A healthy device is left alone
117125

@@ -156,16 +164,37 @@ Expected: `details.reason` is `device_developer_disk_image_unavailable`, `detail
156164
the toggle reason appears here instead, that is the bug this issue exists to fix: paste the whole
157165
error and the `/tmp/device-details.json` payload rather than adjusting a rule.
158166

167+
Capture the details payload at the same moment as the refusal, and check it says
168+
`tunnelState: "connected"` and `bootState: "booted"`. A `ddiServicesAvailable: false` read any other
169+
way is not this case: an asleep or unreachable device has the same field and no obstacle, and the run
170+
must not name device support for it. The hint you get here is the one `core/devicectl.ts` owns and the
171+
device report carries, so it is worded identically to the hint `devicectl` output produces for the
172+
same complaint — paste both strings and confirm they match character for character.
173+
159174
### 5. A device that cannot be read claims nothing
160175

161176
Unplug the iPhone (or shut it down) after a session exists, then rerun the `prepare ios-runner`
162177
command.
163178

164179
Expected: the failure names whatever the transport could not reach, and no `details.reason` of
165180
`device_developer_mode_disabled` or `device_developer_disk_image_unavailable` appears anywhere in the
166-
error. An unreadable device is never diagnosed.
181+
error. An unreadable device is never diagnosed. This is also the case that catches a sleeping phone
182+
reporting `ddiServicesAvailable: false`: if the hint here says `Let Xcode finish preparing this
183+
device`, the corroboration rule has been lost, and pasting the payload with its `tunnelState` and
184+
`bootState` is the evidence — do not adjust the rule to make the run pass.
185+
186+
### 6. A device and a Mac that are both wrong publish the device's reason
187+
188+
With the iPhone's Developer Mode toggle off AND `sudo DevToolsSecurity -status` reporting the
189+
developer-tools setting disabled, run the `prepare ios-runner` command.
190+
191+
Expected: one error, whose `details.reason` is `device_developer_mode_disabled`. The Mac's reason is
192+
the other one (`devtools_security_developer_mode_disabled`) and must not be what you get: the phone's
193+
fix needs no admin rights on the Mac, so the probe that can be acted on has to be the one that speaks.
194+
Record which of the two appears; a captured pairing here is what would let a follow-up drop the
195+
ordering argument.
167196

168-
### 6. Log evidence belongs to the command that wrote it (optional, needs a crash repro)
197+
### 7. Log evidence belongs to the command that wrote it (optional, needs a crash repro)
169198

170199
Run any command that crashes the app under test, then a second command that fails for its own
171200
reason (for example a selector that no longer exists).

‎packages/platform-apple/src/core/__tests__/fixtures/ios-device-info-details.json‎

Lines changed: 76 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,10 @@
4242
"featureIdentifier": "com.apple.dt.serviceconnection.create",
4343
"name": "Create Service Connection"
4444
},
45-
{ "featureIdentifier": "com.apple.dt.servicesocket.create", "name": "Create Service Socket" },
45+
{
46+
"featureIdentifier": "com.apple.dt.servicesocket.create",
47+
"name": "Create Service Socket"
48+
},
4649
{
4750
"featureIdentifier": "com.apple.coredevice.feature.customizeappearancesettings",
4851
"name": "Customize Appearance Settings"
@@ -131,18 +134,30 @@
131134
"featureIdentifier": "com.apple.coredevice.feature.installapp",
132135
"name": "Install Application"
133136
},
134-
{ "featureIdentifier": "com.apple.coredevice.feature.installroot", "name": "Install Root" },
137+
{
138+
"featureIdentifier": "com.apple.coredevice.feature.installroot",
139+
"name": "Install Root"
140+
},
135141
{
136142
"featureIdentifier": "com.apple.coredevice.feature.launchapplication",
137143
"name": "Launch Application"
138144
},
139-
{ "featureIdentifier": "com.apple.coredevice.feature.listFiles", "name": "List Files" },
140-
{ "featureIdentifier": "com.apple.coredevice.feature.listroots", "name": "List Roots" },
145+
{
146+
"featureIdentifier": "com.apple.coredevice.feature.listFiles",
147+
"name": "List Files"
148+
},
149+
{
150+
"featureIdentifier": "com.apple.coredevice.feature.listroots",
151+
"name": "List Roots"
152+
},
141153
{
142154
"featureIdentifier": "com.apple.coredevice.feature.default.user.credentials",
143155
"name": "Modify Credentials for Default Users for a Device"
144156
},
145-
{ "featureIdentifier": "com.apple.coredevice.feature.tags", "name": "Modify Tags" },
157+
{
158+
"featureIdentifier": "com.apple.coredevice.feature.tags",
159+
"name": "Modify Tags"
160+
},
146161
{
147162
"featureIdentifier": "com.apple.coredevice.feature.monitorfilechanges",
148163
"name": "Monitor File Changes"
@@ -151,7 +166,10 @@
151166
"featureIdentifier": "com.apple.coredevice.feature.monitorprocesstermination",
152167
"name": "Monitor Process for Termination"
153168
},
154-
{ "featureIdentifier": "com.apple.coredevice.feature.pasteboard", "name": "Pasteboard" },
169+
{
170+
"featureIdentifier": "com.apple.coredevice.feature.pasteboard",
171+
"name": "Pasteboard"
172+
},
155173
{
156174
"featureIdentifier": "com.apple.dt.customer.postdarwinnotification",
157175
"name": "Post Darwin Notification"
@@ -168,8 +186,14 @@
168186
"featureIdentifier": "com.apple.coredevice.feature.querymobilegestalt",
169187
"name": "Query MobileGestalt"
170188
},
171-
{ "featureIdentifier": "com.apple.coredevice.feature.rebootdevice", "name": "Reboot Device" },
172-
{ "featureIdentifier": "com.apple.coredevice.feature.renamedevice", "name": "Rename Device" },
189+
{
190+
"featureIdentifier": "com.apple.coredevice.feature.rebootdevice",
191+
"name": "Reboot Device"
192+
},
193+
{
194+
"featureIdentifier": "com.apple.coredevice.feature.renamedevice",
195+
"name": "Rename Device"
196+
},
173197
{
174198
"featureIdentifier": "com.apple.coredevice.feature.sendmemorywarningtoprocess",
175199
"name": "Send Memory Warning to Process"
@@ -178,7 +202,10 @@
178202
"featureIdentifier": "com.apple.coredevice.feature.sendsignaltoprocess",
179203
"name": "Send Signal to Process"
180204
},
181-
{ "featureIdentifier": "com.apple.dt.profile", "name": "Service Hub Profile" },
205+
{
206+
"featureIdentifier": "com.apple.dt.profile",
207+
"name": "Service Hub Profile"
208+
},
182209
{
183210
"featureIdentifier": "com.apple.coredevice.feature.servicexpcpeerconnection",
184211
"name": "Service XPC Peer Connection"
@@ -235,7 +262,10 @@
235262
"featureIdentifier": "com.apple.coredevice.feature.remote.universalhidservice",
236263
"name": "UniversalHIDService"
237264
},
238-
{ "featureIdentifier": "com.apple.coredevice.feature.unpairdevice", "name": "Unpair Device" },
265+
{
266+
"featureIdentifier": "com.apple.coredevice.feature.unpairdevice",
267+
"name": "Unpair Device"
268+
},
239269
{
240270
"featureIdentifier": "com.apple.coredevice.feature.viewdevicescreen",
241271
"name": "View Device Screen"
@@ -257,14 +287,14 @@
257287
"00000000-0000000000000000.coredevice.local"
258288
],
259289
"transportType": "wired",
260-
"tunnelIPAddress": "fd1b:bdb2:2626::1",
290+
"tunnelIPAddress": "fd00:0000:0000::1",
261291
"tunnelState": "connected",
262292
"tunnelTransportProtocol": "tcp"
263293
},
264294
"deviceProperties": {
265295
"bootState": "booted",
266296
"bootedFromSnapshot": true,
267-
"bootedSnapshotName": "com.apple.os.update-A22D383A04712C2BCB9B7939F83D537AAD06280E44D5508E0212E24B9FE8587F",
297+
"bootedSnapshotName": "com.apple.os.update-MASKED",
268298
"ddiServicesAvailable": true,
269299
"developerModeStatus": "enabled",
270300
"hasInternalOSBuild": false,
@@ -276,20 +306,32 @@
276306
"supportsCheckedAllocations": true
277307
},
278308
"hardwareProperties": {
279-
"cpuType": { "name": "arm64e", "subType": -2147483646, "type": 16777228 },
309+
"cpuType": {
310+
"name": "arm64e",
311+
"subType": -2147483646,
312+
"type": 16777228
313+
},
280314
"deviceType": "iPhone",
281-
"ecid": 6836093504208924,
315+
"ecid": 0,
282316
"hardwareModel": "V53AP",
283317
"internalStorageCapacity": 256000000000,
284318
"isProductionFused": true,
285319
"marketingName": "iPhone 17 Pro",
286320
"platform": "iOS",
287321
"productType": "iPhone18,1",
288322
"reality": "physical",
289-
"serialNumber": "C07NWHY2H0",
323+
"serialNumber": "C07MASKED00000",
290324
"supportedCPUTypes": [
291-
{ "name": "arm64e", "subType": -2147483646, "type": 16777228 },
292-
{ "name": "arm64", "subType": 0, "type": 16777228 }
325+
{
326+
"name": "arm64e",
327+
"subType": -2147483646,
328+
"type": 16777228
329+
},
330+
{
331+
"name": "arm64",
332+
"subType": 0,
333+
"type": 16777228
334+
}
293335
],
294336
"supportedDeviceFamilies": [1],
295337
"thinningProductType": "iPhone18,1",
@@ -301,18 +343,25 @@
301343
"lastConnectionDate": 811516560,
302344
"pairingState": "paired",
303345
"transportType": "wired",
304-
"tunnelIPAddressString": "fd1b:bdb2:2626::1",
346+
"tunnelIPAddressString": "fd00:0000:0000::1",
305347
"tunnelTransportProtocol": "tcp"
306348
},
307349
"hardware": {
308-
"cpuCount": { "logicalCores": 6, "packages": 1, "physicalCores": 6 },
309-
"cpuType": { "subtype": 18446744071562067970, "type": 16777228 },
310-
"ecid": 6836093504208924,
350+
"cpuCount": {
351+
"logicalCores": 6,
352+
"packages": 1,
353+
"physicalCores": 6
354+
},
355+
"cpuType": {
356+
"subtype": 18446744071562067970,
357+
"type": 16777228
358+
},
359+
"ecid": 0,
311360
"internalStorageCapacity": 256000000000,
312361
"marketingName": "iPhone 17 Pro",
313362
"productType": "iPhone18,1",
314363
"reality": "physical",
315-
"serialNumber": "C07NWHY2H0",
364+
"serialNumber": "C07MASKED00000",
316365
"udid": "00000000-0000000000000000"
317366
},
318367
"software": {
@@ -350,7 +399,11 @@
350399
},
351400
"state": {
352401
"bootState": "booted",
353-
"developerModeStatus": { "enabled": { "mode": 1 } },
402+
"developerModeStatus": {
403+
"enabled": {
404+
"mode": 1
405+
}
406+
},
354407
"name": "apex-test-iphone"
355408
}
356409
},

0 commit comments

Comments
 (0)