Skip to content

fix(javascript): name heap and semantic ceilings - #6022

Merged
morluto merged 8 commits into
mainfrom
cursor/javascript-heap-semantic-ceilings-8b0a
Oct 21, 2026
Merged

morluto merged 8 commits into
mainfrom
cursor/javascript-heap-semantic-ceilings-8b0a

Conversation

@morluto

@morluto morluto commented Oct 21, 2026 •

Copy link
Copy Markdown
Owner

Summary

Refs #5910 (parent #5808). JavaScript analysis failures now name the existing controls an agent can change, and fixed ceilings say this release has no runtime override.

On Node, heap exhaustion names max_heap_mb: the effective mebibytes, the inclusive range 128 to 16384 (default 1024), that a change applies on the next analysis by starting a new worker, and that it does not raise the parent result budget, the transfer record ceiling, the 2 GiB transfer file maximum, the CLI/MCP process heap, or fixed parser limits. On Bun, a worker exit whose stderr matches heap exhaustion is not attributed to that V8 old-space limit, because Bun ignores the flag.

Semantic ceiling coverage keeps semantic_graph_*_ceiling and also names max_semantic_nodes, max_semantic_nodes_per_file, max_semantic_unknowns, and max_semantic_unknowns_per_file (each an integer from 1 to 1000000). The limitation names only the ceiling that stopped retention: the application total, the per-file ceiling, or both when each one stopped a file. coverage.limits still lists both effective argument values and both ceiling names. The transfer record ceiling (8388608 bytes) and the 2 GiB transfer file maximum have no runtime override. The effective transfer file ceiling follows the parent offered result budget, so on Node a larger CLI/MCP process heap (NODE_OPTIONS, for example --max-old-space-size=<MiB>, after restarting that process) can raise it up to 2 GiB. Selecting fewer source_paths can also raise that effective allowance. The parent result budget and parent checkpoint decode follow that same parent V8 heap. Wakaru's 120000 ms deadline has no runtime override; an unchanged retry may hit it again. analysis_timeout_ms (default 300000) was already named on the timeout path and was left unchanged.

Problem and expected behavior

A worker that exhausted its V8 old-space heap reported the exhaustion without naming max_heap_mb, the effective value, the valid range, or when a different value takes effect. The generic memory remediation talked about host memory and did not say what raising the worker heap does not raise.

Truncated semantic graphs reported semantic_graph_node_ceiling, semantic_graph_file_node_ceiling, semantic_graph_unknown_ceiling, and semantic_graph_file_unknown_ceiling without the caller arguments that set those ceilings.

Transfer, checkpoint, and worker-request failures fell through to the generic transport remediation (get_evidence_bundle). Wakaru's fixed 120000 ms deadline and fixed input, output, and diagnostic allowances did not say this release has no runtime override. Explicit-value redaction rebuilt a timeout error without userMessage or remediationAction, so the existing analysis_timeout_ms sentence was dropped on that path.

Review of the first revision: the effective transfer file ceiling and the parent result budget were described as having no runtime override. Both follow the CLI/MCP process heap. A provenance.json over 8 MiB lost the fixed-allowance guidance when parseWakaruReports wrapped the size refusal. The Wakaru deadline said an unchanged retry fails the same way, which is stronger than an elapsed-time check supports. A later review: Bun heap-exhaustion exits still named max_heap_mb, and checkpoint decode named the parent heap without the Node NODE_OPTIONS control. Truncated semantic retention then said both the total and the per-file ceiling were reached even when only one of them stopped retention.

Change and scope

