* fix(bun): report the real runtime and enforce worker memory budgets on Windows Under Bun, REA recorded Node/V8 identity it did not observe and its JavaScript helper processes ran without a memory bound, because Bun ignores the V8 heap flags REA passes. Source-map trace Evidence claimed runtime node-v8 with Bun's synthetic V8 heap limit (the decoder then rejected that limit, so trace_web_source_location always failed), analysis resource failures reported heap limits Bun does not enforce, the HAR decoder claimed a fixed 192 MiB heap, and doctor reported Bun's Node.js compatibility version as the Node version. Identify the runtime once from process.versions. Source-map reports record id bun with the Bun and Node.js compatibility versions and a null v8_heap_limit_bytes; the decoder checks the heap budget only for V8 reports and rejects a report from a runtime other than the launching one. The analysis worker reports a null heap limit under Bun, HAR limitations and failures omit heap sizes under Bun, and the doctor node check reports Bun and passes when its Node.js compatibility version is supported. On Windows under Bun, each helper's owned Job Object now carries a commit limit of its heap budget plus a measured 512 MiB Bun runtime reserve (704 MiB for the codec and HAR decoder, 1536 MiB for the default analyzer). The native addon accepts an optional page-aligned job memory limit on process_spawn, verifies it by readback, associates a private completion port before the child is created, and reports a sticky memoryLimitReached and peak job commit on each poll; inspect reports jobMemoryLimit. A requested limit with an artifact lacking the control refuses the launch, and non-Windows launchers refuse a limit. Reaching the limit is classified by the job notification rather than Bun's exit status: the analyzer fails the current source with a memory resource failure reporting worker_process_memory_limit_bytes, the codec returns a memory resource failure, and the HAR decoder returns its memory failure with process_memory_limit_bytes. Bun source-map Evidence records process_memory_limit_bytes, verified against the launcher. Node.js launches and outputs are unchanged. * fix(windows): drain memory notifications after observing exit --------- Co-authored-by: morluto <76467478+morluto@users.noreply.github.com>
161 lines
8.7 KiB
Markdown
161 lines
8.7 KiB
Markdown
# JavaScript and Electron application artifacts
|
|
|
|
For captured or bundled JavaScript that needs readable source recovery, use
|
|
`recover_javascript_sources` with an absolute `path` and absent
|
|
`output_directory`. Supply related runtime/shared/lazy files in
|
|
`additional_paths` when advertised, then analyze the returned `analysis_input`
|
|
directory together. Each input retains its own snapshot, digest and byte-range
|
|
provenance; inputs and recovered code are never executed. Recovery requires a
|
|
caller-supplied Wakaru on Linux x64; see [the recovery guide](https://github.com/morluto/rea/blob/main/docs/javascript-recovery.md).
|
|
|
|
Use `analyze_javascript_application` directly on the operator-supplied ASAR or
|
|
extracted tree. When size is unknown or large and the connected schema advertises
|
|
`detail`, request `detail: "summary"`. This returns an `inspect_analysis_view`
|
|
Evidence record with a distinct ID and a `normalized_result.parent_evidence_id`
|
|
for the complete retained application analysis. Source-map contents are part of
|
|
that static analysis. Read findings, coverage, limitations and unknowns, then
|
|
follow a specific unanswered question. Older servers without `detail` return
|
|
the complete application Evidence inline when it fits.
|
|
|
|
When the connected schema advertises `max_heap_mb` and `analysis_timeout_ms`,
|
|
these select the isolated source analyzer's old-space heap and per-source
|
|
deadline. Defaults are 1024 MiB and 300000 ms. They do not change the MCP
|
|
process heap. A Bun-hosted REA does not enforce the heap choice; on Windows it
|
|
instead limits the analyzer's committed memory to that choice plus a 512 MiB
|
|
runtime reserve.
|
|
Resource-limited analyses preserve completed static facts and
|
|
report partial semantic coverage with specific unknown scopes; this does not
|
|
mean the source is malformed. Inspect those limits before retrying a source.
|
|
When expanded relationships exceed the parent's available memory, inspect the
|
|
file's modules item view for retained `static_analysis` and
|
|
`semantic_module_analysis`. Their facts remain available even when graph links
|
|
are unknown. Cumulative result exhaustion can stop analysis before every file
|
|
is examined; the inventory and remaining unknown scopes distinguish that case.
|
|
Timeout or cancellation after source analysis begins retains partial Evidence
|
|
in the same session. A returned `error.details.partial_observation` reference
|
|
can be supplied directly to `inspect_analysis_view`. If the SDK cancels locally, retrieve its recorded ID from
|
|
the Evidence bundle before inspecting the partial analysis.
|
|
|
|
## Read a module without repeating analysis
|
|
|
|
Use the actual returned parent ID, on the same connection, as `source.evidence_id`.
|
|
The following IDs are placeholders to replace with returned values. When the
|
|
module's node ID is not already known, page identities before selecting an item.
|
|
Pages return only node IDs, paths and roles; choose a useful page size and follow
|
|
`coverage.next_offset` when another page matters:
|
|
|
|
```json
|
|
{
|
|
"source": {
|
|
"kind": "retained-evidence",
|
|
"evidence_id": "ev_ACTUAL_PARENT_ID"
|
|
},
|
|
"view": { "kind": "page", "collection": "modules", "offset": 0, "limit": 16 }
|
|
}
|
|
```
|
|
|
|
Select the relevant page entry by its exact `node_id` and recorded role:
|
|
|
|
```json
|
|
{
|
|
"source": {
|
|
"kind": "retained-evidence",
|
|
"evidence_id": "ev_ACTUAL_PARENT_ID"
|
|
},
|
|
"view": {
|
|
"kind": "item",
|
|
"collection": "modules",
|
|
"selector": { "node_id": "jag_node_ACTUAL_NODE_ID" }
|
|
}
|
|
}
|
|
```
|
|
|
|
Module pages include asset, bundled and source module roles, so one path can
|
|
identify several entries. Use `selector.path` only when uniqueness is established;
|
|
the returned node ID avoids needing a complete inventory to prove uniqueness. On ambiguity,
|
|
select the matching node ID from the page or the error's candidates. Follow
|
|
`next_offset` when another page matters. An item exposes that module node's
|
|
recorded observations, identity, hashes, exports and source ranges; it does not
|
|
include every child syntax observation, related edge or original source file.
|
|
An absent item fact is not evidence of absence from the whole application.
|
|
|
|
## Trace only the remaining question
|
|
|
|
Use `trace_application_feature` on the parent application Evidence for one
|
|
literal node ID, route, string, API, IPC channel, module, or native export.
|
|
Select `incoming` for relationships leading to the seed, `outgoing` for those
|
|
leaving it, and `both` when the question needs both. Trace traversal includes
|
|
containment relationships, so even a narrow seed can expand many nodes; a
|
|
bidirectional trace can reach unrelated sibling modules. A module item or page
|
|
is preferable when its observations already answer the question. Do not treat
|
|
all reached nodes as participants in the feature.
|
|
|
|
Reuse retained parent Evidence when the server advertises it, or supply complete
|
|
Evidence inline. Include Hopper or Ghidra Evidence only when its artifact digest
|
|
matches exactly.
|
|
|
|
## Recover an oversized display
|
|
|
|
An oversized response reports `resource_constraint` and
|
|
`details.resource: "transport"`. Reuse
|
|
`details.reported_limits.evidence_reference` with `inspect_analysis_view` for a
|
|
summary, one module, or a stable page of module identities.
|
|
`export_evidence_bundle` writes the complete canonical session to a
|
|
caller-selected file. These workflows keep the original Evidence and coverage;
|
|
a broad follow-up can also exceed framing.
|
|
|
|
A client can truncate a successful result inside its text envelope without a
|
|
REA `resource_constraint`. Treat a truncation notice or incomplete JSON as a
|
|
display limitation; do not claim the full record was examined. Reuse the known
|
|
parent ID for smaller views, or export complete Evidence to a selected file
|
|
while the session remains open. If the parent ID was lost from the preview,
|
|
use the prior analysis summary or explicit ledger entries to recover it; do
|
|
not invent an ID or rerun analysis just to reproduce the same display.
|
|
|
|
BrowserWindow preferences, preload and contextBridge surfaces, IPC
|
|
registrations, utility processes, and native binding requests are static syntax
|
|
observations. Only a unique exact literal IPC channel match supports an inferred
|
|
pairing. Dynamic or ambiguous channels remain unresolved. A requested `.node`
|
|
member is not a verified native export. Never claim runtime reachability,
|
|
registration, defaults, or policy enforcement from static analysis.
|
|
|
|
For version comparison, analyze each version once, then call
|
|
`compare_application_versions`. Accept only its digest, source-map, structural
|
|
fingerprint, or non-module semantic matches. Module ordinals and minified names
|
|
are not persistent identity. Report added or removed only with complete
|
|
opposite-side coverage; otherwise report unknown.
|
|
|
|
When the question asks how one exact exported callable's returned object shape
|
|
changed, analyze each version once and then call
|
|
`compare_javascript_export_shapes` with explicit module paths and export names.
|
|
Use the returned IDs on the same connection, or complete inline Evidence
|
|
records, from both analysis calls. Accept variant
|
|
pairing only through the tool's unique exact literal discriminant. Read
|
|
`property_inventories` and each change's `presence` before treating `unknown` as
|
|
"the name was not observed": inventories list observed property names even when
|
|
values stay unknown, with a `source_range` for each paired or unpaired variant.
|
|
Array holes and mutation-invalidated slots are not observed properties.
|
|
Complete parent coverage reports presence-only
|
|
`added`/`removed` independently of unresolved values. Cite the
|
|
comparison Evidence and report JSON Pointer changes; dynamic values, ambiguous
|
|
variants, and incomplete parent-property coverage stay unknown. This is static
|
|
inference, not runtime behavior. When runtime semantics are needed, run
|
|
behavioral probes against the relevant application versions and capture them
|
|
through the available browser, Electron, or process workflows.
|
|
|
|
## Reusing application Evidence
|
|
|
|
When advertised by the connected server, application trace and compare tools
|
|
accept complete inline Evidence or
|
|
`{"kind":"retained-evidence","evidence_id":"ev_<64 lowercase hex characters>"}`
|
|
for their application input (`application`, or `left`/`right`). `inspect_analysis_view`
|
|
uses the same retained-reference form in `source`, or portable inline Evidence,
|
|
to project a summary, module page, or one module with its recorded observations. This notation is
|
|
a template: replace it with the actual returned ID. Versions before 4.1.0 accept only full
|
|
inline Evidence. Use the exact ID
|
|
returned by the producer on the same MCP connection. Resolution does not run
|
|
analysis or select a provider; findings remain inline. Native observation
|
|
arrays still take full Evidence. `close_binary` clears retained references;
|
|
export a bundle before closing, or supply portable inline Evidence in another
|
|
connection. A missing reference includes its ID and recovery guidance.
|