Skip to content

fix(seo): backfill only title copies and missing descriptions; fix retries - #1917

Merged
jth-nw merged 3 commits into
devfrom
james/seo-backfill-tooling
Dec 1, 2026
Merged

jth-nw merged 3 commits into
devfrom
james/seo-backfill-tooling

Conversation

@jth-nw

@jth-nw jth-nw commented Nov 30, 2026 •

Copy link
Copy Markdown
Collaborator

Why

The first backfill PRs (now closed) had descriptions that said things their pages do not. A check found, for example, "AI-powered Navigator" (the page says "an AI assistant"), WMI added to a list of protocols the page does not list, and "MySQL" and "PostgreSQL" on pages that never name them. The model added plausible details from its own knowledge, and a yes/no "is this grounded?" check let some through.

This PR makes the check evidence-based and fixes some problems the pilots exposed. The generated descriptions must match what is in the doc.

What changes

Every claim needs evidence.

  1. Terms: every number, acronym, identifier, and capitalised name in a description (and each part of a hyphenated word) must be on the page. The product's own name is the only exception. A draft that fails is rejected before any model call.
  2. Quotes: a second model call splits the description into claims and must quote, from the page, the text that states each one. Code confirms each quote is really on the page and that every number, acronym, and identifier in the description appears in some quote. A claim with no quote, or an invented one, fails.

A rejected draft goes back to the model with the reason and is told to drop anything the page does not state. After three tries, the page keeps its current description. The drafting prompt now forbids adding anything from the model's own knowledge.

Also from the pilots:

  • By default the backfill only acts on missing descriptions and title copies, not on authored ones that are a little long or short (--include-length to change that).
  • Output budget raised so a model that thinks first cannot return empty text. An empty reply is a retry, not a crash.
  • Each draft is checked with the repo's Vale rules before it is accepted.
  • Pages with no frontmatter are skipped without a model call.
  • The run prints model usage so it can be costed.

Pilot results

  • Re-check of earlier work: 199 descriptions from the closed PRs (59 flagged by a term audit and 140 random others). All 3 known fabrications are caught. 43 fail in total.
    • In the random sample, 14 of 140 fail. By hand, about 8 are real unsupported content (for example "PowerShell" on a page that never says it, "MySQL" and "PostgreSQL", and vague claims like "as part of its script management documentation"). About 6 are false positives, where a true claim was on the page but not quoted verbatim.
  • The 3 known-fabricated pages now get accurate descriptions.
  • Password Reset from scratch: 46 of 48 pages accepted. One has no frontmatter and one was a network error. I read 8 of the accepted ones by hand against their pages, and every claim was supported.
  • Cost: about 4,900 input and 390 output tokens per page, up from about 4,000 and 85.

A false positive costs only coverage: the page keeps its current description.

Testing

npm run test:scripts passes (93 SEO tests).

🤖 Generated with Claude Code

…tries

A 10-page and a 15-page pilot of the backfill showed three problems:

- It rewrote authored descriptions that were only a few characters over or
  under the limit. By default it now acts only on a missing description or one
  that repeats the title (BACKFILL_RULES). --include-length restores the old
  behavior. Across the docs that is 16,134 pages in scope (414 missing, 15,720
  title copies); 431 authored, length-only descriptions are left alone.
- About 1 page in 5 failed because a draft stayed over 160 characters. The
  prompt now aims for 100-145, and a rejected draft goes back to the model with
  the draft and the reason, to be shortened or corrected, for up to three tries.
  The same 15 pages then all succeeded.
- A page with no frontmatter failed after spending model calls. It is now
  reported as skipped, with no call.

The backfill also prints the model usage (calls, input and output tokens, per
page), so a large run can be costed first.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Running the backfill's orchestration on the smallest product (23 pages) showed
16 failures. Four causes, all fixed:

- Output budget: the draft and verifier calls were capped at 400 and 600 tokens.
  A model that thinks first spends some of that before writing, and a cap that is
  too small returns no text (stop_reason max_tokens), which surfaced as
  "Unexpected end of JSON input". Both now allow 4000; the reply is still one
  short sentence (about 150 output tokens per page on average).
- An empty or cut-off reply is now a rejected attempt that is retried, not a
  crash.
- Product name: the verifier flagged a draft that used the product's configured
  name ("Strongpoint for NetSuite Flashlight") when the page only says
  "Flashlight". The draft now follows the page's own spelling, and the verifier
  accepts the configured name. The verifier also lists at most 3 unsupported
  claims, briefly.
