Skip to content

feat(rules): add schema/rating-scope, AggregateRating that is not about its page (#106) - #113

Merged
nc9 merged 1 commit into
mainfrom
loop/106-schema-review-aggregaterating-scope-unen
Aug 19, 2026
Merged

nc9 merged 1 commit into
mainfrom
loop/106-schema-review-aggregaterating-scope-unen

Conversation

@nc9

@nc9 nc9 commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

Closes #106

schema/review validates only the shape of AggregateRating, so one sitewide rating block emitted by a template passes on every page of a site — including privacy policies, terms pages and blog posts (the issue's evidence: 53 pages across four production sites).

New sibling rule schema/rating-scope (page-scoped, warning, weight 4) asks the two questions the shape check cannot:

  • rating-visible — is a rating visible anywhere in the rendered page text? Star glyphs, "4.9 out of 5", "18 reviews", a decimal value printed in the copy, or the same wording in alt / aria-label / title. A third-party review widget (Trustpilot, Yotpo, Judge.me, Elfsight, …) clears the check, because its badge is injected client-side and a raw-HTML crawl cannot see it.
  • rating-subject — is the rated entity the subject of THIS page? Runs only where a rating cannot apply: privacy, terms and article/blog page types. On articles it reports only a business/organization carrier, so a review article rating its own Product stays silent.

Repetition is deliberately not the signal: on a legitimate LocalBusiness site the badge really is on screen and the rating really is about the business the page is about. Both findings name the page type and the rated entity, and frame the risk as a structured-data manual action rather than a validation error.

schema/review is untouched — same checks, same messages.

Acceptance criteria

  • schema/review gains a scope check (or a new sibling rule schema/rating-scope) registered in the rules catalog — new rule, registered in packages/rules/src/schema/index.ts
  • Warns when AggregateRating is present and NO rating value is visible in the rendered page text
  • Warns when AggregateRating is attached to an entity that is not the page's subject on page types where a rating cannot apply — privacy, terms and article/blog
  • The finding names the page type and the rated entity, and states that the markup risks a structured-data manual action rather than reporting it as a validation error
  • Does NOT warn on a LocalBusiness homepage that emits AggregateRating and shows a visible review badge
  • Does NOT warn on a Product page whose AggregateRating matches visible on-page reviews
  • Fixture: privacy policy carrying a sitewide LocalBusiness AggregateRating with no visible rating — warns
  • Fixture: blog post carrying the sitewide business AggregateRating — warns
  • Existing structural checks and their messages are unchanged; tests/review-aggregate-rating.test.ts untouched
  • Docs rule page added (docs/rules/schema/rating-scope.mdx), nav + category index + rule counts updated

Changes

  • packages/rules/src/schema/rating-scope.ts — new rule
  • packages/rules/src/schema/index.ts — catalog registration
  • packages/rules/tests/schema-rating-scope.test.ts — 16 tests, positive and negative cases
  • packages/audit-engine/tests/streaming-rules-canonical-golden.test.ts — tally pin 272 → 273 (the canonical fixture emits no JSON-LD, so the rule adds a tally key and zero findings; findings.length stays 98216)
  • docs/ — rule page, docs.json nav, schema index card, rule counts 272 → 273 / Structured Data 11 → 12; README.md likewise

Verification

Tests and typecheck could not be executed in this sandbox (the runtime is not permitted here), so CI is the first run of bun test, bun run typecheck and bun run docs:check for this branch.

…ut its page (#106)

schema/review only validates the SHAPE of AggregateRating, so one sitewide
rating block emitted by a template passes on every page of the site — the
issue's evidence is 53 pages across four production sites, privacy policies,
terms and 41 /news posts included.

New page rule asks the two questions the shape check cannot:

  - rating-visible: is a rating visible anywhere in the rendered page text
    (star glyphs, "4.9 out of 5", "18 reviews", a decimal value in the copy,
    or the same wording in alt/aria-label/title)? A third-party review widget
    (Trustpilot, Yotpo, Judge.me, ...) clears the check, since its badge is
    injected client-side and a raw-HTML crawl cannot see it.
  - rating-subject: is the rated entity the subject of THIS page? Runs only on
    page types where a rating cannot apply — privacy, terms, article/blog —
    and on articles reports only a business/organization carrier, so a review
    article that rates its own Product stays silent.

Repetition is deliberately NOT the signal: on a legitimate LocalBusiness site
the badge really is on screen and the rating really is about the business the
page is about. Both findings name the page type and the rated entity and frame
the risk as a structured-data manual action, not a validation error.

schema/review is untouched; its checks and messages are unchanged.

Signed-off-by: Nik Cubrilovic <[email protected]>
@nc9
nc9 merged commit 9a77658 into main Aug 19, 2026
14 checks passed
@nc9
nc9 deleted the loop/106-schema-review-aggregaterating-scope-unen branch August 19, 2026 09:48
nc9 added a commit that referenced this pull request Aug 19, 2026
…sitemap-lastmod-churn-all-va

* origin/main:
  feat(rules): add schema/rating-scope, AggregateRating that is not about its page (#106) (#113)

Signed-off-by: Nik Cubrilovic <[email protected]>

# Conflicts:
#	packages/audit-engine/tests/streaming-rules-canonical-golden.test.ts
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.

schema/review: AggregateRating scope unenforced — passes on privacy policies

1 participant