Files
reverse-engineering-anything/docs/playwright-traces.md
T
morluto 98d83d0787 feat(trace)!: give Playwright trace import per-call trace_limits (#14628)
* feat(trace)!: give Playwright trace import per-call trace_limits

inspect_playwright_trace refused large ordinary traces at a fixed archive
allowance, a fixed record nesting allowance and four authored-only
budgets (decoded streams, retained facts, metadata reads, line bytes).
It now accepts trace_limits (CLI --trace-limits JSON) with today's values
as defaults, and each refusal reports details.limit. The record parser
node allowance is derived from facts_bytes and recovers through it;
nesting_depth is capped where a retained record still fits the Evidence
JSON depth. The capture JSON parser takes the trace's depth from the
caller instead of a format special case.

The source-location view's page refusal now reports view.max_bytes in
details.limit. GraphQL AST nesting is registered as a representation
bound, and GraphQL host-limit, web-bundle host-capacity and the trace
decoder's occupied slot declare measured exhaustion.

BREAKING CHANGE: PlaywrightTracePort.inspect takes the resolved limits,
and trace archive and nesting refusals report details.limit instead of a
fixed_ceiling refusal.

* fix(trace): project trace records at the selected depth and record trace_limits

The HAR projection of a trace record read the network capture's depth
(64 by default), so a record admitted under a raised
trace_limits.nesting_depth was dropped as malformed. Projection now runs
under the selected trace depth. Evidence parameters record the caller's
trace_limits selection as given, in complete and partial results.
2026-11-25 22:09:23 -05:00

133 lines
7.1 KiB
Markdown

# Offline Playwright traces
Use `inspect_playwright_trace` or `inspect-playwright-trace` with an existing
local Playwright **trace v10** ZIP. Import is offline: recorded URLs are not
requested, and no browser, application or trace viewer is started.
```sh
rea inspect-playwright-trace /absolute/trace.zip --json
rea inspect-playwright-trace /absolute/trace.zip --detail summary \
--evidence_output /absolute/new-evidence.bundle.json --json
```
MCP defaults to a compact summary and retains complete supported Evidence.
CLI defaults to complete delivery; summary and selected pages require an absent
`--evidence_output` destination, so later queries can read the original parent.
```json
{
"name": "inspect_playwright_trace",
"arguments": {
"path": "/captures/trace.zip",
"view": {
"kind": "playwright-trace",
"collection": "events",
"kinds": ["network"],
"fields": ["method", "url", "status"],
"limit": 10
}
}
}
```
`view` takes precedence over `detail`. The retained parent can be queried with
`inspect_analysis_view`; CLI can use the same request against an exported
Evidence bundle with `inspect-analysis-view`.
## Facts, selection and text
The `playwright-trace` view offers:
| Collection | Available selection |
| ------------- | ---------------------------------------------------------------------- |
| `events` | Batch event/stream/call IDs, event kinds, fields, row offset and limit |
| `streams` | Batch stream IDs, fields and row pages |
| `members` | Batch member IDs, exact archive paths, fields and row pages |
| `diagnostics` | Codes, fields and row pages |
| `event-text` | One event ID, UTF-16 character offset and limit |
An omitted filter selects all retained rows; an explicit empty filter selects
none. Minimal event rows keep event/stream IDs, source member/line, producer
ordinal, kind and credential-redaction status. Page exhaustion describes only
the selected facts and never establishes complete recording coverage.
Default event pages return at most 256 UTF-16 code units in `text_preview`,
with explicit text coverage. Continue from that preview's `next_offset` using
`collection: "event-text"`, its `event_id`, `offset`, and a character `limit`
(default 2,048). Character offsets do not split surrogate pairs. Explicit
`fields: ["text"]` returns the complete interpreted text value; `reported`
returns the retained supported payload and sidecars remain selectable.
Complete Evidence remains accessible through ordinary bundle operations.
## Source and coverage
Archive SHA-256 and directory occurrence bind stable member identity. Each event
retains its member ID, physical one-based NDJSON line and zero-based physical
line ordinal. Headline times retain producer monotonic milliseconds, without
aligning stream clocks. Counts derive from the retained supported records. Call IDs are producer values; they do not establish unique actions
across streams or imply a successfully completed before/after pair. There is no
inferred total ordering or clock alignment between `.trace` and `.network`.
Member `path` preserves the reader's original ZIP name; `logical_path` separately
records its normalized interpretation. Resource references, exact `paths` filters
and trace/network profile pairing use original names, so `resources/x` and
`./resources/x` remain distinct. Reader limitations remain attached to each member
and keep source interpretation partial when present.
`decoder_profile` names the selected interpretation policy, not a verified source version.
Trace members require an initial numeric v10 context header. Other declared
versions are refused. Missing, malformed, repeated or ambiguous profiles remain
unknown; network members require one unambiguous paired trace profile. Valid
siblings of malformed records stay useful, with explicit diagnostics. Unsafe
numeric values are not rounded: exact literals stay in sidecars.
Interpreted facts cover action boundaries (class/method, title, call/page IDs,
selected navigation URL/selector, recorded times and available error text),
console text/location, network metadata and screencast references. Other action
arguments, results, context options, DOM, stacks, unsupported event types and
resource contents are outside this version's interpretation. These omissions
are scope limitations, not assertions that omitted values are secrets or absent.
Original archive bytes remain the complete raw source.
Known HAR transport credentials and structured network, navigation and console-location
URL userinfo are excluded using the existing capture projection. Ordinary names, query values, console text and caller data
are preserved. Network numeric/redaction pointers are relative to `reported`;
combine them with the event source's `record_pointer` (`/snapshot`) to locate the
original NDJSON value. Resource-reference pointers already address the physical
record.
Resource references distinguish `present-unread`, `missing`, `ambiguous` and
`unavailable`. Presence means directory metadata only: screenshots and bodies are
not read or validated. Member `declared_bytes` and `declared_compressed_bytes`
come from the ZIP directory; they are not measurements of unread payloads.
Only decoded stream members have verified ZIP CRC and
size. Duplicate names keep separate occurrence IDs; no filename silently picks
a resource. Recording completeness always remains unknown, including after all
retained pages have been read.
## Bounds and verification
Each decoder admits one archive import at a time; concurrent imports receive a
retryable capacity error. Retained queries do not require another import.
These are resource policies, not Playwright format limits, and each is a
`trace_limits` field (CLI `--trace-limits` JSON) on the next call. Defaults:
`archive_bytes` 256 MiB, `decoded_bytes` 32 MiB of decoded streams,
`facts_bytes` a conservative 32 MiB retained-facts representation,
`metadata_bytes` 4 MiB of ZIP metadata reads, `line_bytes` 4 MiB physical
lines and `nesting_depth` 64 levels per record (at most 996, so a retained
record still fits the Evidence JSON depth). JSON parsing additionally checks
heap headroom and a record node allowance of `facts_bytes / 256` (131,072 by
default), recovered by raising `facts_bytes`. A refusal reports the field,
its effective value and range in `details.limit`, and parser refusals keep the
exhausted limit name and maximum in `details.reported_limits`. Paging or field
selection does not increase parsing allowances; raise the named field, or
choose a smaller complete recorder chunk. The ZIP plaintext-work allowance is
derived from the archive size.
The owned fixtures in `tests/fixtures/playwright-trace/` preserve actual
Playwright 1.64.1 v10 recorder text. Public CLI/MCP tests exercise advertised
schemas, retained and bundle queries without the source file, partial facts,
credential exclusion, bounded Unicode previews, and a loopback listener that
must receive no import-time requests. Recorder/version/platform compatibility
outside this verified profile is unverified.