Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
107 changes: 107 additions & 0 deletions .agents/skills/verify-pr/SKILL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
---
name: verify-pr
description: Verify a merged or open PR end to end the way a maintainer does โ€” run the sample app on an Android emulator without the change and with it, find both runs' events in the shared `sentry-sdks` org, and write a before/after draft report. Use when asked to "verify PR #N", "check that the fix works on device", "reproduce the bug and confirm the fix", or to replay an older fix against real Sentry. Android only for now.
---

Verify one PR on a real Android emulator against real Sentry. The output is a **draft report** showing the claim's symptom **without** the change and its absence (or the feature's presence) **with** it, linked to both runs' Sentry events.

Android only. iOS and CI are out of scope for now โ€” say so and stop if the PR's claim is iOS-only.

## Rules

- **Draft only.** Save the report locally and show it. Never post it to GitHub, Linear, or Slack, and never change an issue or PR, unless the maintainer asks in this session.
- Every repo here is public: the report holds no customer names, emails, tokens, or DSNs. Event links into `sentry-sdks` are fine.
- Leave the working tree as you found it, except for scenario changes to the sample (step 1.3). Undo every SDK revert and list what you left behind.
- Don't run the root formatters (`oxfmt`) on `samples/react-native` files: they rewrite whole files the sample never formatted. Match the surrounding style by hand.
- Never edit the PR's code to make it pass. If the change doesn't do what it claims, that is the verdict.

## Verdicts

| Verdict | Meaning |
|---|---|
| **Verified** | Symptom seen without the change, gone (or feature present) with it. |
| **Not reproduced** | No symptom without the change, so the fix proves nothing on this setup. |
| **Failed** | Symptom still present with the change. |
| **Inconclusive** | An event didn't arrive in time, the build/run broke, or the evidence is indirect. Say which. |

Prefer **Inconclusive** over a guess.

## 1. Plan

Read the PR and anything it links: `gh pr view <N> --json title,body,mergeCommit,baseRefOid,headRefOid,files,comments`, plus the linked issue.

Write down, before touching anything:

1. **Claim** โ€” one sentence: what was broken (or missing) and what should be true now.
2. **Platform** โ€” confirm the claim affects Android. A change under `packages/core/ios/` only is out of scope.
3. **Scenario** โ€” the user actions in `samples/react-native` that produce the symptom. Search the sample's screens (`src/Screens/`, `src/tabs/`) for a way to trigger the symptom, and write the scenario for this run. Add a sample button only if none exists. Leave it in the working tree next to its flow and list it in the report; the maintainer decides whether it's committed. A flow must never point at a button that isn't in the tree.
- **How the sample starts the native SDK matters.** By default Android starts the native SDK from `samples/react-native/sentry.options.json` (`RNSentrySDK.init`), and JS `Sentry.init` runs with `autoInitializeNativeSdk: false`. Options set in `App.tsx` don't reach native Android. For native option claims, set the option in `sentry.options.json` (and say so in the report). Building with `SENTRY_DISABLE_NATIVE_START=true` to switch to JS init did **not** work in a release build (JS still saw it as off); don't rely on it.
4. **Evidence** โ€” what you'll read in Sentry (or on device) to tell the two runs apart, and what each run should show. See [references/evidence.md](references/evidence.md).
5. **Build type** โ€” release when the scenario needs a native crash (`Sentry.nativeCrash()` only crashes in release) or when the PR is about release behavior; otherwise debug is fine.

If you can't state the evidence that would separate the two runs, stop and ask; the run would prove nothing.

## 2. Without the change

Build the "without" side from the current checkout with only the PR's SDK change reversed. This needs one clean build; the "with" side is then an incremental rebuild.

```bash
# merged PR โ€” reverse the merge commit's SDK changes, keep tests/changelog
git show <merge-sha> -- packages/core \
':!packages/core/test' ':!packages/core/RNSentryAndroidTester' ':!packages/core/RNSentryCocoaTester' \
| git apply -R --check && <same command> | git apply -R
# open PR โ€” check out the head first, then reverse its diff against the base
git diff <baseRefOid> <headRefOid> -- packages/core ':!packages/core/test' ... | git apply -R
```

- First check the files the PR touched haven't changed on your checkout since: `git diff <merge-sha> HEAD -- <files>` is empty, or the revert won't be the PR's exact before-state. Note it in the report either way.
- When `git apply -R --check` fails, fall back to the parent commit: `git checkout <merge-sha>^` (detached), `yarn install && yarn build`, build there, then return. Slower; record that you did it.
- The sample bundles `packages/core/dist/`. Before the first sample build, run `yarn build` in `packages/core` if `dist/` is older than `HEAD` โ€” even for native-only PRs.
- **JS changes** (`packages/core/src/`) need that `yarn build` on **both** sides.
- `yarn build` in `packages/core` rewrites the tracked `packages/core/android/libs/replay-stubs.jar`; the restore at the end covers it.

