Skip to content

tech-detect: allocate hint windows across all of a page's bundles before whole remainders (#1420 residual) #1445

Closed

Description

@nc9

Summary

Residual of #1420 (the extras budget for capped bundle scans). On a corpus run, the revision that sends a small script's remainder whole, after the head, gave back about 1.3 percent of the detections an earlier revision of the same fix made (about 70 of 35,000 sites: PostHog, React, Supabase, Sentry, Stripe and a few more; none are losses against the release before #1420).

Mechanism: the page byte budget (512 KB) is already full on those pages. Sending the remainder of a small early script whole uses room that the earlier revision spent on hint windows of later bundles, so when the loader literal sits in a later bundle's hint window, the attached copy loses it.

Acceptance Criteria

  • Hint windows are allocated across all of a page's bundles first; what is left of the page and audit budgets then goes to whole remainders and tails.
  • A synthetic fixture reproduces the mechanism: a page of about 34 scripts at the 512 KB page cap, where an earlier small script's whole remainder would eat the room and the loader literal (for example a posthog.init( or Stripe( call) sits in a later bundle's hint window. Both are found. The fixture fails on the current code.
  • No regression of the shapes the sampler tests already pin (late loaders after crowd windows, tracker-lost long strings, siblings exhausting the page budget, the 13 shapes that regressed between revisions): each still passes at the cloud caps (64 KB / 512 KB / 1 MB) and the local caps. (amended 2026-11-02: the "13 shapes" are not enumerated anywhere, so the pinned shapes are named by their tests: in packages/audit-engine/tests/tech-extras-budget-1420.test.ts "a late Sentry.init after hundreds of earlier hint windows", "React, PostHog and Stripe late in the same bundle", "a loader in a small script survives the string tracker, at both caps (fix(tech-detect): derive search literals for unhinted detectors and share the window budget #1420 #1433 corpus)", "the budget steps of a page (tech-detect: allocate hint windows across all of a page's bundles before whole remainders (#1420 residual) #1445)", "the window scan is bounded and shared fairly (tech-detect: allocate hint windows across all of a page's bundles before whole remainders (#1420 residual) #1445)"; the local caps in tech-local-caps-1387.test.ts; the late-window reserve in tech-window-reserve-1510.test.ts; each passes at the cloud caps and at the local caps)
  • Extras never exceed the budget, are deterministic, repeat no text, and the tail reserve still holds, checked by the existing budget fuzz.
  • Cost stays linear; the 33-bundle comparison against whole-body truth shows 0 regressions and 0 new false detections.
  • docs/cloud/technologies.mdx describes the allocation order accurately; no customer or site names appear in tests or docs.

