Repository navigation
fix: emit v-mode-compatible patterns for tool schemas - #1220
Conversation
Character classes in emitted patterns carried unescaped '-', '/' and '['. Annex-B and u-mode accept them, so REA's own Zod validation (u) and every u-based validator never saw a defect, but v-mode rejects ClassSetSyntaxCharacters and Ruby rejects [^s[]]. With 6.1.0 tools/list, 117 pattern fields across 11 tools were rejected under v. The characters are escaped as \x2d, \x2f, \x5b and \x5d rather than \-/\//\[, because oxlint --fix removes an escaped '-' inside a character class as a useless escape, so an escape-only change does not survive the pre-commit hook. \x2d-style escapes are valid under Annex B, u and v, are matched identically, and are not useless-escape candidates. 22 pattern literals in 18 files are touched; no other token changes.
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: 0db50d731d
ℹ️ 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".
The offset datetime site projected Zod's offset class as [ +- ], which no escape in this repository's sources can reach, so evaluate_reconstruction_coverage stayed unreachable for exactly the clients this change targets. It now uses offsetDateTimeSchema in src/domain/offsetDateTime.ts: the same accepted set with the offset class escaped as [ +\x2d ]. Adds tests/boundary/mcp/advertisedPatternsVMode.test.ts, which performs the real tools/list projection, traverses every advertised input and output schema, compiles each pattern under v, and asserts the inventory it walked so a silent traversal collapse fails instead of passing vacuously.
|
Second review pass on the pushed commits (an independent model, separate from the Codex review). One finding taken, three noted as out of scope. Taken — the parity claim had no test. Not taken — out of scope for this fix, happy to follow up separately:
Validation on the final commit: fast lane 3,463 passed / 4 skipped, |
|
Thank you for making the schemas v mode compatible. I went through the escaped reserved characters and the offset datetime schema replacement, plus the new boundary regression that compiles every advertised input and output pattern. Fixing the 12 unique rejected patterns across 11 tools so providers no longer reject the whole request before the model runs is important work. Really grateful for the careful census and tests. |
* fix: emit v-mode-compatible patterns for tool schemas Character classes in emitted patterns carried unescaped '-', '/' and '['. Annex-B and u-mode accept them, so REA's own Zod validation (u) and every u-based validator never saw a defect, but v-mode rejects ClassSetSyntaxCharacters and Ruby rejects [^s[]]. With 6.1.0 tools/list, 117 pattern fields across 11 tools were rejected under v. The characters are escaped as \x2d, \x2f, \x5b and \x5d rather than \-/\//\[, because oxlint --fix removes an escaped '-' inside a character class as a useless escape, so an escape-only change does not survive the pre-commit hook. \x2d-style escapes are valid under Annex B, u and v, are matched identically, and are not useless-escape candidates. 22 pattern literals in 18 files are touched; no other token changes. * fix: replace the Zod offset pattern and guard the advertised catalog The offset datetime site projected Zod's offset class as [ +- ], which no escape in this repository's sources can reach, so evaluate_reconstruction_coverage stayed unreachable for exactly the clients this change targets. It now uses offsetDateTimeSchema in src/domain/offsetDateTime.ts: the same accepted set with the offset class escaped as [ +\x2d ]. Adds tests/boundary/mcp/advertisedPatternsVMode.test.ts, which performs the real tools/list projection, traverses every advertised input and output schema, compiles each pattern under v, and asserts the inventory it walked so a silent traversal collapse fails instead of passing vacuously.
Summary
tools/listemitspatternstrings that are invalid under ECMA-262vmode, and one of them(
^[^\s[\]]+$, used byobserve_native_calls) is also rejected by Ruby, per #1212. A provider thatvalidates tool
parameterswithformat: "regex"rejects the whole request before the modelruns, so the affected tools are unreachable rather than degraded.
Two changes: the reserved characters in the emitted pattern literals are escaped, and the one
pattern that came from Zod's offset datetime class is replaced by a schema whose pattern is valid
under
v. A boundary regression now compiles every advertised input and output pattern.Refs #1212.
Problem and expected behavior
Smallest trigger, no target artifact needed:
The emitted catalog must contain patterns that are valid in every engine a client may use.
Measured against the 6.1.0
tools/listwith the ECMA-262 engine in Node 22.23.1, two scopes,both reproducible — read the counts below as the 6.1.0 catalog: revisions after it emit fewer fields for the
same set of patterns (on
main: 988patternfields across input and output, the same 12 unique rejectedbefore this change):
patternfields, 71 rejected underv— the same censusreported in [Bug] MCP tool schemas emit regex patterns rejected under strict-mode validation (observe_native_calls blocks the whole request) #1212;
patternfields, 117 rejected underv, reducing to12 unique patterns across 11 tools
(
observe_native_calls,capture_browser_scenario,evaluate_reconstruction_coverage,compare_process_captures,open_binary,build_call_path,inspect_binary_layout,inspect_recorded_crash,compare_source_to_bundle,build_reconstruction_obligation_ledger,verify_reconstruction) — the two tools beyond theinput-only census carry the same patterns in their output schemas. All of them compile with no
flag and with
u, so Zod's own validation cannot observe the defect. Because schema compilationhappens before arguments are supplied, a single offending field is enough to fail the entire
tools request.
Change and scope
Escaped literals. 22 pattern literals in 18 files — no other token changes, no pattern is
rewritten. Reserved characters are escaped as
\x2d,\x2f,\x5band\x5drather than\-,\/and\[, because the repository's own pre-commit hook normalizes the shorter escapesaway (
oxlint --fixthrough lint-staged treats an escaped-inside a character class as auseless escape and removes it):
An earlier revision of this change used
\-and was reduced from 18 files to 5 by that hook.\xNNescapes are valid under Annex B,uandv, match the same characters, and are notuseless-escape candidates. Escaping
\:/\%/\~/\_would have been wrong in the oppositedirection:
uandvreject those as invalid escapes.Offset datetime.
src/domain/reconstructionCoverage.tsusedz.string().datetime({ offset: true }), and Zod projects that validator's offset class as[+-], which no escape in this repository's sources can reach. That site now uses the newoffsetDateTimeSchemainsrc/domain/offsetDateTime.ts: the same accepted set, with the offsetclass escaped as
[+\x2d]. This was not left as a dependency exception because the affectedtool (
evaluate_reconstruction_coverage) was still unreachable for exactly the clients thischange targets.
Regression.
tests/boundary/mcp/advertisedPatternsVMode.test.tsperforms the realtools/listprojection throughcreateServerand an in-memory transport, traverses everyadvertised input and output schema, and compiles each
patternunderv. It asserts theinventory it walked (>100 tools, >500 patterns) so a traversal that silently collapses fails
rather than passing vacuously.
Contract and boundary impact
datetime schema; validation text only.
patterntext changesfrom e.g.
[a-z0-9-]to[a-z0-9\x2d]and from[+-]to[+\x2d], both equivalent underAnnex B and
uand now also valid underv.still rejects the same non-conforming strings.
pattern text, and
docs:checkpasses without regenerating anything.Evidence and regression coverage
Tests added or updated:
tests/boundary/mcp/advertisedPatternsVMode.test.ts(new boundaryregression over the advertised projection).
Base reproduction: restoring
z.string().datetime({ offset: true })inreconstructionCoverage.tswhile the regression is present fails it withReplacing that schema makes it pass. Before the change the whole catalog was rejected under
vwith nothing in CI able to notice.User-visible CLI/MCP output (if applicable): a client that validates schemas with
format: "regex"can dispatch the 11 affected tools instead of failing the whole request.Remaining proof gaps: none known for the advertised catalog; the regression covers future
additions, and provider-level behavior is untouched.
Validation performed
new RegExp(pattern, "v" | "u" | undefined)over all 22 changed pairs — all 22 originals throwunder
v; all 22 patched patterns compile underv,uand with no flags.u) vs patched (vandu), over 1,525 strings per pattern(21,340 comparisons): empty input,
-,/,[,],\,:,~,0x1,0XAB,s:0x1f,%2Fhost:0xff, base64 samples, CSP directive names, module paths and 400k generated randomstrings — 0 divergences.
Z,+02:00,-03:00, a date-only string and anon-date: identical verdicts to
z.string().datetime({ offset: true }).npm run build:unlockedthen a realinitialize+tools/listhandshake against the localbuild — rejected input-and-output patterns went from 117 to 0 (input-only scope: 71 to 0).
npx vitest run --project mcp-boundary tests/boundary/mcp/advertisedPatternsVMode.test.ts—1 passed, and 1 failed with the datetime schema restored.
npx vitest run --project domain --project services --project adapters --project conformance --project evaluation— 3,427 passed, 4 skipped.npx tsc --noEmit— exit 0.npm run docs:check— 2 tasks successful.Compatibility, safety, and release
behavior is touched.
validation patterns, and it removes a state where a strict client silently loses tool access.
Review checklist
type(scope): outcome.