## 3. Run

Setup, build, install, and drive commands are in [references/android.md](references/android.md). The short version:

- Full emulator image (e.g. `Pixel_8`), not an ATD image โ€” ATD returns black screenshots.
- JDK 17, `SENTRY_DISABLE_AUTO_UPLOAD=true`, `yarn build-android-release` (or `-debug` + Metro).
- Drive the UI with **Maestro**. Compose the run's scenario from the shared steps in [flows/steps/](flows/steps/) (`launch.yml` with the run tags, `open-errors-screen-button.yml`, `native-crash-and-relaunch.yml`), using [flows/examples/](flows/examples/) as a pattern. Save the flow next to the report, not in the skill.
- Don't add flows or steps to the skill during a verification run. Promote something to `flows/steps/` only when a second run needs it, in a separate change.
- Pass the run tags as launch arguments (next step). Relaunch after a crash so the event is sent.
- Logs and other batched data are sent later: keep the app running ~20 s after the flow before looking them up.
- Capture a screenshot at the step that shows the scenario ran, and keep logcat: `adb logcat -d > <dir>/<run-id>.logcat`.

## 4. Tag

The sample tags every event with these when they're passed as launch arguments (`samples/react-native/src/verifyRun.ts`); without them it tags nothing:

| Launch argument | Tag | Value |
|---|---|---|
| `verifyPr` | `verify.pr` | PR number |
| `verifyCommit` | `verify.commit` | short sha of what the run built, with `^` for the "without" side (`<merge-sha>^`) |
| `verifyRunId` | `verify.run_id` | unique per run: `pr<N>-<without\|with>-<yyyymmdd-hhmm>` |

Use a fresh run id for every attempt, so a retry never picks up a previous attempt's event. Tags set from JS sync to the native scope, so native crash events carry them too.

## 5. Check

Look the evidence up in `sentry-sdks` (region `https://us.sentry.io`, project `sentry-react-native`) through the Sentry MCP. Repeat every ~30 s; give up after **5 minutes** โ†’ Inconclusive. The lookup per evidence type, link formats, and pitfalls are in [references/evidence.md](references/evidence.md). For error events:

1. `search_errors` with `verify.run_id:<id>` and `period: 1h`.
2. Open each hit with `get_sentry_resource` on its **issue-event URL** (`https://sentry-sdks.sentry.io/issues/<SHORT-ID>/events/<event-id>/`). A bare event id fails.
3. Read the event detail, not the Discover columns: Discover shows `""` for a missing tag and an empty one alike.

Logs can't be searched by `verify.run_id`; put the run id in the log message (see evidence.md).

Compare against the expectation from step 1. Unexpected extra differences go in the report.

## 6. Report

Write the report with [references/report-template.md](references/report-template.md) to a local file (scratchpad, or `samples/react-native/verify-reports/` if the maintainer wants it in the tree). Include the verdict, the claim, the exact scenario, both event links, screenshots, the sample diff if any, timings, and every problem hit. Then show it and ask before posting anywhere.

Finally, restore the SDK sources with `git checkout -- packages/core` (this also restores `replay-stubs.jar`), or return from the detached parent checkout, and report `git status`.

## Recording what you learn

When a step needed a human, a retry, or a workaround, add it to the report's *Problems* list. When it will recur, fix the skill or the flow in the same session.
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Worked example from the #7087 verification, and the skill's own regression
# check (run it after changing `flows/steps/`). Not a scenario to look up:
# write each run's scenario next to its report.
#
# Runs the sample TurboModule calls, which set and then clear the
# `turbo_module.*` scope tags, then crashes natively.
appId: io.sentry.reactnative.sample
---
- runFlow: ../steps/launch.yml
- runFlow:
file: ../steps/open-errors-screen-button.yml
env:
BUTTON: 'TurboModule Playground'
- tapOn: 'Run TurboModule calls'
- extendedWaitUntil:
visible: 'Status: Done'
timeout: 30000
- takeScreenshot: turbo-module-done
- back
- runFlow: ../steps/native-crash-and-relaunch.yml
13 changes: 13 additions & 0 deletions .agents/skills/verify-pr/flows/steps/launch.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Clean launch with the run tags (see samples/react-native/src/verifyRun.ts).
# Pass VERIFY_PR, VERIFY_COMMIT and VERIFY_RUN_ID with `maestro test -e`.
appId: io.sentry.reactnative.sample
---
- launchApp:
clearState: true
stopApp: true
arguments:
verifyPr: ${VERIFY_PR}
verifyCommit: ${VERIFY_COMMIT}
verifyRunId: ${VERIFY_RUN_ID}
- waitForAnimationToEnd:
timeout: 2000
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Crashes natively from the Errors tab, then relaunches without clearing
# state so the SDK sends the stored crash event. Needs a release build.
# "Native Crash" is near the top of the list, so scroll up to it.
appId: io.sentry.reactnative.sample
---
- scrollUntilVisible:
element: 'Native Crash'
direction: UP
timeout: 10000
- tapOn: 'Native Crash'
- launchApp:
clearState: false
stopApp: false
- waitForAnimationToEnd:
timeout: 5000
- takeScreenshot: relaunched
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Scrolls the Errors tab down to a button and taps it. Pass BUTTON.
# Maestro can't parameterize `direction`: when the list was already scrolled
# past the button (a pushed screen keeps the offset), scroll UP inline instead.
appId: io.sentry.reactnative.sample
---
- scrollUntilVisible:
element: ${BUTTON}
direction: DOWN
timeout: 15000
- tapOn: ${BUTTON}
79 changes: 79 additions & 0 deletions .agents/skills/verify-pr/references/android.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
# Android: setup, build, run