Wording and projection only. Numeric defaults and schema bounds are unchanged. No new setting was added.

  • On Node, heap exhaustion uses javaScriptWorkerHeapRemediation. At 16384 MiB the text says not to increase max_heap_mb further. The Windows Bun commit-limit path still uses that remediation, because that limit is max_heap_mb plus a 512 MiB reserve. A Bun exit whose stderr matches heap exhaustion does not attribute the failure to the configured V8 old-space and does not say to increase max_heap_mb.
  • sameLimits compares heapMb and timeoutMs only, and #start applies --max-old-space-size at worker launch. The sentence therefore says a changed max_heap_mb applies on the next analysis, which starts a new worker. It does not change a worker that is already running, and it does not require restarting the REA server.
  • Parent result-budget failures keep their existing reasons. Increasing max_heap_mb does not raise that budget. On Node, NODE_OPTIONS (for example --max-old-space-size=<MiB>) in the environment that starts the CLI or MCP server raises the parent V8 heap, and therefore this budget, after that process restarts. JAVASCRIPT_PARENT_HEAP_NODE_OPTIONS owns that sentence. A bare --max-old-space-size is an illegal V8 option and prevents Node from starting. Parent checkpoint decode uses the same parent-heap control: increasing max_heap_mb does not raise it, and on Node that NODE_OPTIONS restart can admit the checkpoint.
  • Semantic truncation coverage adds the four argument names beside the existing ceiling names, with effective values, defaults (100000 / 20000 / 100000 / 20000), range 1 to 1000000, CLI flags, and that a change applies on the next analyze_javascript_application call without restarting the worker or the REA server. JavaScriptSemanticGraphBuilder records which offered budget stopped node and unknown retention. The offer is the minimum of the per-file ceiling and the remaining application total. The limitation names only that smaller ceiling, or both when the two offers are equal, and tells the caller to set only those arguments. coverage.limits still lists both effective argument values and both ceiling names. At 1000000 the text says not to increase that reached control further. Unknown coverage keeps the omission-counting sentence. The same attribution covers direct projection, adopted file projections, and unavailable-file unknown omissions.
  • The transfer record ceiling is 8388608 bytes and the transfer file maximum is 2147483648 bytes. Both have no runtime override, and raising max_heap_mb does not raise them. The effective file ceiling follows the parent offered result budget. On Node, the same NODE_OPTIONS sentence (--max-old-space-size=<MiB>, then restart the CLI or MCP process) can raise it up to the maximum. Selecting fewer source_paths can also raise that effective allowance, because earlier retained results and the reserve for remaining sources reduce the offered budget. Neither change raises the record ceiling or the maximum. When the effective ceiling is already the maximum, the text says not to expect source_paths to raise it. The parent reattaches that remediation when the worker protocol forwards only message and limits. The 8388608-byte static checkpoint and the 65536-byte worker request ceiling keep the no-override sentence.
  • analysis_timeout_ms user text is unchanged. Redaction copies userMessage and remediationAction, including when those fields contain an explicit sensitive value, and still keeps analysis_timeout_ms.
  • Wakaru's 120000 ms deadline has no runtime override. Raising analysis_timeout_ms or max_heap_mb does not raise it. An unchanged retry may hit the deadline again. Input allowance (maximum_input_bytes, 67108864 bytes), output entries (10000), output bytes (134217728), and the 8388608-byte diagnostic allowance say no runtime override. A provenance.json over 8388608 bytes applies wakaruFixedLimitRecovery, and parseWakaruReports keeps that userMessage and remediationAction on the ProviderAdapterError. Malformed reports stay the generic adapter failure.

