Skip to content

feat: Adds platform domain - Extension runtime architecture and failure modes - #44

Closed
MajorLift wants to merge 10 commits into
MetaMask:mainfrom
MajorLift:add/platform-skills
Closed

MajorLift wants to merge 10 commits into
MetaMask:mainfrom
MajorLift:add/platform-skills

Conversation

@MajorLift

@MajorLift MajorLift commented Jun 5, 2026 •

Copy link
Copy Markdown
Contributor

Overview

Adds a platform domain: the extension's runtime architecture and its failure modes.

  • extension-errors-debugging — triage a runtime error to root cause. Ships a metamask-extension overlay.
  • extension-lifecycle-decoupling — decouple work from the Manifest V3 service-worker lifecycle, so a suspended worker doesn't strand it.
  • Knowledge: extension-architecture, mv3-service-worker.

Needs a decision: /domains/platform/ has no CODEOWNERS entry, falling to the * catch-all — which team should own it?

Motivation

Nothing in mobile or core corresponds, making these a domain rather than a corner of coding.

extension-lifecycle-decoupling is argued as always-loaded, spending shared description budget. It preempts confidently wrong MV3 claims that disrupted the platform team — recurring reports attributing unrelated bugs to the service worker dying mid-session, which it does not do due to a keepalive. Nobody holding a wrong model searches for the skill that corrects it: from the inside, the model is not in question.

Showcase

Neither skill has a trial run reported here, so nothing here speaks to their hit rate.

Adjacent, not a trial run: #44003 (error-handling capture) in the mms-evidence showcase — write gap 631 ms against a 192 ms control, recovery beacons 1 against 0, error toast absent and asserted twice. Handled, not skipped.

CHANGELOG.md tracks consumer-facing changes to the `@metamask/skills` package,
per CONTRIBUTING's "CLI / tooling changes" section. No merged skill-only PR adds
an entry (#80, #78, #70, #62, #61 all touch zero changelog lines).

It was also the sole source of this branch's conflict with `main`, since every
skill PR edits the same `[Unreleased]` block.
@MajorLift MajorLift changed the title Add platform domain plus testing and utility skills feat(platform): add extension runtime, benchmark, and profiling skills Jul 30, 2026
@MajorLift
MajorLift marked this pull request as draft July 30, 2026 14:03
@MajorLift MajorLift changed the title feat(platform): add extension runtime, benchmark, and profiling skills feat(platform): add Extension platform, architecture, profiling skills Jul 30, 2026
`benchmark-design` and `browser-extension-profiling` both cover E2E benchmarking
with statistical rigor, and they sat in different domains here while the rest of
the measurement work — `data-analysis`, `react-render-proof` — lives in the
performance PR. Splitting one subject across two PRs made both harder to review.

Moves `benchmark-design`, its `benchmark-statistical-hygiene` knowledge, and
`browser-extension-profiling`. Neither skill referenced the other by path, so
nothing needed rewriting.

What remains is the extension-runtime work this PR is named for.
Generic scripting guidance — paginate an API, handle rate limits, retry
transient errors — with no MetaMask specificity and no relationship to this PR's
extension-runtime subject. `coding/` otherwise holds MetaMask internals.

Nothing referenced it and it referenced nothing, so removal is self-contained.
The content stays in this branch's history if it is wanted later.
@MajorLift MajorLift changed the title feat(platform): add Extension platform, architecture, profiling skills feat(platform): add Extension architecture, debugging skills Jul 30, 2026
The keepalive row was the one entry here resting on a live implementation detail
rather than on an absent handler or persistent storage, and it was cited as
`background.js:750-758` — a line range that drifts. If the interval grows past
the idle timeout or the keepalive is removed, the conclusion inverts from
"eviction is prevented" to "eviction happens routinely", and a skill still
asserting the first is worse than no skill.

Replaces the line range with a symbol grep (`saveTimestamp`,
`SAVE_TIMESTAMP_INTERVAL_MS`), names the two conditions the conclusion depends
on — sub-idle-timeout interval, and an extension API call rather than a bare
timer — and records what was verified, against which commit.
@MajorLift
MajorLift marked this pull request as ready for review July 30, 2026 18:15
@MajorLift

MajorLift commented Jul 30, 2026 •

Copy link
Copy Markdown
Contributor Author

Context budget

What this PR costs an agent, measured from an install rather than read from the diff. Three tiers, and only the first is unavoidable.

Skill Frontmatter Selected + refs & knowledge
extension-errors-debugging 84 chars ~1,355 tok ~1,355 tok
extension-lifecycle-decoupling 90 chars ~1,178 tok ~1,178 tok

Frontmatter is the only tier paid unconditionally — every agent loads it on every run once the skill is installed, used or not, because it is what the agent reads to decide relevance. The 28 skills across the eleven open skill PRs sit at a median of ~1,716 tokens selected and ~1,860 with references followed. All are within the 1,536-character description budget.

Selected is paid only when the agent picks the skill. + refs & knowledge is the ceiling if every bundled reference is then read; it is a worst case, not an expectation.

Method

tools/install --repo metamask-extension --maturity experimental against this branch at 45f78e127, measured per installed skill directory. Repo overlays are merged into the emitted SKILL.md, so they land in the selected tier rather than being missed by a source-byte count. Token figures are bytes/4 — a proxy for scale, not accounting.

These figures are pinned to the commit above and drift on every push; #96 tracks automating them.

@MajorLift MajorLift changed the title feat(platform): add Extension architecture, debugging skills feat(platform): add Extension runtime architecture, debugging skills Aug 3, 2026
MajorLift added a commit that referenced this pull request Aug 4, 2026
Adds #44 (platform), #69 (typescript), #90 (privacy-egress-diligence),
#91 (agent-run-cost) and #98 (mms-debug). The first nine were taken from an
earlier sync list rather than an enumeration of open PRs, which is how these
were missed.
@MajorLift MajorLift changed the title feat(platform): add Extension runtime architecture, debugging skills feat: Adds platform domain - extension errors debugging, lifecycle decoupling skills Aug 31, 2026
@MajorLift MajorLift changed the title feat: Adds platform domain - extension errors debugging, lifecycle decoupling skills feat: Adds platform domain - /extension-errors-debugging, /extension-lifecycle-decoupling skills Aug 31, 2026
@MajorLift MajorLift changed the title feat: Adds platform domain - /extension-errors-debugging, /extension-lifecycle-decoupling skills feat: Adds platform domain - Extension runtime architecture and failure modes Aug 31, 2026
Both platform teams co-own the domain, as they do `coding`, `general`,
`performance` and `pr-workflow`. A client's overlay is owned by that client's
platform team, placed directly under the domain line so it wins on
last-match and so each domain PR inserts at its own anchor.
…termination

metamask-extension#44348 (move keep-alive polling to service worker startup)
moved the keepalive out of `background.js`, #44373 (remove the
enableMV3TimestampSave debug preference) removed its gate, and #44433
(remove browserify) took `app-init.js` with it. The re-check grep searched
the file the keepalive left, so it told readers to treat eviction as live.
Cold starts are measured and frequent, and whether idle termination is
among their causes is not established.
…start does to cronjobs

Wallet state persists in `chrome.storage.local` with an IndexedDB backup.
On a restart, `CronjobController` runs a recurring job that came due while
the worker was down and drops a one-off background event that did. Chrome
also ends a worker whose single event runs past five minutes or whose
`fetch()` response takes over 30 seconds, the update debounce has a 1s
`maxWait`, and an error's tag split counts errors rather than users.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant