Commit 08c36fe
Budget against max per-clause encoding ratio
The whole-filter ratio is an average; a chunk that happens to contain
only the heavier-encoding clauses (e.g. heavy clauses clustered at one
end of the filter) can exceed the average ratio and push the full URL a
few bytes past _WATERDATA_URL_BYTE_LIMIT. The overflow was invisible in
practice — the 8,000 declared budget vs 8,200 observed 414 cliff gave
enough headroom — but the computed budget was technically being
violated, and a more adversarial clause mix could grow the overflow.
Compute the encoding ratio from the heaviest-encoding clause instead of
the whole filter. Adds one extra chunk on adversarial inputs (8 instead
of 7 for 100 heavy + 400 light) in exchange for every chunk provably
staying under the declared URL limit.
Verified live: the adversarial clustered-heavy filter now produces 8
chunks with max URL 7806 bytes, all returning 200 OK.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent 6868247 commit 08c36fe
2 files changed
Lines changed: 46 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
350 | 350 | | |
351 | 351 | | |
352 | 352 | | |
353 | | - | |
354 | | - | |
355 | | - | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
356 | 358 | | |
357 | 359 | | |
358 | 360 | | |
359 | 361 | | |
360 | | - | |
| 362 | + | |
| 363 | + | |
361 | 364 | | |
362 | 365 | | |
363 | 366 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
337 | 337 | | |
338 | 338 | | |
339 | 339 | | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
340 | 379 | | |
341 | 380 | | |
342 | 381 | | |
| |||
0 commit comments