Skip to content

fix(docs): keep every docs address answering and lint every link - #3986

Merged
yannickmonney merged 8 commits into
mainfrom
fix/docs-broken-links
Sep 30, 2026
Merged

yannickmonney merged 8 commits into
mainfrom
fix/docs-broken-links

Conversation

@yannickmonney

@yannickmonney yannickmonney commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Readers and agents hit many 404s on the docs sites. The live link graph was clean. The 404s came from addresses that used to exist: 359 of the 932 docs.tale.dev URLs ever published answered 404. They were moved or deleted pages, the retired de-CH/de-AT/fr-CH trees, Mintlify-era pages, and legal texts that moved to tale.dev. Agents made it worse by guessing: Tale's own chat agent built URLs from page titles and translated folders (/de/verwaltung/mitglieder-und-rollen, …/automation-concepts, …/retention-limits). On ui.tale.dev, /docs and every section folder answered 404 from the server; only the client redirected.

This PR fixes the 404s and makes them unable to come back:

  • Every published address keeps answering. docs/redirects.json maps the 116 lost slugs to the page that replaced each; legal pages go to https://tale.dev/… in the reader's locale. Append-only ledgers (docs/published.json, services/ui-docs/content/published.json) record every slug either site ever served. A page that goes away without a redirect now fails CI.
  • Guessed addresses land. Just before its 404 page, each server asks a shared near-miss resolver (@tale/ui/docs/near-miss). Retired regional trees and case, index or .html noise fold onto the real page (301). A title-shaped or translated guess lands on the page that clearly wins (302). Junk and missing assets stay 404. The 404 page's "did you mean" list uses the same scorer. ui-docs answers /docs, section folders and moved guides with a 301 from the server.
  • The link lint is rebuilt (@tale/ui/docs/links, replacing three divergent copies). Links are read with the renderer's own parser: component attributes and reference links count, code never does. They resolve against the page URL like a browser does and are judged against what each site actually answers: no 404, no link through a redirect, every fragment an id the target renders, translated pages kept in their locale. ui-docs content is now covered.
  • Links into the docs are gated. bun run lint:links (tools/lint-links, CI Format job, bun run check) judges every absolute docs address in the repo and the docs paths code builds (${TALE_DOCS_URL}/…, the marketing site's docs lists).
  • Retiring a page is checked against the change. lint:links compares the working tree with the change's base commit: HEAD^1 in CI (a PR's merge commit), with the Format job checking out at fetch-depth: 2; locally the merge base with origin/main. It refuses a deleted or renamed page whose old address now 404s (retired-page-404), naming the exact redirects.json line to add, and a line removed from a published.json ledger (published-line-removed), so an agent can't make the published suite pass by deleting the ledger line. docs/AGENTS.md now has the step-by-step "Retire, rename or merge a page" procedure, and the ui-docs content contract, the write-docs skill and the repo contract point at it.
  • Built sites are crawled. @tale/e2e/crawl serves dist/ with each site's own server and follows everything the pages, llms.txt, the sitemap and the .md exports carry (test:prerender, now in CI's Build job).
  • Smaller fixes found on the way:
    • File links (/llms.txt, *.md) no longer go through the client router.
    • llms.txt now says German and French live under /de and /fr with the same, never-translated path.
    • The DPA's subprocessor link (a tale.dev 404 in all locales) now points at the docs list.
    • The marketing chat page no longer links a redirect.

Commits are atomic; see each body for detail.

Checklist

  • bun run check passes. Ran format:check, lint:conflicts, lint:links, lint:manual, knip, and turbo lint, typecheck and test for @tale/ui, @tale/docs, @tale/ui-docs, @tale/e2e, @tale/lint-links and @tale/web. Also typechecked @tale/platform and @tale/marketing-ui and ran their i18n, SEO and markdown tests. The full platform test/test:ui run is left to CI.
  • bun run lint:sast passes (467 rules, 0 findings).
  • Translations: N/A for keys. No UI string was added; the DPA link and the web docs path changed in en/de/fr. llms.txt is one English index for every locale.
  • Docs: N/A for docs/{en,de,fr} pages (no product behaviour changes). Contributor docs are updated: docs/AGENTS.md, services/docs/tests/AGENTS.md, the service READMEs, the ui-docs content contract, .agents/repo.md, and the write-docs skill. Manual boxes NAV-F18–F20 and SEO-12/13 are added, NAV-B1/F9 updated, and the automation registers extended.
  • Root READMEs: N/A.

