Repository navigation
Conversation
…he extras across hints round by round, reserve the tail #1420 Signed-off-by: Nik Cubrilovic <[email protected]>
This was referenced Oct 31, 2026
Contributor
Author
|
Superseded by #1433, shipped in v0.0.151. nik |
nc9
added a commit
that referenced
this pull request
Nov 5, 2026
…essEntities #1421 Signed-off-by: Nik Cubrilovic <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1420.
Cause (confirmed in the code). Past the first 256 KB of a bundle,
sampleBundleExtrasfills a 24 KB budget with windows around hint literals, then the tail. 184 of the 194script-contentdetectors declared no hint (Sentry.init, the React devtools hook,posthog.init,Stripe(, GA4 config, the ad pixels), so they could match only in whatever tail the windows left. #1379 let the windows take more (24 to 48 kept hits, no kept cap for pattern-tested hints, new hint literals), so the tail shrank or vanished and those detections were lost.Fix, three parts, all in the sampler (
packages/tech-detect/src/bundle-sample.ts, newhint-derive.ts).hintgets the literals its pattern requires, derived from the regex source (deriveHints): per top-level alternative, the longest run of plain characters every match must contain (at least 4). Conservative by construction: a group, class,., escape class, or a character followed by?,*or{ends a run and is never part of a hint, so a hint is never a literal a match can lack. Case-insensitive patterns get lower-cased hints and are searched in a lower-cased copy (only when its length matches the original). Of the unhinted detectors, more than 120 now have one; the rest stay tail-only.Cost. 1 MB benign: 22 ms, 5 MB: 86 ms, 16 MB: 275 ms; a body of dense hits for five detectors: 181 ms. The hostile 5 MB sampler test is unchanged.
Tests (fail on the old sampler).
packages/tech-detect/tests/extras-budget-1420.test.ts(13):deriveHintscases, a soundness sweep over every script-content pattern (each derived hint is a literal part of its pattern), a lateSentry.initwith 400 earlier Supabase and Firebase windows (the AC test), first-window-before-second fairness across Sentry, PostHog, React and Stripe, a case-insensitive detector found, the tail reserve, and a hostile single-literal body.packages/audit-engine/tests/tech-extras-budget-1420.test.ts(3): the same through the cloud payload path at the real 64 KB / 512 KB caps withbuildTechInputs: Sentry, then React, PostHog and Stripe, late in a 700 KB bundle with a crowd of earlier windows.What I could not do here. The AC's corpus comparison against v0.0.140 needs 53's stored corpus (10,133 sites); I do not have it. The unit tests pin the mechanism and the soundness of the derived hints, not the 30 real sites. Please re-run the corpus with this branch: expect Sentry back on all 30, no losses against v0.0.140. Separately, 53's note that the uncapped build still loses Contentful (4 sites) and Clarity (4) against v0.0.140 does not come from the extras budget (an uncapped body is read whole); that is probably candidate ordering (
MAX_IN_CODE_CANDIDATES, the first matches sitting in strings or comments) and is filed as #1422.Interplay with #1413 (merging the local whole-bundle scan into the signed-in section, #1406). It touches the CLI and audit-engine
technologies.tsand the docs, not the sampler, so they do not conflict in code (only CHANGELOG andtechnologies.mdxtext). They are complementary, not one subsuming the other: #1413 gives a signed-in CLI audit the whole-bundle result, while this fixes the capped payload everything else still sends (the hosted services andcloud-audit-runtime, which keep the 64 KB / 512 KB caps and the 256 KB script limit, and the CLI payload itself).Docs:
docs/cloud/technologies.mdx(what the extras hold). CHANGELOG under Unreleased / Fixed. Skill: no change needed.nik