# Analysing a recording

The "analyse" part of the loop: which response carries a value, what the site is made of, what its responses look like and whether they changed, and where every request input comes from. None of these commands sends a request. Every option is in [commands.md](commands.md); replaying and generating a client are in [replay.md](replay.md).

Large answers (`analyze deps` on a long recording easily passes 100 KB) come back as `{summary, file, bytes, truncated: true}`: the summary has the counts, `file` the whole answer. Read the file, or ask for less with `--select`, `--grep`, `--fields` (`tabcap analyze deps <bundle> --select unresolved`), or pass `--full`.

## Where does a shown value come from? (`where`)

`tabcap where e12` (a ref from your latest snapshot; its visible text is used) or `tabcap where "1.234,56"` answers which recorded response carries that value: each candidate names the request (`r-N`), the JSON path (or an HTML selector), the decode chain as `analyze find` reports it, `match` (`exact`, or `normalized` with the rules used: thousands / decimal separators, accounting negatives, trailing minus, full-width digits, nbsp, `2026-09` / `202609` / `09/2026` months, dotted codes such as `1001.01`, `DR` / `CR`) and a `score`. It searches only the session's recording (start `net start` before loading the page) and never sends a request. An `04/03/2026`-style date gets candidates only when another date on the same page proves the day / month order; otherwise `ambiguous` lists both readings. Values such as `0`, `-` or empty are `too-common`. `--as text` forces a literal search for something that looks like a ref; `--text` prints a report; `--write-findings` records the candidates as findings in the bundle. Over the output budget its summary keeps the five best candidates.

## What is this site made of? (`recon`)

After recording a session over the pages you care about (`net start`, then use the site), `tabcap recon` writes a dossier into the bundle, `exports/dossier.json` (schema `tabcap-dossier/0`) and `exports/dossier.md` (`--text` prints the Markdown), and answers four questions from the recording and the current page only (it sends no request): the **stack** (adapter `detect` results on the current page, plus hints from `server` / `x-powered-by` / … headers and session-cookie names such as `JSESSIONID` or `PHPSESSID`, all 推断); the **data channels** (requests grouped by method, path template with ids as `{id}`, resource type and body class `json | html | fragment | text | binary | ws | sse`, with count, first `r-N`, statuses, `unreadByPage`, decode steps) and the **coverage**: how many of the page's visible text tokens were found in recorded responses, with up to 20 that were not (a low ratio means the data is computed in the page or came from a request that was not recorded); the **cookies** (origin: `set-cookie` by `r-N`, present at session start, or unrecorded; lifetime; flags; a role from a name table, 推断; `requiredBy` from `analyze deps`; csrf-named headers and fields are listed too); and **protection**: the guard's challenge detections and response signals (HTML 403, 429, `retry-after`, rate-limit and bot-management header names). Identification only: never suggest a way around a protection; a challenge goes to the human. `tabcap analyze recon <bundle>` does the same offline, with the last recorded document standing in for the page.

## What do the responses look like, and did they change? (`analyze shape`, `analyze schema-diff`)

`tabcap analyze shape <bundle>` infers, per endpoint (method + path template with ids as `{id}`, all its recorded exchanges), the shape of the JSON responses and of the request (query names, body fields): a type tree with `kind` (`object`, `array`, `string`, `number`, `boolean`, `null`, or `union` with `variants`), `format` (`date`, `datetime`, `int`, `float`, `id`, `url`, `email`), per field `samples` and `optional`, and `enum` (at most 8 short literals, only when each repeats and the field name is not sensitive). It reads a decode plugin's view when there is one and otherwise follows gzip / base64 / jsonp / ndjson to the JSON. Values never appear. `--template 'GET /api/list'` keeps one endpoint, `--request r-N` shapes one exchange, `--text` prints one line per place (`$.items[].price  string(float)`), `--write` stores `exports/shape.json`. Only API-like exchanges are shaped by default: resource types xhr, fetch and document, plus any response with a JSON content type, so css / js / images with a `?v=` query no longer show up as endpoints (`excluded.types` counts what was left out). Exchanges without a response (outcome `incomplete`, also left out of HAR exports) are never shaped, whatever `--types` says (`excluded.incomplete`); `--request r-N` still shapes one. `--types xhr,fetch` shapes exactly those types, `--types all` everything.

