fix(mcp): re-emit advertised patterns in a portable regex grammar (#10582)

* test(mcp): check advertised schemas against a portable dialect in every profile

* fix(mcp): re-emit advertised patterns in a portable regex grammar

* fix(mcp): validate advertised dialect by selected profile

* fix(mcp): preserve schema widening through references

* fix(mcp): refuse zero-padded repeat bounds and record host-specific path patterns

* fix(mcp): keep references valid when presentation widens their targets

* fix(mcp): relax references into negations and conditionals presentation may remove

* fix(mcp): keep astral literals and dynamic references widening in every mode

* fix(mcp): omit astral literals and relax untracked references when presentation widens

* fix(mcp): read reference pointers by schema position, not segment spelling

* fix(mcp): protect references into collapsing boolean unions and keep referencing branches out of the collapse

* fix(mcp): omit patterns whose classes name astral characters

* fix(mcp): decide union collapse and pointer protection from canonical branches

* docs(mcp): document non-u astral matching and pin BMP agreement across V8 modes

* test(mcp): expect the advertised base64 schema to omit the unbounded pad-bit probe

* fix(mcp): protect references into unevaluated keywords lost evaluation removes

* fix(mcp): emit stack-safe classes with non-ASCII members and protect draft-07 reference siblings

* fix(mcp): protect references into literal siblings of relaxed draft-07 references
This commit is contained in:
morluto authored and GitHub committed 2026-11-15 17:06:43 +08:00
1 parent 5bf66f7500
commit d0fee4e58e
13 files changed
+1575 -195

No files matched your search

+14 -4
View File
@@ -212,9 +212,9 @@ directives are errors. `vitest/valid-expect` warns (`maxArgs: 2`) because valid
collected assertions can be awaited later. `import/no-duplicates` warns with
`preferInline: false`.
`no-useless-escape` keeps intentional `\-` regex escapes because advertised
patterns must also compile in `v` mode; the catalog regression checks every
advertised pattern.
`no-useless-escape` keeps intentional `\-` regex escapes. Source regexes need
no escaping for clients: the presentation re-emits every advertised pattern in
the portable grammar (`src/contracts/portablePattern.ts`).
Fast lint stays syntax-based. `npm run lint:typed` runs serially with pinned
`oxlint-tsgolint` 7.0.2005 and records native plus typed diagnostics in
@@ -294,7 +294,17 @@ advertised dialect: the keyword allowlist, size and depth limits, and the regex
grammar that compiles in V8, Python, RE2 and Rust. `advertisedDialect.test.ts`
lists every input, output and catalog profile combination and compares the
violation counts with `advertisedDialectBaseline.ts`, which may only shrink;
the packaged catalog check applies the same rules to the default profiles. Keep canonical rejection checks separate from the
the packaged catalog check applies the same rules to the default profiles.
Advertised patterns, input and output, are enforced at zero:
`portablePattern.ts` re-emits each one exactly, widens it, or omits it, and the
presentation drops any enclosing `not` or `if` and turns `oneOf` into `anyOf`
when a pattern widens. `portablePattern.test.ts` pins the same acceptance of
BMP strings in V8's plain, `u` and `v` modes. Python, Go and Rust read code
points as `u` does; Python's `$` also matches before a final newline, which
only widens. A client compiling without `u` may still reject one astral
character where a wildcard, shorthand or negated class must match it (for
example `^[\S]$`); `PortablePatternProjection` documents this accepted
limitation. Keep canonical rejection checks separate from the
intentionally reduced compact advertisement, and probe actual client renderers
when changing schema representations.