## Setup

| Need | How |
|---|---|
| JDK 17 | Gradle **and** Maestro need it. `export JAVA_HOME=<jdk17>; export PATH=$JAVA_HOME/bin:$PATH` (e.g. `~/.sdkman/candidates/java/17.0.9-tem`). The default JDK may be 11. |
| Emulator | A full image (`emulator -list-avds`, e.g. `Pixel_8`). **Not** an ATD image (`*_atd`): its screenshots are all black. `adb devices` must list exactly one device, or pass `-s`. |
| Maestro | `maestro --version`. Already used by the repo's e2e tests. |
| Source maps upload | `export SENTRY_DISABLE_AUTO_UPLOAD=true` for release builds. The local token can't upload, and verification doesn't need it. |
| Sentry | The Sentry MCP with read access to `sentry-sdks`. `sentry-cli` can't read events (no `api` command, `org:ci` token). |

Start an emulator if none is running: `emulator -avd Pixel_8 -no-snapshot-save &`, then `adb wait-for-device`.

## Build

From `samples/react-native`:

```bash
yarn build-android-release # โ†’ samples/react-native/app.apk (New Architecture)
yarn build-android-debug # needs Metro: `yarn start`
```

- `*-legacy` variants build the Old Architecture. Verify on the architecture the claim is about; when it's both, run both.
- Build time depends on the Gradle cache: ~5โ€“6 min with a cold cache, 15โ€“40 s with a warm one, including after a native-only change.
- JS SDK changes: `cd packages/core && yarn build` first, on both sides.
- Run builds in the background and wait for them to finish; don't poll.

## Install and launch

```bash
adb install -r samples/react-native/app.apk
adb shell am start -n io.sentry.reactnative.sample/.MainActivity \
-e verifyPr <N> -e verifyCommit <sha> -e verifyRunId <id>
```

`adb shell monkey -p <pkg> -c android.intent.category.LAUNCHER 1` doesn't start this app; use `am start`.
Use `adb uninstall io.sentry.reactnative.sample` before switching between debug and release (different signatures).

## Drive the UI with Maestro

```bash
maestro test \
-e VERIFY_PR=<N> -e VERIFY_COMMIT=<sha> -e VERIFY_RUN_ID=<id> \
--test-output-dir <out-dir> \
<out-dir>/<run-id>.yml # the run's own flow, saved next to the report
```

- `runFlow` paths resolve relative to the flow file. A flow saved outside the skill must reach the shared steps by absolute path: `runFlow: <repo>/.agents/skills/verify-pr/flows/steps/launch.yml`.
- With more than one device running (an emulator and a simulator), pass `--device <id>` (`adb devices` / `xcrun simctl list devices booted`).

- Screenshots from `takeScreenshot: <name>` land in `<out-dir>/screenshots/<name>.png`.
- Maestro matches text case-insensitively (Android upper-cases button labels) and scrolls with `scrollUntilVisible`.
- `scrollUntilVisible.direction` can't come from a variable. A pushed screen keeps the list's scroll offset when you go back, so scroll **UP** to buttons near the top after a `back`.
- After a crash, relaunch with `clearState: false` so the stored event is sent (`steps/native-crash-and-relaunch.yml`).
- Maestro's log prints `${VAR}` unexpanded in launch arguments and in `runFlow` env values (e.g. `Tap on "${BUTTON}"`); the values are still applied. Confirm in logcat (`grep '"verify.run_id"'`).
- Maestro has no plain sleep. When the evidence is batched (logs), wait in the shell after `maestro test` returns, with the app still running.

## Fallback: uiautomator

When Maestro can't run, drive the app with `adb`:

