Repository navigation
feat(engine): one report capper and a 1 MiB published-report constant (repo#2656) - #640
Conversation
… (repo#2656) PUBLISHED_REPORT_MAX_BYTES (1 MiB) and REPORT_CAPS in core-contracts, and capReportForPublish in audit-engine (Worker-clean, ./publish-cap entry): one aggregate per issue class with a 10-page / 5-item sample and its true counts, per-page pass rows dropped with their counts kept in checkTallies, rule text left out of the body, and a byte fitter (10/5, 5/3, 3/1, counts only, no entity map, then classes admitted by byte budget). Deterministic, never mutates its input. withCatalogRuleText in @squirrelscan/report joins rule description and solution back from the rule catalog at render time. Not wired into either publish producer yet: the server rescore reads the tallies first (repo#2657). Signed-off-by: Nik Cubrilovic <[email protected]>
d85d2bb to
be074d8
Compare
… page first (repo#2656) Aligns the capper with the caps tuned on 187 real published reports: - fitter fills breadth first: every class a counts row, then 3/1, then 10/5, in priority order while the budget lasts; then minimal display sections without the entity map; then byte admission. Replaces the global 10/5 -> 5/3 -> 3/1 -> counts ladder, so a tight budget cuts the least important classes instead of every class. - items ranked by page spread, with a per-item pageCount when the sample lists fewer source pages; ranked before the 1,000-item clamp. - each class's page sample leads with the page it hits hardest. - top-level siteChecks entries that repeat a published rule check are left out (no reader besides schema bounds and publish counts). - envelope reserve 16 KiB (report >= 816 KiB of 1 MiB), sitemaps 25 entries / 10 children; detail.classesReduced counts reduced classes. Signed-off-by: Nik Cubrilovic <[email protected]>
|
Review of #640 (one report capper, 1 MiB published-report constant). I read the diff through the sampling and fixed-section code. I did not read the byte fitter,
Overall the design is sound: it is deterministic, doesn't mutate its input, and has good test coverage. I found nothing blocking. |
…ty map failure stamp (repo#2656) - docs no longer claim the whole body fits whatever the crawl size: it needs repo#2658 to bound resolutionSignal/pageStatuses. A TODO gate in publish-cap.ts and at the CLI's slimForPublish says not to wire the capper before repo#2658 and repo#2657. - messageChars documented as UTF-16 units (the schema's unit), not bytes; a CJK + emoji test pins the byte bound, the unit clamp and no split surrogate pair. - detail.entityMapFailed marks an entity map that could not be projected, apart from a budget drop (entityMapDropped). - notes: measured heap cost of the full-limit class fold at 10,000 pages, and the summary's two-level depth that capSummary relies on. Signed-off-by: Nik Cubrilovic <[email protected]>
|
Review triage, all in 20f5e97:
Checks: |
|
I read the diff, with most attention on the No blocking issues found. Comments:
Test coverage looks good. There are dedicated tests for size, determinism, and for tallies matching the scorer, plus a rule-catalog test. I would add a test for the case where |
|
Second review, triage (no new commit, to save a CI run; each point lands with the PR that owns it):
|
|
Reviewed the diff (new
The module is not wired into any producer, so runtime risk is limited to the new export. Determinism, no input mutation, and the scorer-unit tallies look carefully designed. I found no blocking issues. |
|
Review triage (integrator, head f519e60, an update-branch merge of main with no change to this PR's diff):
|
Summary
Part of squirrelscan/repo#2656 (epic squirrelscan/repo#2655): every published report gets capped at the source, to one 1 MiB constant, by one function that the CLI and the cloud container will both call. The caps follow the tuning on 187 real published reports in the cap-tuning comment on repo#2656.
PUBLISHED_REPORT_MAX_BYTES(1 MiB) andREPORT_CAPSin@squirrelscan/core-contracts/limits. Every number is a named, tunable constant: 10 pages / 5 items / 1 source page per issue class, 25 classes per rule, site checks 10/10,resourceSizes20 rows x 3 source pages, 50 robots directives, sitemaps 25 entries x 10 children, entity map 128 KiB, 192 KiB kept back for the scoring transport, 16 KiB for the envelope (so the report itself gets at least 816 KiB).capReportForPublishin@squirrelscan/audit-engine(Worker-clean./publish-capentry, also on the main barrel):details.pagesTruncated,details.additional,details.occurrences). The fold runs once per class (no stacked(+N more pages)), members go in page order, and a class of one per-page check stays that page's check;sourcePagessample is shorter than its spread carriespageCount. An items array over the 1,000-item clamp is ranked before the clamp;checkTallies, the contract repo#2657 reads: per rule and check name, the scorer's ownIssueTallyfields over this run's fresh checks, unfolded, carried and unrendered left out. A test showscalculateHealthScoreFromTalliesover them equalscalculateHealthScoreover every row;siteChecksentries that repeat a site checkruleResultsalready publishes are left out (9,137 of 9,138 entries on the tuning corpus; the only readers are schema bounds, the publish breadcrumb count and the payload scanner). Anything no rule carries stays;description/solutionleft out of the body (descriptionstays as""because the publish schema requires the field);PublishedReportTooLargeError;detail: { capped, tier, caps, classesReduced?, classesDropped?, entityMapDropped?, fullDetail? }stamp for the viewers (repo#2661).tieris how far the fitter went (0 full sample, 1 breadth-first fill, 2 minimal sections, 3 admission);pageStatusescome out in a fixed order, and source pages are sampled in URL order. Never mutates its input.withCatalogRuleText/ruleCatalogLookupin@squirrelscan/report(plus./rule-catalogand./affected-pagesentries): whoever renders a report joins the rule text back from the catalog, and the catalog wins whenever it knows the rule.CheckItem.pageCount(optional) in core-contracts.Nothing calls the capper yet, so this PR changes no behaviour. Wiring it into
slimForPublish(CLI) andtruncateReportForPublish(container) has to wait until the API readscheckTalliesfor the rescore (repo#2657) and joins rule text at render. Until then, a capped body would move the server score and blank rule descriptions.Known limits
resolutionSignalandpageStatusesstill grow with pages crawled (raw URLs). The fitter measures them first and fits everything else into what they leave, never less than the budget minus its 192 KiB reserve. When the signal is over its reserve (2,000+ pages, or hundreds of classes failing on 100+ pages, as in the engine worst-case test) the whole body is over 1 MiB until repo#2658 bounds it. The breadth-first fill uses the room it is given, so this shows up more readily than with the old ladder's slack.pageCountare over what that fold kept (pageCountis a floor there). Passing unfolded classes to the capper is a wiring-time choice.Measured (real-shape fixture from the private repo, not checked in here)
Every page-scope class failing on every page, 10 of the heaviest real items each (352 B): 1,008KB, tier 1. 206 of 220 aggregates keep the full 10/5 sample, 30 classes get a smaller one, none is left out (the old ladder put every class at 5/3). 10,000 pages was not re-run on the fixture (memory on the lane box); the engine test covers flatness to 10,000 pages on a lighter shape.
Verification
bun test packages/audit-engine/tests/publish-cap.test.ts: 33 pass. Covers the size bound at 50 / 500 / 2,000 / 10,000 pages, the every-class-fails worst case filled breadth first with every class kept, max-length strings (tier 2, every class kept), fail-before-warn priority just under the full-sample size, admission past the fill, the typed error, sample caps and true totals, ranking (per-page fold and site check), ranking past the 1,000-item clamp, worst-page pin (folded here and folded elsewhere), siteChecks dedupe (including key order and an upstream-clamped copy), score parity from tallies, suffix stacking, provenance split, 25-class cap, determinism across rule, check and page order, no input mutation. Mutation-checked: removing the ranking, the pre-clamp ranking, the pin, the zero-weight pages in the pin, the dedupe, the sorted-key dedupe, the clamped-form dedupe key, or reversing the fill priority each fails a test.apps/worker-agent/src/publish-cap-2656.test.ts(real-shape fixture) 3 pass,apps/api/tests/schemas/capped-report-2656.test.ts6 pass.tsgo --noEmitin packages/core-contracts, packages/report, packages/audit-engine and apps/cli: clean.bun build --target=browser src/publish-cap.ts: nonode:imports or linkedom in the import closure (only bun's inlinednode:netpolyfill via utils, as before).pageCountkept across a fold, source pages sampled in URL order. Rebutted: dedupe compares the clamped form on purpose, since the producer's top-level copy is clamped (capMixedRuleChecksForPublish) and never equals the raw rule check.Docs: none in this PR, since nothing user-facing changes yet. The CLI wiring PR adds the docs note on the capped published report and where full detail lives.
squirrelscan agent skill: no change. The audit-website skill reads the local
--format llmoutput, never the published report.Checklist
Signed-off-byline (git commit -s).