Capture Proxy, Shadow & Watch
This page covers three long-running local commands:
recon proxysits between a client and an upstream API and records every exchange in the Flight Recorder.recon shadowsends each request to a primary backend, returns the primary’s answer, and compares it in the background with a candidate backend’s answer.recon watchwatches the workspace and reruns the.httprequests affected by a file change.
All three bind to 127.0.0.1 only.
Capture proxy: recon proxy
Section titled “Capture proxy: recon proxy”Point a client at the proxy instead of the real API. The proxy forwards each request to --target and records the request and response.
recon proxy --target http://127.0.0.1:4500 --port 4502 --export-http collections/captured.httphttp://127.0.0.1:4502Capture Reverse Proxy listening on http://127.0.0.1:4502 (Ctrl-C to stop)…Send traffic through it:
curl -si -H 'Authorization: Bearer abc123' 'http://127.0.0.1:4502/_sandbox/local/v1/students?x=1'curl -s -X POST -H 'Content-Type: application/json' \ -d '{"student_id":"001001","course":"CS-401"}' \ http://127.0.0.1:4502/_sandbox/local/v1/enrollmentscurl -si http://127.0.0.1:4502/_sandbox/local/v1/students-pagedHTTP/1.1 200 OKcontent-type: application/jsondate: Mon, 30 Nov 2026 15:45:55 GMTx-recon-captured: truecontent-length: 669...Press Ctrl-C. The proxy prints its counters and writes the .http export:
Captured 3 request(s) (0 upstream errors).### GET /_sandbox/local/v1/students-paged# @name GET /_sandbox/local/v1/students-paged# @folder Captured ProxyGET {{base_url}}/_sandbox/local/v1/students-pageduser-agent: curl/8.5.0accept: */*
### GET /_sandbox/local/v1/students# @name GET /_sandbox/local/v1/students# @folder Captured ProxyGET {{base_url}}/_sandbox/local/v1/students?x=1user-agent: curl/8.5.0accept: */*
### POST /_sandbox/local/v1/enrollments# @name POST /_sandbox/local/v1/enrollments# @folder Captured ProxyPOST {{base_url}}/_sandbox/local/v1/enrollmentsuser-agent: curl/8.5.0accept: */*content-type: application/json
{"student_id":"001001","course":"CS-401"}The Authorization header is missing from the export because it was redacted when recorded (see below).
What the proxy does with each request
Section titled “What the proxy does with each request”- Reads the full request body, up to 32 MiB.
- Copies the request headers, except
Hostand these hop-by-hop or framing headers:connection,keep-alive,proxy-authenticate,proxy-authorization,te,trailers,transfer-encoding,upgrade,content-length,content-encoding. Header values that are not valid visible ASCII are dropped. - Builds the target URL as
--target(trailing/removed) followed by the incoming path and query string. - Runs the request through the Outbound Secret Firewall. The proxy passes no secret taints, so in practice this step only rejects a URL that does not parse.
- Sends the request with a 15 second timeout. Redirects are not followed.
- Runs the response through the PII Airlock to produce an Airlock receipt, and records the exchange in the Flight Recorder.
- Returns the upstream status, headers (minus the hop-by-hop and framing headers above) and body to the client, with
X-Recon-Captured: trueadded.
What gets recorded
Section titled “What gets recorded”| Field | Value |
|---|---|
| Actor label | proxy |
| Environment | --env (default capture) |
| Request ID | proxy-<method>-<path>, for example proxy-get-_sandbox-local-v1-students |
| Request name | <METHOD> <normalized path>, for example GET /_sandbox/local/v1/students |
| Request headers | As forwarded, with authorization, proxy-authorization, cookie, set-cookie and x-api-key values replaced by [REDACTED:PROXY_HEADER] |
| Request body | As text (lossy UTF-8) |
| Response | Status, headers, body, timing waterfall, TLS info, byte counts, Airlock receipt |
The captured_requests counter only counts exchanges that were written to the Flight Recorder successfully.
Errors returned to the client
Section titled “Errors returned to the client”| Status | Cause | Body |
|---|---|---|
502 |
Request body could not be read (for example, over 32 MiB) | {"error":"failed reading incoming body: ..."} |
403 |
Firewall rejected the request | {"error":"..."} |
502 |
Upstream connection or timeout failure | {"error":"..."} |
These responses carry X-Recon-Captured: error and count as upstream_errors. Nothing is recorded for them.
Export on shutdown
Section titled “Export on shutdown”With --export-http <FILE>, Recon writes a .http file after you press Ctrl-C. Parent directories are created. The export:
- reads the 200 most recent Flight Recorder runs whose environment equals
--env, so it can include runs from earlier proxy sessions with the same label; - keeps one request per method and path-plus-query, ordered by method and then path;
- puts every request in the folder
Captured Proxyand rewrites the URL to{{base_url}}followed by the path and query; - drops headers whose recorded value starts with
[REDACTED; - writes a body that starts with
{or[as JSON and any other non-empty body as text.
| Flag | Default | Description |
|---|---|---|
--target <URL> |
required | Upstream origin or base URL. Must be http or https. |
--port <PORT> |
9090 |
Port on 127.0.0.1. 0 picks a free port. |
--env <NAME> |
capture |
Environment label stored on each captured run. |
--export-http <FILE> |
none | Write captured requests as a .http file on shutdown. |
On shutdown, --format json prints {"captured_requests": N, "upstream_errors": N} to stdout. Human format prints the Captured ... line to stderr. Exit code is 0. Startup errors (invalid --target, port in use) exit 2 with E_CLI_RUNTIME.
Shadow mirror: recon shadow
Section titled “Shadow mirror: recon shadow”Use shadow mode to compare a new backend against the current one with real traffic. The client always gets the primary’s response. The candidate is called afterwards, off the request path.
recon shadow \ --primary http://127.0.0.1:4500/_sandbox/local \ --candidate http://127.0.0.1:4500/_sandbox/staging \ --port 4503 --format jsoncurl -si http://127.0.0.1:4503/v1/studentsHTTP/1.1 200 OKcontent-type: application/jsondate: Mon, 30 Nov 2026 15:46:14 GMTx-recon-shadow: primarycontent-length: 669...After Ctrl-C, JSON format prints the counters and every recorded finding:
{ "findings": [ { "candidate_ms": 0.384713, "candidate_status": 200, "diff": { "body_changes": [ { "kind": "changed", "left": "\"local\"", "path": "$.environment", "pattern": "$.environment", "right": "\"staging\"" }, { "kind": "type_changed", "left": "3.92", "path": "$.students[0].gpa", "pattern": "$.students[*].gpa", "right": "\"3.92\"" }, ... ], "header_changes": [ { "kind": "changed", "left": "669", "path": "header:content-length", "pattern": "header:content-length", "right": "673" } ], "identical": false, "ignored_count": 1, "latency_delta_ms": -2.135155, "status_changed": false, "status_left": 200, "status_right": 200 }, "method": "GET", "path": "/v1/students", "primary_ms": 2.519868, "primary_status": 200, "timestamp": "2026-11-30T15:46:14.657885680+00:00" } ], "stats": { "candidate_errors": 0, "dropped_count": 0, "mirrored_count": 1, "regressions_count": 1, "total_proxied": 2 }}In this run a POST was also sent through the proxy. It counts in total_proxied but was not mirrored, because mutating methods are not mirrored by default.
Human format prints one line to stderr instead and does not print findings:
Shadow summary: proxied=2, mirrored=1, regressions=1, dropped=0How it works
Section titled “How it works”- The request is read (body up to 16 MiB) and its headers are filtered the same way as in the capture proxy.
- The request goes to
--primaryplus the incoming path and query, through the Outbound Secret Firewall (no taints), with a 15 second timeout and no redirect following. - The primary’s response goes back to the client with
X-Recon-Shadow: primary. - If the method is
GET,HEADorOPTIONS, or--mirror-mutationsis set, a mirror task is put on a queue with room for 256 tasks. If the queue is full, the task is dropped anddropped_countgoes up. The client never waits for the queue. - One background worker takes tasks in order, sends the same method, path, headers and body to
--candidate, and computes a semantic diff of the primary and candidate responses. The workspacevolatile_pathsfrom.recon.tomlare excluded from the diff. The diff format is described in Twin-Run & Diff. - If the diff is not identical, a finding is stored. Only the 200 newest findings are kept, newest first.
Nothing from shadow mode is written to the Flight Recorder.
Counters
Section titled “Counters”| Field | Meaning |
|---|---|
total_proxied |
Requests that got a primary response. |
mirrored_count |
Candidate comparisons completed. |
regressions_count |
Comparisons where the diff was not identical. |
dropped_count |
Mirror tasks dropped because the queue was full. |
candidate_errors |
Candidate requests that failed the firewall or the network call. |
Finding fields
Section titled “Finding fields”| Field | Meaning |
|---|---|
timestamp |
RFC 3339 time the comparison finished. |
method |
HTTP method. |
path |
Path and query string as received. |
primary_status, candidate_status |
Status codes. |
primary_ms, candidate_ms |
Total latency of each call in milliseconds. |
diff |
Semantic diff (identical, status_changed, status_left, status_right, header_changes, body_changes, ignored_count, latency_delta_ms). |
Errors returned to the client
Section titled “Errors returned to the client”| Status | Cause |
|---|---|
502 |
Request body could not be read, or the primary call failed. |
403 |
Firewall rejected the primary request. |
These responses carry X-Recon-Shadow: error and a JSON body {"error":"..."}. They do not count in total_proxied and are not mirrored.
| Flag | Default | Description |
|---|---|---|
--primary <URL> |
required | Authoritative upstream. Its responses go to the client. Must be http or https. |
--candidate <URL> |
required | Upstream compared in the background. Must be http or https. |
--port <PORT> |
9091 |
Port on 127.0.0.1. 0 picks a free port. |
--mirror-mutations |
off | Also mirror methods other than GET, HEAD and OPTIONS. |
As with the capture proxy, the global transport flags are not applied. Exit code is 0 after Ctrl-C and 2 for startup errors.
Watch mode: recon watch
Section titled “Watch mode: recon watch”recon watch watches a directory recursively. When files change, it works out which saved requests are affected and runs them.
recon watch --onceWatch executed 3 impacted request(s) [FAIL] ✓ List Students (200) ✓ Create Enrollment (201) ✗ Stripe Prod Key Leak Check (0)--once runs every request in the workspace one time and exits. The exit code is 0 if all passed and 1 otherwise. This is the mode to use in scripts and CI. In this example the third request is a firewall drill that is meant to be blocked.
Without --once, Recon prints Recon watching <path> for handler & .http changes (Ctrl-C to stop)… to stderr and keeps running.
What triggers a run
Section titled “What triggers a run”Events are collected for 150 ms after the first one (the debounce window), then handled as one batch. Paths are ignored if they contain one of the directories .git/, .recon/, target/, node_modules/ or dist/, or end in ~, .swp or .tmp.
For each batch, Recon reloads the workspace, scans the repository with Code Scanning, and selects requests:
- If
.recon.tomlor any file under the environments directory changed, every request runs. - Otherwise a request runs if any of these is true:
- its own
.httpfile changed; - its
# @handlerlocation points at a changed file; - a scanned route defined in a changed file has the same method and a matching path;
- a scanned route uses a request or response DTO that is defined in a changed file, and has the same method and a matching path.
- its own
Selected requests run one after another through the Outbound Secret Firewall and your transport settings. A request passes if all its assertions pass, or, when it has no assertions, if the status is below 400. Each run is recorded in the Flight Recorder with the actor label watch, without the request headers or body.
--drift
Section titled “--drift”With --drift, Recon also computes the Three-Way Drift report from the 30 most recent runs after each batch. Any breaking drift marks the batch as failed. The drift report appears only in JSON output, under drift.
Output
Section titled “Output”JSON format prints one object per batch. This is recon watch --once --format json:
{ "changed_files": [], "drift": null, "executed": 3, "full_suite": true, "passed": false, "results": [ { "ms": 0.615596, "passed": true, "request": "List Students", "status": 200 }, { "ms": 0.274017, "passed": true, "request": "Create Enrollment", "status": 201 }, { "error": "outbound secret firewall blocked 1 violation(s)", "passed": false, "request": "Stripe Prod Key Leak Check" } ]}changed_files holds workspace-relative paths. It is empty for --once.
Known issue: continuous re-runs
Section titled “Known issue: continuous re-runs”| Flag | Default | Description |
|---|---|---|
[PATH] |
--workspace |
Directory to watch. It is also used as the workspace root for loading .recon.toml, requests and environments, and for the code scan. |
--env <NAME> |
workspace default_env |
Environment to run requests against. |
--drift |
off | Compute Three-Way Drift after each batch. |
--once |
off | Run every request once and exit with 0 (all passed) or 1. |
The global transport flags apply to watch runs. Errors before a --once batch starts (for example a missing workspace) exit 2 with E_CLI_RUNTIME.
Also available via
Section titled “Also available via”- Web Studio: the Studio button in the top bar opens the “Freeze-to-Mock & Shadow Studio” dialog. Its Shadow Mirror tab takes a primary and candidate URL (prefilled with the offline sandbox
localandstagingURLs), a “Mirror POST/PUT/PATCH/DELETE mutations” checkbox, and shows the shadow endpoint,proxiedandregressionscounts, and the 10 newest findings. It binds an ephemeral port. See Web Studio. - HTTP API:
POST /api/v1/shadow/start(body{primary_url, candidate_url, port?, mirror_mutations?}),GET /api/v1/shadow/findings,POST /api/v1/shadow/stop. Starting a new shadow stops the previous one. See HTTP API. - The capture proxy and watch mode have no HTTP route or MCP tool.