[PR #6267] [MERGED] feat(config): make the regex matching deadline configurable #7242

Closed
opened 2026-11-01 21:46:26 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/morluto/rea/pull/6267
Author: @morluto
Created: 10/22/2026
Status: ✅ Merged
Merged: 10/22/2026
Merged by: @morluto

Base: main ← Head: cursor/regex-matching-deadline-b35c


📝 Commits (3)

  • ae96ddb feat(config): make the regex matching deadline configurable
  • 87456fc fix(setup): preserve the regex matching deadline in registrations
  • 609f0be test(config): restore a stubbed regex matching deadline on failure

📊 Changes

26 files changed (+588 additions, -95 deletions)

View changed files

📝 docs/kuna-provider.md (+1 -1)
📝 docs/native-investigation.md (+11 -3)
📝 scripts/lib/test-projects.mjs (+1 -1)
📝 src/application/Doctor.test.ts (+1 -0)
📝 src/application/SetupRegistrationEnvironment.ts (+1 -0)
📝 src/composition/binary.ts (+3 -1)
📝 src/config/environment.ts (+2 -0)
📝 src/config/parseConfig.ts (+8 -0)
➕ src/config/regexMatchingDeadline.test.ts (+136 -0)
➕ src/config/regexMatchingDeadline.ts (+92 -0)
📝 src/config/types.ts (+3 -0)
📝 src/contracts/officialToolContracts.ts (+5 -2)
📝 src/hopper/HopperProvider.ts (+9 -4)
📝 src/hopper/HopperProviderCapabilities.ts (+53 -45)
📝 src/hopper/HopperRegexSearch.ts (+9 -1)
📝 src/kuna/KunaProvider.ts (+15 -0)
📝 src/kuna/KunaProviderCapabilities.ts (+10 -4)
📝 src/kuna/KunaQueryWork.ts (+6 -0)
📝 src/kuna/KunaSessionClient.ts (+15 -7)
📝 src/process/RegexMatcher.test.ts (+6 -4)

...and 6 more files

📄 Description

Summary

Part of #6176. The supervised ECMAScript regex matching deadline is now REA_REGEX_MATCHING_DEADLINE_MS. Unset still uses 5000 ms. This does not cover the issue's later decoder-heap or MCP startup budgets.

Problem and expected behavior

MATCHING_DEADLINE_MS was a fixed 5000 ms, and capability, limitation, and recovery text said this release has no runtime override. Callers need a named setting whose default is that constant, with invalid values refused and recovery that names the setting, effective milliseconds, source (default or setting), default, floor, and maximum.

A caller override such as REA_REGEX_MATCHING_DEADLINE_MS=10000 rea setup was validated and then omitted from setup-created MCP registrations, so the launched server returned to 5000 ms.

Change and scope

src/config/regexMatchingDeadline.ts owns the setting. Startup (parseConfig) and doctor (parseEnvironment) resolve it with the same schema. The effective deadline 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.

Setup now keeps REA_REGEX_MATCHING_DEADLINE_MS in SELECTED_REGISTRATION_SETTINGS, with the other caller-selected registration settings. A present value is copied into the generated registration. An unset value is omitted.

The floor is 1 ms. The maximum is 2147483647 ms, the largest delay Node schedules exactly; a larger setTimeout delay is clamped to 1 ms, so it is refused rather than left unbounded. Zero, negative, non-decimal, and out-of-range values are configuration_invalid and do not fall back to 5000. The schema does not trim whitespace.

Follow the contribution scope. This is an ordinary configuration of an existing matching deadline. It does not add target execution, injection, mutation, or protection recovery. Maintainer scope decision: not applicable.

Contract and boundary impact

  • Semantic owner and earliest changed stage: src/config/regexMatchingDeadline.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_MATCHING_DEADLINE_MS, the 5000 ms default, and the 2147483647 ms maximum. Capability and deadline failures name the effective value and source.
  • Provider, bridge, target-format, or platform compatibility: Hopper and Kuna share the deadline. The worker heap flags are unchanged and do not raise it.
  • Evidence, artifact, provenance, or reconstruction contract: deadline failures add matching_deadline_source beside matching_deadline_ms.
  • 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 deadline 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 and startup rejection; doctor and client-registration rejection; Hopper/Kuna capability text; worker timer armed at 10000 ms; a 100 ms deadline stops a slow match; the Kuna boundary probe still waits the unset 5000 ms deadline and a selected REA_REGEX_MATCHING_DEADLINE_MS=200 stops early. Ambient process.env does not override the selected environment. The Kuna capability assertion restores stubbed environment in finally. Setup-host state includes 10000 when set and omits the key when unset. Public Codex and Kimi setup writes REA_REGEX_MATCHING_DEADLINE_MS=10000 and still omits REA_UNRELATED_MARKER.
  • Base reproduction or other evidence: on main the deadline constant is 5000 and recovery says there is no runtime override. The unset Kuna probe still reports matching_deadline_ms: 5000 and takes about 5.4 s. Before this fix, SELECTED_REGISTRATION_SETTINGS did not include the deadline, so setup-created registrations dropped the override.
  • User-visible CLI/MCP output (if applicable): a deadline failure for the default says The effective REA_REGEX_MATCHING_DEADLINE_MS value is 5000 ms (source default; default 5000 ms, floor 1 ms, maximum 2147483647 ms). Set REA_REGEX_MATCHING_DEADLINE_MS in the environment that starts REA to a positive decimal integer from 1 to 2147483647, then restart REA. A 10000 ms setting uses source setting and 10000 ms.
  • Remaining proof gaps: no real Hopper or Kuna binary was used. The Kuna probe uses the fake Kuna executable and the production regex 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 test:local -- src/config/regexMatchingDeadline.test.ts src/application/Doctor.test.ts — 74 passed.
  • npm run test:local -- src/config/regexMatchingDeadline.test.ts src/process/RegexMatcher.test.ts src/hopper/HopperProvider.test.ts — parser, matcher, and Hopper provider tests passed (the first parser run found and fixed schema/assertion failures; the rerun passed).
  • npm run check:fast — typecheck and lint passed (rerun on this fix; passed).
  • npm run format:check — passed on the previous head. This fix was covered by check:fast lint.
  • npm run test:focused -- tests/boundary/process/regexMatcher.test.ts tests/boundary/providers/kuna/kunaRegexSearch.test.ts tests/boundary/filesystem/clientConfigurationEnvironment.test.ts src/config/regexMatchingDeadline.test.ts src/process/RegexMatcher.test.ts — 107 passed, 10 skipped. Unset Kuna deadline probes took 5409 ms and 5356 ms. REA_REGEX_MATCHING_DEADLINE_MS=200 on the selected environment finished in 568 ms and reported source setting.
  • npm run test:local -- src/config/regexMatchingDeadline.test.ts src/setupEnvironment.test.ts — 23 passed.
  • npm run test:focused -- tests/acceptance/setup/registrationRuntimeEnvironmentCli.test.ts — 15 passed, 1 skipped. Codex and Kimi setup preserved 10000.

Compatibility, safety, and release

  • Breaking changes or migration steps: none for an unset environment. The deadline remains 5000 ms. User-facing text no longer says the deadline has no runtime override; it names REA_REGEX_MATCHING_DEADLINE_MS. Invalid values that were previously ignored, because the variable was unread, now fail configuration. An existing registration created before this fix does not gain the override until setup runs again with the setting present.
  • Real Hopper/Ghidra, browser, or OS coverage: not run. Deadline behavior was measured with the production regex worker and the fake Kuna probe.
  • Package or release metadata impact: none.
  • Security, privacy, process, or containment review: the worker is still terminated when the deadline fires. The heap request is unchanged. A longer deadline only extends that existing supervision.

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 

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/morluto/rea/pull/6267 **Author:** [@morluto](https://github.com/morluto) **Created:** 10/22/2026 **Status:** ✅ Merged **Merged:** 10/22/2026 **Merged by:** [@morluto](https://github.com/morluto) **Base:** `main` ← **Head:** `cursor/regex-matching-deadline-b35c` --- ### 📝 Commits (3) - [`ae96ddb`](https://github.com/morluto/rea/commit/ae96ddbe3e6ae1cafb5261e9e5a636d1d4c82e44) feat(config): make the regex matching deadline configurable - [`87456fc`](https://github.com/morluto/rea/commit/87456fc08bb8c357ca36c7b96615837c26360fa4) fix(setup): preserve the regex matching deadline in registrations - [`609f0be`](https://github.com/morluto/rea/commit/609f0be2b6042eee25aa30fad9b23d7df332c877) test(config): restore a stubbed regex matching deadline on failure ### 📊 Changes **26 files changed** (+588 additions, -95 deletions) <details> <summary>View changed files</summary> 📝 `docs/kuna-provider.md` (+1 -1) 📝 `docs/native-investigation.md` (+11 -3) 📝 `scripts/lib/test-projects.mjs` (+1 -1) 📝 `src/application/Doctor.test.ts` (+1 -0) 📝 `src/application/SetupRegistrationEnvironment.ts` (+1 -0) 📝 `src/composition/binary.ts` (+3 -1) 📝 `src/config/environment.ts` (+2 -0) 📝 `src/config/parseConfig.ts` (+8 -0) ➕ `src/config/regexMatchingDeadline.test.ts` (+136 -0) ➕ `src/config/regexMatchingDeadline.ts` (+92 -0) 📝 `src/config/types.ts` (+3 -0) 📝 `src/contracts/officialToolContracts.ts` (+5 -2) 📝 `src/hopper/HopperProvider.ts` (+9 -4) 📝 `src/hopper/HopperProviderCapabilities.ts` (+53 -45) 📝 `src/hopper/HopperRegexSearch.ts` (+9 -1) 📝 `src/kuna/KunaProvider.ts` (+15 -0) 📝 `src/kuna/KunaProviderCapabilities.ts` (+10 -4) 📝 `src/kuna/KunaQueryWork.ts` (+6 -0) 📝 `src/kuna/KunaSessionClient.ts` (+15 -7) 📝 `src/process/RegexMatcher.test.ts` (+6 -4) _...and 6 more files_ </details> ### 📄 Description <!-- CURSOR_AGENT_PR_BODY_BEGIN --> ## Summary Part of #6176. The supervised ECMAScript regex matching deadline is now `REA_REGEX_MATCHING_DEADLINE_MS`. Unset still uses 5000 ms. This does not cover the issue's later decoder-heap or MCP startup budgets. ## Problem and expected behavior `MATCHING_DEADLINE_MS` was a fixed 5000 ms, and capability, limitation, and recovery text said this release has no runtime override. Callers need a named setting whose default is that constant, with invalid values refused and recovery that names the setting, effective milliseconds, source (`default` or `setting`), default, floor, and maximum. A caller override such as `REA_REGEX_MATCHING_DEADLINE_MS=10000 rea setup` was validated and then omitted from setup-created MCP registrations, so the launched server returned to 5000 ms. ## Change and scope `src/config/regexMatchingDeadline.ts` owns the setting. Startup (`parseConfig`) and doctor (`parseEnvironment`) resolve it with the same schema. The effective deadline 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`. Setup now keeps `REA_REGEX_MATCHING_DEADLINE_MS` in `SELECTED_REGISTRATION_SETTINGS`, with the other caller-selected registration settings. A present value is copied into the generated registration. An unset value is omitted. The floor is 1 ms. The maximum is 2147483647 ms, the largest delay Node schedules exactly; a larger `setTimeout` delay is clamped to 1 ms, so it is refused rather than left unbounded. Zero, negative, non-decimal, and out-of-range values are `configuration_invalid` and do not fall back to 5000. The schema does not trim whitespace. Follow the [contribution scope](https://github.com/morluto/rea/blob/main/CONTRIBUTING.md#contribution-scope). This is an ordinary configuration of an existing matching deadline. It does not add target execution, injection, mutation, or protection recovery. Maintainer scope decision: not applicable. ## Contract and boundary impact - Semantic owner and earliest changed stage: `src/config/regexMatchingDeadline.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_MATCHING_DEADLINE_MS`, the 5000 ms default, and the 2147483647 ms maximum. Capability and deadline failures name the effective value and source. - Provider, bridge, target-format, or platform compatibility: Hopper and Kuna share the deadline. The worker heap flags are unchanged and do not raise it. - Evidence, artifact, provenance, or reconstruction contract: deadline failures add `matching_deadline_source` beside `matching_deadline_ms`. - 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 deadline had no override. Expected effects (check known effects; use documentation-only on its own). Unchecked items do not establish absence; leave uncertainties visible. - [x] 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 and startup rejection; doctor and client-registration rejection; Hopper/Kuna capability text; worker timer armed at 10000 ms; a 100 ms deadline stops a slow match; the Kuna boundary probe still waits the unset 5000 ms deadline and a selected `REA_REGEX_MATCHING_DEADLINE_MS=200` stops early. Ambient `process.env` does not override the selected environment. The Kuna capability assertion restores stubbed environment in `finally`. Setup-host state includes `10000` when set and omits the key when unset. Public Codex and Kimi setup writes `REA_REGEX_MATCHING_DEADLINE_MS=10000` and still omits `REA_UNRELATED_MARKER`. - Base reproduction or other evidence: on main the deadline constant is 5000 and recovery says there is no runtime override. The unset Kuna probe still reports `matching_deadline_ms: 5000` and takes about 5.4 s. Before this fix, `SELECTED_REGISTRATION_SETTINGS` did not include the deadline, so setup-created registrations dropped the override. - User-visible CLI/MCP output (if applicable): a deadline failure for the default says `The effective REA_REGEX_MATCHING_DEADLINE_MS value is 5000 ms (source default; default 5000 ms, floor 1 ms, maximum 2147483647 ms). Set REA_REGEX_MATCHING_DEADLINE_MS in the environment that starts REA to a positive decimal integer from 1 to 2147483647, then restart REA.` A 10000 ms setting uses `source setting` and `10000 ms`. - Remaining proof gaps: no real Hopper or Kuna binary was used. The Kuna probe uses the fake Kuna executable and the production regex worker. For evidence-bearing changes: - [x] Observed, derived, and inferred claims remain distinguishable. - [x] Artifact identity, source provenance, and failed attempts remain preserved. - [x] Unsupported, incomplete, unavailable, or uncertain outcomes remain visible. ## Validation performed - `npm run test:local -- src/config/regexMatchingDeadline.test.ts src/application/Doctor.test.ts` — 74 passed. - `npm run test:local -- src/config/regexMatchingDeadline.test.ts src/process/RegexMatcher.test.ts src/hopper/HopperProvider.test.ts` — parser, matcher, and Hopper provider tests passed (the first parser run found and fixed schema/assertion failures; the rerun passed). - `npm run check:fast` — typecheck and lint passed (rerun on this fix; passed). - `npm run format:check` — passed on the previous head. This fix was covered by `check:fast` lint. - `npm run test:focused -- tests/boundary/process/regexMatcher.test.ts tests/boundary/providers/kuna/kunaRegexSearch.test.ts tests/boundary/filesystem/clientConfigurationEnvironment.test.ts src/config/regexMatchingDeadline.test.ts src/process/RegexMatcher.test.ts` — 107 passed, 10 skipped. Unset Kuna deadline probes took 5409 ms and 5356 ms. `REA_REGEX_MATCHING_DEADLINE_MS=200` on the selected environment finished in 568 ms and reported source `setting`. - `npm run test:local -- src/config/regexMatchingDeadline.test.ts src/setupEnvironment.test.ts` — 23 passed. - `npm run test:focused -- tests/acceptance/setup/registrationRuntimeEnvironmentCli.test.ts` — 15 passed, 1 skipped. Codex and Kimi setup preserved `10000`. ## Compatibility, safety, and release - Breaking changes or migration steps: none for an unset environment. The deadline remains 5000 ms. User-facing text no longer says the deadline has no runtime override; it names `REA_REGEX_MATCHING_DEADLINE_MS`. Invalid values that were previously ignored, because the variable was unread, now fail configuration. An existing registration created before this fix does not gain the override until setup runs again with the setting present. - Real Hopper/Ghidra, browser, or OS coverage: not run. Deadline behavior was measured with the production regex worker and the fake Kuna probe. - Package or release metadata impact: none. - Security, privacy, process, or containment review: the worker is still terminated when the deadline fires. The heap request is unchanged. A longer deadline only extends that existing supervision. ## Author readiness Human owner: @morluto - [x] 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. - [x] I checked the evidence above, confirmed it supports the current change, and recorded meaningful validation gaps. - [x] I declare this PR ready for initial maintainer review. ## Before merge - [x] This PR addresses a concrete problem or an agreed enhancement. - [x] Material scope and authority questions are resolved, and any required maintainer scope decision covers the final diff. - [x] The PR has one focused outcome and the title follows `type(scope): outcome`. - [x] Related issue is linked, or the reason for not linking one is stated above. - [x] Tests cover changed observable behavior and meaningful failure paths. - [x] Owning docs, contracts, and generated metadata are updated where needed. - [x] User-visible CLI/MCP changes include representative output. - [x] I checked the final diff for secrets, unrelated cleanup, and unsupported claims. <!-- CURSOR_AGENT_PR_BODY_END --> <div><a href="https://cursor.com/agents/bc-2e60afce-9d76-5143-b7d9-f1a858fdb35c?cursor_ref=pr_footer&cursor_cta=open_in_web"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/open-in-web-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/open-in-web-light.png"><img alt="Open in Web" width="114" height="28" src="https://cursor.com/assets/images/open-in-web-dark.png"></picture></a>&nbsp;<a href="https://cursor.com/background-agent?bcId=bc-2e60afce-9d76-5143-b7d9-f1a858fdb35c&cursor_ref=pr_footer&cursor_cta=open_in_cursor"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/open-in-cursor-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/open-in-cursor-light.png"><img alt="Open in Cursor" width="131" height="28" src="https://cursor.com/assets/images/open-in-cursor-dark.png"></picture></a>&nbsp;</div> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-01 21:46:26 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
morluto/rea#7242
No description provided.