Repository navigation
Description
Found while grading #1445 against v0.0.159. Reproduced with a synthetic page; it wastes budget, it does not miss a detection.
When a page has about 7 to 10 scripts of around 40,000 bytes plus a late bundle (amended 2026-11-02: the mechanism is wider than this shape, see the section below), the technology-detection sampler (cloud caps: 512 KB page budget) sends part of each script twice. Probe: 7 scripts of 40,000 bytes (unique lines) plus one 200 KB late bundle: each 40,000-byte script is emitted as 63,619 bytes. The whole file is sent once, then bytes 16,425 to the end are sent a second time (524 of 889 lines repeat, 23.6 KB per script, 165 KB or more of the 524,288-byte page total is duplicate text). The 12 x 10 KB + 7 x 40 KB + late-bundle shape does the same (3 scripts at 63,619 bytes, 1 at 52,462). It does not occur with 1 or 3 scripts or with 13 or more 40 KB scripts, occurs at 8 and 10 scripts and partly at 12, and reproduces with a different filler. The page, audit and bundle budgets still hold and the loaders in the probe are still detected, but duplicate text spends budget that a later bundle's window could have used.
The existing fuzz in packages/audit-engine/tests/tech-extras-budget-1420.test.ts asserts the budgets and a byte-identical rebuild but not that no text is sent twice (the #1445 criterion 4 names "repeat no text").
Amendment 2026-11-02: mechanism and corpus measurement
Original text above is kept. The "7 to 10 scripts" shape is one way to hit a wider mechanism, and it predates #1445 (v0.0.151 is byte-identical). Mechanism: a script over the 64 KB bundleBytes disables the all-whole path; scripts in (16 KB, 64 KB] then get a floor head plus extras, and the head grows back to the whole file, so the extras repeat bytes the head already holds.
Minimal two-script repros (one small script S, one other script O): S=40,000 / O=70,000 emits 63,619 bytes with 1,038 repeated lines; S=20,000 / O=70,000 emits 23,619 with 164; S=17,000 / O=70,000 emits 17,619 with 28; S=40,000 / O=60,000 emits the whole file with 0 repeated lines (no repeat).
Corpus (masked counts, measured by squirrelscan-53): 337,080 of 608,313 pages (55 percent; 45 percent of sites) match the mechanism, and 291,310 of them have a script over 512 KiB, where the duplicate bytes compete with the page budget. No detection loss was seen; it wastes budget.
Acceptance Criteria addition
- The two-script shapes above (S=40,000, 20,000 and 17,000 with O=70,000) are covered by a failing-first test: no line of S appears twice in what is sent, and S is emitted once whole (amended 2026-11-02)
Acceptance Criteria (original)
- A failing-first test builds a page of 7 to 10 scripts of about 40,000 bytes (unique lines, built from parts) plus a late bundle at the cloud caps and asserts that no line of any script appears twice in what is sent (it fails on v0.0.159 and passes after the fix)
- The existing fuzz also asserts that no text is repeated within a script's emitted window set
- The page, audit and bundle budgets and the byte-identical rebuild still hold, and a detector whose literal sits in the late bundle's window is still found
- The docs for the bundle sampler say that a script's text is sent at most once
Refs #1445.
nik
Activity
WilliamK112 commentedon Nov 2, 2026
I can take this. I’ll first pin the 7–10 × ~40 KB duplicate-window shape with a failing test, then make the smallest sampler change that prevents overlapping emissions while preserving the cloud budgets, late-bundle detection, byte-identical rebuild, and existing fuzz coverage; I’ll update the sampler docs and run the focused audit-engine suite.
nc9 commentedon Nov 2, 2026
Body amended (original text kept, marked as amended 2026-11-02): the mechanism, two-script repros, corpus counts and one added criterion. Measured by squirrelscan-53: two scripts trigger it, it predates #1445, and 337,080 of 608,313 corpus pages match the mechanism; no detection loss seen. A fix is in review.
nik
fix(tech-detect): avoid duplicate bundle text #1534
fix(tech-detect): bundle head tops up to the allowance after the boun…
nc9 commentedon Nov 4, 2026
Acceptance check against main 7c31d5b. The fix is in v0.0.161 (89fd475, then 0ff91db for the allowance top-up).
packages/audit-engine/tests/tech-bundle-allowance-1534.test.ts"page shapes from the #1534 report repeat no full line" > "two scripts: 40000 / 20000 / 17000 and 70000 bytes, the small one is sent once and whole". I ran that file against the sampler sources of the parent of 89fd475: all three fail there, and all pass on main.tech-extras-budget-1420.test.ts"7 x 40 KB scripts plus a late bundle send no script line twice (#1534)" fails on the parent of 89fd475 and passes on main. The 1534 file adds 7, 13 and 16 scripts.tech-extras-budget-1420.test.ts"200 seeded pages: the page, audit and bundle budgets hold and a rebuild is byte-identical" now callsexpectEachMarkerOnceper script; it fails on the pre-fix sampler (seed 6, script 2) and passes on main.posthogandsupabaseare detecteddocs/cloud/technologies.mdxsampler bullet: the bundle "is read up tobundle_byteswith no text sent twice"Ran on main:
tech-bundle-allowance-1534.test.ts(54 pass),tech-extras-budget-1420.test.ts(30 pass).All boxes are proven, so closing.
nik