Skip to content

perf(cli): stop the report building per-page fields nothing reads - #260

Merged
nc9 merged 2 commits into
mainfrom
feat/report-page-fields
Sep 7, 2026
Merged

nc9 merged 2 commits into
mainfrom
feat/report-page-fields

Conversation

@nc9

@nc9 nc9 commented Sep 7, 2026 •

Copy link
Copy Markdown
Contributor

Closes squirrelscan/repo#1938. No behaviour change; the emitted report and the publish body are unchanged.

What was happening

reconstructReport built a full PageAudit for every crawled page: meta, og, twitter, schema, links, images, h1Count, h1Text, loadTime, responseHeaders, security. Most of it was built and thrown away.

No output format emits report.pages — not json, llm, markdown, sarif, xml, html, pdf or text. The publish path sends pages: [] after taking the urls, the statuses and the home page's title.

What actually reads a page field

Searched rather than assumed, across the CLI and packages/report:

consumer reads
cli/commands/audit.ts .length
controllers/report/publish.ts .url, .statusCode, and meta/og on the home page
cli/commands/report.ts, reports/filters.ts .checks, filtered in place
reports/reconstruct.ts .fallbackReason, for one count

links had a reader on paper, apps/cli/src/links/index.ts, but that module is referenced only by its own test file and never runs in production.

So meta and og are kept, because pickHomepageSummary reads them off the home page to seed the website record. Everything else in the list above is no longer built.

Also removed with them

The per-page getLinkAppearancesForPage query and the whole-crawl getLinks read that fed links, and three of the five objects in the per-page detach. The image-appearance query stays: it also drives summary.missingAltText, which is emitted.

Measured neutral here, and the fixture is why

Growth across reconstructReport on the 1,000-page corpus, warmed, two runs per side:

heap RSS wall
before +114 MB +52 to +127 MB 468-479 ms
after +113 to +117 MB +82 to +152 MB 446-607 ms

The two largest fields dropped are links and images, and this corpus stores zero of either. They are written by the external-link phase, and the benchmark runs --offline against a site with no outbound links, so the arrays being dropped were already empty and the per-page query had nothing to return.

What the change removes structurally — a storage query per page on any site that does have external links — is not claimed as a number, because I did not measure it. The benchmarks file says so in those words rather than recording a win that was not observed.

Parity

  • Publish body: a differential test builds the same report with and without every dropped field and asserts the two slimForPublish outputs are byte-identical, plus that the home-page title still comes through and non-2xx statuses are still reported. That is the one consumer that could have depended on a field quietly.
  • Emitted report: byte-identical end to end at 400 pages against the pre-feat(rules): content/near-duplicate groups pages with nearly identical main text (repo#1369) #1913 baseline.
  • Engine goldens green; the engine's own buildV1Report, which publishes pages[] unstripped and needs these fields, is untouched.

A side effect worth calling out

responseHeaders going means there is no Set-Cookie strip left to forget: the field the cookie used to ride on is no longer built. The test that covered that strip now asserts over the whole report serialized as JSON, so a cookie arriving by some other route would fail it too.

Stated precisely, because the review caught me overstating it: the first version of that test looked only at the first page's fields, which did not prove the claim the commit made. It looks at the whole report now. Note also that the security/cookie-flags rule deliberately keeps cookie names in its check items and discards the values; this is about the values.

Type shape

The dropped fields stay in PageAudit as optional rather than being removed, so anything constructing or consuming one still compiles.

Nik Cubrilovic added 2 commits September 8, 2026 08:11
`reconstructReport` built a full PageAudit per page — meta, og, twitter, schema,
links, images, h1Count, h1Text, loadTime, responseHeaders, security — and most
of it was discarded. No output format emits `report.pages`, and the publish path
sends `pages: []` after taking the urls, the statuses and the home page's title.

Searched rather than assumed. Exactly one reader survived: `pickHomepageSummary`
reads `meta` and `og` off the home page to seed the website record's title and
description, which is why those two are kept. `links` had a reader on paper, in
apps/cli/src/links/index.ts, but that module is referenced only by its own test
and never runs in production.

The dropped fields stay in the type as optional, so anything constructing or
consuming a PageAudit still compiles, and the hosted builder — which publishes
these and needs them — is untouched.

Also removed with them: the per-page `getLinkAppearancesForPage` query and the
whole-crawl `getLinks` read that fed `links`, and three of the five objects in
the per-page detach. The image-appearance query stays; it also drives
`summary.missingAltText`, which IS emitted.

`responseHeaders` going means Set-Cookie can no longer reach a report at all,
rather than being stripped by a helper that could be forgotten. The test that
covered the strip now asserts the stronger property against the whole page as
JSON.

Measured neutral on the 1,000-page fixture: heap +114 MB before, +113 to +117
after. The reason is the fixture, and it is worth stating rather than hiding —
`links` and `images` are written by the external-link phase, the benchmark runs
`--offline` against a site with no outbound links, so this corpus stores zero of
either and the arrays being dropped were already empty. What the change removes
structurally is a query per page on any site that does have external links; that
is not claimed as a number because it was not measured. Recorded that way in the
benchmarks file.

The publish body is pinned byte-identical with and without the dropped fields by
a differential test, the emitted report is unchanged end to end at 400 pages,
and the engine goldens are green.

Signed-off-by: Nik Cubrilovic <[email protected]>
… page #1938

Review pushed back on the claim, correctly. The commit above said Set-Cookie
"can no longer reach a report at all", but the test only looked at the first
page's fields, so it did not prove that. It now serializes the whole report, so
a cookie arriving by some other route — a check's items, the summary, a field
the type does not declare — fails it too.

Also noted in the test where it belongs: the security/cookie-flags rule keeps
cookie NAMES in its check items on purpose and discards the values. The property
being asserted is about the values.

Signed-off-by: Nik Cubrilovic <[email protected]>
@nc9
nc9 force-pushed the feat/report-page-fields branch from 2664f54 to ad90b96 Compare September 7, 2026 22:12
@nc9
nc9 merged commit 8db4c38 into main Sep 7, 2026
13 checks passed
@nc9
nc9 deleted the feat/report-page-fields branch September 7, 2026 22:19
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.

1 participant