Status: Accepted (2026-11-28, DC2; fixes security review SR-01, SR-08, SR-15 in packages/doc; S1 wires the budgets in the doc workers). Changes shared/src/doc-api.ts (FindBudget, FindResult.truncated, SvgOptions).
Shared doc workers run find and toSvg for every tenant (docs/security/review-2026-11.md):
toSvg built the whole string before its size check (SR-08);nameRegex runs only on V8’s linear-time engine (flag l, enabled by --enable-experimental-regexp-engine), against the first 256 UTF-16 units of each name.
QueryError (field: 'nameRegex').checkNameRegex / compileNameRegex expose the same rule to validators, so they cannot drift.find takes a budget {timeMs?, maxNodes?}. Work is counted per node, plus string tests by length, plus 1,024 units per regex test; the clock is read every 1,024 units.
truncated: true, a lower-bound total and a cursor.toSvg takes {maxChars?, timeMs?}. Output is counted while it is built and the build throws QueryError('region') before passing the cap (default 32 Mi chars), or once the deadline passes (checked every 256 elements). Text is cut at 4,096 chars per node plus an ellipsis.esc maps C0 controls (except tab, LF, CR), U+FFFE, U+FFFF and lone surrogates to U+FFFD. The doc rules do not reject these characters:
DOC_RULES_VERSION and invalidate existing pages, for a problem of one export format.l but execute with backtracking, plus V8’s excessive-backtrack fallback: still ~0.2 ms per name and unbounded per request. Rejected.find and toSvg callers must handle truncated and QueryError.packages/doc/test/query-safety.test.ts. It runs the three probe patterns on 100K x 1 KB names (each 40 ms-budget call < 250 ms) and checks budgeted paging equals unbudgeted results over many query shapes. It also covers the 2,000 x 64 KiB apostrophe page, the build-time budget and the XML sanitizer.