# Trace mode, signal probe, wire probe

Analysis only: these report what a page reads and what this browser or a generated client presents. Never change a value to make columns match, and never suggest a way around a protection. Every option is in [commands.md](commands.md).

## Trace mode: which scripts read which browser signals

Trace mode answers "which page script read `navigator.userAgent` / `screen.width` / the time zone / canvas / WebGL …, from which line, how often". It is explicit: nothing is traced until `tabcap trace start` (with `net start` recording, so the reads land in the bundle as `signal` events), and it stays on for every tab, frame and worker of the session until `tabcap trace stop` or `session stop`. While it is on, every answer carries `"trace":"on"` (`"paused"` while the session waits for the human). It only records: it never changes a value in the page, and you should not try to change one either. Debugger breakpoints make scripts slower and the timing is observable, so tell the user before you turn it on. `tabcap trace list [--api <name>] [--script <url>]` gives the API × script table (lines 1-based; your own `evaluate` reads show as `tabcap`); over the output budget its summary keeps the API × script counts. `tabcap trace status` lists the active APIs, the names this browser lacks and per-document counts.

## Observe mode: the plaintext a page parses out of an encrypted response

Sites that encrypt API bodies decrypt them in their own page JS. `tabcap trace start --decode` (with `net start` recording) is the observe mode instead of signal tracing: no signal breakpoints, `--apis` is refused. tabcap keeps three sink breakpoints up (`JSON.parse` gated by an argument-length condition, plus a log-point that captures the exact argument; `TextDecoder.prototype.decode` and `SubtleCrypto.prototype.decrypt` counted as evidence — a CryptoKey is never read), a finished response that looks like ciphertext (or a bare ≥64-char base64 / hex body) arms a 5 s window, and the plaintext the page itself hands to `JSON.parse` is filed into the bundle's `decoded.jsonl` sidecar as a view `by:"page"` (cap 16 MiB; a recorded raw body — the envelope, a plain control — is dropped). `find`, `where`, `deps`, `recon` and `replay check` search it through the built-in decode step `page`. It attributes a plaintext to its response when the parsing frames can reach that response's ciphertext or raw text (a local, block or closure variable, or a property one level down in a plain object there): `evidence.link: "strong"`. Otherwise, when exactly one suspect is armed, the row goes to it after a 500 ms settle with `link: "weak"`, and `find` hits in that view carry `"link":"weak"` — check such a hit before relying on it. On real sites weak rows have been wrong: `config.json` `{"trace": {"weakRows": false}}` turns them off (each is then counted as `drops.weak` — see `--verbose` below — instead of filed); the `decode` block says `weakRows`. With several armed suspects and no match the row is unattributed with the candidates listed (at most 50 per recording); it never guesses by recency. A ciphertext is matched in the forms a page holds it in before decrypting — as served, with whitespace stripped (MIME base64 wrapped every 76 chars), without surrounding quotes, URL-decoded — and a strong row says which in `evidence.matchForm`. A plaintext longer than a response can decrypt to (base64 × 3/4, hex / 2, a high-entropy body its byte length; no compression before encryption assumed) is never filed under it as weak or unattributed; with no armed suspect it fits, the parse is dropped (`drops.noFit`) — so a `localStorage` parse next to small encrypted responses no longer shows up as their plaintext. Weak and unattributed rows settle 500 ms, and a row whose text turns out to be a recorded raw body (an envelope parsed before tabcap indexed it) is dropped. A parse without a strong match first waits up to 1.5 s for its own response to be indexed (a page that parses in an XHR `onload` beats the recorder), so such rows may appear up to 1.5 s late; `trace status` counts the waiting ones in `decode.pending`, and `trace stop` decides them before it answers. `tabcap net body <id>` shows the page view by default (`--decoded` too, during and after recording; a decode plugin's view outranks it, and a body a plugin already filed a view for is not observed at all — `trace start --decode` names the enabled decode plugins in `decodePlugins` with a `decodePluginsNotice`; `tabcap plugin disable <name>` to observe the page instead; `trace status` and `trace stop` carry the same two fields while decode is on); a row's `evidence.frames[].url` is the URL of the script that parsed it (an inline script's is the page URL); when there is none and the body looks encrypted its error points here. When `find` reports payloads that look encrypted and zero hits, re-run the page with this mode on, then `find` again. It changes no page state; the only page function it calls is the native `console.dirxml` of its log-point (a page that planted getters on `console.dirxml` runs them and can notice the mode — as it can from the timing).

**Turn it off after the recording** (`tabcap trace stop`, or the next `trace start --no-decode`). Every `JSON.parse` of a string ≥32 characters pauses (~0.4 ms plus a CDP round trip). A table-heavy page or a WebSocket that parses at high frequency will slow down and its timing will change; that is acceptable for a diagnostic window, not for a long crawl. The mode does not see request-side encryption, chunked / SSE decrypts, or plaintext that never goes through `JSON.parse` (a Worker that `postMessage`s a structured-clone object, WASM JSON, HTML / protobuf / JSON5). `trace status` / `trace stop` carry a compact `decode` block: `{on, weakRows, rows: {strong, weak, unattributed}, pending, dropped}` — `on` false means the sinks are down (recording stopped, or the trace), `pending` is parses not decided yet, `dropped` all drops summed. `trace stop` decides every pending parse first, so its `pending` is 0 and `decidedAtStop` says how many it decided; one that met no response is in `dropped`, not lost elsewhere. Add `--verbose` for the counters behind it (`drops` by reason, `armed`, `held`, `settling`, `evidenceHits`, `recovered`, `walks`, `sinks`, `unattributedKept`; docs/04 §33 has the table).

## Signal probe: what this browser presents, next to the user's reference

`tabcap fingerprint probe` shows the values this browser presents for a fixed signal list (navigator, UA client hints, screen, time zone, canvas and audio hashes, WebGL, voices, fonts, permissions, media queries). It opens tabcap's own probe page on 127.0.0.1 in a background tab of the session, closes it afterwards, and while `net start` records it writes the table into the bundle as a `state` event with `what:"env"`. `--ref <name>` adds a reference column with a verdict per field: `same`, `differs`, `missing` (this browser lacks a field the reference has) or `extra` (this browser has a field the reference lacks); `tabcap fingerprint diff <bundle> --ref <name>` does the same offline for a recording. References are the user's own captures: the user runs `tabcap fingerprint serve`, opens the printed URL in their own browser by hand and presses "Save as reference"; never capture or edit one yourself. Report the table as it is, and do not suggest or attempt changing any value to make the columns match.

## Wire probe: which network layer a generated client differs in

`tabcap wire probe --client <dir>` answers one question about a client from `replay export-python`: compared with the Chrome for Testing that tabcap launches, which layer of what it sends differs — the TLS ClientHello (`tls`), the HTTP/2 connection settings (`h2`) or the request headers (`headers`) — and in which fields. Everything happens on a local echo at 127.0.0.1: tabcap captures the browser baseline in a background tab of the session (cached per Chrome version and launch flags; `tabcap wire profile` captures it explicitly), then runs the client's `uv run client.py wire-report` against the same echo. Each layer gets `same`, `differs` or `missing`; while `net start` records, every differing layer becomes a `finding` (tool `wire`). It is diagnostic only: report the layers and fields as they are; they say which layer differs on a local echo, not why a site refused a request, and do not suggest or attempt changing any value to make them match.
