diff --git a/apps/dox/scripts/deploy-smoke.mjs b/apps/dox/scripts/deploy-smoke.mjs index b446ddffc..c78276c79 100644 --- a/apps/dox/scripts/deploy-smoke.mjs +++ b/apps/dox/scripts/deploy-smoke.mjs @@ -18,11 +18,12 @@ * The whole set is retried up to 6 times, 10 s apart, for route propagation. The exit code * is 1 with a table of failures when the last attempt still fails. It does not roll back. * - * `DOX_SMOKE_LOCAL=http://localhost:8787` runs only the crawl-hygiene rows (`_headers` and the 404 - * page) against a local `wrangler dev` that serves the built `dist`. The redirect rows need the - * live hosts and are skipped, the slash rows (6a, 6b) among them, which check the 308 the Worker - * makes from the assets binding's 307. The workers.dev - * `noindex` rows (6c) match a host name, which `localhost` is not. + * `DOX_SMOKE_LOCAL=http://localhost:8787` runs only the crawl-hygiene rows (`_headers`, the 404 + * page and the slash rows 6a and 6b) against a local `wrangler dev` that serves the built `dist`. + * `wrangler dev` answers a slashless page with the assets binding's 307 as production does, so the + * 308 the Worker makes from it is checked there too. The old-host redirect rows need the live + * hosts and are skipped. The workers.dev `noindex` rows (6c) match a host name, which `localhost` + * is not. */ import { readFileSync } from "node:fs"; import { request as httpRequest } from "node:http"; @@ -148,19 +149,26 @@ const slashHop = (rows, label, url) => { }; /** - * The first page URL in the live sitemap that matches `re`: the first `` of the index, then the - * first match in that child sitemap. `undefined` when there is none, so a row can fail by name. + * The first page URL in the sitemap that matches `re`: the first `` of the index, then the + * first match in that child sitemap. Each `` names `northguild.dev`, so its path is read under + * `ND`, which is the local server under `DOX_SMOKE_LOCAL`. `undefined` when there is none, so a + * row can fail by name. */ async function firstSitemapUrl(re) { + const here = (loc) => `${ND}${new URL(loc).pathname}`; const index = await send("GET", `${ND}/gmt/sitemap-index.xml`); const child = /([^<]+)<\/loc>/.exec(index.body)?.[1]; if (child === undefined) return undefined; - const sitemap = await send("GET", child); + const sitemap = await send("GET", here(child)); return [...sitemap.body.matchAll(/([^<]+)<\/loc>/g)] - .map((m) => m[1]) + .map((m) => here(m[1])) .find((loc) => re.test(loc)); } +/** A function page from the sitemap, never a name typed here: pages get renamed. */ +const functionPage = () => + firstSitemapUrl(/\/gmt\/reference\/[^/]+\/[^/]+\/[^/]+\/$/); + /** The meta tag that asks a crawler not to index a page. */ const NOINDEX_META = /]*name="robots"[^>]*content="[^"]*noindex/i; @@ -170,6 +178,17 @@ const NOINDEX_META = /]*name="robots"[^>]*content="[^"]*noindex/i; */ async function crawlRows() { const rows = []; + slashHop(rows, "6a", `${ND}/gmt/reference`); + const fnPage = await functionPage(); + if (fnPage === undefined) { + rows.push({ + label: "6b", + url: `${ND}/gmt/sitemap-index.xml`, + steps: [{ status: 200, check: () => "no function page in the sitemap" }], + }); + } else { + slashHop(rows, "6b", `${fnPage.slice(0, -1)}?a=1`); + } const noindex = ({ headers }) => headers["x-robots-tag"] === "noindex" ? undefined @@ -337,20 +356,10 @@ async function buildRows() { hop(rows, "3", `${WD}/reference/`, `${ND}/gmt/reference/`); // The old host adds the page slash in its one 301, so an old link never chains. hop(rows, "6", `${WD}/reference`, `${ND}/gmt/reference/`); - slashHop(rows, "6a", `${ND}/gmt/reference`); - // A function page from the live sitemap, never a name typed here: pages get renamed. - const fnPage = await firstSitemapUrl( - /\/gmt\/reference\/[^/]+\/[^/]+\/[^/]+\/$/, - ); - if (fnPage === undefined) { - add({ - label: "6b", - url: `${ND}/gmt/sitemap-index.xml`, - steps: [{ status: 200, check: () => "no function page in the sitemap" }], - }); - } else { + // 6a and 6b, the slash rows, are in `crawlRows`; a missing function page fails there as 6b. + const fnPage = await functionPage(); + if (fnPage !== undefined) { const slashless = fnPage.slice(0, -1); - slashHop(rows, "6b", `${slashless}?a=1`); hop( rows, "6d", diff --git a/apps/dox/scripts/rendered-links.mjs b/apps/dox/scripts/rendered-links.mjs index 5795fd39a..cfb1ef792 100644 --- a/apps/dox/scripts/rendered-links.mjs +++ b/apps/dox/scripts/rendered-links.mjs @@ -21,7 +21,7 @@ */ import path from "node:path"; import { fileURLToPath } from "node:url"; -import { distPages, parseSweep, sweep } from "./lib/a11y-sweep.mjs"; +import { distPages, parseSweep, settle, sweep } from "./lib/a11y-sweep.mjs"; import { isPageLinkWithoutSlash, resolveHref } from "./lib/page-links.mjs"; import { listWidgetPages } from "./lib/widget-pages.mjs"; @@ -56,6 +56,7 @@ await sweep({ run, check: async ({ page }) => { await page.waitForSelector("[data-widget]", { state: "attached" }); + await settle(page); const pageUrl = page.url(); return (await readLinks(page)) .filter(({ href }) => isPageLinkWithoutSlash(resolveHref(href, pageUrl))) diff --git a/apps/dox/scripts/robots-policy.test.ts b/apps/dox/scripts/robots-policy.test.ts index c27111b04..98aaf9e2f 100644 --- a/apps/dox/scripts/robots-policy.test.ts +++ b/apps/dox/scripts/robots-policy.test.ts @@ -1,4 +1,3 @@ -import { describe, expect, it } from "vitest"; import { checkRobots, ROBOTS_POLICY } from "./robots-policy.mjs"; const SIGNAL = "Content-Signal: search=yes, ai-input=yes, ai-train=yes"; diff --git a/context/dox/built/index.md b/context/dox/built/index.md index 039102dbe..9a3b9ace1 100644 --- a/context/dox/built/index.md +++ b/context/dox/built/index.md @@ -77,7 +77,8 @@ change. | [tier-2-platform.md](tier-2-platform.md) | Component kit, global sheets, widget tests, test isolation, element identity, playground, Escape | | [tier-2-tools.md](tier-2-tools.md) | Rules for every tool, registering a tool, industry tags, permalinks, traps | | [tier-2-webmcp.md](tier-2-webmcp.md) | Page tools (WebMCP): marker and offer, shared facts, schemas, links, the gate, the origin-trial token | -| [tier-2-gates.md](tier-2-gates.md) | Gates, the runner, CI jobs | +| [tier-2-gates.md](tier-2-gates.md) | Gates | +| [tier-2-runner-and-ci.md](tier-2-runner-and-ci.md) | The gate runner, sharding, CI jobs for Dox | | [slides.md](slides.md) | Slide decks: the stage, `.gmt-stage-fit`, presenter previews, text floor, title-safe edges and guide, wake lock, venue runbook | | [tier-3-chrome.md](tier-3-chrome.md) | HUD chrome, header, landing entrance, cross-site transition | | [tier-3-sound.md](tier-3-sound.md) | Sound engine and cues, the settings control, native panel motion | diff --git a/context/dox/built/tier-0-1-site.md b/context/dox/built/tier-0-1-site.md index 34d8886b2..ed1721aa0 100644 --- a/context/dox/built/tier-0-1-site.md +++ b/context/dox/built/tier-0-1-site.md @@ -51,7 +51,9 @@ Rules, traps and runbooks for the site shell. Index: [index.md](index.md). `/gmt/*.md` and `/gmt/*.txt` are `X-Robots-Tag: noindex` (the test fails on any `.txt` other than `llms.txt` and `llms-full.txt`). - `scripts/deploy-smoke.mjs` checks the redirect matrix and crawl rows after each deploy. - `DOX_SMOKE_LOCAL=http://localhost:8787` runs only the crawl rows against `wrangler dev`. + `DOX_SMOKE_LOCAL=http://localhost:8787` runs only the crawl rows (`_headers`, the 404 page and the + slash rows 6a and 6b, whose 308 the Worker makes from the assets binding's 307) against + `wrangler dev`; the old-host and `workers.dev` rows need the live hosts. - `robots.txt` is served by the landing Worker. Googlebot and Bingbot have a group of their own that skips the `.md` twins and page URLs with a query; every other agent reads them. `scripts/robots-policy.mjs` holds the policy table, and `deploy-smoke` checks the live file diff --git a/context/dox/built/tier-2-gates.md b/context/dox/built/tier-2-gates.md index 9374eedf6..7ae11be29 100644 --- a/context/dox/built/tier-2-gates.md +++ b/context/dox/built/tier-2-gates.md @@ -21,26 +21,4 @@ Part of [built/index.md](index.md). Operator steps (run, baseline, weekly sweep, - `contrast-measure` is Chromium only. It clips a glyph rect to each scroller's client box, never its border box. Its disabled-field border check measures the visible element: for a switch, whose input is transparent, that is the track beside it (`.track`, a dashed `--gmt-ice-dim` edge at 3:1). `a11y-media`'s `forced-colors-boundary` does the same. Both match the switch's own markup (an `input[role="switch"]` at opacity 0 with an `aria-hidden` track after it); any other transparent control is judged on itself. - `canada-layout-check` takes `--browsers` and `--engine`, checks both clock-change pages in dark and light at 1440, 1024, 420, 375 and 300 px (420 is just above the WebKit stack threshold), and measures the probe table as loaded and with the verdict forced to ok, bad and unreadable. Offsets come from the page's own config through `expectedOffsets` in `scripts/lib/clock-check-harness.mjs`. -## The runner - -- `pnpm --filter dox gates` (`scripts/gates.mjs`) runs every gate from one build and one static server and prints one screen. Gates are data in `scripts/gates/registry.mjs` (`id`, `script`, `tier`, `browsers`, `fullBrowsers`, `themes`, `needs`, plus `args`, `base`, `browserArg`, `pages`). `select.mjs` turns changed files and the import graph (`graph.mjs`) into pages; `screen.mjs` prints. -- Tiers nest. `pr`: contrast-measure, grow-measure, readout-still, data-credits-check, esc-cascade, hero-phone, sound-check, rail-stored-still, canada-layout-check, rendered-links, frame-check, a11y-axe, a11y-tab-walk, a11y-media. `weekly` adds canada-clock-still, canada-stored-still, table-fit, plate-fit. `local` adds globe-smoke, html-diff, visual-diff (they need a GPU or a baseline). -- Page contract: every gate script answers `--list-pages` (a JSON array of site paths without `/gmt`, no browser, printed whole however long, since the runner reads it through a pipe), takes `--pages ` (an unknown path exits 2) and, when it loads pages, `--base `. With `GATE_REPORT` set, each failure goes through `recordFinding` as `{ gate, rule, page, selector, browser, width, theme, message }` (`rule` is a short stable id such as `readout-moved`, never prose), and the run ends with `recordMeasured(gate, n)` (`scripts/gates/findings.mjs`, `contract.mjs`). Exit 0 without that line, or with `n = 0`, is `FAIL measured nothing`; exit 0 with findings is FAIL. -- `hero-phone` (`hero-phone-check.mjs`, Chromium and WebKit; pages `/` and `/guides/`; zone pinned to Africa/Nairobi) holds the stacked landing on six phone sizes (`hero-phone-check.mjs` lists them), in `?globe=canvas2d`: title, buttons, then the Earth on the first screen; the atmosphere whole; no carousel, hidden or scrolling pane; headings clear of the header; a tap on "Find a zone" that does not scroll and keeps the field in view; 44 px targets, failing on fewer than expected (sheet buttons, field, three options; four zoom buttons); a tap on the Earth that leaves the sheet shut; the zone card, dragged toward each edge, inside the stage and above the open sheet; a still disc under a drag; no sideways scroll; zero layout shift (engines that report it); stars smaller than at 1440 x 900; and the header rule (title not clipped, wordmark and name ≥ 12px, no Dox, GitHub or Discord link below 50rem, the hero row only "Get started" and "Ask Dox", no eyebrow, the h1 kept). At 1440 x 900 the carousel is wired; a stacked-to-locked resize shows only the pane the reader had scrolled to, with no entrance motion. CI runs the Chromium leg (`other`); WebKit runs locally with `--browsers webkit`. -- Page costs: a gate whose pages differ a lot in run time is `costs: true` in the registry and also answers `--list-page-costs` (each path's minutes). `readout-still` is the one: its costs are the `minutes` on each `TOOLS` entry, one WebKit run of that tool on one machine, since only the ratios matter. A page with no cost stops a sharded run. -- `grow-measure`, `readout-still`, `data-credits-check` and the three Canada scripts accept `firefox` in `--browsers`. -- The deadline (`--deadline `) is enforced by `scripts/gates/run-command.mjs` (`runCommand`, tested in `run-command.test.ts`): at the limit it records the report file's byte length, sends SIGTERM and sends SIGKILL after a 10 s grace. Playwright's default `handleSIGTERM` closes the browsers but never exits, so `launchBrowser` passes `handleSIGTERM: false` and the gate dies with the signal. `readReport(file, { upTo })` drops every line past that offset, so a gate that kept running cannot file `check-crashed` for the pages it never reached. The row says "stopped at the Nm deadline" and `outOfTime` files that alone. A runner test that spawns a child uses a fake clock or an `AbortSignal` and kills the child in `afterEach`. -- A retry starts only when the time left exceeds the first attempt's duration (`retryFits`). A retry the deadline cuts short does not replace the first attempt: `afterRetry` keeps attempt 1's status and findings and adds the out-of-time note. -- `shardOf(list, shard, costs, offset = 0)` deals round-robin from `(index + offset) % n`. `gates.mjs` passes the gate's index in `registry.mjs` as the offset, so one-page gates land on different legs and not all on shard 1. Costed dealing (`readout-still`) ignores the offset. -- Selection: a changed file selects the pages whose import closure holds it (`.mdx`, `.astro`, `.ts`, `.tsx`, `.mjs`, `.css`; relative paths and `~/`). A change under `packages/gmt/src///` selects the pages that import `@northguild/gmt//` plus the sample. Chrome files (`src/styles/*`, Starlight overrides, `astro.config.mjs`, `apps/dox/package.json`, `pnpm-lock.yaml`), any other library change and any `apps/dox/` file no page closure holds select the sample (`SAMPLE` in the registry; `registry.test.ts` asserts each path is in `dist`). A changed gate script runs that gate on the sample; a changed runner file (`scripts/gates/`, `gates.mjs`, `gate-checks.mjs`, `scripts/lib/`) runs every gate on the sample. A deck route (`src/pages/slides/[slug]/`) is a page at each deck's path (`gates.mjs` passes `allDeckRoutes` to `buildPages`), so a deck change selects its deck. Over 12 pages the run keeps the sample plus 6 picked evenly, plus one selected page for any gate those would leave with none (a deck for `slides-check`); `--all` lifts the cap. Test files and `apps/dox/src/test/` helpers never select a page. With no changed file under `apps/dox/`, `packages/gmt/src/` or `pnpm-lock.yaml`, the runner prints `gates: PASS nothing to check` and does not build. -- An empty run is not a pass: when the diff selects pages but no requested browser can run an applicable gate (`emptyRunOutcome` in `gates/select.mjs`), `gates` exits 2. `contrast-measure` is Chromium only, so `--browsers firefox` alone runs nothing for it. - -## CI jobs for Dox - -- `dox-site` ("Dox site build") builds `@northguild/gmt` and the site once on Node 22 with `fetch-depth: 0` and uploads the `dox-site` artifact. It runs when `determine-affected` selects `dox-dist` or `dox-tables`, and on every PR reporting `dox_changed`. The artifact is one tar of `apps/dox/dist`, every gitignored generated file (`src/generated/`, reference, changelog and industry pages under `src/content/docs/`, `public/llms*.txt`) and every tracked file the build rewrote; `dist/` alone is not enough because gate selection reads `src/content/docs/**`. The pack step passes NUL-delimited names to `tar --null -T -`. It keeps 14 days with `overwrite: true` (`download-artifact` keeps the first of two same-named artifacts, #380). A failed `dox-site` skips every job that needs it. -- `consistency` keeps only fast checks and builds nothing. -- `dox-browser` unpacks the artifact, builds `@northguild/gmt`, and runs `test:dist` (`DOX_DIST_REQUIRED=1`), the browser tests and `frame-check`, on the `dox-dist` and `dox-tables` checks. -- `dox-table-fit` runs `table-fit` in four shards ("Dox tables fit (shard 1/4)" to "4/4"), Chromium only, `fail-fast` off. The `dox-tables` check (`scripts/lib/affected.mjs`) runs on every Dox change and every `packages/gmt/src` change (`GMT_LIB`) and always opens every table page: a shared change can spill a table on a page it never touched. A shard that measures no table fails. -- `dox-gates` runs on PRs reporting `dox_changed`, after `dox-site`, as five legs, each `gates --tier pr --browsers chromium --themes dark,light --no-build --against origin/`. The runner exits 2 if `dist/gmt/index.html` is missing. Gates stay serial within a leg because the clock-still gates flake when gates share a runner. The legs are `readout-still` (`--only readout-still`, job 40 min and step 35; one page takes 4m35s, with the Timetable Reader 25m37s), `contrast` (`--only contrast-measure`), `canada` (`--only canada-layout-check,data-credits-check,a11y-media,frame-check`), `esc-grow` (`--only esc-cascade,grow-measure`) and `other` (`--skip` the gates the others name, so a gate added later lands here). Non-`readout-still` legs have 20 / 15 minute job / step limits. `scripts/gates/ci-legs.test.ts` reads `ci.yml` and fails when a `pr`-tier gate runs in no leg or two. The runner prints its screen at the end and appends it to `$GITHUB_STEP_SUMMARY` (`gates/step-summary.mjs`). Each gate logs to `.gates/`; a leg's step stops 5 minutes before its job so a failed leg uploads `apps/dox/.gates/` (without `vite-cache/`) as `dox-gates--`. -- The `dox-gates` jobs are advisory until the owner makes them required. A PR touching nothing under `apps/dox/` or `pnpm-lock.yaml` skips them; a lockfile change alone runs them (Playwright or axe-core may bump). -- One Dox PR runs up to 11 Dox jobs against the organisation's 20 concurrent jobs. +The runner and the CI jobs that run these gates: [tier-2-runner-and-ci.md](tier-2-runner-and-ci.md). diff --git a/context/dox/built/tier-2-runner-and-ci.md b/context/dox/built/tier-2-runner-and-ci.md new file mode 100644 index 000000000..3b77ad650 --- /dev/null +++ b/context/dox/built/tier-2-runner-and-ci.md @@ -0,0 +1,27 @@ +# Tier 2: the gate runner and CI + +Part of [built/index.md](index.md). The gates themselves: [tier-2-gates.md](tier-2-gates.md). Operator steps: [tier-6-runbooks.md](tier-6-runbooks.md). + +## The runner + +- `pnpm --filter dox gates` (`scripts/gates.mjs`) runs every gate from one build and one static server and prints one screen. Gates are data in `scripts/gates/registry.mjs` (`id`, `script`, `tier`, `browsers`, `fullBrowsers`, `themes`, `needs`, plus `args`, `base`, `browserArg`, `pages`). `select.mjs` turns changed files and the import graph (`graph.mjs`) into pages; `screen.mjs` prints. +- Tiers nest. `pr`: contrast-measure, grow-measure, readout-still, data-credits-check, esc-cascade, hero-phone, sound-check, rail-stored-still, canada-layout-check, rendered-links, frame-check, a11y-axe, a11y-tab-walk, a11y-media. `weekly` adds canada-clock-still, canada-stored-still, table-fit, plate-fit. `local` adds globe-smoke, html-diff, visual-diff (they need a GPU or a baseline). +- Page contract: every gate script answers `--list-pages` (a JSON array of site paths without `/gmt`, no browser, printed whole however long, since the runner reads it through a pipe), takes `--pages ` (an unknown path exits 2) and, when it loads pages, `--base `. With `GATE_REPORT` set, each failure goes through `recordFinding` as `{ gate, rule, page, selector, browser, width, theme, message }` (`rule` is a short stable id such as `readout-moved`, never prose), and the run ends with `recordMeasured(gate, n)` (`scripts/gates/findings.mjs`, `contract.mjs`). Exit 0 without that line, or with `n = 0`, is `FAIL measured nothing`; exit 0 with findings is FAIL. +- `hero-phone` (`hero-phone-check.mjs`, Chromium and WebKit; pages `/` and `/guides/`; zone pinned to Africa/Nairobi) holds the stacked landing on six phone sizes (`hero-phone-check.mjs` lists them), in `?globe=canvas2d`: title, buttons, then the Earth on the first screen; the atmosphere whole; no carousel, hidden or scrolling pane; headings clear of the header; a tap on "Find a zone" that does not scroll and keeps the field in view; 44 px targets, failing on fewer than expected (sheet buttons, field, three options; four zoom buttons); a tap on the Earth that leaves the sheet shut; the zone card, dragged toward each edge, inside the stage and above the open sheet; a still disc under a drag; no sideways scroll; zero layout shift (engines that report it); stars smaller than at 1440 x 900; and the header rule (title not clipped, wordmark and name ≥ 12px, no Dox, GitHub or Discord link below 50rem, the hero row only "Get started" and "Ask Dox", no eyebrow, the h1 kept). At 1440 x 900 the carousel is wired; a stacked-to-locked resize shows only the pane the reader had scrolled to, with no entrance motion. CI runs the Chromium leg (`other`); WebKit runs locally with `--browsers webkit`. +- Page costs: a gate whose pages differ a lot in run time is `costs: true` in the registry and also answers `--list-page-costs` (each path's minutes). `readout-still` is the one: its costs are the `minutes` on each `TOOLS` entry, one WebKit run of that tool on one machine, since only the ratios matter. A page with no cost stops a sharded run. +- `grow-measure`, `readout-still`, `data-credits-check` and the three Canada scripts accept `firefox` in `--browsers`. +- The deadline (`--deadline `) is enforced by `scripts/gates/run-command.mjs` (`runCommand`, tested in `run-command.test.ts`): at the limit it records the report file's byte length, sends SIGTERM and sends SIGKILL after a 10 s grace. Playwright's default `handleSIGTERM` closes the browsers but never exits, so `launchBrowser` passes `handleSIGTERM: false` and the gate dies with the signal. `readReport(file, { upTo })` drops every line past that offset, so a gate that kept running cannot file `check-crashed` for the pages it never reached. The row says "stopped at the Nm deadline" and `outOfTime` files that alone. A runner test that spawns a child uses a fake clock or an `AbortSignal` and kills the child in `afterEach`. +- A retry starts only when the time left exceeds the first attempt's duration (`retryFits`). A retry the deadline cuts short does not replace the first attempt: `afterRetry` keeps attempt 1's status and findings and adds the out-of-time note. +- `shardOf(list, shard, costs, offset = 0)` deals round-robin from `(index + offset) % n`. `gates.mjs` passes the gate's index in `registry.mjs` as the offset, so one-page gates land on different legs and not all on shard 1. Costed dealing (`readout-still`) ignores the offset. +- Selection: a changed file selects the pages whose import closure holds it (`.mdx`, `.astro`, `.ts`, `.tsx`, `.mjs`, `.css`; relative paths and `~/`). A change under `packages/gmt/src///` selects the pages that import `@northguild/gmt//` plus the sample. Chrome files (`src/styles/*`, Starlight overrides, `astro.config.mjs`, `apps/dox/package.json`, `pnpm-lock.yaml`), any other library change and any `apps/dox/` file no page closure holds select the sample (`SAMPLE` in the registry; `registry.test.ts` asserts each path is in `dist`). A changed gate script runs that gate on the sample; a changed runner file (`scripts/gates/`, `gates.mjs`, `gate-checks.mjs`, `scripts/lib/`) runs every gate on the sample. A deck route (`src/pages/slides/[slug]/`) is a page at each deck's path (`gates.mjs` passes `allDeckRoutes` to `buildPages`), so a deck change selects its deck. Over 12 pages the run keeps the sample plus 6 picked evenly, plus one selected page for any gate those would leave with none (a deck for `slides-check`); `--all` lifts the cap. Test files and `apps/dox/src/test/` helpers never select a page. With no changed file under `apps/dox/`, `packages/gmt/src/` or `pnpm-lock.yaml`, the runner prints `gates: PASS nothing to check` and does not build. +- An empty run is not a pass: when the diff selects pages but no requested browser can run an applicable gate (`emptyRunOutcome` in `gates/select.mjs`), `gates` exits 2. `contrast-measure` is Chromium only, so `--browsers firefox` alone runs nothing for it. + +## CI jobs for Dox + +- `dox-site` ("Dox site build") builds `@northguild/gmt` and the site once on Node 22 with `fetch-depth: 0` and uploads the `dox-site` artifact. It runs when `determine-affected` selects `dox-dist` or `dox-tables`, and on every PR reporting `dox_changed`. The artifact is one tar of `apps/dox/dist`, every gitignored generated file (`src/generated/`, reference, changelog and industry pages under `src/content/docs/`, `public/llms*.txt`) and every tracked file the build rewrote; `dist/` alone is not enough because gate selection reads `src/content/docs/**`. The pack step passes NUL-delimited names to `tar --null -T -`. It keeps 14 days with `overwrite: true` (`download-artifact` keeps the first of two same-named artifacts, #380). A failed `dox-site` skips every job that needs it. +- `consistency` keeps only fast checks and builds nothing. +- `dox-browser` unpacks the artifact, builds `@northguild/gmt`, and runs `test:dist` (`DOX_DIST_REQUIRED=1`), the browser tests and `frame-check`, on the `dox-dist` and `dox-tables` checks. +- `dox-table-fit` runs `table-fit` in four shards ("Dox tables fit (shard 1/4)" to "4/4"), Chromium only, `fail-fast` off. The `dox-tables` check (`scripts/lib/affected.mjs`) runs on every Dox change and every `packages/gmt/src` change (`GMT_LIB`) and always opens every table page: a shared change can spill a table on a page it never touched. A shard that measures no table fails. +- `dox-gates` runs on PRs reporting `dox_changed`, after `dox-site`, as five legs, each `gates --tier pr --browsers chromium --themes dark,light --no-build --against origin/`. The runner exits 2 if `dist/gmt/index.html` is missing. Gates stay serial within a leg because the clock-still gates flake when gates share a runner. The legs are `readout-still` (`--only readout-still`, job 40 min and step 35; one page takes 4m35s, with the Timetable Reader 25m37s), `contrast` (`--only contrast-measure`), `canada` (`--only canada-layout-check,data-credits-check,a11y-media,frame-check`), `esc-grow` (`--only esc-cascade,grow-measure`) and `other` (`--skip` the gates the others name, so a gate added later lands here). Non-`readout-still` legs have 20 / 15 minute job / step limits. `scripts/gates/ci-legs.test.ts` reads `ci.yml` and fails when a `pr`-tier gate runs in no leg or two. The runner prints its screen at the end and appends it to `$GITHUB_STEP_SUMMARY` (`gates/step-summary.mjs`). Each gate logs to `.gates/`; a leg's step stops 5 minutes before its job so a failed leg uploads `apps/dox/.gates/` (without `vite-cache/`) as `dox-gates--`. +- The `dox-gates` jobs are advisory until the owner makes them required. A PR touching nothing under `apps/dox/` or `pnpm-lock.yaml` skips them; a lockfile change alone runs them (Playwright or axe-core may bump). +- One Dox PR runs up to 11 Dox jobs against the organisation's 20 concurrent jobs. diff --git a/context/dox/cloudflare-runbook.md b/context/dox/cloudflare-runbook.md index d47be5a68..2dd2a25cc 100644 --- a/context/dox/cloudflare-runbook.md +++ b/context/dox/cloudflare-runbook.md @@ -109,85 +109,8 @@ rollback does not remove the Route, and an older build may lack the `/gmt/` file ## 4. Search engines and crawler reports -1. **Search Console**, Domain property `northguild.dev` (verified by the - `google-site-verification` TXT record). Under **Sitemaps** submit - `https://northguild.dev/gmt/sitemap-index.xml`, and the root `sitemap-index.xml` once it - exists. Check: status "Success" with a URL count; **Indexing → Pages** shows the not-indexed - reasons. **URL Inspection** on `/gmt/`, a reference page and `/gmt/install.md` names the - canonical Google chose. -2. **Bing Webmaster Tools** → **Add site → Import from Google Search Console**, then submit the - same sitemaps. Check: verified, sitemap processed, indexed-page count shown. -3. **AI Crawl Control** report: per-crawler request counts for the last 30 days. Read-only; the - switches stay as §1 sets them. Check: counts for GPTBot, OAI-SearchBot, ChatGPT-User, - ClaudeBot, Claude-SearchBot, Claude-User, PerplexityBot, Google-Extended and Bingbot, and no - blocked requests. -4. **Reindexing steps** after a change to redirects, the `workers.dev` host rule or `robots.txt` - reaches production: - 1. **robots.txt report** (Settings → robots.txt). Check that it shows the fetch with the - `Googlebot` group. If the fetch is older, choose "Request a recrawl". Google caches - robots.txt for up to 24 hours. - 2. **Sitemaps.** Resubmit `https://northguild.dev/gmt/sitemap-index.xml`. In Bing Webmaster - Tools, resubmit the same sitemap. - 3. **Validate Fix**, per reason, in the Page indexing report: "Duplicate, Google chose - different canonical than user", "Crawled – currently not indexed", "Discovered – currently - not indexed" and "Alternate page with proper canonical tag". Do **not** validate "Page with - redirect" or "Excluded by 'noindex' tag": those URLs stay excluded as intended, and - validation would only report them as failing. - 4. **URL Inspection → Request indexing** for the pages in the list below, nine requests inside - the daily quota. The pages under "Crawled – currently not indexed" are substantial, 200, - self-canonical and in the sitemap, so the report needs no change on the site; Google says - the state needs no action and can change on a later crawl. - -**Pages to inspect again** (URL Inspection → "Google-selected canonical"). Paths are under -`https://northguild.dev/gmt/`. - -*Duplicate, Google chose different canonical* (each page has a self canonical, a sitemap entry and -a 200): - -| Page | Google-selected canonical | Referring pages | Last crawl | Cause | -| --- | --- | --- | --- | --- | -| `reference/duration/calculate/totalDuration/` | N/A | `gmt-dox.northguild.workers.dev/reference/duration/calculate/totalDuration/`; `/gmt/tools/interval-visualizer/` | 2026-11-17 | the `workers.dev` copy; its `noindex` rule and one hop fix it | -| `reference/calendar/hours/operatingIntervals/` | N/A | `/gmt/reference/zoned/calculate/endOfQuarterForZoned` (no slash, 307); `/gmt/tools/interval-visualizer/` | 2026-11-16 | the slashless 307; the 308 fixes it | -| `reference/types/RoundingOptions/` | `https://gmt-dox.northguild.workers.dev/reference/types/RoundingOptions/` | the old host without the slash; `/gmt/tools/interval-visualizer/` | 2026-11-03 | the old host; one 301 and `noindex` fix it | - -The Sitemaps line for `RoundingOptions` reads "Temporary processing error"; step 2 covers it. - -*Crawled – currently not indexed*, the six HTML pages: - -| Page | Words | Verdict | -| --- | --- | --- | -| `guides/recurrence-and-cron/` | 2,903 | substantial, linked from every sidebar | -| `guides/splitting-and-counting/` | 2,324 | same | -| `guides/workforce-hours-of-work/` | 7,525 | same | -| `guides/mistakes/transport/` | 3,031 | same | -| `guides/durations/` | 2,344 | same | -| `reference/plain/parse/parseMonthFromDateTime/` | 127 | thin, the same shape as about 1,000 indexed generated reference pages | - -What "Google-selected canonical" means for those pages: - -| Google-selected canonical | Meaning | Action | -| --- | --- | --- | -| the same URL without the slash | the 307 source | Validate Fix after the 308 is live | -| the `.md` twin | the twin outranked the page | none; the `robots.txt` group skips the twins | -| a `?w=` or `?tz=` URL | a permalink outranked the page | none; the `robots.txt` group skips them | -| a `gmt-dox.northguild.workers.dev` URL, or N/A with that host as referring page | the duplicate host | none; inspect again after the host's `noindex` is live | -| the page itself | resolved | none | - -**Timeline and shape:** - -| When | Expect | -| --- | --- | -| 1 day | the robots.txt report shows the new file | -| 1–2 weeks | about 242 `.md` twins and 134 query URLs move to "Blocked by robots.txt" (expected, no action); validation of the four reasons reports progress | -| 2–4 weeks | the slashless 307 URLs consolidate to their slash pages; "Page with redirect" stops growing (it does not empty: the 301s and `http://` URLs stay) | -| 4–8 weeks | "Discovered – currently not indexed" falls as the freed crawl reaches the 331 pages | - -Check the report at 2, 4 and 8 weeks. - -**Watch for "Indexed, though blocked by robots.txt".** If a `?w=` or `?tz=` URL or a `.md` twin -appears there, Google is indexing it from links alone. Report it with the URLs. The answer is a -decision about the policy in `robots-policy.mjs`, not a `robots.txt` edit, because unblocking -would undo the block. +Search Console, Bing Webmaster Tools, the steps after a deploy and the pages to inspect again: +[search-console-runbook.md](search-console-runbook.md). ## 5. GitHub diff --git a/context/dox/index.md b/context/dox/index.md index 1f76f95b1..b826d85e4 100644 --- a/context/dox/index.md +++ b/context/dox/index.md @@ -10,6 +10,8 @@ Load only what the task needs: - [tracker.md](tracker.md) — stories, GitHub issues, status. - [cloudflare-runbook.md](cloudflare-runbook.md) — zone settings, API tokens, deploy checks and search-engine setup for `northguild.dev`. Load for a deploy, a zone audit or a 403 from a crawler. +- [search-console-runbook.md](search-console-runbook.md) — Search Console and Bing Webmaster + Tools for `northguild.dev`: the steps after a deploy and the pages to inspect again. - [specs/index.md](specs/index.md) — the execution spec of a story in progress; deleted when the story is Done, with any rule the code cannot show moved into `built/`. - [reference/design-system.md](reference/design-system.md) — theme implementation rules: stylesheet stack, tokens, maintenance rules, the visual gate. Load when styling. Scoped companions, loaded diff --git a/context/dox/reference/verification-and-risks.md b/context/dox/reference/verification-and-risks.md index 54da3711c..daa984bf3 100644 --- a/context/dox/reference/verification-and-risks.md +++ b/context/dox/reference/verification-and-risks.md @@ -37,7 +37,7 @@ [design-system.md](design-system.md)). - **Where they run:** a Dox PR runs the `pr` tier on its changed pages in Chromium (the `dox-gates` job), and `dox-gates-weekly.yml` sweeps every page in three browsers. See - [CI jobs for Dox](../built/tier-2-gates.md#ci-jobs-for-dox) and + [CI jobs for Dox](../built/tier-2-runner-and-ci.md#ci-jobs-for-dox) and [The weekly gate sweep](../built/tier-6-ops.md#the-weekly-gate-sweep). - **Gate findings:** a finding's key is `gate:rule:page:target`, where the target is the element's identity key. A widget root without `data-widget` makes every finding under it fall back to the diff --git a/context/dox/search-console-runbook.md b/context/dox/search-console-runbook.md new file mode 100644 index 000000000..5c031ad52 --- /dev/null +++ b/context/dox/search-console-runbook.md @@ -0,0 +1,85 @@ +# Search engine runbook — northguild.dev (the owner's) + +Part of the [Cloudflare and GitHub runbook](cloudflare-runbook.md). Search Console, Bing +Webmaster Tools and the crawler reports for `northguild.dev`. Load it after a deploy that changes +what crawlers see, or to read the Page indexing report. + +1. **Search Console**, Domain property `northguild.dev` (verified by the + `google-site-verification` TXT record). Under **Sitemaps** submit + `https://northguild.dev/gmt/sitemap-index.xml`, and the root `sitemap-index.xml` once it + exists. Check: status "Success" with a URL count; **Indexing → Pages** shows the not-indexed + reasons. **URL Inspection** on `/gmt/`, a reference page and `/gmt/install.md` names the + canonical Google chose. +2. **Bing Webmaster Tools** → **Add site → Import from Google Search Console**, then submit the + same sitemaps. Check: verified, sitemap processed, indexed-page count shown. +3. **AI Crawl Control** report: per-crawler request counts for the last 30 days. Read-only; the + switches stay as [cloudflare-runbook.md §1](cloudflare-runbook.md#1-zone-settings) sets them. + Check: counts for GPTBot, OAI-SearchBot, ChatGPT-User, ClaudeBot, Claude-SearchBot, + Claude-User, PerplexityBot, Google-Extended and Bingbot, and no blocked requests. +4. **Reindexing steps** after a change to redirects, the `workers.dev` host rule or `robots.txt` + reaches production: + 1. **robots.txt report** (Settings → robots.txt). Check that it shows the fetch with the + `Googlebot` group. If the fetch is older, choose "Request a recrawl". Google caches + robots.txt for up to 24 hours. + 2. **Sitemaps.** Resubmit `https://northguild.dev/gmt/sitemap-index.xml`. In Bing Webmaster + Tools, resubmit the same sitemap. + 3. **Validate Fix**, per reason, in the Page indexing report: "Duplicate, Google chose + different canonical than user", "Crawled – currently not indexed", "Discovered – currently + not indexed" and "Alternate page with proper canonical tag". Do **not** validate "Page with + redirect" or "Excluded by 'noindex' tag": those URLs stay excluded as intended, and + validation would only report them as failing. + 4. **URL Inspection → Request indexing** for the pages in the list below, nine requests inside + the daily quota. The pages under "Crawled – currently not indexed" are substantial, 200, + self-canonical and in the sitemap, so the report needs no change on the site; Google says + the state needs no action and can change on a later crawl. + +**Pages to inspect again** (URL Inspection → "Google-selected canonical"). Paths are under +`https://northguild.dev/gmt/`. + +*Duplicate, Google chose different canonical* (each page has a self canonical, a sitemap entry and +a 200): + +| Page | Google-selected canonical | Referring pages | Last crawl | Cause | +| --- | --- | --- | --- | --- | +| `reference/duration/calculate/totalDuration/` | N/A | `gmt-dox.northguild.workers.dev/reference/duration/calculate/totalDuration/`; `/gmt/tools/interval-visualizer/` | 2026-11-17 | the `workers.dev` copy; its `noindex` rule and one hop fix it | +| `reference/calendar/hours/operatingIntervals/` | N/A | `/gmt/reference/zoned/calculate/endOfQuarterForZoned` (no slash, 307); `/gmt/tools/interval-visualizer/` | 2026-11-16 | the slashless 307; the 308 fixes it | +| `reference/types/RoundingOptions/` | `https://gmt-dox.northguild.workers.dev/reference/types/RoundingOptions/` | the old host without the slash; `/gmt/tools/interval-visualizer/` | 2026-11-03 | the old host; one 301 and `noindex` fix it | + +The Sitemaps line for `RoundingOptions` reads "Temporary processing error"; step 2 covers it. + +*Crawled – currently not indexed*, the six HTML pages: + +| Page | Words | Verdict | +| --- | --- | --- | +| `guides/recurrence-and-cron/` | 2,903 | substantial, linked from every sidebar | +| `guides/splitting-and-counting/` | 2,324 | same | +| `guides/workforce-hours-of-work/` | 7,525 | same | +| `guides/mistakes/transport/` | 3,031 | same | +| `guides/durations/` | 2,344 | same | +| `reference/plain/parse/parseMonthFromDateTime/` | 127 | thin, the same shape as about 1,000 indexed generated reference pages | + +What "Google-selected canonical" means for those pages: + +| Google-selected canonical | Meaning | Action | +| --- | --- | --- | +| the same URL without the slash | the 307 source | Validate Fix after the 308 is live | +| the `.md` twin | the twin outranked the page | none; the `robots.txt` group skips the twins | +| a `?w=` or `?tz=` URL | a permalink outranked the page | none; the `robots.txt` group skips them | +| a `gmt-dox.northguild.workers.dev` URL, or N/A with that host as referring page | the duplicate host | none; inspect again after the host's `noindex` is live | +| the page itself | resolved | none | + +**Timeline and shape:** + +| When | Expect | +| --- | --- | +| 1 day | the robots.txt report shows the new file | +| 1–2 weeks | about 242 `.md` twins and 134 query URLs move to "Blocked by robots.txt" (expected, no action); validation of the four reasons reports progress | +| 2–4 weeks | the slashless 307 URLs consolidate to their slash pages; "Page with redirect" stops growing (it does not empty: the 301s and `http://` URLs stay) | +| 4–8 weeks | "Discovered – currently not indexed" falls as the freed crawl reaches the 331 pages | + +Check the report at 2, 4 and 8 weeks. + +**Watch for "Indexed, though blocked by robots.txt".** If a `?w=` or `?tz=` URL or a `.md` twin +appears there, Google is indexing it from links alone. Report it with the URLs. The answer is a +decision about the policy in `robots-policy.mjs`, not a `robots.txt` edit, because unblocking +would undo the block. diff --git a/context/dox/specs/dox-g17/index.md b/context/dox/specs/dox-g17/index.md deleted file mode 100644 index 5de70e8c0..000000000 --- a/context/dox/specs/dox-g17/index.md +++ /dev/null @@ -1,127 +0,0 @@ ---- -story: DOX-G17 -issue: 559 -status: approved -dox: none ---- - -# DOX-G17: Search Console's unindexed pages - -Search Console (2026-11-23) lists 887 URLs as not indexed and 1,136 as indexed. Most of the 887 -are URLs we never want indexed. Google keeps fetching them while 331 real pages wait in -"Discovered – currently not indexed". This story stops Google spending its crawl on those URLs. It -makes the slash redirect permanent and adds a gate for each fix, so no bucket can grow back. Site -work only: there is no tool, no Dox button and no `packages/gmt` change. - -## Buckets and what this story does - -| GSC reason (count) | What is in it | Cause | Slice | -| --- | --- | --- | --- | -| Crawled – currently not indexed (251) | ~242 `.md` twins, 2 slashless URLs, 6 HTML pages | `.md` twins are crawlable and only `X-Robots-Tag: noindex` keeps them out, so Google still fetches each one | [3](./s3-search-crawlers-skip.md), [4](./s4-triage-and-search-console.md) | -| Alternate page with proper canonical tag (134) | `?w=…&wa=…` and `?tz=…&t=…` permalinks | example links on tool and scenario pages are plain ``; the canonical tag is correct | [3](./s3-search-crawlers-skip.md) | -| Page with redirect (166) | ~155 slashless pages (307), ~6 renamed pages (301), 2 `?tz=` links, `http://` | slashless page links in our own HTML until DOX-G8 (#488, 2026-11-09); Cloudflare answers them with 307 | [1](./s1-permanent-slash.md), [2](./s2-rendered-links.md) | -| Discovered – currently not indexed (331) | clean sitemap URLs, never fetched | crawl scheduling on a young site, made worse by the URLs above | indirect: 1 and 3 free the crawl | -| Duplicate, Google chose different canonical (3) | `totalDuration`, `operatingIntervals`, `RoundingOptions` | no sibling is a canonical (URL Inspection); the old `gmt-dox.northguild.workers.dev` host and the slashless 307 | [1](./s1-permanent-slash.md), [4](./s4-triage-and-search-console.md) | -| Excluded by noindex (2) | `/gmt/llms-full.txt`, `/gmt/dox/` | intended | none | - -**Where the slashless URLs came from (re-verified).** Before `29e8010c` (DOX-G8, 2026-11-09), -992 page links in the built HTML lacked the slash. GSC's oldest crawl dates for these URLs are -10-20 to 10-24. The two named examples, `/reference/gnss` (2026-10-17) and -`/reference/types/TwoDigitYearOptions` (2026-10-10), date from before that fix. The live HTML, -`llms*.txt`, the `.md` bodies, the sampled bundles and `packages/gmt` all link with the slash. -`_redirects` targets all end in `/` (`build-utils/redirects.ts`). One source is still unguarded: -links that a mount renders at run time. Googlebot renders pages and follows those links, and -`pageLinksWithoutSlash` reads only the built HTML. Slice 2 closes that gap. - -## Slices - -| # | Slice | Repo | Gate that stops the bucket regrowing | -| --- | --- | --- | --- | -| 1 | [One permanent hop to a page; the workers.dev copy is noindex](./s1-permanent-slash.md) | gmt | `worker/index.test.ts`; `dist-base.test.ts`; `deploy-smoke` slash and host rows | -| 2 | [Links a page renders end in a slash](./s2-rendered-links.md) | gmt | new `rendered-links` gate, tier `pr` | -| 3 | [Search crawlers skip `.md` twins and query states](./s3-search-crawlers-skip.md) | northguild.dev **and** gmt | `robots-policy.test.ts`; `deploy-smoke` robots rows (daily) | -| 4 | [Canonical and crawled-not-indexed triage, Search Console steps](./s4-triage-and-search-console.md) | gmt (docs only) | none: owner steps; URL Inspection results recorded | - -Order: 1, 2, then 3, then 4. Each slice runs only its own tests, lint and `astro check`. The full -gates ([Run the gates](../../built/tier-6-runbooks.md#run-the-gates)), `pnpm run validate` and -`dox-tester` run once, after slice 4. - -**Merge order across repos.** Slice 3's `robots.txt` lives in `northguild/northguild.dev` -(`apps/site/public/robots.txt`), which deploys on every push to its `main`. That PR merges and -deploys **before** the gmt PR. Otherwise the new `deploy-smoke` robots rows fail the Dox deploy. -Slice 3 is built in a `northguild.dev.worktrees/` worktree, never in the gmt tree. - -## Files - -| File | Slice | Change | -| --- | --- | --- | -| `apps/dox/worker/index.ts` | 1 | turn the assets binding's trailing-slash 307 into 308; old-host 301 adds the page slash (`withPageSlash`) | -| `apps/dox/worker/index.test.ts` | 1 | 308 rows; missing page stays 404 | -| `apps/dox/src/assets-root/_headers`, `scripts/dist-base.test.ts` | 1 | `noindex` for `https://gmt-dox.northguild.workers.dev/gmt/*`; the test allows that one host | -| `apps/dox/scripts/deploy-smoke.mjs` | 1, 3 | 308 slash rows; workers.dev `noindex` pair; robots row | -| `apps/dox/scripts/lib/page-links.mjs` (new) | 2 | the slash predicate moves here from `dist-base.ts` | -| `apps/dox/scripts/build-utils/dist-base.ts` | 2 | imports the predicate; behaviour unchanged | -| `apps/dox/scripts/rendered-links.mjs` (new) + `gates/registry.mjs` | 2 | the gate | -| `apps/dox/scripts/robots-policy.mjs` (new) + `robots-policy.test.ts` | 3 | the crawler policy table and its checker | -| `apps/dox/package.json`, `pnpm-lock.yaml` | 3 | `robots-parser` `3.0.1`, exact, devDependency | -| `northguild.dev`: `apps/site/public/robots.txt`, `CLAUDE.md` | 3 | the search-crawler group; the rule line | -| `context/dox/built/tier-0-1-site.md`, `cloudflare-runbook.md` | 1, 3, 4 | present-tense rules; Search Console steps | -| `context/dox/specs/index.md` | — | lists this spec while in progress; the finalizer removes the line | - -No `packages/` file changes, so the gmt PR carries no changeset. No page's canonical is a sibling -(slice 4 Results), so there is no JSDoc or content fix. - -## Authority - -| Choice | Source | -| --- | --- | -| A search-crawler group replaces `*` for that crawler, so it repeats every `*` rule | RFC 9309 §2.2.1; Google, *How Google interprets the robots.txt specification* ("Order of precedence for user agents": groups for a named crawler and `*` are not combined) | -| One group may name several crawlers | RFC 9309 §2.2.1 and §2.1 grammar (`startgroupline` repeats) | -| Longest match wins, so `Disallow: /gmt/*.md$` beats `Allow: /` | RFC 9309 §2.2.2 | -| `*` and `$`; a rule's `*` also matches the query (`/*.php` matches `/f.php?parameters`) | RFC 9309 §2.2.3; Google robots spec, "URL matching based on path values" | -| `Content-Signal` sits inside a group and does not end it | RFC 9309 §2.2.4; contentsignals.org (the signal applies to the group it is in) | -| Block crawl with robots.txt, not noindex, when the aim is to save crawls | Google, *Crawl budget management for large sites* ("Don't use noindex, as Google will still request…") | -| Query states of a page: disallow in robots.txt; canonical and `nofollow` are "less effective in the long term" | Google, *Managing crawling of faceted navigation URLs* | -| Applebot follows the `Googlebot` group unless robots.txt names Applebot | Apple, *About Applebot* (support.apple.com/en-us/119829) | -| Bingbot obeys its own group and supports `*` and `$` | Bing Webmaster Guidelines, robots.txt section | -| 307 is temporary, 308 is permanent and keeps the method | RFC 9110 §15.4.8, §15.4.9 | -| 301/308 are a strong canonical signal for the target; 307 is a weak one | Google, *Redirects and Google Search* | -| `_headers` accepts an absolute `https:///…` rule; `X-Robots-Tag: noindex` on a workers.dev host | Cloudflare Workers, *Static assets → Headers* (custom headers, absolute URLs) | -| A page served on a second host is a duplicate; `noindex` keeps it out | Google, *Block Search indexing with noindex* | -| Cloudflare's `auto-trailing-slash` answers `/folder` with 307 only when `/folder/index.html` exists, and the code cannot be set | Cloudflare Workers, *Static assets → HTML handling* | -| Validation, reasons and timing in the Page indexing report | Google Search Console Help, *Page indexing report*; *robots.txt report* (cache up to 24 h) | - -## Owner decisions - -1. **Crawl block.** The `northguild.dev` robots.txt gains a `Googlebot` + `Bingbot` group that - repeats every `*` rule and the `Content-Signal` line. It blocks `/gmt/*.md$`, `/gmt/?` and - `/gmt/*/?`. `Applebot` is named in the `*` group. The exact text is approved and is in - [slice 3](./s3-search-crawlers-skip.md#the-file-northguilddevappssitepublicrobotstxt). -2. **Keep the existing hints.** Pages keep `` and the - `.md` twins keep `X-Robots-Tag: noindex`. -3. **Slice 2 is in.** The `rendered-links` gate runs at tier `pr` in Chromium. -4. **Parser.** `robots-parser` `3.0.1` is pinned exactly, as a devDependency. If it gets any - policy row wrong, the builder stops and reports. -5. **Cross-repo order.** dox-builder writes slice 3's robots.txt in a - `northguild.dev.worktrees/` worktree. That PR merges and deploys before the gmt PR, and - the deploy-smoke robots row checks the live file. Nothing is committed, pushed or opened as a PR - without the owner's word. -6. **The six crawled-not-indexed HTML pages** get no code change. Once slice 3 is live, the - runbook lists them for Request indexing. -7. **The three canonical pages.** URL Inspection (slice 4 Results) shows no sibling canonical, so - there is no JSDoc or content fix. The causes are the old workers.dev host and the slashless - 307, both fixed in slice 1, with slice 3 freeing the crawl. After the deploy, the owner inspects - the three pages again and requests indexing. -8. **Where the slashless URLs came from.** The full "Page with redirect" export puts every crawl - of a slashless URL between 10-20 and 10-24, before DOX-G8. The generated corpus's slashless - paths (`functionUrl`, `typePageUrl`) reach no crawlable response. They become `_redirects` - sources, and the chat's citations pass through `pageHref` (`ask/resolve-href.ts`). - -## Definition of done (story) - -- Each slice's definition of done holds; the full gates, `pnpm run validate` and `dox-tester` - are green once, after slice 4. -- Duplication pass: rule 10's size check, and `git grep -n "status: 30[78]"` in - `apps/dox/scripts` shows the slash expectation in one row helper only. -- `context/dox/built/tier-0-1-site.md` and `cloudflare-runbook.md` describe what is built, in the present tense. - This spec folder stays until the finalizer folds it. diff --git a/context/dox/specs/dox-g17/s1-permanent-slash.md b/context/dox/specs/dox-g17/s1-permanent-slash.md deleted file mode 100644 index 3b4e5dd35..000000000 --- a/context/dox/specs/dox-g17/s1-permanent-slash.md +++ /dev/null @@ -1,171 +0,0 @@ -# Slice 1: one permanent hop to a page; the workers.dev copy is noindex - -[Story](./index.md) · repo: gmt · gate: `worker/index.test.ts`, `dist-base.test.ts`, `deploy-smoke` -slash, legacy and host rows - -## Why - -`/gmt/reference/gnss` answers `307 location: /gmt/reference/gnss/` (probed live; the query is kept). -That 307 comes from the assets binding's `auto-trailing-slash` html handling, which always uses 307 -(Cloudflare *Static assets → HTML handling*). RFC 9110 §15.4.8 makes 307 temporary. Google treats -a temporary redirect as a weak canonical signal, so the slashless source URL may stay canonical -(*Redirects and Google Search*). That keeps about 155 URLs in "Page with redirect" and is the likely -cause of the three "Google chose different canonical" pages (slice 4). A 308 (RFC 9110 §15.4.9) is -permanent, keeps the method and is a strong signal. - -The Worker already sees every slashless request. `run_worker_first` holds `/*` minus `/gmt/`, -`/gmt/*/` and `/gmt/*.*` (`apps/dox/wrangler.jsonc`; `worker/static-routing.test.ts` proves -`/gmt/reference` reaches the Worker). Its last line hands the request to `env.ASSETS.fetch`. - -## Change: the 308 - -`apps/dox/worker/index.ts`, at the last step only: - -1. `const res = await env.ASSETS.fetch(request);` The request stays unmodified, as the comment says. -2. Turn `res` into a 308 only when all of these hold: - - `res.status === 307`; - - `new URL(res.headers.get("location"), url)` has the same origin as `url`; - - its pathname is `url.pathname + "/"`; - - its search is `url.search`. - Return `new Response(res.body, { status: 308, headers: res.headers })`. The Location is copied - unchanged; RFC 9110 §10.2.2 allows a relative reference. -3. Return any other response as it is. A 404, a 200 and any other 307 pass through. -4. Put the test in a small named function, `permanentSlash(res, url)`, beside `redirect()`, with one - JSDoc line that cites RFC 9110 §15.4.9. Rewrite the last-step comment to say that the slash hop - is made permanent here. - -Do not add the slash in the Worker or check whether the page exists. Assets already know whether -`/folder/index.html` exists, so their 307 is the only proof that the page is real. A missing path -keeps its direct 404 (probed: `/gmt/nope` → 404). - -## Change: the old host lands in one hop - -**Finding (probed 2026-11-27).** `gmt-dox.northguild.workers.dev/reference/types/RoundingOptions` -answers 301 to `northguild.dev/gmt/reference/types/RoundingOptions`, which then answers 307 (308 -after this slice). Old links take two hops. Google still keeps that old URL as the page's canonical -(slice 4 Results). - -In the not-under-the-base branch (step 1 in the Worker's header comment), wrap the 301 target with -`withPageSlash` from `src/lib/site.ts`. The Worker already imports `SITE_URL` from that module, and -`withPageSlash` is the site's one page-path rule: no dot in the last segment, slash added before the -query. So `redirect(withPageSlash(\`${SITE_URL}${url.pathname}${search}\`))`. Then: - -- `/reference/types/RoundingOptions?a=1` → 301 `https://northguild.dev/gmt/reference/types/RoundingOptions/?a=1`; -- `/install.md`, `/llms.txt`, `/robots.txt` and any path with a dot are unchanged. `/robots.txt` - keeps its own branch; -- the API routes are still served in place before this line, so nothing under the old `/api/` - changes, and `/gmt/api/` is under the base and never reaches this branch; -- a missing path gets one 301 to its slash URL, then a 404 there, never a chain; -- the `key` filter runs first, as now, so the key is still dropped. - -Add one sentence to the header comment's step 1: the 301 adds the page slash, so an old link lands -in one hop. - -## Tests: `apps/dox/worker/index.test.ts` - -Reuse `fixtureAssets()` and its `assets.calls`. Add a fixture answer that returns 307 with a -relative Location, as the live binding does. - -- `/gmt/reference` → 308, `location` `/gmt/reference/`; `assets.calls` holds the request unmodified. - Update the existing test "hands a page path to the assets binding untouched, base included" to - this expectation; do not add a second test for the same thing. -- `/gmt/reference/duration/calculate/totalDuration?a=1` → 308, location keeps `?a=1`. -- Body and headers other than the status are the binding's own (check `cache-control` and `location`). -- A 307 whose Location is not the same path plus `/` (another path, another origin, or a query that - differs) → passed through as 307. -- A missing page → 404 straight from the binding, never 308 (row 21 stays as it is). -- A 200 from the binding is passed through unchanged. -- Legacy host: `/reference/types/RoundingOptions?a=1` → one 301 to - `${SITE_URL}/reference/types/RoundingOptions/?a=1`. `/reference?key=k&a=1` → 301 to - `${SITE_URL}/reference/?a=1`. `/install.md` → 301 to `${SITE_URL}/install.md` (no slash). Update - the existing legacy-redirect rows that expect a slashless target; do not duplicate them. - -No timers or listeners start, so no teardown is needed. The tests never touch the network -([rule](../../built/index.md)). - -## Tests: `apps/dox/scripts/deploy-smoke.mjs` - -- Row "6" becomes one hop: `WD/reference` → `301 ${ND}/gmt/reference/` → `200`. -- New row "6a": `${ND}/gmt/reference` → `308 ${ND}/gmt/reference/` → `200`. -- Row "36 /gmt/nope": keep the optional first step, but as `status: 308`. That hop exists only if - assets ever answers a missing folder with a slash redirect. A 307 there must now fail. -- New row "6b": a slashless function page with a query. Take the first `/gmt/reference////` - URL from the live sitemap: the script already requests `${ND}/gmt/sitemap-index.xml` (row near - line 850). Follow its first `` to the child sitemap with one small `firstSitemapUrl(re)` - helper built on `send()`. Request it without the slash and with - `?a=1`, and expect `308` to the slash URL with `?a=1`, then `200`. Never hard-code a function name, - because pages get renamed. -- New row "6d": the same sitemap page on the old host without `/gmt`, without its slash and with - `?a=1` → exactly one `301` whose Location ends in `/?a=1`, then `200`. The existing `hop` rows - for `WD/install.md` and `WD/llms.txt` stay, and they prove a file path keeps its form. -- Write the 308 rows (6a, 6b) with one helper, `slashHop(rows, label, url)`, so the expected status sits in - one place. The story's duplication grep relies on that. -- `DOX_SMOKE_LOCAL`: run `wrangler dev` on the built `dist` once and check whether - `/gmt/reference` answers 307 or 308 there. If it does, add rows "6a" and "6b" to the local crawl rows. If - `wrangler dev` does not reproduce the binding's 307, leave the row live-only, and say why in the - header comment. - -## The workers.dev host: `noindex` - -**Finding (probed 2026-11-27).** `https://gmt-dox.northguild.workers.dev/gmt//` answers 200 -with the full page and no `X-Robots-Tag`. `run_worker_first` leaves out `/gmt/*/`, so the assets -binding serves the page on every host. The page's canonical points to `northguild.dev`, but the -copy is still crawlable and indexable. URL Inspection for `…/totalDuration/` names this copy as the -referring page. The paths without `/gmt` on that host answer 301 to `northguild.dev/gmt/…` -(CORE-86) and stay as they are, so `workers_dev: true` stays. - -**Change.** Add one rule to `apps/dox/src/assets-root/_headers`, with a comment saying it keeps -the old host out of search results: - -```text -https://gmt-dox.northguild.workers.dev/gmt/* - X-Robots-Tag: noindex -``` - -Cloudflare's `_headers` accepts an absolute `https` URL, matched by host. Its own example is -`https://myworker.mysubdomain.workers.dev/*` with `X-Robots-Tag: noindex` (Workers *Static assets → -Headers*). The rule names the host literally, because this Worker has one name and no preview URLs. -The path stays `/gmt/*`: only assets answer there, and the rule then fits the house rule that every -`_headers` rule sits under `/gmt/`. A `.md` or `.txt` file on that host gets both rules. Cloudflare -joins the values, so the header reads `noindex, noindex`, which is harmless. - -**Tests.** - -- `apps/dox/scripts/dist-base.test.ts`, "every _headers rule sits under /gmt/": strip an optional - `https://gmt-dox.northguild.workers.dev` prefix before the check, and allow no other host. Add - one case asserting that this host rule is present. -- `deploy-smoke.mjs`: a live-only row pair, built on the page `firstSitemapUrl` returns: - - "6c workers.dev noindex": `WD/gmt//` answers 200 with an `x-robots-tag` that holds - `noindex`; - - "6c canonical host": `ND/gmt//` answers 200 with no `x-robots-tag`. - `wrangler dev` serves on `localhost`, where the host rule cannot match, so both rows are skipped - under `DOX_SMOKE_LOCAL`. - -## Traps - -- Do not read `res.url`. It is the asset URL, not the Location. -- A `Response` from the binding may have immutable headers. Pass `res.headers` into the new - `Response` and never mutate them. -- `HEAD` must behave like `GET`, so add a test with `HEAD /gmt/reference` → 308. -- The workers.dev host (`WD`) answers `301` to `ND` with the slash already added, so a 308 only - happens on `ND`. Rows 6 and 6d prove the old host never chains. - -## Close-out (in this slice) - -- `context/dox/built/tier-0-1-site.md`, Deploy section: add one line in the present tense. A page - path without its slash answers 308 to the slash URL, query kept. The Worker upgrades the assets - binding's 307 because a permanent redirect is the canonical signal Google honours (RFC 9110 - §15.4.9). An old `workers.dev` path is one 301 to the page URL with its slash (`withPageSlash`). -- Same section: the workers.dev host serves its `/gmt/` pages with `X-Robots-Tag: noindex` - (a host rule in `_headers`), because assets answer them there too and only `northguild.dev` may - be indexed. The host stays on for the CORE-86 301s. -- `context/dox/cloudflare-runbook.md` §3: add `h $ND/gmt/reference # 308 /gmt/reference/` beside - the existing `$ND/gmt` lines, plus `curl -sI $WD/gmt/ | grep -i x-robots # noindex`. - -## Definition of done - -- `pnpm --filter dox exec vitest run worker/` passes; `pnpm --filter dox lint` and `check` are clean. -- `git grep -n "status: 307" apps/dox/scripts/deploy-smoke.mjs` prints nothing. -- `pnpm --filter dox exec vitest run scripts/dist-base.test.ts` passes after a build. -- After the deploy, `node apps/dox/scripts/deploy-smoke.mjs` passes against production. The - deploy workflow runs it, and so does the daily schedule. diff --git a/context/dox/specs/dox-g17/s2-rendered-links.md b/context/dox/specs/dox-g17/s2-rendered-links.md deleted file mode 100644 index 71393035b..000000000 --- a/context/dox/specs/dox-g17/s2-rendered-links.md +++ /dev/null @@ -1,108 +0,0 @@ -# Slice 2: links a page renders end in a slash - -[Story](./index.md) · repo: gmt · gate: new `rendered-links` (tier `pr`, Chromium) - -## Why - -`test:dist` fails a page link without its slash in the built HTML (`pageLinksWithoutSlash`) and in -Markdown (`pageLinksWithoutSlashInMarkdown`). Both live in `apps/dox/scripts/build-utils/dist-base.ts` -(DOX-G8). Widgets add more links at run time: about 20 modules under `src/lib/` and -`src/components/` set an `href`. Today they all build hrefs with `withBase("/…/")`, so none of them -lacks the slash. But no check holds them to it, and Googlebot renders the page and follows those -links. A slashless link added later would grow "Page with redirect" again with no gate to catch it. -Slice 1 makes such a hop permanent, but every hop still costs a crawl. - -## Reuse - -| Piece | Path | Use | -| --- | --- | --- | -| Slash predicate | `scripts/build-utils/dist-base.ts` (`isPageLinkWithoutSlash`, private) | **moves** to `scripts/lib/page-links.mjs`, exported; `dist-base.ts` imports it. One check, one home. | -| Gate contract | `scripts/gates/contract.mjs`, `scripts/lib/gate-cli.mjs` (`--list-pages`, `--pages`, `--base`, `recordFinding`, `recordMeasured`) | the new gate's CLI and report | -| Browser launch | `scripts/lib/browser-launch.mjs` | Chromium | -| Page list from `dist` | pattern of `scripts/lib/tool-pages.mjs` (`listToolPages(distRoot)`) | new `listWidgetPages(distRoot)` in `scripts/lib/widget-pages.mjs` | -| Registry | `scripts/gates/registry.mjs` | one row; it lands in the `other` CI leg on its own (`ci-legs.test.ts`) | - -New files and their layer: - -- `scripts/lib/page-links.mjs` (shared). Exports `isPageLinkWithoutSlash(value)` and the `ORIGIN` - and `underBase` it needs. `dist-base.ts` imports all three instead of defining them, so the base - rule exists once. -- `scripts/lib/widget-pages.mjs` (shared). `listWidgetPages(distRoot)` returns the site path of every - built page whose HTML holds a `data-widget=` element, sorted. The list is read from `dist`, never - typed in. -- `scripts/rendered-links.mjs` (the gate). -- `scripts/lib/page-links.test.ts` and `widget-pages.test.ts`: unit tests. - -**Second-instance test.** A second rendered-link rule, such as no `http://` links, would add one -predicate to `page-links.mjs` and one call in the gate. It would need no second gate and no second -page list. - -## The gate: `scripts/rendered-links.mjs` - -- Pages: `listWidgetPages(distRoot)`. `--list-pages` prints them, and `--pages` narrows them. -- For each page, in Chromium at 1440 × 900: - 1. Load the page and wait for `load`, then for each `[data-widget]` root to be attached. Reuse the - wait an existing Chromium gate uses (`a11y-axe.mjs`), not a fixed sleep. - 2. Read `href` from every `a[href]` and `area[href]` **attribute** in the document - (`getAttribute`, not the resolved `.href`), so a relative or base-less value is judged as - written. - 3. Record a finding (rule `page-link-without-slash`) for each value where - `isPageLinkWithoutSlash` is true. The finding names the page, the value and the closest - `[data-widget]` name. - 4. `recordMeasured` the number of links checked. A page with no widget root fails as - `measured nothing`, as every gate does. -- A static link is checked again here, and that is fine: one predicate makes the same verdict in - both checks, and `test:dist` stays the fast check. -- Close the page and the browser in `finally`, so a failed assertion still tears down. - -Registry row: - -```js -{ id: "rendered-links", script: "rendered-links.mjs", tier: "pr", - browsers: ["chromium"], fullBrowsers: ["chromium"], themes: false, needs: null } -``` - -The link logic does not depend on the theme, so `themes: false` (as 18 gates already use) halves the run. - -## Tests - -- `page-links.test.ts`. The cases `dist-base.test.ts` already covers for the HTML scan move here as - table cases for the predicate: - - `/gmt/reference` → true; `/gmt/reference/` → false; `/gmt/llms.txt` → false; - - `https://northguild.dev/gmt/tools/x?w=1#a` → true; `/other` → false; `//cdn/x` → false. - `dist-base.test.ts` keeps its HTML-scanning tests. Delete any case that only exercised the - predicate there. -- `widget-pages.test.ts`: a temporary `dist` with three pages: one holding `data-widget="a"`, one - without, and one with `data-widget` only inside a `