[PR #1299] [MERGED] fix(mcp): advertise input patterns without look-around #2779

Closed
opened 2026-10-17 21:10:08 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/morluto/rea/pull/1299
Author: @kaoru0822-kitauji
Created: 10/9/2026
Status: ✅ Merged
Merged: 10/9/2026
Merged by: @kaoru0822-kitauji

Base: main ← Head: fix/schema-patterns-without-lookaround


📝 Commits (1)

  • a8701ea fix(mcp): advertise input patterns without look-around

📊 Changes

4 files changed (+113 additions, -3 deletions)

View changed files

📝 src/domain/apple/dylibResolution.ts (+6 -2)
➕ src/domain/portableSchemaPatterns.test.ts (+79 -0)
📝 src/domain/process/processScenario.ts (+22 -1)
📝 tests/boundary/mcp/advertisedPatternsVMode.test.ts (+6 -0)

📄 Description

Summary

#1282 reported that a strict schema validator rejects every request while REA is registered, because tool inputSchema.pattern values used constructs its regex engine refuses. #1220 removed the two reported constructs (\0 and an unescaped [ inside a class). Two input patterns that same engine rejects were still advertised on main, both using negative look-ahead:

tool input pattern on main
trace_dylib_resolution roots[] `^(?!/)(?!(?:.*/)?.{1,2}(?:/
capture_process_scenario environment keys ^(?!REA_PROCESS_RUN_ID(?![\s\S]))[^=\u0000]+$

The reporter's measurements match the Rust regex crate. ripgrep (default engine: Rust regex) reproduces their pass/fail table exactly, and compiling every pattern from main's tools/list with it rejects exactly these two: error: look-around, including look-ahead and look-behind, is not supported. Because tool schemas ride along with every request, either one still makes the whole catalog unusable for such a client.

Closes #1282

Change

Same constraints, spelled without look-around:

  • Dylib roots: one or more segments joined by a single /. Each segment is non-empty, contains no /, \ or NUL, and is not . or ... A segment is spelled as "starts with a non-dot", or ". plus a non-dot", or ".. plus at least one character".
  • Environment names: environmentNamePattern(reserved) builds the complement of the one reserved word over [^=\u0000]. A name either diverges from REA_PROCESS_RUN_ID at some position, stops at a non-empty proper prefix, or continues past the full word. It remains a plain JSON Schema pattern. The caller-visible diagnostic (REA_PROCESS_RUN_ID is reserved by the process adapter) is unchanged.
  • tests/boundary/mcp/advertisedPatternsVMode.test.ts now also asserts that no advertised pattern contains look-around ((?=, (?!, (?<=, (?<!) or backreferences (\1–\9, \k<). It fails on main, naming these two tools.

Verification

  • src/domain/portableSchemaPatterns.test.ts checks equivalence against the old look-ahead regexes through the real Zod schemas: exhaustive over {a . / \ NUL} up to length 7 (97,655 roots), and the reserved name with prefixes, single-character insertions, substitutions, deletions and extensions (including =, NUL and non-ASCII). No mismatches.
  • Every pattern in this branch's tools/list (92 unique, input and output) compiles with ripgrep's Rust regex engine; on main, 2 are rejected.
  • npm run check:changed (603 passed), npm run docs:check
  • npm run test:focused -- on all of tests/boundary/mcp/*.test.ts plus every test that references dylib resolution or REA_PROCESS_RUN_ID (86 files, 344 tests passed)
  • CLI capture-process with REA_PROCESS_RUN_ID still returns invalid_request with the same reserved-name message.

🤖 Generated with Claude Code


🔄 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/1299 **Author:** [@kaoru0822-kitauji](https://github.com/kaoru0822-kitauji) **Created:** 10/9/2026 **Status:** ✅ Merged **Merged:** 10/9/2026 **Merged by:** [@kaoru0822-kitauji](https://github.com/kaoru0822-kitauji) **Base:** `main` ← **Head:** `fix/schema-patterns-without-lookaround` --- ### 📝 Commits (1) - [`a8701ea`](https://github.com/morluto/rea/commit/a8701eaf489692449739d5b2490502b1a14951c5) fix(mcp): advertise input patterns without look-around ### 📊 Changes **4 files changed** (+113 additions, -3 deletions) <details> <summary>View changed files</summary> 📝 `src/domain/apple/dylibResolution.ts` (+6 -2) ➕ `src/domain/portableSchemaPatterns.test.ts` (+79 -0) 📝 `src/domain/process/processScenario.ts` (+22 -1) 📝 `tests/boundary/mcp/advertisedPatternsVMode.test.ts` (+6 -0) </details> ### 📄 Description ## Summary #1282 reported that a strict schema validator rejects every request while REA is registered, because tool `inputSchema.pattern` values used constructs its regex engine refuses. #1220 removed the two reported constructs (`\0` and an unescaped `[` inside a class). Two input patterns that same engine rejects were still advertised on `main`, both using negative look-ahead: | tool | input | pattern on `main` | |---|---|---| | `trace_dylib_resolution` | `roots[]` | `^(?!\/)(?!(?:.*\/)?\.{1,2}(?:\/|$))(?!.*\/\/)(?!.*\/$)[^\\\u0000]+$` | | `capture_process_scenario` | `environment` keys | `^(?!REA_PROCESS_RUN_ID(?![\s\S]))[^=\u0000]+$` | The reporter's measurements match the Rust `regex` crate. ripgrep (default engine: Rust `regex`) reproduces their pass/fail table exactly, and compiling every pattern from `main`'s `tools/list` with it rejects exactly these two: `error: look-around, including look-ahead and look-behind, is not supported`. Because tool schemas ride along with every request, either one still makes the whole catalog unusable for such a client. Closes #1282 ## Change Same constraints, spelled without look-around: - **Dylib roots:** one or more segments joined by a single `/`. Each segment is non-empty, contains no `/`, `\` or NUL, and is not `.` or `..`. A segment is spelled as "starts with a non-dot", or "`.` plus a non-dot", or "`..` plus at least one character". - **Environment names:** `environmentNamePattern(reserved)` builds the complement of the one reserved word over `[^=\u0000]`. A name either diverges from `REA_PROCESS_RUN_ID` at some position, stops at a non-empty proper prefix, or continues past the full word. It remains a plain JSON Schema `pattern`. The caller-visible diagnostic (`REA_PROCESS_RUN_ID is reserved by the process adapter`) is unchanged. - `tests/boundary/mcp/advertisedPatternsVMode.test.ts` now also asserts that no advertised pattern contains look-around (`(?=`, `(?!`, `(?<=`, `(?<!`) or backreferences (`\1`–`\9`, `\k<`). It fails on `main`, naming these two tools. ## Verification - `src/domain/portableSchemaPatterns.test.ts` checks equivalence against the old look-ahead regexes through the real Zod schemas: exhaustive over `{a . / \ NUL}` up to length 7 (97,655 roots), and the reserved name with prefixes, single-character insertions, substitutions, deletions and extensions (including `=`, NUL and non-ASCII). No mismatches. - Every pattern in this branch's `tools/list` (92 unique, input and output) compiles with ripgrep's Rust `regex` engine; on `main`, 2 are rejected. - `npm run check:changed` (603 passed), `npm run docs:check` - `npm run test:focused --` on all of `tests/boundary/mcp/*.test.ts` plus every test that references dylib resolution or `REA_PROCESS_RUN_ID` (86 files, 344 tests passed) - CLI `capture-process` with `REA_PROCESS_RUN_ID` still returns `invalid_request` with the same reserved-name message. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-17 21:10:08 +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#2779
No description provided.