Skip to content

feat(process): make the regex worker heap request configurable - #6301

Merged
morluto merged 3 commits into
mainfrom
cursor/regex-worker-heap-request-d806
Oct 22, 2026
Merged

morluto merged 3 commits into
mainfrom
cursor/regex-worker-heap-request-d806

Conversation

@morluto

@morluto morluto commented Oct 22, 2026 •

Copy link
Copy Markdown
Owner

Summary

Part of #6176. The regex worker old-generation request is now REA_REGEX_WORKER_HEAP_REQUEST_MIB. Unset still requests 128 MiB. This does not cover the issue's decoder heap or MCP startup budgets.

Problem and expected behavior

The regex worker requested a fixed 128 MiB old generation, and capability and recovery text said that request had no runtime override. Callers need a named setting whose default is that constant. Invalid values must fail configuration and name the setting. A positive Node --max-old-space-size, including NODE_OPTIONS, still overrides the request and is not clamped by the setting.

Unset behavior stays a 128 MiB request. A value from 7 to 16384 MiB is the request. Any other value fails startup, doctor, and client-registration configuration and names REA_REGEX_WORKER_HEAP_REQUEST_MIB. It does not fall back to 128. Setup copies a caller-selected value through SELECTED_REGISTRATION_SETTINGS.

Recovery, capability, and limitation text name the setting, the effective request, the source (default or setting), the default, the floor, the maximum, and how to change it. They also name the process effective heap when launch flags establish it.

Change and scope

src/config/regexWorkerHeapRequest.ts owns the setting. Startup (parseConfig) and doctor (parseEnvironment) resolve it with the same schema. The effective request is stored on AppConfig and passed into Hopper and Kuna, which pass it to RegexMatcher. A direct KunaProvider resolves the selected environment instead of ambient process.env. An omitted matcher request means the 128 MiB default, not ambient process.env.

Setup keeps REA_REGEX_WORKER_HEAP_REQUEST_MIB in SELECTED_REGISTRATION_SETTINGS. A present value is copied into the generated registration. An unset value is omitted.

The floor is 7 MiB. On Linux, the production worker (^a against ["a"], no NODE_OPTIONS) returns ERR_WORKER_OUT_OF_MEMORY at 6 MiB on Node 24.21.0 and 24.22.1, and on most runs of Node 24.11.0, 24.18.0, and 26.0.0. 7 MiB returned that match on Node 22.19.0, 22.23.4, 24.11.0, 24.18.0, 24.21.0, 24.22.1, 26.0.0, and 26.12.1, so a smaller request is not a matching bound on every supported Node line. The maximum is 16384 MiB, the same ceiling REA already uses for one isolated JavaScript analysis worker. Node starts with a larger flag; this maximum bounds only the REA request. A positive --max-old-space-size is reported as the effective heap and is not limited by this floor or maximum.

Follow the contribution scope. This is configuration of an existing regex worker request. It does not add a provider or a capability that executes, injects, mutates, or recovers a target. Maintainer scope decision: not applicable. The product decision to make this ceiling a setting is recorded in #6176.