Web bundles, MCP response/startup naming (#6005), provider command_timeout_ms (#6014), Android, native, engines, and ASAR are out of scope. The 1 GiB Wakaru address-space ceiling has no dedicated error and was not given a new detector. Success-path RECOVERY_LIMITATIONS was left unchanged so successful recoveries keep their evidence identity.

Follow the contribution scope.
Unresolved scope, authority, side effects, or required verification block
integration. Link the required maintainer scope decision for new providers or
capabilities involving target execution, injection, mutation, or protection
recovery; ordinary fixes within existing boundaries may state "not applicable".
Draft PRs may leave the scope decision pending and the readiness and merge checklists
unchecked. Maintainers can help resolve open questions.

Not applicable. This is recovery and coverage text for existing JavaScript analysis and Wakaru limits. It does not add a provider, target execution, injection, mutation, or protection recovery.

Contract and boundary impact

  • Semantic owner and earliest changed stage: javaScriptAnalysisResourceControlsSchema owns max_heap_mb and the four max_semantic_* arguments. JavaScriptAnalysisWorker owns heap, parent-budget, checkpoint-decode, and worker-request recovery. JavaScriptAnalysisTransfer owns transfer ceilings. JavaScriptSemanticGraphBuilder owns semantic coverage limits and which ceiling stopped retention. Wakaru recovery owns the fixed adapter deadline and allowances. The worker protocol still forwards only message and limits; the parent reattaches remediation from those limit keys.
  • Contribution scope fit and linked maintainer decision: not applicable. Wording within existing JavaScript analysis and recovery boundaries.
  • CLI and MCP/tool-catalog contract: failure text and truncated semantic-graph coverage change. Schema fields, ranges, and defaults are unchanged: max_heap_mb 128..16384 default 1024 (CLI --max-heap-mb); max_semantic_nodes default 100000; max_semantic_nodes_per_file default 20000; max_semantic_unknowns default 100000; max_semantic_unknowns_per_file default 20000; each semantic argument is an integer from 1 to 1000000 (CLI --max-semantic-nodes, --max-semantic-nodes-per-file, --max-semantic-unknowns, --max-semantic-unknowns-per-file); analysis_timeout_ms 1..2147483647 default 300000. No catalog or tool-schema change.
  • Provider, bridge, target-format, or platform compatibility: none. Bun still ignores V8 heap flags; a Bun heap-exhaustion exit states that and does not claim --max-old-space-size was exhausted. Parent-heap guidance names Node NODE_OPTIONS and does not claim Bun honors --max-old-space-size.
  • Evidence, artifact, provenance, or reconstruction contract: truncated semantic graphs gain argument-named coverage limits and a limitation that names only the ceiling that stopped retention. graph_id includes limitations and coverage.limits, so a truncated graph's id changes. Graphs that are not truncated do not gain that limitation. Wakaru success-path limitations are unchanged.
  • Target selection, authority, upstream behavior, and cleanup details (if applicable): not applicable. No new process authority. Cleanup guidance on the Wakaru deadline is the existing "confirm outstanding work and cleanup" sentence.
  • Generated metadata (docs/public/product-catalog.json), package, or installation impact (CI generates and validates ignored catalogs and skills/; edit authored instructions in .agents/skills/reverse-engineer-anything/ and never commit build outputs): none. Skill text was not changed. docs/javascript-artifact-reconstruction.md and docs/javascript-recovery.md describe the named controls, the adjustable file ceiling, and the no-override sentences for fixed ceilings. The reconstruction doc says truncated coverage lists both effective ceilings and that the limitation names only the ceiling that stopped retention.

Expected effects (check known effects; use documentation-only on its own).
Unchecked items do not establish absence; leave uncertainties visible.

  • Read existing files or captured data.
  • Launch or attach to a process.
  • Inject instrumentation or run scripts/code.
  • Change process memory, registers, files, or configuration.
  • Contact network services.
  • Recover protected code or work around protections.
  • Documentation or usability only; no target interaction.
  • Not sure yet; investigation or maintainer guidance needed.

Evidence and regression coverage

  • Tests added or updated: src/domain/javascript/javascriptAnalysisResourceControls.test.ts, src/application/javascript/JavaScriptSemanticGraphBuilder.test.ts, src/application/javascript/JavaScriptSemanticUnknownCapacity.test.ts, src/javascript/analysis/JavaScriptAnalysisTransfer.recovery.test.ts, src/javascript/recovery/WakaruCommand.test.ts, src/javascript/recovery/WakaruReport.test.ts, src/domain/explicitSensitiveFailure.test.ts, tests/boundary/javascript/workerOrderAudit.test.ts, tests/boundary/cli/javascriptApplicationJsonOutput.test.ts.
  • Base reproduction or other evidence: schema and worker launch were read in source. max_heap_mb is applied only in #start via --max-old-space-size. prepareForAnotherAnalysis keeps the heap selected at launch, and sameLimits treats a different heapMb as a different worker. Semantic budgets are per-request node_budget / unknown_budget, not launch flags. javaScriptTransferByteBudget is max(512 MiB, offered result budget / 8) capped at 2 GiB. #refreshResultBudget and checkpoint decode both read getHeapStatistics().heap_size_limit. WORKER_HEAP_FLAGS_ENFORCED is true only when javaScriptRuntime is Node. Remaining sources reserve one next static checkpoint (checkpointBytes * 6, 48 MiB). Node truncation is attributed from the early exit when state.nodes.size >= nodeCeiling, from fileNodesDropped against the file offer, and from nodesTruncated on an adopted projection. Unknown omissions are attributed the same way for direct projection, adopted omissions, and unavailable files.
  • User-visible CLI/MCP output (if applicable): rea analyze-javascript-application JSON for a truncated semantic graph includes coverage limits { name: "max_semantic_nodes", value: 50 } and { name: "max_semantic_nodes_per_file", value: 30 } beside the existing ceiling names, and a limitation containing max_semantic_nodes and 1 to 1000000. That CLI fixture hits both ceilings (30 nodes in the first file, then the remaining 20 of the total). That CLI assertion was run on an earlier revision; this revision did not repeat it.
  • Remaining proof gaps: no live V8 heap-exhaustion allocation and no real Wakaru binary run. The worker test writes a heap-exhaustion stderr line and exits. The Bun wording is covered by the recovery helper, not by a Bun process. Address-space exhaustion still has no dedicated error. Checkpoint decode wording is covered by the shared remediation constant; the remaining-heap guard was not forced with a multi-gigabyte checkpoint. GitHub CI was not run here.

For evidence-bearing changes:

  • Observed, derived, and inferred claims remain distinguishable.
  • Artifact identity, source provenance, and failed attempts remain preserved.
  • Unsupported, incomplete, unavailable, or uncertain outcomes remain visible.

Validation performed

  • npm run check:fast — typecheck and lint succeeded (2 tasks). Repeated after rebasing onto the branch; the second run was a cache hit.
  • npm run test:focused -- src/domain/javascript/javascriptAnalysisResourceControls.test.ts src/application/javascript/JavaScriptSemanticGraphBuilder.test.ts src/application/javascript/JavaScriptSemanticUnknownCapacity.test.ts — 86 tests passed, including per-file-only, total-only, and both-reached node and unknown limitations. Repeated after the rebase; 86 tests passed again.
  • npx oxfmt --write on the five edited TypeScript files, then the formatter left them matching.

Earlier revisions also ran the worker-order, CLI JSON, Wakaru, and redaction focused tests. Those files are unchanged by the NODE_OPTIONS example fix and were not re-run for it. The semantic-ceiling revision above ran on Node v22.23.3.

The NODE_OPTIONS revision (7d3dc248e), rebased on 65d4a570, ran on Node v24.18.0:

  • npm run check:fast — typecheck and lint succeeded (2 tasks, 4.173s, 0 cached).
  • npm run test:focused -- src/domain/javascript/javascriptAnalysisResourceControls.test.ts src/javascript/analysis/JavaScriptAnalysisTransfer.recovery.test.ts — 8 tests passed. Parent-budget, checkpoint, and adjustable transfer remediations require --max-old-space-size=<MiB>.

Real Hopper, Ghidra, browser, or Wakaru provider workflows were not required. These paths are JavaScript analysis projection and the existing worker boundary.

Compatibility, safety, and release

  • Breaking changes or migration steps: none for callers of the schema. Truncated semantic graphs gain coverage limit entries and limitation text, so their graph_id changes. Failure strings change. Limits, defaults, and configuration parsing are unchanged.
  • Real Hopper/Ghidra, browser, or OS coverage: not applicable. No live heap exhaustion and no real Wakaru execution.
  • Package or release metadata impact: none.
  • Security, privacy, process, or containment review: remediation names NODE_OPTIONS with --max-old-space-size=<MiB> for the parent heap and does not ask the agent to patch REA source. A Bun heap-exhaustion exit does not ask the caller to raise max_heap_mb. Explicit-value redaction still redacts timeout userMessage and remediationAction; the test places explicit-secret in both fields and requires analysis_timeout_ms to remain.

Author readiness

Human owner: @morluto

  • I reviewed the final diff and relevant existing code, understand the change and its edge cases, and take responsibility for the complete PR, including AI-assisted work.
  • I checked the evidence above, confirmed it supports the current change, and recorded meaningful validation gaps.
  • I declare this PR ready for initial maintainer review.

Before merge

  • This PR addresses a concrete problem or an agreed enhancement.
  • Material scope and authority questions are resolved, and any required maintainer scope decision covers the final diff.
  • The PR has one focused outcome and the title follows type(scope): outcome.
  • Related issue is linked, or the reason for not linking one is stated above.
  • Tests cover changed observable behavior and meaningful failure paths.
  • Owning docs, contracts, and generated metadata are updated where needed.
  • User-visible CLI/MCP changes include representative output.
  • I checked the final diff for secrets, unrelated cleanup, and unsupported claims.
Open in Web Open in Cursor 

Refs #5910. Heap exhaustion names max_heap_mb with its effective value,
range, and next-analysis worker restart. Semantic ceiling coverage names
the four max_semantic_* arguments. Wakaru and transfer ceilings say this
release has no runtime override.

Co-authored-by: morluto <morluto@users.noreply.github.com>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-21T16:53:23.721349Z 7d3dc24 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ea76f6eeac

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@greptile-apps

greptile-apps Bot commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; no blocking issue remains.

Summary

This PR names the controls behind JavaScript resource failures and distinguishes adjustable allowances from fixed limits.

  • JavaScript analysis errors point callers to the heap or transfer limit involved.
  • Truncated semantic graphs name the caller setting that stopped retention.
  • Wakaru recovery errors explain which limits have no runtime override.
  • Timeout recovery guidance stays visible after sensitive values are redacted.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  A[Application room remaining] --> C[Smaller offered budget]
  B[Per-file ceiling] --> C
  C --> D[Project one file]
  D --> E{Records omitted?}
  E -->|Yes| F[Mark the ceiling that bound the offer]
  F --> G[Name reached controls in limitations]
  G --> H[List both effective values in coverage]
Loading

Reviews (4) · Last reviewed commit: "fix(javascript): limit the old-space pla..." · Reviewed by Greptile

The effective transfer file ceiling and the parent result budget follow
the CLI/MCP process heap, so recovery names NODE_OPTIONS instead of
denying an override. A provenance report over 8 MiB keeps the fixed
allowance guidance, and the Wakaru deadline says an unchanged retry may
hit it again.

Refs #5910

Co-authored-by: morluto <morluto@users.noreply.github.com>

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a8fec6406b

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Bun heap-exhaustion exits no longer claim the ignored max_heap_mb V8
old-space limit. Checkpoint decode names the parent heap and Node
NODE_OPTIONS, the same control as the parent result budget.

Refs #5910

Co-authored-by: morluto <morluto@users.noreply.github.com>

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 21b55f9817

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

…ached

Truncated semantic retention names the total and per-file controls as
effective ceilings. Callers only know that retention was truncated, so
the limitation no longer says both ceilings were reached.

Refs #5910

Co-authored-by: morluto <morluto@users.noreply.github.com>

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 579feb0bae

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

cursoragent and others added 3 commits October 21, 2026 16:40
Semantic ceiling limitations claimed both the application total and the
per-file control whenever either one truncated the graph. Record which
offered budget stopped node and unknown retention, and name only those
controls. Coverage limits still list both effective values.

Co-authored-by: morluto <morluto@users.noreply.github.com>
A bare --max-old-space-size is an illegal V8 flag and prevents Node from
starting. Parent-heap and transfer-ceiling recovery now share
--max-old-space-size=<MiB>, and the Kuna heap remediation uses the same
complete form.

Co-authored-by: morluto <morluto@users.noreply.github.com>
…very

The review covers the CLI/MCP NODE_OPTIONS example and the transfer-ceiling
copy. The Kuna heap-headroom sentence stays unchanged.

Co-authored-by: morluto <morluto@users.noreply.github.com>
@morluto
morluto merged commit a0214e0 into main Oct 21, 2026
41 of 42 checks passed
@morluto
morluto deleted the cursor/javascript-heap-semantic-ceilings-8b0a branch October 21, 2026 18:44
@github-actions github-actions Bot mentioned this pull request Oct 21, 2026
3 tasks done
@morluto morluto added the bug Something isn't working label Nov 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants