Repository navigation
feat(config): make the regex matching deadline configurable - #6267
Conversation
REA_REGEX_MATCHING_DEADLINE_MS defaults to 5000 ms and refuses values outside 1..2147483647. Recovery and capability text name the effective deadline, its source, and how to change the setting. Co-authored-by: morluto <[email protected]>
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ae96ddbe3e
ℹ️ 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".
[Medium impact] The PR appears safe to merge; no blocking issue remains. SummaryMakes
Diagram%%{init: {'theme': 'neutral'}}%%
flowchart TD
E["Selected environment"] --> V["Shared deadline schema"]
V --> C["AppConfig"]
C --> H["Hopper"]
C --> K["Kuna"]
H --> W["Regex worker timer"]
K --> W
E --> S["Setup selects registration settings"]
S --> R["Check merged client environment"]
R --> P["Save client registration"]
Reviews (2) · Last reviewed commit: "test(config): restore a stubbed regex ma..." · Reviewed by Greptile |
prasad2512
left a comment
There was a problem hiding this comment.
This is a very thorough and well-designed addition. Making the regex matching deadline configurable while strictly enforcing boundaries avoids accidental worker starvation on large binaries.
A few technical observations and suggestions:
1. Great Defensive Boundary on 32-bit Max Timeout
The decision to enforce MAXIMUM_REGEX_MATCHING_DEADLINE_MS = 2_147_483_647 (signed 32-bit limit) is spot-on. In Node.js, values exceeding 2^31 - 1 trigger integer overflow and cause setTimeout to clamp to 1 ms, which would immediately fail every regex query. Enforcing this explicitly in regexMatchingDeadline.ts rather than letting it fail silently is great defensive engineering.
2. Idiomatic Timer Spy in RegexMatcher.test.ts
In src/process/RegexMatcher.test.ts:
const delays: number[] = [];
const original = global.setTimeout;
global.setTimeout = ((handler, timeout, ...args) => {
if (typeof timeout === "number") delays.push(timeout);
return original(handler, timeout, ...args);
}) as typeof setTimeout;
try {
// ...
} finally {
global.setTimeout = original;
}Suggestion: Rather than manually monkey-patching global.setTimeout with a cast as typeof setTimeout, we can use Vitest's built-in vi.spyOn (similar to V8InspectorProvider.partial.test.ts):
const timeoutSpy = vi.spyOn(globalThis, "setTimeout");
try {
await matchRegexValues({
operation: "search_procedures",
pattern: "^a",
caseSensitive: true,
values: ["a"],
deadline: { deadlineMs: 10_000, source: "setting" },
});
expect(timeoutSpy).toHaveBeenCalledWith(expect.any(Function), 10_000);
expect(timeoutSpy).not.toHaveBeenCalledWith(expect.any(Function), 5_000);
} finally {
timeoutSpy.mockRestore();
}This avoids global object mutation risks during parallel worker runs and removes manual type casting.
3. Whitespace Resiliency in Environment Parsing
In regexMatchingDeadlineMsSchema:
const decimalInteger = /^[1-9]\d*$/u;If an operator exports REA_REGEX_MATCHING_DEADLINE_MS=" 5000 " with accidental leading/trailing whitespace (common in .env files or shell profiles), the current regex rejects it with ConfigurationError. Consider adding .trim() before matching decimalInteger to make environment parsing slightly more forgiving, or explicitly note the zero-whitespace expectation in configuration docs.
Overall, the propagation through AppConfig, HopperRegexSearch, KunaQueryWork, and capability text diagnostics is exceptionally clean!
Setup validated REA_REGEX_MATCHING_DEADLINE_MS but left it out of the selected registration environment, so a caller override never reached the launched server and matching fell back to 5000 ms. Co-authored-by: morluto <[email protected]>
Kuna deadline assertions now unstub the environment in finally, so a thrown construction or expectation cannot leave the setting stubbed. Co-authored-by: morluto <[email protected]>
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
* 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]>
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_MSwas 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 (defaultorsetting), default, floor, and maximum.A caller override such as
REA_REGEX_MATCHING_DEADLINE_MS=10000 rea setupwas validated and then omitted from setup-created MCP registrations, so the launched server returned to 5000 ms.Change and scope
src/config/regexMatchingDeadline.tsowns the setting. Startup (parseConfig) and doctor (parseEnvironment) resolve it with the same schema. The effective deadline is stored onAppConfigand passed into Hopper and Kuna, which pass it toRegexMatcher. A directKunaProviderresolves the selected environment instead of ambientprocess.env.Setup now keeps
REA_REGEX_MATCHING_DEADLINE_MSinSELECTED_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
setTimeoutdelay is clamped to 1 ms, so it is refused rather than left unbounded. Zero, negative, non-decimal, and out-of-range values areconfiguration_invalidand 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
src/config/regexMatchingDeadline.tsparses the setting;parseConfigresolves it before providers match.explicitSetupRegistrationEnvironmentpreserves a caller-selected value when setup writes a registration.search_proceduresandsearch_stringsdescriptions nameREA_REGEX_MATCHING_DEADLINE_MS, the 5000 ms default, and the 2147483647 ms maximum. Capability and deadline failures name the effective value and source.matching_deadline_sourcebesidematching_deadline_ms.docs/public/product-catalog.json), package, or installation impact (CI generates and validates ignored catalogs andskills/; 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.
Evidence and regression coverage
REA_REGEX_MATCHING_DEADLINE_MS=200stops early. Ambientprocess.envdoes not override the selected environment. The Kuna capability assertion restores stubbed environment infinally. Setup-host state includes10000when set and omits the key when unset. Public Codex and Kimi setup writesREA_REGEX_MATCHING_DEADLINE_MS=10000and still omitsREA_UNRELATED_MARKER.matching_deadline_ms: 5000and takes about 5.4 s. Before this fix,SELECTED_REGISTRATION_SETTINGSdid not include the deadline, so setup-created registrations dropped the override.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 usessource settingand10000 ms.For evidence-bearing changes:
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 bycheck:fastlint.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=200on the selected environment finished in 568 ms and reported sourcesetting.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 preserved10000.Compatibility, safety, and release
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.Author readiness
Human owner: @morluto
Before merge
type(scope): outcome.