# Device profiles

<!-- toc -->
- [1. The catalog](#1-the-catalog)
- [2. Selection and width](#2-selection-and-width)
- [3. Provisioning on iOS](#3-provisioning-on-ios)
- [4. Provisioning on Android](#4-provisioning-on-android)
- [5. Driving a profiled device](#5-driving-a-profiled-device)
- [6. Writing findings that merge across languages](#6-writing-findings-that-merge-across-languages)
- [7. Proving a profile finding](#7-proving-a-profile-finding)
- [8. Teardown](#8-teardown)
- [9. Known failure modes](#9-known-failure-modes)
- [10. Without provisioning](#10-without-provisioning)
<!-- /toc -->

A bug bash finds more when its sessions do not all run on the same phone. A
device profile fixes the model, OS, system language, text size, appearance
and location of one simulator or emulator, plus the person who uses it. A
layout that holds on a mid-size phone in English breaks on the smallest
screen in German, at the largest accessibility text size, or right to left in
Arabic, and those defects are usually seen on one profile only. This ref is
read by `/multi-agent:bug-bash` before Step 1 when the run is mobile.

## 1. The catalog

`$HOME/.claude/schemas/device-profiles.json`, validated against
`device-profiles.schema.json` beside it. A project may keep its own catalog
and pass it with `--profiles <file>`; it gets the same checks.

| Field | Meaning |
|---|---|
| `id` | kebab-case, unique; charters and sessions refer to it |
| `platform` | `ios` or `android` |
| `stance` | who uses the device, one sentence the explorer plays on top of its charter persona |
| `os` | iOS major, or Android API level (29 to 36) |
| `device` | simctl device type name, or AVD hardware profile id |
| `locale` | BCP-47 tag; it sets the whole device, not one app |
| `appearance` | `light` or `dark` |
| `text` | iOS content size name, or Android font scale 0.8 to 2.0 |
| `location` | latitude and longitude |
| `default` | part of the set a run takes when `--devices` is not given |

## 2. Selection and width

```bash
node "$HOME/.claude/scripts/bug-bash.mjs" devices --platform ios \
  --select "${DEVICES:-default}" ${WIDTH:+--width "$WIDTH"} [--profiles FILE]
```

`--select` is `default`, `all`, or a comma list of ids. The output lists the
selected profiles, the width (`min(--width or 4, selected)`), and for each
profile the exact toolkit arguments under `calls`. Copy those arguments; do
not compose them. Exit 1 names an unknown id or an invalid catalog.

Every simulator is a full iOS instance. Four of them next to an Xcode build
can exhaust a laptop's memory, so on a laptop start with `--width 2`.

## 3. Provisioning on iOS

Needs `@mmerterden/multi-agent-mcp` 4.6.0 or later. For each selected profile:

1. `ios_create_device` with `calls.ios_create_device`. It refuses an iOS major
   or a model that is not installed. Do not retry with a fallback flag
   unless the user agrees, because a different runtime tests a different
   app: on iOS 27 an app that has not adopted the scene lifecycle stops at
   launch.
2. `ios_configure_device` with `device_id` and `calls.ios_configure_device`.
   It writes the system language and region, switches to a US software
   keyboard with autocorrection off, reboots, then sets appearance, text size
   and location, and reads the language back. The US keyboard is there
   because typing tools send key events for a US layout; on another layout a
   shortcut can land on a different key. The reboot is there because apps
   and the keyboard read the language when they start.
3. Build once (`ios_xcodebuild` for a simulator destination), then
   `ios_install_app` with `launch: true` on each device.
4. Append to `$LOG/devices.json`:
   `{profile, udid, name, created: true, os, locale, appearance, text}`.

A device that already exists and matches a profile may be used instead; write
it with `created: false` so teardown leaves it alone.

## 4. Provisioning on Android

Needs toolkit 4.7.0 or later (`android_create_avd`, `android_start_emulator`,
`android_configure_device`). Use `google_apis` system images: a Play Store
image has no root, so the system language cannot be set. Grant runtime
permissions only when the charter asks for them; a persona that refuses
location must meet the permission prompt. With an older toolkit, run on the
emulators already booted and say once that profiles were not applied.

## 5. Driving a profiled device

Every explorer gets its profile (id, stance, udid or serial) and these rules
in addition to the exploratory-testing orders:

- Pass `device_id` on every toolkit call. Without it a tool acts on the first
  booted device, which is another explorer's.
- Write `device: {profile, udid}` into the run file.
- Take a screenshot after every action and look at it before the next one.
  Number the screenshots in order; findings cite them.
- A keyboard-shaped region at the bottom of the screen is the system
  keyboard, not the app. A paste permission alert that names the automation
  bridge comes from the typing tool, not the app.
- Before reporting that a setting has no effect, leave the screen it
  changes, open it again and look: many screens read settings only when they
  open.
- A blocked step is a finding, not the end of the session. Record it, then
  change one thing at a time (another test address, lower case, a longer
  value, scroll, back, another control) the way a user would.
- Stop after two crashes, or after four different attempts at the same
  blocked step. The budget stop rules still apply.
- On every new screen run `ios_list_crashes` for crashes since the session
  started, and `ios_accessibility_audit` with `device_id`. Report each kind of
  accessibility issue once, with the screens it appeared on; it is minor
  unless it stops a task.

## 6. Writing findings that merge across languages

The merge groups findings by screen and expectation. Sessions in Turkish,
Arabic and German describe the same defect in different words, so:

- Write `screen` and `expected` in English, naming the screen the way the
  code does (the view or route name when known).
- Put the control's accessibility identifier, or its label when it has none,
  in `element`.
- Give a `class`: `functional`, `layout`, `text-size`, `feedback`,
  `accessibility`, `translation`, `rtl`, `large-screen`, `system-ui`, `copy`,
  `visual`, `crash`, or `artifact` for a defect of the simulator, the device
  image or the automation rather than the app.

Two mistranslated labels are two findings, and so are two cut-off buttons on
different screens.

## 7. Proving a profile finding

A candidate lists the profiles it was seen on. Its repro test runs on one of
them, and the verification records it as `repro.device`; a proof on another
profile is reported as `unproven`. For XCUITest, run on the profile's device
and pass the profile to the app:

```bash
xcodebuild test -destination "id=<udid>" -only-testing:<target>/<test> \
  # launchArguments in the test: -AppleLanguages "(tr)" -AppleLocale tr_TR
  # -UIPreferredContentSizeCategoryName UICTContentSizeCategoryAccessibilityXXXL
```

A toolkit replay (`agent_run_steps` with `replay`) on the same `device_id`
counts as well. A candidate seen on a single profile of several is listed
under "Seen on one profile only" in the report whether or not it was
proven, because device-specific defects are the reason the profiles exist.

## 8. Teardown

After the report, unless `--keep-devices`: for each entry in
`$LOG/devices.json` with `created: true`, `ios_delete_device` with its `udid`.
Never delete by prefix alone and never touch an entry with `created: false`.
Confirm once before deleting (autopilot: proceed). List what was deleted.

## 9. Known failure modes

| Seen | Rule that answers it |
|---|---|
| The system keyboard reported as part of the app | section 5, keyboard-shaped region |
| A screenshot taken before the screen finished changing | look at each screenshot before the next action; take another when content is still moving |
| A setting reported as ignored that applies on reopen | section 5, leave and reopen |
| Old Android images show an outdated system web view | class `artifact`, not a product defect |
| Accented characters lost when typing on Android | check the typed value on the screenshot; class `artifact` when the field holds what the tool sent |
| Usage limits reached with many sessions at once | keep the width at 2 to 4 and run the rest in later batches |

## 10. Without provisioning

With a toolkit older than 4.6.0 (iOS) or 4.7.0 (Android), or with
`--devices none`, the run uses the devices already booted, at width
`min(4, devices)`. Say so once. Sessions then carry no `device`, the report
has no device columns, and the proof rule is the one in the command.
