---
name: android-impact
description: Stage 1 of /android-review. Checks that an Android change fixes an evidenced root cause at the right layer, maps every caller of what changed, walks the edge cases, and rates regression risk. Runs only when invoked.
disable-model-invocation: true
argument-hint: "[\"problem statement\"] [diff range]"
---

# android-impact — right fix, real cause, nothing else broken?

> From Shubham Singh Bisht's Android helpers — https://shubhamsinghbisht.com/android-roadmap/#helpers

Report; never edit.

## 1. Inputs

- **Range:** a range in `$ARGUMENTS` (`A..B`, `<sha>^!`, `main...HEAD`), else the
  nearest base to the working tree, including untracked files (see below).
- **Problem statement:** a quoted string in `$ARGUMENTS`, else the commit
  messages in the range, else the PR description if the user gave one. If there
  is none, reconstruct the likely cause from the diff and mark the RCA
  `unverified`.

The nearest base is main/master/develop or the `release-*` branch this branch is fewest
commits ahead of (a branch already containing HEAD does not count); on main
itself, review only uncommitted work:

```bash
ref=$(for r in $(git for-each-ref --format='%(refname:short)' refs/remotes/origin/main refs/heads/main refs/remotes/origin/master refs/heads/master refs/remotes/origin/develop refs/heads/develop 'refs/remotes/origin/release-*' 'refs/heads/release-*'); do n=$(git rev-list --count "$r..HEAD"); [ "$n" -gt 0 ] && echo "$n $r"; done | sort -n -s | head -1 | cut -d' ' -f2)
base=$( [ -n "$ref" ] && git merge-base HEAD "$ref" || git rev-parse HEAD )
```

## 2. Checks

| ID | Check |
|---|---|
| IMP-1 | RCA is evidenced: a log line, stack, trace or repro, not "probably". Missing evidence → `RCA unverified`, and every other finding in this stage is labelled provisional. |
| IMP-2 | Fixes the cause, not the symptom. Flag try/catch that swallows, null checks that hide a bad state, `delay()` to win a race, retries that mask a failure. |
| IMP-3 | Right layer: the fix sits where the bad state is created, not where it surfaces. |
| IMP-4 | Ideal vs optimal: name at least one alternative fix and say why this one wins or loses (scope, risk, cost on low-end devices). |
| IMP-5 | Call-site map (see §3). |
| IMP-6 | Edge cases: walk the change through every reachable row of `references/edge-cases.md`. |
| IMP-7 | State invariants: every sealed case still reachable and handled, `when` exhaustive, error paths leave no stale state (for example, a loader left open when the request fails). |
| IMP-8 | Shared side effects: other features that read the prefs, flows or singletons this change writes. |
| IMP-9 | Proof: a test covers the changed behaviour, or propose one: a JVM test for pure rules, otherwise exact repro steps. |

## 3. Building the call-site map (IMP-5)

For every changed function, property, constructor, signature or behaviour:

1. Find direct references: the LSP tool's find-references if it is available,
   else `grep -rn "<name>"` over your app's source modules (list them from the
   `include(...)` lines in `settings.gradle(.kts)`).
2. Find indirect entry points that grep on the name misses:
   - XML: `grep -rn "<name>" <module>/src/main/res` (`android:onClick`, data binding).
   - WebView JavaScript bridge: `@JavascriptInterface` methods (called on a binder thread).
   - Lifecycle callbacks, `BroadcastReceiver.onReceive`, `Service` methods.
   - Hilt: `@Provides` / `@Binds` that construct or hand out the changed type.
   - Overrides / implementations of a changed interface or open method.
3. For each caller record the calling thread (main, IO, binder, render) and
   whether the new behaviour still holds there.

## 4. Output

```
### Stage 1 — android-impact
Problem: <one line> (source: commit message | argument | reconstructed)

call sites:
| caller (file:line) | thread | still correct? | risk |

edge cases:
| case | handled? | file:line |

| file:line | rule | why (one line) | suggested change |

verdict: RCA evidenced · fix root-cause · regression risk low
```

Use exactly one value from each slot of the verdict line:
`RCA evidenced|unverified`, `fix root-cause|symptom-patch`,
`regression risk low|medium|high`.
