Repository navigation
Record the app's traffic once and replay it with no backend (#150) - #178
Merged
Merged
Conversation
bitomule
force-pushed
the
worktree-t-mav-150-network-mocking
branch
from
December 3, 2026 13:59
be76d1e to
52bcc5c
Compare
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.
Closes #150.
Adds
network.mock: the app's traffic is recorded once against the real backend into a HAR file, and replayed afterwards with no backend at all. The app does not change.CLI:
mav network mock --record FILE | --replay FILE [--unmatched N] [--strict] [--match-body] [--ignore-params a,b], ended bymav network stop, read bymav network status.How
<simulator>/data/Containers/Bundle/Application/, so only the run's simulator's apps are intercepted (verified: the same app on a second simulator is not). mav boots the simulator and installs mitmproxy's CA withsimctl keychain add-root-certonce mitmdump is up. Simulator only: device and macOS getnetwork_mock_unsupported.--server-replaywithserver_replay_extra=<unmatched>,server_replay_reuse=true,connection_strategy=lazy,upstream_cert=false,http3=false. A replay that opened any server connection fails the run withnetwork_mock_not_hermetic.network_mock_addon.py,go:embed): one JSON line per request (recorded/replayed/unmatched,reached_server) plus every server connection. Two things mitmproxy does not do on its own:server_replay_extraanswer as a replay too, so the addon tells unmatched requests apart by looking them up in the recording;server_replay_reuseserverplayback always serves the first recorded response; the addon makes equal requests get them in recorded order, then the last one again.ReadyFilecheck for this.mav runthe mock is thenetwork-mockhelper of the An exec step cannot start a helper process that outlives the step #149 registry, stopped on every way out. From the CLI it is detached and recorded inprocesses.jsonl, likenetwork.start.mock_replayed/mock_unmatched(mock_recorded/mock_recordingwhen recording) on the run's result line,network_mockinreport.json(with a warning for unrecorded requests),network-mock.jsonin the run.strict: truefails withnetwork_mock_unmatchednaming the requests.record/replay, replay file exists,unmatchedis 100–599,strict/matchBody/ignoreParams/unmatchedonly with replay, device/macOS refused,network.mockwithnetwork.startrefused (network_mock_conflicts_capture, also at run time).network_mock_redirector_unavailable, whose hint says to approve the extension or retry.Docs: README (flow steps, "Network mocks" section with what it does not cover, the secrets warning and the Maestro comparison),
skills/mav/SKILL.md, CHANGELOG.Tests
drivers/network/mock_test.go: arguments for record and replay, each option (unmatched,matchBody,ignoreParams,lazy,upstream_cert), and refused specs.network_mock_test.go: summary counters, strict, not hermetic, recording moved only when the run passed, params, CLI flags, flow parsing (paths relative to the flow), lint, the run's result line and the run end failing a strict replay, report section.network_mock_integration_test.go(skipped without mitmdump): real mitmdump in regular mode with the embedded addon. Records againsthttptest, shuts it down and puts a tripwire on its address, replays: recorded order then last,ignoreParams, 404 for an unrecorded request,reached_server = 0, no connection to the tripwire, andstrictfailing. One request goes through a CONNECT tunnel, because then the proxy knows the server before any request, as in local mode.Removing each fix makes its test fail (then restored, green again):
make checkpasses on the final commit.End to end on a simulator
A throwaway simulator created for this, a minimal UIKit app (not in the PR) that GETs the URLs in its environment and shows the answers, a local Python backend, and
mav run. Paths, IP and UDID replaced.The replay run's screenshot shows the recorded answers (
"source": "real-backend", with the backend down) and/not-recorded → 404; the second simulator, not intercepted, gets "Could not connect to the server".