```bash
adb shell uiautomator dump /sdcard/ui.xml && adb shell cat /sdcard/ui.xml # find a node's bounds by text
adb shell input tap <x> <y>
adb shell input swipe 540 600 540 1500 200 # scroll up
```

Match `text` or `content-desc` case-insensitively. The dumped text is also usable evidence when screenshots fail.

## On-device evidence

```bash
adb logcat -c # before the scenario
adb logcat -d > <out-dir>/<run-id>.logcat # after it
adb exec-out screencap -p > <out-dir>/<name>.png
```

The sample runs with `debug: true` (`sentry.options.json`), so logcat shows the Sentry scope and events as JSON (`D Sentry :` lines) โ€” useful for checking the native scope before an event is sent.
56 changes: 56 additions & 0 deletions .agents/skills/verify-pr/references/evidence.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# Evidence: what to check and how to find it

## Pick the evidence first

Choose the signal that differs between the two runs, and write the expectation for each side before running.

| Claim is aboutโ€ฆ | Evidence | How to look it up |
|---|---|---|
| Event content (tags, contexts, extras, stack trace, mechanism) | The error event of each run | `search_errors` by `verify.run_id`, then open the event (below) |
| A crash the change prevents | A crash event without the change; none with it, **plus** proof the scenario ran (screenshot, logcat line, a later event from the same run) | `search_errors` by run id; `adb logcat -d \| grep "FATAL EXCEPTION"` |
| Logs | Log entries of each run | `search_logs` (recipe below). Delivery alone may not separate the runs: in the #6967 run, a native `Sentry.logger()` call was delivered with logs disabled |
| Spans, transactions, measurements | The transaction of each run | `search_traces` / `get_trace_details`; add the run id as a tag before the transaction starts |
| Profiles | Profile chunks of each run | `search_profiles` by time window; open from the transaction |
| Replays, attachments | The replay or attachment on the run's event | the event's `replays.attached` field / `get_event_attachment` |
| Option mapping, native init | The **resolved option on device**, logged by the scenario (e.g. `ScopesAdapter.getInstance().getOptions().getLogs().isEnabled()`); the option's effect in Sentry is secondary | logcat, or put the value in the message/tag the run sends. Mind the sample's init path (SKILL.md step 1.3) |
| Performance (startup, allocation) | Usually not checkable end to end on an emulator | Say so and mark **Inconclusive** rather than measuring noise |

An absence ("tag missing", "no crash") only counts when the same run also shows the scenario ran.

## Sentry MCP sequence

Org `sentry-sdks`, region `https://us.sentry.io`, project `sentry-react-native`.

1. **Search** โ€” `search_errors`:
```
organizationSlug: sentry-sdks
regionUrl: https://us.sentry.io
query: verify.run_id:<id>
period: 1h
fields: ["id", "title", "issue", "timestamp", "tags[verify.commit]"]
```
Events usually show up within a minute of the relaunch. Repeat every ~30 s; after **5 minutes** with nothing, the run is Inconclusive (check logcat for `Envelope sent successfully` / rate limits first).
2. **Open** โ€” `get_sentry_resource` with `url: https://sentry-sdks.sentry.io/issues/<issue short id>/events/<event id>/`. Looking up a bare event id (`resourceType: event`) fails with "No issue found".
3. **Read** the `tags` and `contexts` in the event detail.

## Logs

`search_logs` rejects `verify.run_id` ("Unknown attribute"), and a wildcard on the run id alone returned nothing. What worked:

1. The scenario logs a message with a fixed prefix plus the run id, e.g. `verify-pr log <run id> ...`.
2. `search_logs` with `message:"*<fixed prefix>*"`, `period: 1h`; pick the entry whose message holds the run id.
3. Wait ~20 s after the flow before the first lookup: logs are batched on device.

## Links for the report

| Evidence | Link |
|---|---|
| Error event | `https://sentry-sdks.sentry.io/issues/<short id>/events/<event id>/` |
| Log entry | `https://sentry-sdks.sentry.io/explore/logs/?project=-1&logsPinned=<log id>` |

## Pitfalls

- **Discover can't tell missing from empty.** A `tags[x]` column shows `""` for both. In the event detail, a tag the SDK sent as `""` appears with `value: null` (ingestion dropped it); a tag never sent is absent.
- **Processing errors aren't visible through the MCP.** The event's `errors` list (e.g. "Discarded invalid value") isn't returned. Use indirect evidence (a `null` tag value) and say so in the report. Reading it needs a token with `event:read`.
- **Stale events.** The sample keeps unsent envelopes across launches. Use a fresh run id per attempt and launch with `clearState: true`.
- **Grouping.** Both runs' events may land in the same, long-lived issue (e.g. `SENTRY-REACT-NATIVE-28E` for `Sentry.nativeCrash()`). Link the **events**, not the issue.
Loading
Loading