Skip to content

Commit 5e05948

Browse files
authored
Merge branch 'main' into mmpay_recipient_update
2 parents a03b3b8 + a69be23 commit 5e05948

113 files changed

Lines changed: 4270 additions & 1344 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.agents/skills/perps-core-sync/SKILL.md

Lines changed: 33 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ description: Sync the perps controller from mobile to the core monorepo with cha
77

88
## Purpose
99

10-
Use this skill to sync `app/controllers/perps/` from mobile to `packages/perps-controller/src/` in the core monorepo. The sync is driven by `scripts/perps/validate-core-sync.sh` — a 9-step pipeline (preflight, conflict check, copy, install, verify, eslint fix, build, lint, write sync state).
10+
Use this skill to sync `app/controllers/perps/` from mobile to `packages/perps-controller/src/` in the core monorepo. The sync is driven by `scripts/perps/validate-core-sync.sh` — a 13-step pipeline that validates not only source sync but also the built publish artifact safety for extension consumers.
1111

1212
Use when:
1313

@@ -58,37 +58,39 @@ Options:
5858
- `--skip-test` — skip the test step for faster iteration
5959
- `--verbose` — show full output for every step (useful for debugging)
6060

61-
The script runs these 12 steps in order:
62-
63-
| Step | What it does |
64-
| ----------------------- | --------------------------------------------------------------------------------------- |
65-
| 1. Pre-flight checks | Confirms mobile source, core destination, required tools |
66-
| 2. Conflict check | Fetches origin/main, checks for upstream perps-controller changes, validates sync state |
67-
| 3. Copy source files | rsync `.ts` files (excluding tests, mocks, fixtures) |
68-
| 4. Install dependencies | `yarn install` in core |
69-
| 5. Verify build fixes | Checks for `__DEV__`, mobile imports, closure fixes |
70-
| 6. ESLint auto-fix | Runs `--fix`, `--suppress-all`, `--prune-suppressions`, checks suppression delta |
71-
| 7. Format fix (oxfmt) | Runs `yarn lint:misc --write` — core uses oxfmt, not prettier |
72-
| 8. Build | `yarn workspace @metamask/perps-controller build` |
73-
| 9. Lint | Final lint pass to confirm zero violations |
74-
| 10. Test | `yarn workspace @metamask/perps-controller test` — catches DI/fixture mismatches |
75-
| 11. Changelog check | Verifies `CHANGELOG.md` has been updated (core CI requirement) |
76-
| 12. Write sync state | Updates `.sync-state.json` with commit hashes and checksum |
61+
The script runs these 13 steps in order:
62+
63+
| Step | What it does |
64+
| -------------------------- | -------------------------------------------------------------------------------------------------- |
65+
| 1. Pre-flight checks | Confirms mobile source, core destination, required tools |
66+
| 2. Conflict check | Fetches origin/main, checks for upstream perps-controller changes, validates sync state |
67+
| 3. Copy source files | rsync `.ts` files (excluding tests, mocks, fixtures) |
68+
| 4. Install dependencies | `yarn install` in core |
69+
| 5. Verify build fixes | Checks for `__DEV__`, mobile imports, closure fixes |
70+
| 6. ESLint auto-fix | Runs `--fix`, `--suppress-all`, `--prune-suppressions`, checks suppression delta |
71+
| 7. Format fix (oxfmt) | Runs `yarn lint:misc --write` — core uses oxfmt, not prettier |
72+
| 8. Build | `yarn workspace @metamask/perps-controller build:all` (builds references on a clean Core checkout) |
73+
| 9. Verify publish artifact | Confirms built `dist/PerpsController.{mjs,cjs}` still preserves the MYX webpack-ignore safeguard |
74+
| 10. Lint | Final lint pass to confirm zero violations |
75+
| 11. Test | `yarn workspace @metamask/perps-controller test` — catches DI/fixture mismatches |
76+
| 12. Changelog check | Verifies `CHANGELOG.md` has been updated (core CI requirement) |
77+
| 13. Write sync state | Updates `.sync-state.json` with commit hashes and checksum |
7778

7879
## Failure Resolution
7980

