Commit 65cbeec
authored
feat(perps): decouple agentic cache fingerprint from project EAS fingerprint (MetaMask#30569)
## **Description**
Adds `scripts/perps/agentic/lib/compute-cache-fp.js`, an agentic-local
native-build fingerprint, and switches the build cache in
`bc_fingerprint` to use it instead of `scripts/generate-fingerprint.js`.
The project-wide fingerprint script and `fingerprint.config.js` are
untouched, so EAS Build, EAS Update, and the OTA fingerprint guard in
`nightly-ota-updates.md` keep their existing semantics.
**Why:** `--mode auto`'s shared cache (MetaMask#30565) was keyed off the same
fingerprint EAS/OTA depend on, which conservatively hashes build outputs
(`ios/build/`, `.gradle/`, IDE `xcuserdata`, env-populated
`xcconfig`/`google-services.json`). Those paths diverge per worktree, so
two slots on the same commit hashed to different keys and never shared a
cached `.app` — the cross-worktree benefit the cache was designed for
never landed. The new fingerprint uses the same `extraSources` (so
anything that genuinely affects the binary still participates) but
ignores the per-worktree noise paths.
Verified across three worktrees on the same commit (`c06187a24c`, all on
`main`):
```
mm-1: c7fe9e2161109d4ff2e092e068821a2e9984aac5
mm-5: c7fe9e2161109d4ff2e092e068821a2e9984aac5
mm-6: c7fe9e2161109d4ff2e092e068821a2e9984aac5
```
Identical → next `--mode auto` dispatch on any of these slots will
install the cached artifact from whichever slot built first.
## **Changelog**
CHANGELOG entry: null
## **Related issues**
Follows MetaMask#30565.
## **Manual testing steps**
```gherkin
Feature: Agentic cache fingerprint decoupled from project fingerprint
Scenario: Project fingerprint unchanged
When I run "node scripts/generate-fingerprint.js"
Then the hash is the same as on `main` before this PR
And EAS / OTA tools that depend on it are unaffected
Scenario: Agentic cache fingerprint ignores build artifacts
Given a worktree at any state
When I capture the agentic fingerprint
And I write a poison file under `ios/build/`
And I capture the agentic fingerprint again
Then the two fingerprints are identical
Scenario: Cross-worktree fingerprint match on same commit
Given two worktrees (mm-5, mm-6) at the same git commit
When I compute the agentic fingerprint in each
Then they match
And `--mode auto` on the second slot installs from the cached artifact stored by the first
```
Programmatic check the test suite runs:
```bash
bash scripts/perps/agentic/lib/test-build-cache.sh
```
New section "agentic fp ignores build artifacts" verifies the
ignorePaths actually take effect.
## **Screenshots/Recordings**
N/A — script-only change, no UI surface.
### **Before**
N/A
### **After**
N/A
## **Pre-merge author checklist**
- [x] I've followed [MetaMask Contributor
Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Mobile
Coding
Standards](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/CODING_GUIDELINES.md).
- [x] I've completed the PR template to the best of my ability
- [x] I've included tests if applicable (new "agentic fp ignores build
artifacts" assertion in `test-build-cache.sh`)
- [x] I've documented my code using [JSDoc](https://jsdoc.app/) format
if applicable (file-level rationale in `compute-cache-fp.js`)
- [x] I've applied the right labels on the PR
#### Performance checks (if applicable)
- [ ] I've tested on Android — N/A (script-only)
- [ ] I've tested with a power user scenario — N/A
- [ ] I've instrumented key operations with Sentry traces — N/A
(developer tooling)
## **Pre-merge reviewer checklist**
- [ ] I've manually tested the PR.
- [ ] I confirm that this PR addresses all acceptance criteria.
<!-- CURSOR_SUMMARY -->
---
> [!NOTE]
> **Medium Risk**
> Changes the cache key used for agentic preflight native build reuse;
incorrect ignore/hashing boundaries could cause stale or mismatched
cached binaries across worktrees.
>
> **Overview**
> Decouples the agentic shared native build cache fingerprint from the
repo-wide EAS/OTA fingerprint by introducing
`scripts/perps/agentic/lib/compute-cache-fp.js` and switching
`bc_fingerprint` to use it.
>
> The new fingerprint inherits `fingerprint.config.js` `extraSources`
(plus explicitly hashes `app/core/InpageBridgeWeb3.js`) while adding
`ignorePaths` for per-worktree build outputs (e.g., `ios/build`, Xcode
`xcuserdata`, `.gradle`, NDK `.cxx`) so cache artifacts can be shared
across parallel worktrees.
>
> Updates agentic docs to describe the new keying behavior and extends
`test-build-cache.sh` with boundary tests ensuring ignored paths don’t
shift the fingerprint while binary-affecting sources still do (and
adjusts the fast-mode failure test to reference the new script).
>
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
32aa686. Bugbot is set up for automated
code reviews on this repo. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->1 parent 6018bf7 commit 65cbeec
4 files changed
Lines changed: 148 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
224 | 224 | | |
225 | 225 | | |
226 | 226 | | |
227 | | - | |
| 227 | + | |
228 | 228 | | |
229 | 229 | | |
230 | 230 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
78 | 78 | | |
79 | 79 | | |
80 | 80 | | |
81 | | - | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
82 | 85 | | |
83 | 86 | | |
84 | 87 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
184 | 184 | | |
185 | 185 | | |
186 | 186 | | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
187 | 255 | | |
188 | 256 | | |
189 | 257 | | |
| |||
215 | 283 | | |
216 | 284 | | |
217 | 285 | | |
218 | | - | |
| 286 | + | |
219 | 287 | | |
220 | 288 | | |
221 | 289 | | |
| |||
0 commit comments