Test plan

Everything below was run locally against production builds of this branch, served by each site's own server:

  • resolve-urls.ts: all 932 historic docs URLs resolve to a 200 page (live v0.5.63: 359 × 404). All 20 historic ui-docs URLs resolve.
  • The 7 addresses Tale's chat agent guessed each answer 302 to the right German page. They are locked in services/docs/tests/near-miss.test.ts.
  • ui-docs: /docs, /docs/components and /components/button answer 301; /docs/button and /docs/components/buton answer 302; /docs/components/select and /assets/missing.js stay 404.
  • Playwright: the German guess lands on "Mitglieder und Rollen". The 404 page ranks the Chat pages for /platform/chat/zzzz. llms.txt links do a full load.
  • A browser click-crawl of 426 docs pages (592 unique link targets, client-side navigation) found 0 client 404s, 0 missing fragments and 0 failed requests; ui-docs had 0 across 22 pages.
  • Both test:prerender crawls are green.
  • Retirement checks in the worktree: deleting a page in all locales yields one retired-page-404 naming the missing redirect, plus every inbound link (docs pages, READMEs, SCREENSHOTS.md, the marketing catalogs). Also deleting its ledger line adds published-line-removed. A git mv rename names the exact entry ("platform/chat/voice-mode": "platform/chat/voice"). Done right (redirect added, line kept), both rules pass and the inbound links are flagged link-via-redirect until they point at the new page. tools/lint-links/tests/git.test.ts covers base resolution against a real repository.
  • Mutation checks: planted breakages (typo, section folder, missing fragment, broken <Card href>, reference definition, image, locale switch, a README link, ${TALE_DOCS_URL}/develop/api-refrence) are each reported with a fix suggestion. Code samples and ../relative links are judged correctly.

Deploy note: merging doesn't deploy the sites. The live 404s stay until the next release builds the docs images.

The two documentation sites answer missing and moved addresses the same
way, so the machinery moves into the shared docs frame:

- `@tale/ui/docs/redirects`: the redirect map out of services/docs (slug
  maps, derived section folders, locale expansion, `.md` exports), now
  also taking an https target for a page that moved to another site.
- `@tale/ui/docs/near-miss`: the page a guessed address means, scored on
  slugs and titles in every locale. Language models guess addresses from
  titles (`/de/verwaltung/mitglieder-und-rollen`); an exact alias or a
  clear fuzzy winner is answered, anything else stays a 404. The 404
  page's "did you mean" list ranks with the same scorer.
- `@tale/ui/docs/published`: the append-only ledger of published slugs.
- `@tale/ui/docs/links`: the link rules, reading a page with the
  renderer's own parser and judging each link against what its site
  answers. They replace the i18n framework's two weaker copies
  (`markdown-link-target`, `markdown-anchor-parity`) and its drifted
  heading-slug function; heading ids now come from one pure module.
- `startReactServer` gains a `resolveNotFound` hook, asked only for a
  plain miss before the 404 page.
359 of the 932 docs addresses ever published answered 404: pages that
moved or were deleted without a redirect, the retired de-CH, de-AT and
fr-CH trees, Mintlify-era pages, and legal texts that moved to tale.dev.
ui.tale.dev answered 404 for /docs and every section folder, which only
the client redirected.

- docs/redirects.json maps the 116 lost slugs to the page that replaced
  each (rename history first, then content), the legal texts to
  https://tale.dev in the reader's locale, and the old Inbox pages to the
  Platform page that documents Home.
- docs/published.json and services/ui-docs/content/published.json record
  every slug either site ever served; the content builds append new pages.
  The published suites fail when a recorded slug stops answering in any
  locale, so a page can no longer go away without a redirect.
- Both servers answer what is still missing just before their 404 page:
  a retired regional tree, capitals or `index`/`.html` noise fold onto the
  real address (301); a guessed address, such as the German titles Tale's
  own chat agent turned into slugs, lands on the page that clearly wins
  (302). Junk and missing assets stay 404.
