Skip to content

ci/duplicates: Add duplicated content PR check - #2076

Open
marcleblanc2 wants to merge 4 commits into
mainfrom
marc/dev/check-duplicates
Open

marcleblanc2 wants to merge 4 commits into
mainfrom
marc/dev/check-duplicates

Conversation

@marcleblanc2

@marcleblanc2 marcleblanc2 commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

Add PR check to compare PR changes by Jaccard similarity to existing doc content, to identify if the PR is adding duplicate content.

How

  • dev/check-duplicates.mjs: splits every page under docs/ into passages (paragraphs, list items, tables, fenced code blocks), normalizes them (lowercase; Markdown, JSX, link targets stripped), and compares word trigrams by Jaccard similarity, so paraphrases are caught, not only verbatim copies. Reports groups of similar passages as file:line plus a snippet, biggest groups first. --baseline and --diff scope it to what a PR adds, same as check-links and check-redirects. Auto-generated pages and SCHEMA_SYNC blocks are skipped; those are fixed upstream.
  • .github/workflows/check-duplicates.yml: records the findings on the merge base, then comments the passages the PR adds that duplicate another, plus an inline review comment on each added passage naming its duplicates. Advisory, never fails the PR, same as spelling and hostnames.
  • AGENTS.md: a "One home per fact" section (link instead of copy; rg the key under docs/ before writing a config snippet; the SCHEMA_SYNC blocks own every setting's default), and the new check listed with the others.

Against main today

  • node dev/check-duplicates.mjs finds 622 pairs in 291 groups across the hand-written pages
  • The biggest group is the Kustomize deprecation callout copied verbatim onto 8 pages
  • It also finds the code-search/features.mdx paragraphs that restate search-contexts.mdx and admin/search.mdx, which came up in docs: Fix stale experimentalFeatures settings #2074
  • ~12% of the pairs are same-file code blocks that vary one parameter (API examples); the threshold is tunable with --threshold if those are noisy

Tested locally

  • Ran the CI steps by hand against a worktree of origin/main as the base
    • A paragraph copied from admin/config/settings.mdx into another page was reported with the inline comment on its first added line
    • A one-word edit to a pre-existing duplicate was suppressed by the baseline
  • actionlint and CSpell pass

Test result

Throwaway PR #2077 copied a paragraph from docs/admin/config/settings.mdx into docs/admin/how-to/enable-experimental-feature.mdx, and changed one word in docs/code-search/features.mdx:60, which was already a duplicate of docs/code-search/working/search-contexts.mdx:9. The check posted:

Nothing else on the base branch was reported.

@github-actions

github-actions Bot commented Oct 6, 2026

Copy link
Copy Markdown
Contributor

@vercel

vercel Bot commented Oct 6, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated
sourcegraph-docs Ignored Ignored Preview Oct 6, 2026 11:10pm UTC

Request Review

marcleblanc2 and others added 2 commits October 6, 2026 16:35
Each fact should have one home in the docs, with other pages linking to
it; copies drift out of date the moment the original changes. This adds
a non-blocking PR check that comments the passages a PR adds which say
the same thing as a passage elsewhere under `docs/`, paraphrased or
verbatim, plus an inline comment on each added passage pointing at its
duplicates.

`dev/check-duplicates.mjs` splits every page into passages (paragraphs,
list items, tables, fenced code blocks), normalizes them, and compares
word trigrams by Jaccard similarity. Auto-generated pages and
SCHEMA_SYNC blocks are skipped. Like the links and redirects checks, CI
records the findings on the merge base and reports only the ones the PR
adds; main has hundreds of pre-existing findings.

AGENTS.md gains the "One home per fact" rules so the duplication does
not grow back.

Amp-Thread-ID: https://ampcode.com/threads/T-01a11326-478d-72cf-bbb7-587d16b378e9
Co-authored-by: Amp <[email protected]>
A PR that edits one copy of a duplicated passage now gets a comment
naming the other copies, so the author can pick the home and replace
the rest with links, or make the same change there. Added duplication
and edited duplication are reported in separate sections with their
own advice. Also strip trailing spaces from the example-hostnames
bullet in AGENTS.md.

Amp-Thread-ID: https://ampcode.com/threads/T-01a11326-478d-72cf-bbb7-587d16b378e9
Co-authored-by: Amp <[email protected]>
dev/check-duplicates.mjs, check-hostnames.mjs, check-redirects.mjs, and
example-hostnames.json only run in PR checks; the site build never reads
them, so a change to them should not deploy a preview.

Amp-Thread-ID: https://ampcode.com/threads/T-01a11326-478d-72cf-bbb7-587d16b378e9
Co-authored-by: Amp <[email protected]>

This branch was successfully deployed

1 active (outdated) deployment
Preview — 6ecae68e Deployed Oct 6, 2026 by vercel[bot]
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