Skip to content

Twin-Run & Diff

recon twin sends one saved request to two environments at the same time and shows how the responses differ. recon diff compares two runs that are already in the Flight Recorder. Use Twin-Run to catch drift between, say, local and staging before you deploy, and diff to compare a run today with one from last week. Both use the same semantic diff, described at the end of this page.

Terminal window
recon twin "List Students"
recon twin campus-demo-list-students --env-a staging --env-b local
Twin-Run: List Students (local vs staging)
local: HTTP 200 in 0.5ms | staging: HTTP 200 in 0.4ms (Δ -0.1ms)
! $.environment: "local" -> "staging"
! $.students[0].gpa: 3.92 -> "3.92"
! $.students[0].studentId: ∅ -> "001001"
! $.students[0].student_id: "001001" -> ∅
! $.students[1].gpa: 3.74 -> "3.74"
! $.students[1].studentId: ∅ -> "001042"
! $.students[1].student_id: "001042" -> ∅
Flag Default Meaning
<REQUEST> required Saved request ID (exact) or name (case-insensitive). URLs are not accepted.
--env-a <ENV_A> local Baseline (left) environment.
--env-b <ENV_B> staging Candidate (right) environment.

The global --workspace and --format flags and the transport flags from Transport: TLS, Proxy & Cookies also apply.

  1. Loads the request and both environments. An unknown request or environment is an error (request ... not found, environment ... not found).
  2. Resolves templates, secrets and auth separately for each environment.
  3. Checks both resolved requests with the Outbound Secret Firewall. If either is blocked, the command stops with E_CLI_RUNTIME (“outbound secret firewall blocked 1 violation(s)”) and exit status 2. Nothing is sent.
  4. Sends both requests concurrently and evaluates the request’s assertions against each response.
  5. Computes the semantic diff (left = --env-a, right = --env-b), ignoring the JSONPaths in volatile_paths from .recon.toml.

Twin-Run does not run pre-request or post-response scripts, and it does not record either response in the Flight Recorder.

Human output prints the request name and environments, then each side’s status and total time, and the latency delta (right minus left). If the responses are identical, it prints ✓ Responses semantically identical. Otherwise it prints one ! line per body change as <path>: <left> -> <right>, with ∅ for a missing side. Header changes and status changes are not printed in human mode; use JSON output to see them.

JSON output is an object with three keys:

Key Content
left Full response from --env-a: request_id, final_url, status, protocol, headers, body, body_text, wire_bytes, decoded_bytes, content_encoding, waterfall, tls, redirects, assertions.
right The same for --env-b.
diff The semantic diff object (see below).

left and right contain the raw response bodies. They are not masked by the PII Airlock, even with --format agent.

Code When
0 Both requests completed. This holds even when the responses differ or assertions fail.
2 Any error: unknown request or environment, firewall block, transport failure (E_CLI_RUNTIME).

To fail a script when responses differ, read diff.identical from the JSON output.

Terminal window
recon diff <LEFT_RUN_ID> <RIGHT_RUN_ID>

Run IDs come from recon send (run_id in JSON output), recon history or recon search. diff loads both runs from the Flight Recorder and compares their stored status, response headers, response body and total time. It uses the volatile_paths from the current .recon.toml.

Terminal window
recon diff 01a22d23-0ba7-72b1-9fa2-34385f8581fa 01a22d23-0bb8-7191-82bd-32470bf3e5b3
Semantic Diff: 01a22d23-0ba7-72b1-9fa2-34385f8581fa (200) -> 01a22d23-0bb8-7191-82bd-32470bf3e5b3 (200)
[Changed] $.environment: "local" -> "staging"
[TypeChanged] $.students[0].gpa: 3.92 -> "3.92"
[Added] $.students[0].studentId: ∅ -> "001001"
[Removed] $.students[0].student_id: "001001" -> ∅
[TypeChanged] $.students[1].gpa: 3.74 -> "3.74"
[Added] $.students[1].studentId: ∅ -> "001042"
[Removed] $.students[1].student_id: "001042" -> ∅