- ui-docs answers /docs, section folders and moved guides with a 301 from
  the server, from the same shared redirect machinery as the docs.
The old checks read inline Markdown links only, resolved them against
the locale root instead of the page, skipped anything with an extension,
never looked at ui-docs content, and left links into the docs from the
rest of the repository to "grep the monorepo".

- Each site describes what it answers (scripts/link-site.ts: pages,
  files, artifacts, redirects), and its link suite judges every link a
  page renders (the renderer's own parser, so component attributes and
  reference links count and code never does) against it: no 404, no link
  through a redirect, every fragment an id the target renders, translated
  pages kept in their locale. anchors.test.ts folds into it.
- tools/lint-links (`bun run lint:links`, CI's Format job and `bun run
  check`) judges the same way every absolute docs address in every other
  file, and the docs paths code builds (`${TALE_DOCS_URL}/…`, the
  marketing site's docs lists). It found the marketing site still linking
  a moved chat page.
- `@tale/e2e/crawl` serves a built site with its own server and follows
  every address the prerendered pages, llms.txt, the sitemap and the
  Markdown exports carry. Both sites run it in `test:prerender`, now in
  CI's Build job, catching the links the docs frame builds.
- turbo hashes the shared rules and the crawler for the tasks that read
  them, and caches dist-seo/ with the build, so neither a rule change nor
  a cache hit can replay a stale green.
RoutedMarkdown and Card sent every internal href through TanStack
Router, including `/llms.txt`, a page's `.md` export or an image. The
router knows only pages, so a click on such a link rendered the SPA's
not-found page instead of fetching the file. A link whose last segment
names a file now renders as a plain anchor, so the server answers it;
an external link keeps opening in a new tab.
llms.txt listed English addresses only and said nothing about the German
and French trees, so a model answering in German guessed, and translated
the path (`/de/verwaltung/mitglieder-und-rollen`). The index now says, in
the spec's place for how to read it, that every page lives under `/de`
and `/fr` with the same path, never translated, and to open only listed
addresses. The shared SEO pipeline carries an optional preamble through
both the precompiled and the on-demand builders.
- The data processing agreement pointed its subprocessor list at
  /legal/subprocessors on tale.dev, a 404 in every locale. The list is
  published on the docs site, so the agreement now links it there.
- The chat page's "Agents in chat" link went through the redirect of a
  merged docs page; it now links the page that redirect lands on.

Both were found by `bun run lint:links` and the tale.dev crawl.
The published suites only saw the tree as it is. An agent that met
`published-address-lost` could delete the ledger line, or the line and
its redirect together, and the lost address would pass. `lint:links` now
compares a change with its base commit:

- `retired-page-404`: a page file the change deletes or renames leaves
  its old address answering 404. One finding per page, naming the
  `redirects.json` line to add (with the new slug for a rename).
- `published-line-removed`: a slug the ledger held before the change is
  gone. The ledger is append-only.

The base is `LINT_LINKS_BASE`, else `HEAD^1` in GitHub Actions (a pull
request's merge commit has the base branch as its first parent; the
Format job now checks out with `fetch-depth: 2`, and a missing parent is
an error, never a skip), else the merge base with origin/main.

Page existence in the lint now comes from the content files rather than
the generated manifest, so a page deleted without regenerating it still
reads as gone, and a "did you mean" never names an address that is
missing itself.

docs/AGENTS.md gains the step-by-step retirement procedure. The ui-docs
content contract, the write-docs skill (whose description now names
moving and deleting pages), the repo contract and the published-suite
messages point at it.
CI's Unit job timed out `every link under en/ lands` at vitest's 5 s
default: on a two-core runner beside other suites, parsing the whole
corpus with the renderer's parser takes seconds, and it grows with every
page. Each page was also parsed twice, once as a source for its links and
again as a target for its anchors. The site modules now parse a page once
per run and answer both from it (the suite drops from ~1.6 s to ~1.1 s
per locale locally), and the corpus-wide cases carry an explicit 60 s
timeout. The near-miss test no longer asserts a wall-clock bound, which a
loaded runner could break; the word cap is asserted by its outcome.
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