Repository navigation
test(audit-engine): pin the mixed-fold laundering path (squirrelscan/repo#2072) - #327
Merged
Merged
Conversation
squirrelscan/repo#2072 recorded 258 checks in the incident report tagged `fresh` on 88 pages the crawl never fetched, in three rules, and no server can refuse a `fresh` label. The mechanism turned out to be the one #326 had already fixed, so this adds the test that proves it rather than a second fix. Every one of those checks carries `details.pagesTruncated`, which only `unfoldAggregateCheck` leaves on a per-page check — so they are the expansion of a sampled AGGREGATE that reached the server with no provenance. An aggregate loses its label when its fold group is mixed, and a rule emitting two checks per page overflows `maxChecksPerRule` as soon as the producer's local store is large: 16 crawled pages plus 481 replayed is 994 checks for one rule. The report stamps `pagesTruncated: 497` on those checks, exactly 16 + 481 for one check name, which is what identifies the path. The test drives the whole chain — producer fold, publish sample, server merge — because neither half alone catches it: the fold change is invisible without a merge asserting the pages, and the merge filter is invisible without a fold that labels what it produces. Reverting `foldGroupKey` to (name, status) fails it and nothing else. No behaviour change: the fix shipped in #326, whose CHANGELOG entry covers it. Closes squirrelscan/repo#2072 Claude-Session: https://claude.ai/code/session_0174D96WamG9ZhJxRudpeniA 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.
Closes squirrelscan/repo#2072. Branches off main after #326; it does not stack on an open PR.
The premise changed
#2072 was filed on my own measurement: replaying the incident report through the fixed engine still reported 111 audited pages for a 16-page crawl, and the residue was 258 checks tagged
freshon 88 pages the crawl never fetched, in three rules. I expected the cause to betagCarriedCheckfailing to label them, and said so in the issue.It is not. The mechanism is the one #326 already fixed, so this PR adds the test that proves it rather than a second fix.
How the residue is actually produced
Every one of those 258 checks carries
details.pagesTruncated. Nothing puts that on a per-page check exceptunfoldAggregateCheck, which copies an aggregate'sdetailsonto each page it expands. So they are the expansion of a sampled AGGREGATE that reached the server with no provenance at all, and an unlabelled aggregate is indistinguishable from evidence.An aggregate loses its label when its fold group is mixed:
foldGroupkeeps "carried" only when every constituent carries it. A rule emitting two checks per page overflowsmaxChecksPerRuleas soon as the producer's local store is large. Forax/token-weighton that site: 16 crawled pages + 481 replayed, two checks each, is 994 checks, so the rule folds, and each(name, status)class folded one mixed group into one unlabelled aggregate.The arithmetic is what settles it. The real report stamps
pagesTruncated: 497on those checks. 16 + 481 = 497, for one check name. The three affected rules are exactly the ones that emit more than one check per page; the rules with large carried sets but one check per page stayed under the 500 cap, never folded, and are correctly tagged per check in the same report.Ruled out along the way, recorded on the issue so nobody redoes them:
tagCarriedCheckcannot miss, sincecarriedLastSeenis keyed(normalizedUrl, ruleId, checkName)and a replay carries exactly those; the rule cache is not it, since the run three minutes later on the same machine has zero of these; template fanout is not it, since #1951 records a cluster's verdicts beforepageUrlis stamped; and the pages were not crawled, since a crawled page in that report carries about 200 checks and these carry two to six.What this adds
One test driving the whole chain: build the pre-publish shape (16 crawled + 481 replayed, two checks per page), fold and sample it the way publish does, then merge the result. It asserts the fold emits four aggregates rather than two, that the carried pair keeps
provenance: "carried",lastSeenAtandpagesTruncated: 481, and that the merge then audits 16 pages, writes 16 site pages and persists 16 findings with nothing on a replayed URL.Neither half would catch this alone. The fold change is invisible without a merge asserting the resulting pages, and the merge filter is invisible without a fold that labels what it produces.
Verified by mutation: reverting
foldGroupKeyto(name, status)fails this test and nothing else in the file.No CHANGELOG entry. There is no behaviour change here; the fix shipped in #326, whose entry already covers it.
Evidence
One rules run reported a single failure on a 5s timeout under load; a clean re-run is 2235/0 and the diff touches no rules code.
What is still open
An old CLI keeps producing unlabelled mixed aggregates until users upgrade, and the server cannot refuse them: a
freshlabel is the producer asserting it observed the page. The window closes when the fold change ships in v0.0.95 and people update.The server could narrow it sooner by refusing page attributions absent from
report.resolutionSignal.crawledUrls, which is unsampled and authoritative for what the run crawled. I have not done that here because the signal's crawled list is capped with no marker for having been clipped, so a large crawl could drop genuine fresh findings. That is a design call with a data-loss failure mode and it should be someone's decision, not a side effect of this PR.https://claude.ai/code/session_0174D96WamG9ZhJxRudpeniA