Activity

  1. added
    bug
    size: M
    rules
    on Oct 31, 2026
  2. added theissue type on Oct 31, 2026
  3. nc9 commented on Oct 31, 2026

    @nc9
    ContributorAuthor

    Verified against main after v0.0.152 (bundle hint windows are chosen across all bundles before any remainder or tail). Met and ticked: criteria 1 (allocation in rounds, tests pass) and 6 (docs match, no site names). Open: criterion 2 (the synthetic fixture uses 25 scripts, not about 34, and it is not shown to fail on the old code), criteria 3 and 4 (no fuzz test and no explicit determinism test found; the budget and tail-reserve tests pass) and criterion 5 (no 33-bundle comparison against whole-body truth recorded). Leaving this open for those.

    nik

  4. nc9 commented on Nov 1, 2026

    @nc9
    ContributorAuthor

    Checked against main after v0.0.154. Ticked: criterion 2 (the 34-script fixture exists), on top of 1 and 6 already ticked. Open: that the fixture fails on the old code is not proven in the repo, the 13 shapes are not enumerated, the fuzz has no assertion that no text is repeated, and the 33-bundle comparison is not recorded. Leaving this open for those.

    nik

  5. nc9 commented on Nov 2, 2026

    @nc9
    ContributorAuthor

    Amended criterion 3 (original text kept visible): the "13 shapes that regressed between revisions" are not listed anywhere in the repo or on this issue, so the criterion now names the shapes the sampler tests actually pin, by file and test name, and asks that each pass at the cloud and local caps. They all pass on v0.0.159. Criterion 5 (the recorded 33-bundle comparison) stays open as a corpus step, and the sampler sending part of a script twice on pages of 7 to 10 scripts (criterion 4's "repeat no text") is tracked in #1534.

    nik

  6. nc9 commented on Nov 2, 2026

    @nc9
    ContributorAuthor

    Ticked criterion 5. Corpus comparison of the 33-bundle set, v0.0.151 against v0.0.159 (masked, run by squirrelscan-53): 0 regressions, 0 new false detections, whole-body truth identical. Cost is linear: at 3.5, 7, 14.1 and 28.1 MB the time is 295, 581, 1,196 and 2,297 ms on v0.0.151 and 312, 605, 1,057 and 1,054 ms on v0.0.159. Criterion 4 stays open for #1534 (repeated text); criterion 3 is amended as noted in the body.

    nik

  7. nc9 commented on Nov 4, 2026

    @nc9
    ContributorAuthor

    Acceptance check against main 7c31d5b. The allocation shipped in v0.0.152 (d8bc9c4) and the deterministic-allocation test in v0.0.154 (10663f7); everything below is in v0.0.161.

    # Criterion Result Evidence
    1, 2, 5, 6 allocation order, 34-script fixture, linear cost and corpus, docs PASS (ticked earlier)
    3 No regression of the pinned shapes at the cloud caps and the local caps FAIL (gap) Every named case passes on main: tech-extras-budget-1420.test.ts (30 pass), tech-local-caps-1387.test.ts (12 pass), tech-window-reserve-1510.test.ts (12 pass). But the criterion says each passes at the cloud caps and at the local caps, and the named cases in tech-extras-budget-1420.test.ts run at DEFAULT_TECH_BUNDLE_LIMITS only (the #1433 cases add a 24 KB bundle cap, the seeded fuzz three smaller or larger caps); none runs at DEFAULT_LOCAL_TECH_BUNDLE_LIMITS. tech-local-caps-1387.test.ts covers local reads separately but not these shapes.
    4 Extras never exceed the budget, deterministic, repeat no text, tail reserve holds, by the existing fuzz PASS "200 seeded pages: the page, audit and bundle budgets hold and a rebuild is byte-identical" asserts all three byte caps, a JSON-identical rebuild and, per script, that no line marker appears twice (added by 89fd475 for #1534; I ran it against the sampler sources of that commit's parent and it fails there, passes on main). Determinism also has "the same page twice gives byte-identical extras". The tail reserve has "the tail reserve holds on a page" and "a window-heavy bundle still sends its tail (the reserve holds)".

    Left open for criterion 3. To close the gap, either run the named cases (or a local-cap variant of each) at DEFAULT_LOCAL_TECH_BUNDLE_LIMITS, or amend the criterion to say the local scan reads bundles whole and point at tech-local-caps-1387.test.ts.

    nik

  8. nc9 commented on Nov 4, 2026

    @nc9
    ContributorAuthor

    Re-check of criterion 3 against main 8d22fa2. Criteria 1, 2, 4, 5 and 6 stay ticked; the sampler sources and the named test files have not changed since the previous check.

    I ran tech-extras-budget-1420.test.ts as an uncommitted copy with the limits swapped to DEFAULT_LOCAL_TECH_BUNDLE_LIMITS (8 MB bundle, 32 MB page, 64 MB audit) and the local detect options: 29 of 30 cases pass, including the late Sentry.init, React, PostHog and Stripe late in one bundle, the string-tracker loader, the window-scan bound and the seeded fuzz. The one failure is "the page budget is spent, not wasted: whole remainders fill what the windows left", which asserts that 24 scripts of 40 KB fill to within 8 KB of the page cap. That holds for a 512 KB cap and cannot hold for a 32 MB one (960 KB of input), so it is cap-specific by construction, not a regression.

    So the behaviour holds at both cap sets, but the repository only pins it at the cloud caps: no committed test runs these shapes at the local caps, and the one cap-specific case has no local equivalent. Criterion 3 stays unticked. To close, either commit a local-cap variant of the shape cases (leaving the page-fill case cloud-only), or amend the criterion to say the local scan reads bundles whole and point at tech-local-caps-1387.test.ts.

    nik

  9. nc9 commented on Nov 9, 2026

    @nc9
    ContributorAuthor

    Verified on main at 486cd13: the pinned shapes are tests in packages/audit-engine/tests/tech-extras-budget-1420.test.ts (Sentry.init near the end of a big bundle with hundreds of earlier hint windows, React/PostHog/Stripe late in one bundle, the 25- and 34-script page-cap fixtures, the seeded budget and determinism tests), tech-local-caps-1387.test.ts and tech-window-reserve-1510.test.ts. Those three files pass in full (54 tests, 0 fail). The last box is ticked and every other box was already checked.

    nik

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugrulessize: M

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions