Repository navigation
feat(rules): add crawl/sitemap-lastmod-drift (#107) - #114
Merged
Merged
Conversation
Site-scope rule comparing each sitemap lastmod against the page's own strongest date signal (schema dateModified, else the dateModified-equivalent itemprop/meta markup, else the visible date). Two directions, distinct check names, since they point at different code: - sitemap-lastmod-behind-page: lastmod older than dateModified by >7d (stale sitemap / inverted `publishedAt ?? updatedAt` precedence) - sitemap-lastmod-ahead-of-page: lastmod newer by >30d, configurable (lastmod stamped at build time) Each finding reports both dates plus the delta in days. Pages with no page-side date are skipped (content/freshness territory), and same-day / within-threshold gaps never warn. Reads only parsed-page scalars, never a DOM, so output is identical on the legacy and siteQuery/streaming paths. Signed-off-by: Nik Cubrilovic <[email protected]>
11 tasks
nc9
added a commit
that referenced
this pull request
Sep 12, 2026
…nce (squirrelscan/repo#2063) (#326) * fix(audit-engine): refuse producer-carried checks as this run's evidence A published report is the UNION of the crawl and the producer's own finding store, with the replayed half tagged `provenance: "carried"`. The cloud merge read every check's `pageUrl` as a page crawled this run, so a machine whose local store still held an old audit turned it into cloud state: findings first seen at the publish instant on pages the crawl never opened, and 129 "audited pages" for a 16-page crawl. Two runs of the same site three minutes apart scored 50 and 88. - `runCloudSmartAudits` drops carried/unrendered checks from `crawledUrls`, `freshFindings`, the union's fresh side and the #1167 sample sets. The cloud's OWN carry is unaffected: it is replayed from the store with the date the cloud last saw it. Surfaced as `replayedChecksDropped`. - `foldOverflowChecks` keys groups on provenance as well as issue class. A mixed group folded to an aggregate with no provenance, which reads as evidence from this run, so a rule with enough carried pages to overflow the cap laundered every one of them. - `buildStreamFindings` / `buildSkippedPassCounts` apply the same exclusion on the complete-store path, and `buildResolutionSignal` stops spending its budget on pages the run never evaluated. Second half of the same bug: page identity was query-BLIND, so 384 `?id=N` pages collapsed into one stored URL carrying 362 copies of one rule's finding. Adds `normalizePageUrl` (query-preserving, everything else unchanged) and uses it for page identity in the merge, the streamed findings and the resolution hashes. `normalizeUrl` keeps its query-blind semantics for the comparisons that want them (sitemap matching, link-count buckets, cache keys). The merge accepts a resolution hash under either spelling, so an older publisher over-carries rather than resolving a finding that is still there. Closes #2063 Claude-Session: https://claude.ai/code/session_0174D96WamG9ZhJxRudpeniA Signed-off-by: Nik Cubrilovic <[email protected]> * fix(audit-engine): count provenance-split fold classes in the bounded report Review follow-up to the #2063 fold change. `complete-store-fold` counted `(name, status)` classes and used that count as the re-fold's `maxChecks`, so a class that now splits into a carried and an unrendered aggregate was capped at one: the two merged, an occurrence went missing, and the survivor was then reconciled against a class key it no longer matched, which deleted its provenance and last-seen. Keys the accumulator, the cap and the reconciliation on the shared `foldGroupKey`. Also tie-breaks the fold's sort on that key. Provenance splits a class into up to three aggregates, which `(name, status)` no longer separates, leaving their order to rule execution order — nondeterministic (#114), so a repeat audit could emit a different byte sequence. Two existing tests asserted the old mixed-provenance behaviour and now assert the split; one fixture gains a `site_pages` row so the drop it exercises still happens. Documents the complete-store identity contract (producer and consumer must run one engine build) and why coverage counts evidenced pages rather than the raw crawl count; the residual sampling gap is #2067. Claude-Session: https://claude.ai/code/session_0174D96WamG9ZhJxRudpeniA Signed-off-by: Nik Cubrilovic <[email protected]> * feat(audit-engine): report how many replayed pages the cloud has never seen #2063 ran for a month with nothing saying it was happening. The count of refused checks cannot say it either: an ordinary partial re-audit replays thousands of them for pages the cloud knows, and carries those from its own store as always. `replayedUnknownPages` counts the pages a producer's replayed checks named that this site has no record of — not crawled this run, not known from any earlier audit. That is the mechanism, not a proxy for it: 508 such pages against a 16-page crawl was the incident. The set is bounded by pages, built only in the sampled branch, and dropped once counted. Claude-Session: https://claude.ai/code/session_0174D96WamG9ZhJxRudpeniA Signed-off-by: Nik Cubrilovic <[email protected]> * fix(audit-engine): keep replays out of the complete-store union too Acceptance review found the sampled branch covered and the complete-store branch not. It copied the staged shell's checks into `freshResults` unchanged, and the shell is that path's report body: a producer's replayed check reached `freshForUnion` and the union, landing beside the cloud's own carry for the same page, with the producer's date, on a page the crawl never fetched. Reproduced in both the materialized and the streamed variant. Complete mode deliberately does not unfold — the shell's aggregates ARE its display surface — so a replay arrives there as a per-page check OR as a folded aggregate naming its pages. `isReplayedCheck` now matches both, using `unfoldAggregateCheck`'s own gate so the two branches agree on what an aggregate is. Genuine site-scope checks stay: the tally fold scores those verbatim. Every rule keeps its key even when all of its checks go, because the fold reads rule membership to decide which rules the shell already handled. The filtered shell is what both tally-fold entry points read now, rather than the raw input. Tests, each checked by removing the one line it protects: a genuinely truncated carried aggregate whose sample names a page the fresh aggregate clipped out (the shape that resolves a finding the crawl never re-examined), both complete-store variants asserting union contents, `unrendered` as check and as aggregate, and the two `stream-findings` guards. Claude-Session: https://claude.ai/code/session_0174D96WamG9ZhJxRudpeniA Signed-off-by: Nik Cubrilovic <[email protected]> * test(audit-engine): pin the pass count of a rule the replay filter empties Review nit on the previous commit: the complete-store tests asserted union contents but never the tallies, and every rule in them kept a check — so nothing failed when the emptied rules were dropped from the shell or when the folds were handed the raw input. A page rule whose every published check is a replay ends up with no checks and must still keep its KEY, because `foldShellRules` reads rule membership to give it the fresh-clean pass count for the pages the crawl found nothing on. Dropping it loses those passes out of the denominator, which is #918 in miniature. The new test asserts that tally directly and fails if the key goes. Also corrects two comments the review caught: dropping an emptied rule loses fresh-clean passes rather than double-counting, and the page-attribution gate reads the CHECK's shape rather than the rule's scope — an aggregate naming pages is a page replay whichever rule emitted it. Documents that the refused-check counter's unit differs by mode, since the sampled branch unfolds before it filters and complete mode never unfolds. Claude-Session: https://claude.ai/code/session_0174D96WamG9ZhJxRudpeniA Signed-off-by: Nik Cubrilovic <[email protected]> --------- 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 #107
New site-scope rule
crawl/sitemap-lastmod-drift: for every crawled page present in a sitemap with alastmod, compare thatlastmodagainst the page's own strongest date signal and report the two directions separately, because they point at different code.sitemap-lastmod-behind-pagelastmodolder than the page'sdateModifiedby >behind_days(7)publishedAt ?? updatedAtwhile the route rendersupdatedAt ?? publishedAtsitemap-lastmod-ahead-of-pagelastmodnewer by >ahead_days(30, configurable)lastmodstamped at build/deploy timeEach finding carries both dates, the source tier of the page date, and the delta in days; findings are sorted worst-first (URL tie-break) and capped at 50 items with the real total in
details.Page-date tiers: schema
dateModified(flattened JSON-LD,@graphincluded) → thedateModified-equivalent markup the parser lifts from[itemprop="dateModified"]meta/<time>(visibleDateModified) → visible published date. Pages with none of these are skipped — that iscontent/freshnessterritory, not drift.Acceptance criteria
crawl/sitemap-lastmod-driftunderpackages/rules/src/crawl/, registered in the rules cataloglastmodagainst the page's own strongest date signal (schemadateModified, elsedateModifiedequivalent meta, else visible date)lastmodis older than the page'sdateModifiedby more than 7 days, reported as a distinct check name from the ahead caselastmodis newer than the page'sdateModifiedby more than a configurable threshold (default 30 days)siteQuerypathsdocs/(plusdocs.jsonnav and the Crawlability card grid)streaming-rules-canonical-golden.test.tsupdated:v1.findings.length98217 → 98218 andv1.perRuleTally.length274 → 275, each with a comment naming this rule, matching the convention used for the rules above itNotes
parsed.schema.raw,visibleDateModified,visibleDatePublished) and neverparsed.document, so the streaming site pass — where every DOM is dropped before site rules run andsiteQueryis threaded — sees identical input and emits identical checks. It does not branch onctx.siteQuery; a unit test asserts the output is unchanged when one is present, and the canonical 518-page v1↔v2 gate covers it end to end.[itemprop="dateModified"]meta/<time>extraction. OGarticle:modified_timeis not carried as a parsed scalar today, so picking it up would need a new parser field across the parser and both audit adapters — deliberately left out of this rule's diff.lastmodat all, so the rule contributes exactly oneskippedcheck (hence +1 finding, +1 tally key, health score unmoved).bun/nodeexecution is blocked in this environment (every invocation required an approval that could not be granted non-interactively), so the new tests, typecheck andmake validateindocs/were not run locally — CI (quality / cli-tests / engine-tests / docs) is the first execution of this change.