Contract and boundary impact

  • Semantic owner and earliest changed stage: src/config/regexWorkerHeapRequest.ts parses the setting; parseConfig resolves it before providers match. explicitSetupRegistrationEnvironment preserves a caller-selected value when setup writes a registration.
  • Contribution scope fit and linked maintainer decision: existing regex matching only; not applicable.
  • CLI and MCP/tool-catalog contract: search_procedures and search_strings descriptions name REA_REGEX_WORKER_HEAP_REQUEST_MIB, the 128 MiB default, the 7 MiB floor, and the 16384 MiB maximum. Capability and heap failures name the effective request and source.
  • Provider, bridge, target-format, or platform compatibility: Hopper and Kuna share the request. A positive Node --max-old-space-size, including NODE_OPTIONS, still overrides it. Percentage, --max-heap-size, env-file, and experimental config-file launches still leave the effective heap unestablished.
  • Evidence, artifact, provenance, or reconstruction contract: heap failures add requested_worker_heap_source beside requested_worker_heap_mib.
  • Target selection, authority, upstream behavior, and cleanup details (if applicable): none.
  • 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): tool descriptions changed in source contracts. No authored skill text claimed the heap request had no override.

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: parser accepts 7 and rejects 6; doctor and client-registration rejection of 6; Hopper/Kuna capability text for a 256 MiB request while ambient process.env is 8; a selected request of 256 stays in effect, and --max-old-space-size=64 still overrides it to 64 MiB without clamping. A clean Node process, with NODE_OPTIONS removed and without --import tsx on execArgv, calls production matchRegexValues at the floor and matches ^a against ["a"].
  • Base reproduction or other evidence: on main the request constant is 128 and recovery says there is no runtime override for that request. The 6 MiB floor was only a Node 22.23.4 startup bound. Reproducing the review on Linux Node 24.21.0 with the production matcher returned ERR_WORKER_OUT_OF_MEMORY at 6 MiB (5/5) and {ok:true, indices:[0]} at 7 MiB (5/5). The same 7 MiB production call matched on Node 22.19.0, 22.23.4, 24.11.0, 24.18.0, 26.0.0, and 26.12.1 (3/3 each). Raw worker repeats at 6 MiB were 0/10 matches on 24.21.0 and 24.22.1, 1/10 on 24.11.0 and 24.18.0, and 2/10 on 26.0.0; 7 MiB was 10/10 on those builds.
  • User-visible CLI/MCP output (if applicable): the default recovery says The effective REA_REGEX_WORKER_HEAP_REQUEST_MIB value is 128 MiB (source default; default 128 MiB, floor 7 MiB, maximum 16384 MiB). Set REA_REGEX_WORKER_HEAP_REQUEST_MIB in the environment that starts REA to a decimal integer from 7 to 16384, then restart REA. A 256 MiB setting uses source setting and 256 MiB.
  • Remaining proof gaps: no real Hopper or Kuna binary was used. Windows was not executed. Node 22 and Node 26.12.1 can complete the trivial match at 6 MiB, but the setting rejects 6 so one accepted value works on every supported Node line. A heap above 128 was checked through resolveRegexWorkerHeap and capability text, not by exhausting a 256 MiB worker.

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, 2 tasks successful (6.695s).
  • npm run format:check — all matched files use the correct format (4944 files).
  • npm run test:local -- src/config/regexWorkerHeapRequest.test.ts src/process/RegexMatcher.test.ts src/application/Doctor.test.ts — 124 passed.
  • npm run test:focused -- tests/boundary/process/regexMatcher.test.ts tests/boundary/filesystem/clientConfigurationEnvironment.test.ts — 43 passed, 10 skipped. The real-worker floor test is in the process-boundary file.

Compatibility, safety, and release

  • Breaking changes or migration steps: none for an unset environment. The request remains 128 MiB. REA_REGEX_WORKER_HEAP_REQUEST_MIB=6 is now a configuration error. It previously passed configuration and then failed regex search on supported Node 24 and Node 26.0.0. A positive --max-old-space-size still overrides the request.
  • Real Hopper/Ghidra, browser, or OS coverage: not run. Heap-request behavior was measured with the production regex worker on the Linux Node versions listed above.
  • Package or release metadata impact: none.
  • Security, privacy, process, or containment review: the worker still uses resourceLimits.maxOldGenerationSizeMb. The setting changes only that REA request. It does not raise a Node --max-old-space-size already applied to the process, and it does not change target memory.

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 

cursoragent and others added 2 commits October 22, 2026 09:36
REA_REGEX_WORKER_HEAP_REQUEST_MIB keeps the 128 MiB default and refuses
values outside 8 to 16384 MiB. A positive Node --max-old-space-size still
overrides the request and is not clamped by the setting.

Co-authored-by: morluto <[email protected]>
… bound

On Node 22.23.4 a 5 MiB old-generation request aborts the regex worker
during startup, and 6 MiB starts it and returns a match. The setting floor
is that measured bound.