The human output prints the two run IDs with their statuses, then each body change with its kind. Header changes are not printed. JSON output is the semantic diff object alone:

{
"status_left": 200,
"status_right": 200,
"status_changed": false,
"latency_delta_ms": 0.0,
"header_changes": [],
"body_changes": [],
"ignored_count": 0,
"identical": true
}
Argument Meaning
<LEFT_RUN_ID> Baseline run ID.
<RIGHT_RUN_ID> Candidate run ID.

diff has no flags of its own. The global --workspace and --format flags apply.

Code When
0 The runs are identical (identical: true).
1 The runs differ in status, a non-volatile header, or the body.
2 A run ID was not found (run ... not found) or another error (E_CLI_RUNTIME).

A difference in a header such as content-length makes the exit status 1 even though human output shows no lines for it.

Both commands call compute_semantic_diff in recon-core/src/diff.rs. The result has these fields:

Field Meaning
status_left, status_right Status codes of the baseline and candidate.
status_changed true if the two status codes differ.
latency_delta_ms Candidate total time minus baseline total time.
header_changes Changes in response headers.
body_changes Changes in the response body.
ignored_count Number of differences suppressed by volatile ignore rules.
identical true when the status did not change and there are no header or body changes. Latency does not count.

Each change has:

Field Meaning
path Concrete location, such as $.students[0].gpa, header:content-type, or $ for the whole body.
pattern The path with every array index replaced by [*], such as $.students[*].gpa. You can copy it into volatile_paths.
kind added, removed, changed or type_changed.
left, right Compact JSON text of the baseline and candidate values, or null when that side has no value. Values longer than 240 characters are cut and end in ....
Kind Produced when
added A key or array element exists only in the candidate, or a header appears only in the candidate.
removed A key or array element exists only in the baseline, or a header appears only in the baseline.
changed Two values have the same JSON type but differ, a header value differs, or a non-JSON body differs.
type_changed Two values at the same path have different JSON types, for example number 3.92 versus string "3.92", or an object versus an array.

JSON types are null, bool, number, string, array and object.

  • If both bodies parse as JSON, they are walked together from $.
    • Objects are compared key by key over the union of keys, in sorted key order.
    • Arrays are compared by index. Element [i] on the left is compared with element [i] on the right. Extra elements on the longer side are reported as added or removed. Arrays are not reordered or matched by content, so inserting one element at the front reports a change at every later index.
    • Scalars that differ are changed or type_changed.
  • If either body is not valid JSON, the two bodies are compared as text. A difference is one changed entry at $ with each side cut to 400 characters.

Header names are compared case-insensitively. If a header name appears more than once, only its first value is compared. These headers are always ignored: date, etag, x-request-id, x-correlation-id, x-trace-id, cf-ray, x-amzn-requestid, set-cookie, expires, age. Header paths look like header:content-length.

Paths listed in volatile_paths in .recon.toml are skipped. The default list, written by recon init, is $.request_id, $.timestamp and $.trace_id. A rule matches when:

  • it equals the concrete path exactly, or
  • it contains [*], has the same number of .-separated segments as the path, and each segment is equal or is name[*] where the path has name[<index>].

A rule ignores everything under the matched path. Each suppressed difference adds 1 to ignored_count. Rules are not checked for array elements that exist on only one side, so an extra element under an ignored [*] pattern is still reported as added or removed. Volatile rules apply to the body only, not to headers. In the Twin-Run above, the differing request_id values are ignored and ignored_count is 1.

The CLI applies only volatile_paths. Per-request ignore rules that you add through the Web Studio are stored in the Flight Recorder and applied by the HTTP API’s twin and diff endpoints, not by recon twin or recon diff. See Configuration (.recon.toml) for volatile_paths.

Surface Twin-Run Diff
MCP recon_twin_run recon_diff_runs
HTTP API POST /api/v1/twin POST /api/v1/diff

The HTTP endpoints also add per-request rules from /api/v1/volatile-ignores. See MCP Tools, Resources & Prompts, HTTP API and Web Studio.