Skip to content

fix(rules): expose LCP preload evidence - #1127

Closed
WilliamK112 wants to merge 1 commit into
squirrelscan:mainfrom
WilliamK112:codex/lcp-preload-details-1074
Closed

WilliamK112 wants to merge 1 commit into
squirrelscan:mainfrom
WilliamK112:codex/lcp-preload-details-1074

Conversation

@WilliamK112

Copy link
Copy Markdown
Contributor

Summary

  • keep the existing per-page count and empty items, while adding bounded details with each unmatched candidate’s resolved URL
  • include the resolved image preload href and imagesrcset URLs used for comparison, capped with an explicit remainder count
  • preserve the evidence through null-document analysis and stored rule_results, and document the JSON/report behavior

Closes #1074

Tests

  • npx -y [email protected] test ./apps/cli/tests/rules/lcp-hints.test.ts ./packages/rules/tests/cwv-reuse.test.ts ./packages/rules/tests/lcp-fetchpriority.test.ts
  • npx -y [email protected] test ./packages/rules/tests/noscript-content.test.ts
  • npx -y [email protected] run typecheck in packages/core-contracts, packages/rules, and apps/cli
  • npx -y [email protected] run format:check and npx -y [email protected] run lint in apps/cli
  • npx -y [email protected] run docs:check
  • full rules suite: 7,558 passed; the existing resolution byte-budget case timed out under suite load and passed alone (55/55)
  • in-memory SQLite rule_results round trip retained candidate and preload details
  • detect-secrets-hook 1.5.0 on changed files

Docs: Updated docs/rules/perf/lcp-hints.mdx. Skill: none.

@WilliamK112
WilliamK112 force-pushed the codex/lcp-preload-details-1074 branch from d964ee6 to fc7fb8b Compare October 25, 2026 17:20
@nc9

nc9 commented Oct 25, 2026

Copy link
Copy Markdown
Contributor

Thanks, the rule side is clean: the bound is right (3 candidates, 10 preloads plus a remainder), the keys do not collide with the engine's reserved detail keys, the null-document path is tested, and the existing href/imagesrcset tests keep a preloaded hero passing. A few things before merge:

  1. JSON report on multi-page audits. packages/report/src/grouping.ts folds every page's lcp-preload check into one grouped check and merges details with { ...existing.details, ...details }, so squirrel report --format json ends up with the last page's candidates/preloads, unattributed, under a check that lists every affected page. additionalPreloads is only set on some pages, so it can also survive from an earlier page next to a later page's shorter list. Per-page evidence is intact in rule_results. Smallest fix: add page: ctx.page.url to the details, always emit additionalPreloads (0 when nothing was cut), and reword the docs and CHANGELOG to say the JSON report's grouped check shows one affected page's evidence while rule_results has every page. Carrying every page's evidence in the JSON report (per-page items with meta, or a report-side change) changes finding identity for this check, so we would decide that on perf/lcp-hints: lcp-preload warning does not name the likely-LCP image(s) #1074 first.
  2. Byte bound. The count is bounded but the strings are not: collectImagePreloadUrls keeps data:/blob: hrefs (which can never match a candidate), so one inlined preload can add tens of KB to every warned page's details. Please skip those schemes there and clamp each reported URL with clampItemString from core-contracts so the record stays under CHECK_DETAILS_LIMITS.maxBytes (8 KB).
  3. Docs: name the keys (details.candidates[].src, details.candidates[].reason, details.preloads, details.additionalPreloads) so agents reading JSON or rule_results know where to look.
  4. Nit: please drop the unrelated description: reflow in lcp-hints.ts.

A test in packages/report that groups two warned pages with different candidates and asserts what the JSON check carries would lock in whichever behaviour we settle on.

@WilliamK112
WilliamK112 force-pushed the codex/lcp-preload-details-1074 branch from fc7fb8b to 07e70ea Compare October 25, 2026 22:29
@WilliamK112

WilliamK112 commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor Author

Addressed at current head 7cdf8f8: details now name the page and always carry additionalPreloads; data/blob preload evidence is omitted; reported candidate/preload URLs are clamped; the grouped-report behavior is documented and covered by a two-page report test; and the unrelated description reflow is removed. The branch is rebased onto current main, and the formatting failure is fixed. The focused 22-test set, CLI typecheck, and repository-wide format check pass; the earlier full report and rules suites (including 7,559 rule tests) also passed.

@WilliamK112
WilliamK112 force-pushed the codex/lcp-preload-details-1074 branch 2 times, most recently from 22c2c1b to 7cdf8f8 Compare October 25, 2026 23:26
@WilliamK112
WilliamK112 force-pushed the codex/lcp-preload-details-1074 branch from 7cdf8f8 to 6150c7e Compare October 26, 2026 06:38
@nc9 nc9 mentioned this pull request Oct 26, 2026
@nc9

nc9 commented Oct 26, 2026

Copy link
Copy Markdown
Contributor

Merged: landed in the v0.0.134 batch (#1149), main commits 4e891ec. Thank you @WilliamK112, naming the candidate and the preloads it was compared against finally makes the lcp-preload hint fixable, and the byte clamp and two-page report test closed the gaps cleanly. (Nik)

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

perf/lcp-hints: lcp-preload warning does not name the likely-LCP image(s)

2 participants