Skip to content

Latest commit

 

History

History
40 lines (22 loc) · 8.92 KB

NETWORK_CONDITIONS.md

File metadata and controls

40 lines (22 loc) · 8.92 KB

Network conditions — milestone 4

Integrated on main: This milestone is part of PRs #19–26. For current usage see USAGE.md; later acceptance and owner exclusions are in ROADMAP_COMPLETION.md. Verification/pending lists below retain their original checkpoint scope.

The localhost service and browser UI support persisted global, app, host and endpoint profiles. One enabled profile wins: endpoint, host, app, global; then ascending priority, numeric creation time and ID. Host matching ignores case; endpoint paths match exactly without the query. App attribution uses already ingested SDK events and their registered app ID. Automatic SDK telemetry is best-effort: eventual Inspector context does not prove that an app identity was available when the profile was selected. A request without that attribution can select a broader profile; it retains that initial snapshot. Missing or ambiguous attribution does not match an app profile; no arbitrary request header is trusted as an app identity.

Profiles add request latency with uniform ±jitter, a nonnegative delay floor, buffered upload/download rate simulation, offline behavior and configurable request failure percentage. Offline/failure stops the request and keeps an inspectable error. These are application request failures, not transport packet loss. DNS, encrypted passthrough and ongoing WebSocket messages are outside these HTTP body profiles.

Mitmproxy buffers HTTP bodies before request/response hooks. Rate simulation waits body-byte-count / bytes-per-second after request rules and response rewrites, then forwards the buffered message. It measures end-to-end transfer time; it does not pace individual packets, share bandwidth across concurrent flows, or emulate a slow streaming connection. The upstream streaming behavior explains why streamed bodies would bypass these body edits. True transport packet loss is unavailable in the selected capture integration, so no packet-loss setting is accepted.

Each stage permits at most 120 seconds of simulated delay; exceeding that bound stops the flow with a diagnostic instead of silently clipping the rate. Delay/jitter are each limited to 10 seconds, optional rates to 1 KiB/s–1 GiB/s, failure probability to 0–100%, and the workspace to 100 profiles. Disable all is available across routes, prevents profiles on new requests and releases a pending simulated wait after its next policy check (normally within 100 ms, plus local service time). A profile snapshot applies to a flow; disable/delete releases waits, while other edits apply to subsequent requests.

Migration 7 adds profiles with a pre-migration database backup. Portable bundle v6 includes profiles and accepts older versions 2–5. Imports validate profiles before mutation, start them disabled, and include them in the existing atomic replace transaction. Local command authentication and private rule-socket permissions are retained.

Reproducible checks

Build cargo build -p simulator-api-flow-server --locked --offline, then run python3 scripts/check-network-conditions.py. The standard-library check launches a disposable service, origin and reverse proxy on loopback; it does not change host-wide proxy settings. It measures 32 KiB bodies at 64 KiB/s in each direction plus 200 ms latency against a no-profile baseline; expected additional elapsed time is 1.2 seconds, accepted at 1.05–1.65 seconds for local scheduling overhead. Jitter samples around 300 ±50 ms accept 180–550 ms. It also verifies disable-all releases a waiting request, new requests lose the delay, and offline/100% failure diagnostics persist.

Focused Rust checks cover scope precedence, invalid/unknown fields (including unsupported packet loss), SDK ambiguity, migration/reopen/disable/cap enforcement, and bundle disabled import/export/replace rollback. Frontend compilation passed. At that source-check checkpoint, browser security policy blocked the localhost preview. Subsequent owner-authorized computer use passed bounded profile-editor and disable-all workflows; see PLATFORM_ACCEPTANCE.md. Full device timing and UI acceptance remain separate.

Live loopback result: baseline 0.082 s; combined 64 KiB/s upload/download plus 200 ms latency 1.227 s; jitter samples 0.215/0.265/0.204 s after baseline subtraction; disable released the waiting request at 0.340 s. Offline and 100% failure diagnostics persisted. Protocol regression checks passed HTTP/2/TLS/gRPC trailers and WebSocket text/binary/empty capture. OpenJEV selected specificity-first matching without provider fallback.