- Style: the drafts broke house rules (Oxford comma, and others). Each draft is
  now checked with the repo's Vale on just its description line, and a violation
  goes back to the model like any other rejection.

The same 23 pages then all succeeded and passed the quality check.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
A check of the first backfill PRs found descriptions that said things their
pages do not: "AI-powered Navigator" (the page says "an AI assistant"), WMI added
to a list of protocols the page does not list, "MySQL" and "PostgreSQL" on pages
that never name them. The model had added plausible details from its own
knowledge, and a yes/no "is this grounded?" check let some of them through.

The check is now evidence-based, in two layers:

1. Terms. Every number, acronym, identifier, and capitalised name in the
   description, and each part of a hyphenated word, must be on the page (the
   product's own name excepted). This rejects a draft before any model call.
2. Quotes. A second model call must split the description into claims and quote,
   from the page, the text that states each one. Code confirms each quote really
   is on the page (ignoring markdown, case, and spacing), and that every number,
   acronym, and identifier in the description appears in the text quoted for some
   claim. A claim with no quote, or with an invented one, fails.

A rejected draft goes back to the model with the reason and is told to drop
whatever the page does not state; after three tries the page keeps its current
description. The drafting prompt now forbids adding anything from the model's own
knowledge of the product. auditDescription() runs the same check on a description
that already exists, to audit earlier work.

Pilot, before this goes further:
- All 3 known fabrications are caught when re-checked (199 earlier descriptions
  re-checked; 43 fail, about 6% of a random sample looked like real problems, and
  about 4% are false positives, where a true claim was not quoted verbatim).
- The 3 pages that were fabricated now produce accurate descriptions.
- Password Reset, from scratch: 46 of 48 pages accepted (1 has no frontmatter,
  1 was a network error); 8 read by hand against their pages were all supported.

A false positive costs only coverage: the page keeps its current description.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown
Contributor

Code Review

No blocking issues found. The changes are limited to scripts/seo/ and the SEO tests. They don't touch the build, routing, the KB copy pipeline, or any workflows.

What I checked:

  • needsDescription / BACKFILL_RULES: rules = null keeps the old behavior for describe.mjs and the stop hook. Only backfill.mjs narrows the rules, and only when --include-length is not passed.
  • Vale gate: parseFrontmatter(trial).fields.description.line is always set at that point because setDescription has just written the line. runVale returns status: 'missing' when Vale isn't installed, so the gate is skipped and nothing throws. config.vale.ignore exists.
  • Empty or cut-off replies: readJson returns null, and that is handled for both the draft call and the verifier call. It becomes a retry or a failed result, not an exception.
  • Grounding: a null quote becomes '', which fails the 8-character minimum, so a claim without a quote is rejected. Quotes are checked against pageText (the title plus the full body). That is a superset of the 12,000-character body the model sees, so a real quote can't be rejected for falling outside the checked text.
  • Injection: present() escapes each term before building its RegExp. No shell or eval use was added. Vale gets the text on stdin through spawnSync.

Minor, non-blocking:

  1. describe.mjs CLI: the new skipped status (no frontmatter) exits 0. The CLI prints it as SKIPPED, but the file header still says "Exit 0 = every page fixed or already fine", and the describePage JSDoc doesn't list 'skipped'. Update the comments, or count skipped as a non-zero exit if a page with no frontmatter should fail a --file run.
  2. proposeDescription retry prompt: when a Vale finding rejects a draft, the reason (style rule ...) matches neither the length regex nor the grounding regex. The retry falls through to ", using only facts the page states", which doesn't tell the model to fix the style issue. The reason text is still included earlier in the prompt, so this is cosmetic.
  3. present(): for terms longer than 3 characters, the stem forms are matched as substrings, and t.replace(/(es|s)$/, '') turns "Access" into "acces". The term check can therefore pass when it should fail (lenient), never the reverse. The quote layer still backs it up, so this is acceptable. Noting it in case stricter matching is wanted later.
  4. runVale is synchronous (spawnSync), so with --concurrency 3 each Vale run briefly blocks the other in-flight requests. This is negligible compared with model latency.

This was referenced Dec 1, 2026

This branch was previously deployed

1 inactive deployment
development — 1484d8c6 Deployed Nov 30, 2026 by jth-nw via build-and-deploy #5379
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