`tabcap analyze schema-diff <old bundle> <new bundle>` compares the two shapes endpoint by endpoint: `added` / `removed` as `path:type` (`$.items[].name:string`, `query:v:string(int)`, `body:$.qty:number(int)`), `changed` (`{path, from, to}`, e.g. `string(float)` → `number(float)`), `optionalityChanged`, `enumChanged`, and a verdict `same | drift | new | gone`. It exits 1 when any endpoint drifted (the envelope is still `ok`), so it works in a cron job against yesterday's recording; `--text` prints one line per change. A JSON endpoint that answers HTML in the new recording (a login page) is `drift` with everything removed. A rename shows as one removed and one added field. Small samples make optional fields and enums noisy: record the same pages both times. Diffing a HAR import against the bundle it came from compares two request sets: pass the HAR's `--types` to `schema-diff` (it filters both sides), and expect drift where the HAR export left out `incomplete` exchanges or where redaction turned a sensitive query value into a placeholder (docs/04 §32).

## Offline analysis of a bundle

- `tabcap analyze find <bundle> <text>` finds which request / frame / console line carries a text (through base64, gzip, URL encoding, JSON …); `tabcap analyze diff <b1> <b2>` classifies parameters across recordings. Answers that compare bundles (`analyze diff`, `analyze schema-diff`) list them as `bundles: [{short, dir}]` (`short` = the directory name); a row names its bundle as `bundle: "<short>"` next to the request `id` of that bundle.
- State embedded in an HTML page is decoded for `analyze find`, `where` and `analyze deps` alike: JSON scripts (`__NEXT_DATA__`, JSON-LD) as `script[0].$…`, top-level `window.__X__ = {…}` / `var x = […]` literals as `assign[__X__]…`, and base64 `__VIEWSTATE`-style hidden fields as `viewstate[__VIEWSTATE]` (the value as sent) with its printable `strings[…]`; page scripts are never run.
- `tabcap analyze deps <bundle> [--request r-N]` says where every input of every request came from (an earlier `set-cookie`, a response body path, a recorded fill / type, an earlier request, a constant, a timestamp), or marks it `caller-input` (a plain value the caller chooses: page, pageSize, limit, offset, from / to, period, year / month, groupBy, sort, q … or short numbers, dates, single words; never signature-like or sensitive), `computed-in-page` or `unrecorded` when the recording does not hold its source; it matches exactly and never guesses. A header such as `Authorization: Bearer <token>` is also compared without its scheme prefix (`Bearer `, `Basic `, `Token `, `JWT `) or quotes, and its source then carries `prefix`. Over the output budget its summary lists the inputs per request and the unresolved count.
- **Encoded or encrypted bodies**: if the user has a decode plugin for the site (`tabcap plugin list` shows `kind: decode`; tabcap enables none, and its keys are the plugin's own; a Python runner template with an example is in the package at `templates/plugins/decode-python/`, e.g. `$(npm root -g)/tabcap/templates/plugins/decode-python/` after a global npm install, or beside `skills/` in a release archive: copy the whole directory to `~/.config/tabcap/plugins/<name>/`; `decode()` returning `None` means "not my body": no view, not a failure), its plaintext is stored next to each matching body as `request.decoded` / `response.decoded`, and `find`, `where`, `analyze deps`, `recon` and `replay check` read it: the decode chain then starts with `plugin:<name>` (`["plugin:xor-decode"]`, then the usual steps). `net body r-N` shows the view (`view: "decoded"`; `--raw` for the original bytes). For a bundle recorded before the plugin was enabled, `tabcap bundle decode <bundle> [--plugin name]` adds the views (finished bundles only; ids stay the same; the summary counts `declined` bodies apart from `failed`; a decline hides that plugin's earlier failure on the body, counted as `superseded`; CORS preflights and empty bodies are never offered to a plugin, counted in `skipped`). A body that only looks encrypted (`hints.suspectEncrypted`) with no plugin is the user's call: suggest a decode plugin, never guess keys.
- `tabcap analyze chain <bundle> [--request r-N]` lists the requests needed to reproduce one request, in order, with what each provides to the next and what it still needs from the caller (`todo`; `caller-input` values under `inputs`, since the caller just picks them); like `find` / `diff`, both commands print one JSON envelope (`--text` for a human report).