Android Emulator HTTPS acceptance — 2026-10-03

The actual API 37 ARM emulator/debug app passed real SDK attribution and overlapping global 1800/app 600/host200/endpoint1000 profiles through HTTPS. Three captured baseline requests had median 70 ms. Additional app delay was 584/689/610 ms, with concurrent app requests at 583/572/573 ms; host won at 173 ms, endpoint at 984 ms, and disable-all returned to 60 ms total. Each request ID joined its completed capture; SDK headers were removed upstream. The fixture measured captured HTTP time rather than SDK duration (which includes cold client TLS setup), accepted configured delay ±150 ms, and required at least 250 ms between precedence levels. It matched the original request authority retained by mitmproxy rather than the mapped upstream address. Evidence and fixture limits are in PLATFORM_ACCEPTANCE.md. Simulator/physical-device profiles and the rest of the matrix remain separate.

Simulator diagnostics observed correct app/host/endpoint selections and disable-all leaving a new request unprofiled. A selected app 600 wait measured 601.5 ms despite 211.1 ms initial lookup overhead; another request selected global 1800 and waited 1802.2 ms. These observations explain why eventual SDK enrichment and full captured duration cannot identify the initially applied profile. A complete lower-overhead run passed once, but an unmodified confirmation and the final selected-profile matrix failed the unchanged strict captured-time/separation criteria. A manually instrumented, persisted-attribution-gated run also exceeded app 600 tolerance once (767 ms increase). No production change or tolerance relaxation was made. See PLATFORM_ACCEPTANCE.md for exact limits and preserved artifacts.

A separate actual Simulator manual-SDK request confirmed disable-all releasing an already active global 2000 wait. The origin was absent before disable and reached 141.82 ms after it began; captured total 231 ms, next unprofiled request +56 ms against 43 ms baseline. All five SDK/capture pairs and upstream header removal passed; cleanup left no owned listeners or rollback. See /private/tmp/mas-ios-profile-release/. A separate real manual-SDK deletion check also released an active 2,000 ms wait: origin at 104.50 ms after deletion began, captured total 203 ms; the next request added 40 ms over a 39 ms baseline. The profile list was empty before the next request. Five SDK/capture pairs and upstream header removal passed, with no CA installation or trust change. Evidence: /private/tmp/mas-ios-profile-delete/. These bounded release checks do not close the strict timing/precedence matrix.

The complete manually instrumented, persisted-attribution-gated Simulator matrix later passed with diagnostic measurements and an unmodified production confirmation, keeping ±150 ms/250 ms criteria. Production increments were serial app 564/556/567, concurrent 597/563/748, host 170, endpoint 972 and disabled -35 ms against a 66 ms median baseline. All 12 SDK/capture pairs and upstream header removal passed; cleanup preserved original data/trust. Earlier intermittent failures remain retained, and no tolerance or production timing code changed. See PLATFORM_ACCEPTANCE.md for the paired transport timings, exact artifacts and limits; automatic best-effort attribution and physical/default-routing cases remain separate.

Owner-led acceptance still pending

  1. Extend the recorded Simulator and Android Emulator profile/recovery/Replay/SDK/import checks to physical-device HTTP(S) and remaining cases; see PLATFORM_ACCEPTANCE.md for exact completed scopes.
  2. Extend the now-passed gated Simulator overlapping/concurrent profile cases to physical devices and automatic attribution scenarios consistent with the best-effort SDK contract.
  3. Validate large bodies, supported HTTP/2/HTTP/3 capture modes and the explicit streaming/WebSocket/packet-loss limits.
  4. Validate packaged entry points, keyboard/accessibility and release compatibility. Current automated loopback checks exercise the localhost service and browser UI.

At the milestone-4 checkpoint, milestones 5–8 were separate work. Their source is now integrated in the stacked drafts; ROADMAP_CHECKPOINT.md records current status. Broader device/release acceptance remains separate.