Co-authored-by: morluto <[email protected]>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 22, 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 ⚠️ Failed 2026-10-22T11:58:34.311128Z
We couldn’t complete this review. Comment @codex review to try again.
8b9ad21 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.

@greptile-apps

greptile-apps Bot commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; the previous minimum-heap issue is addressed and no new blocking issue was found.

Summary

Makes REA_REGEX_WORKER_HEAP_REQUEST_MIB configurable for Hopper and Kuna while preserving the 128 MiB default and Node heap overrides.

  • Regex searches can use a caller-set worker heap request.
  • Setup carries a selected heap request into client registrations.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  Environment[Selected environment] --> Parser[Validate heap request]
  Parser --> Config[Resolved request and source]
  Config --> Hopper[Hopper]
  Config --> Kuna[Kuna]
  Hopper --> Matcher[RegexMatcher]
  Kuna --> Matcher
  Matcher --> Worker[Worker heap request]
  Flags[Positive Node heap flag] --> Override[Overrides worker request]
  Worker --> Override
Loading

Reviews (2) · Last reviewed commit: "fix(process): raise the regex worker hea..." · Reviewed by Greptile

Comment thread src/config/regexWorkerHeapRequest.ts Resolved
6 MiB passes configuration but returns ERR_WORKER_OUT_OF_MEMORY for a
trivial match on supported Linux Node 24 and Node 26.0.0. 7 MiB returned
that match on the measured 22, 24, and 26 lines. A clean-process test
runs the production worker at the floor.

Co-authored-by: morluto <[email protected]>
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

@morluto
morluto merged commit 9512a80 into main Oct 22, 2026
45 checks passed
@morluto
morluto deleted the cursor/regex-worker-heap-request-d806 branch October 22, 2026 15:43
cursor Bot pushed a commit that referenced this pull request Oct 22, 2026
Integrate origin/main, including the regex worker heap request from #6301.
Doctor and client-configuration tests keep both invalid-value cases.

Co-authored-by: morluto <[email protected]>
@morluto morluto mentioned this pull request Oct 25, 2026
3 tasks done
kaoru0822-kitauji added a commit that referenced this pull request Oct 25, 2026
* fix(mcp)!: return a compact binary_session status by default

binary_session {} with no target open returned about 66 KB, most of it
provider rejection diagnostics and candidate capability sets that the
skill's recovery flow re-reads on every retry. 6.8.0 grew it by 21%
because the shared regex capability limitation began repeating setting
bounds and step-by-step recovery for every search operation of every
provider (#6099, #6267, #6301, #7049) and IDA gained that limitation for
its two search operations (#4862).

The regex limitation now states the effective deadline and heap, their
sources and where to change them; the deadline and heap errors keep the
full recovery. binary_session gains detail: summary (default) or
complete. The summary keeps open state, target identity, the binding,
route capabilities, run, activity and health status, each candidate's
availability and target-support status, code and reason, and every
tool's availability, reason, remediation and modes, and lists the
fields it leaves out in omitted_fields. Complete detail returns the
previous shape. The CLI capabilities and providers commands keep
complete provider facts through the same application projection.

BREAKING CHANGE: binary_session {} no longer returns
analysis_provider_candidates[].availability.diagnostics,
target_support.diagnostics or capabilities, or tool_availability group
surface, effects and annotations. Pass {"detail": "complete"} to get
them.

Fixes #7109

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(mcp): key binary_session output fields by detail

The output schema accepted detail: "complete" with summary candidates or
tool groups, and a summary without omitted_fields, so detail did not
tell callers which fields existed. Each session kind is now crossed
with a detail-specific shape: a summary requires omitted_fields and
summary-only candidates and tool groups; complete requires diagnostics,
candidate capabilities and static tool flags and forbids omitted_fields.
Both the canonical schema and the SDK-validated advertised schema reject
mismatched shapes.

The verifier helper accepts summary candidates only for a validated MCP
summary; CLI provider output still requires candidate capabilities.
Regex limitation tests check values, sources and setting names instead
of whole sentences.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
@morluto morluto added area: runtime Process capture and runtime observation enhancement New feature or request labels Nov 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: runtime Process capture and runtime observation enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants