fix(query-cache): measure pagination per page, reject bare W/" ETag, drop dead RPC helper (Q-6.3-12)

- cursor pagination re-serialized every accumulated item on each page
  (O(pages x total)) and used items.push(...page.items), which throws
  RangeError for a large page, so loadAll rejected instead of returning
  a Result. Each page is now measured once and summed (errs high by at
  most one byte per page), the item count is checked before copying,
  and items are appended one by one.
- conditional-validator-store accepted `W/"` as a weak ETag because its
  opening quote also satisfied endsWith('"'). The closing quote must now
  come after the opening one.
- browser-rpc-runtime's validTransportFailure had no callers, duplicated
  decodeTransportFailure and read properties directly, which RPC-RR-04
  forbids. Deleted (approved for this template).

Verified: new tests failed RED (18 serialized items instead of 6 because
the accumulated array was passed each time, RangeError for a 1,000,000
item page, `W/"` installed) and pass now. All lane gates pass except the
known removal-fixture test.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
DongHyeonka
2026-09-24 13:41:45 +09:00
co-authored by Claude Opus 5.5
parent 1b9e2c5ec6
commit 1d7ca9dcb8
5 changed files with 77 additions and 25 deletions
@@ -138,12 +138,11 @@ export function createConditionalValidatorStore(
function isSafeEntityTag(value: string): boolean {
if (value.length < 3 || value.length > 256) return false;
const opaque = value.startsWith('W/"')
? value.slice(3, -1)
: value.startsWith('"')
? value.slice(1, -1)
: null;
if (opaque === null || !value.endsWith('"')) return false;
const start = value.startsWith('W/"') ? 3 : value.startsWith('"') ? 1 : -1;
// Q-6.3-12. The closing quote must follow the opening one: a bare `W/"`
// ends with its opening quote and is unclosed.
if (start < 0 || value.length <= start || !value.endsWith('"')) return false;
const opaque = value.slice(start, -1);
return [...opaque].every((character) => {
const code = character.codePointAt(0) ?? 0;
return code === 0x21 || (code >= 0x23 && code <= 0x7e) ||