Repository navigation
feat: add mm network, a passive request log for pages and the service worker - #111
Open
cryptotavares wants to merge 1 commit into
Open
cryptotavares wants to merge 1 commit into
cryptotavares wants to merge 1 commit into
Conversation
cryptotavares
force-pushed
the
cryptotavares/mmcli-p2-17-network
branch
from
November 18, 2026 15:45
d064833 to
7e49d95
Compare
cryptotavares
force-pushed
the
cryptotavares/mmcli-p2-16-logs
branch
from
November 18, 2026 17:09
19aa455 to
20224ca
Compare
cryptotavares
force-pushed
the
cryptotavares/mmcli-p2-17-network
branch
from
November 18, 2026 17:28
7e49d95 to
c5140f5
Compare
cryptotavares
force-pushed
the
cryptotavares/mmcli-p2-16-logs
branch
from
November 18, 2026 18:05
20224ca to
9ef48e3
Compare
cryptotavares
force-pushed
the
cryptotavares/mmcli-p2-17-network
branch
from
November 18, 2026 18:13
c5140f5 to
48c7db6
Compare
cryptotavares
force-pushed
the
cryptotavares/mmcli-p2-16-logs
branch
from
November 18, 2026 18:47
9ef48e3 to
2b3db17
Compare
… worker
Joins Network.requestWillBeSent / responseReceived / loadingFinished /
loadingFailed from every page and the Extension service worker into one
record per request, keyed by (target kind, target id, request id) and
updated in place: method, redacted URL, type, status, ms, failure and
rpcMethods (always an array; single and batch JSON-RPC bodies). Only
http(s) requests are recorded; others are counted as ignored. A redirect
gives one record per hop.
'mm network configure --rpc-errors' reads JSON-RPC response bodies with
Network.getResponseBody (64 KiB, 8 at a time, 2 s timeout; skipped reads
are counted) and records { code, message } as rpcError. Off by default.
Adds CdpManager.sendToEventTarget for commands on the target of an event.
'mm network' reads with --cursor/--since/--limit/--url/--errors.
cryptotavares
force-pushed
the
cryptotavares/mmcli-p2-17-network
branch
from
November 18, 2026 18:51
48c7db6 to
ce385a3
Compare
cryptotavares
marked this pull request as ready for review
November 18, 2026 18:58
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Important
Stacked on #110 (P2-16) → #109 (P2-15) → #107 (P2-28, ready to review on
main). Review those first. This PR targets #110's branch and contains one commit.Release validation needs, for each flow, the backend calls the wallet made, with status, duration, failures and JSON-RPC methods. On the Extension most of that traffic (gas, Blockaid, bridge, intents, Relay, Hyperliquid) comes from the MV3 service worker.
mock-networkonly sees hosts it routes and records no timing. The closed #106 did this with Playwright context events. This PR uses our own CDP sessions (#107) instead, so it needs no minimum Playwright version, and a mobile source can later fill the same record format.src/events/network-source.ts):Network.requestWillBeSent/responseReceived/dataReceived/loadingFinished/loadingFailedon every page and the service worker, joined by(target.kind, target.targetId, requestId)into one record per request, updated in place. A record keeps its firstseqand gets asettledSeqwhen it ends, that is, when no field of it can change any more (itsrpcErrorread, when configured, included). An unfiltered read returns records inseqorder; a filtered one returns settled records insettledSeqorder.t: request start (wallTime, epoch ms).ms: CDP monotonic time from the start to the finish or the failure.type: lowercase CDP resource type.failure: CDPerrorText(+ blocked reason, +cors: <CorsErrorStatus>when Chrome reports one), redacted;target closedwhen the page or worker goes away mid-request or the source restarts;abandonedwhen the request is dropped from the pending limit.url: redacted with the P2-15 rules.rpcMethods: always an array, parsed from the JSON-RPC request body (postData/postDataEntries, up to 64 KiB; single and batch). Absent for non-RPC requests. A method name is cut at 128 characters.http(s)URLs are recorded. Others are counted instats.ignored.rpcError{ code, message }, opt-in:mm network configure --rpc-errorsreadsNetwork.getResponseBodyfor JSON-RPC requests only.Network.dataReceived.dataLength, elseencodedDataLength), 8 reads at once, 2 s timeout. Skipped reads are counted instats.rpcErrorsSkipped. Off by default.Network.enablecaps the response buffers (128 KiB per resource, 1 MiB total) since no bodies are kept otherwise.CdpManager.sendToEventTarget, with the target lookup inside the timeout. It never re-attaches a gone target.mm network [--cursor N | --since <iso|ms>] [--limit N] [--url <glob|text>] [--errors] [--settled]→{ records, cursor, hasMore, gap, summary, stats: { pending, ignored, rpcErrorsSkipped } }.--errors: status ≥ 400,failureorrpcError.--url: a glob (*,**) or a substring, likemock-network requests --url(feat: record request bodies in mock-network #93).seq), pending requests included, and its cursor moves past all of them. A read with--urlor--errorsreturns only settled requests, insettledSeqorder: a request may become a match only when it ends (a 404, a failure, anrpcError), so it is returned once by the read that follows its end, even when it started before the cursor. The cursor stays a plain buffer position (one counter shared by appends and settles), so it also continues a read of the other kind oncehasMoreis false, and a record that settles after a read always lands above the returned cursor.--settledasks for that same settle-order read without a filter (value-less, like--errors): one call at the end of a step reads the final status of every request that ended since the mark, including ones started earlier; requests still open are not returned. An unsettled request is never returned by a filtered or--settledread, so a request that never ends never matches one.--sincecompares the request start (t), not when it ended (documented).failure: "target closed"and stops counting instats.pending; a request dropped from the pending limit is finalized withfailure: "abandoned".mark→network/logs --cursor,startedAtcheck, capture gap). Unknown read flags and missing values exit 2;configuretakes exactly one of--rpc-errors/--no-rpc-errors.Part of the mm CLI v2 effort: ticket
P2-17(Phase 2).Shared #93 helper:
--urlusesmock-network'smatchesUrlFilter, somm network --urlandmm mock-network requests --urlmatch URLs the same way.Breaking changes
None.
Consumer impact
test/e2e/playwright/llm-workflow/tests/llm-workflow/The Extension release-validation skill (Consensys/skills#122) can take one
mm events markat flow start and readmm network/mm logsat flow end, falling back to itsmock-networkrecorder on oldermm. The reports importer mapsfailure/text/rpcMethods/target.Proof
Real daemon (
createServerfrom the builtdist/) + built CLI, headless Chromium, read-only, no funds. Rerun after the review fixes on the rebuiltdist/of this head (ce385a3): 12/12 harness checks pass (the new17.5is the--settledend-to-end scenario), the redaction grep finds nothing (18 ×[REDACTED]), and the 22mm events|logs|networkreads take a mean of 96 ms wall-clock (max 130 ms, CLI start included). A live late-settle check on the samedist/: a 2 s pagefetchstarted before a filtered read (read returns 0 records, cursor 3), then the next read with cursor 3 returns it once (seq3,settledSeq4), and the read after that returns nothing.fetch200 / 404 / aborted and a pagefetch: status orfailure,ms,target.kindsw … 200 123ms,sw … 404 0ms,sw … net::ERR_ABORTED 60ms,page … 200 122msrpcMethods["eth_call"],["eth_chainId","eth_blockNumber"]--rpc-errors:execution reverted→rpcError{"code":-32000,"message":"execution reverted"}; the batch without errors has none;rpcErrorsSkipped0ServiceWorker.stopAllWorkers(0 worker targets) and a wake?boot=1fetchsummary.startedAt;seqrestarts; an old cursor reads the new session from the start (gap: true)apiKey=supersecret(query) over every CLI output[REDACTED]--limit 3paging--errors,--urlglob,events clearkeepsseq, bad flag--settled --cursor <mark>: only settled requests, insettledSeqorder, with final status; a repeat with the returned cursor returns none17.5: 6 settled (csv 22,26,27,29,32,33),settledSeq29 is theexecution revertedrequest, repeat 0 records,gapfalsedist/chrome, first screen, no wallet)GET https://accounts.api.cx.metamask.io/v2/supportedNetworks 200 60ms,chainid.network200, refused e2e fixture ports asnet::ERR_CONNECTION_REFUSED; 90chrome-extension://loads ignoredmm events/logs/networkcalls: mean 96 ms wall-clock (CLI start included), max 130 ms--errorsread returns it once; a record that settles after the read (even one older than the cursor) is returned once;limit: 1pages late failures; unfiltered reads unchanged. Live: late-settle check aboveTranscript (MV3 test extension)
MetaMask test build (first screen, no wallet)
The e2e build's onboarding screen sends little: wallet traffic (gas, Blockaid, RPC) needs an unlocked wallet, which this proof does not create.
Unit tests
New:
src/events/network-source.test.ts(join, in-place update, failure, redirect hops (each hop settles), per-target keys, ignored URLs,postData/postDataEntries, pending cap,rpcErroron/off (settles after the read, including skipped and failed reads), base64, decoded vs encoded size, size/concurrency/failure skips,dataReceived,targetDetachedfinalization, CORS reason, settle on finish/fail/redirect/start),src/events/event-buffer.test.ts(settle order, paging by settle position, gap (a dropped unsettled record,since), dropped/cleared records never settle, stale cursor,sinceont, one cursor across kinds),src/events/json-rpc.test.ts(method cap),src/tools/network.test.ts(late settle after a read, older record,limit: 1paging, unfiltered reads unchanged,settled: trueend-to-end),src/events/network-source.test.ts(abandoned,target closedon restart),CdpManager sendToEventTargetandtargetId(timeout, race), CLI routing and schemas.