80-
| Failure | Cause | Fix |
81-
| -------------------------------------------------------- | -------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------- |
82-
| `__DEV__` found | Mobile code uses `__DEV__` guard | Replace with `false` in the mobile source file, or route through `PerpsPlatformDependencies` for environment-aware behavior. Fix in mobile, then re-sync. |
83-
| Mobile imports (Engine, react-native, Sentry, DevLogger) | Direct platform import in controller | Route through `PerpsPlatformDependencies` (DI). All platform services must come through the `infrastructure` constructor param. Fix in mobile. |
84-
| Suppression delta increase | Sync introduces new ESLint violations | Fix violations in mobile first (e.g., `'x' in y``hasProperty(y, 'x')` from `@metamask/utils`). Re-run sync after fixing. |
85-
| Build failure | Missing tsconfig references, missing dependencies, type errors | Check `packages/perps-controller/tsconfig.json` references. Ensure new imports have corresponding `dependencies` in `package.json`. |
86-
| Lint failure after fix | Auto-fix didn't resolve all issues | Re-run the eslint fix step. If persistent, check for new rule violations that need manual fixes in mobile. |
87-
| Format fix failure | oxfmt can't auto-fix some files | Check for syntax errors that prevent parsing. Core uses `oxfmt` (not prettier) for TS formatting. |
88-
| Test failure | Test fixtures missing new DI dependencies | Add mocks for new `PerpsPlatformDependencies` fields (e.g., `diskCache`) in `tests/defer-eligibility.test.ts`. |
89-
| Changelog check failure | `CHANGELOG.md` not updated | Add entries under `## [Unreleased]` with `### Added`, `### Fixed`, `### Changed` sections linking to the PR. |
90-
| Conflict check: behind origin/main | Someone pushed perps-controller changes to main | `cd <core-path> && git merge origin/main` before re-running sync. |
91-
| Conflict check: checksum mismatch | Core source was hand-edited since last sync | Review the edits. Either port them back to mobile or discard and re-sync. |
81+
| Failure | Cause | Fix |
82+
| -------------------------------------------------------- | -------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
83+
| `__DEV__` found | Mobile code uses `__DEV__` guard | Replace with `false` in the mobile source file, or route through `PerpsPlatformDependencies` for environment-aware behavior. Fix in mobile, then re-sync. |
84+
| Mobile imports (Engine, react-native, Sentry, DevLogger) | Direct platform import in controller | Route through `PerpsPlatformDependencies` (DI). All platform services must come through the `infrastructure` constructor param. Fix in mobile. |
85+
| Suppression delta increase | Sync introduces new ESLint violations | Fix violations in mobile first (e.g., `'x' in y``hasProperty(y, 'x')` from `@metamask/utils`). Re-run sync after fixing. |
86+
| Build failure | Missing tsconfig references, missing dependencies, type errors | Check `packages/perps-controller/tsconfig.json` references. Ensure new imports have corresponding `dependencies` in `package.json`. |
87+
| Lint failure after fix | Auto-fix didn't resolve all issues | Re-run the eslint fix step. If persistent, check for new rule violations that need manual fixes in mobile. |
88+
| Format fix failure | oxfmt can't auto-fix some files | Check for syntax errors that prevent parsing. Core uses `oxfmt` (not prettier) for TS formatting. |
89+
| Test failure | Test fixtures missing new DI dependencies | Add mocks for new `PerpsPlatformDependencies` fields (e.g., `diskCache`) in `tests/defer-eligibility.test.ts`. |
90+
| Publish artifact verification failure | Built Core dist lost the MYX webpack-ignore safeguard | Restore the `myxModulePath` workaround in mobile `PerpsController.ts`, rebuild Core, and confirm `dist/PerpsController.{mjs,cjs}` still contains `webpackIgnore: true`. |
91+
| Changelog check failure | `CHANGELOG.md` not updated | Add entries under `## [Unreleased]` with `### Added`, `### Fixed`, `### Changed` sections linking to the PR. |
92+
| Conflict check: behind origin/main | Someone pushed perps-controller changes to main | `cd <core-path> && git merge origin/main` before re-running sync. |
93+
| Conflict check: checksum mismatch | Core source was hand-edited since last sync | Review the edits. Either port them back to mobile or discard and re-sync. |
9294

9395
## Post-Sync
9496

@@ -131,6 +133,8 @@ After all 12 steps pass:
131133

132134
6. **Use `--verbose` when debugging** — without it, step output is captured to temp files and only shown on failure. With `--verbose`, all output streams to the terminal.
133135

136+
7. **Treat extension-consumer safety as a hard invariant.** If `packages/perps-controller/package.json` excludes `dist/providers/MYXProvider*`, the built `dist/PerpsController.{mjs,cjs}` must still preserve the `webpackIgnore` safeguard so extension bundlers never statically resolve the missing file.
137+
134138
## Portability Rules
135139

136140
Reference: `docs/perps/perps-review-antipatterns.md` (Controller Portability section).

0 commit comments

Comments
 (0)