Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 31 additions & 22 deletions apps/dox/scripts/deploy-smoke.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -148,19 +149,26 @@ const slashHop = (rows, label, url) => {
};

/**
* The first page URL in the live sitemap that matches `re`: the first `<loc>` 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 `<loc>` of the index, then the
* first match in that child sitemap. Each `<loc>` 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>([^<]+)<\/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>([^<]+)<\/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 = /<meta\s[^>]*name="robots"[^>]*content="[^"]*noindex/i;

Expand All @@ -170,6 +178,17 @@ const NOINDEX_META = /<meta\s[^>]*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
Expand Down Expand Up @@ -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",
Expand Down
3 changes: 2 additions & 1 deletion apps/dox/scripts/rendered-links.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand Down Expand Up @@ -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)))
Expand Down
1 change: 0 additions & 1 deletion apps/dox/scripts/robots-policy.test.ts
Original file line number Diff line number Diff line change
@@ -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";
Expand Down
3 changes: 2 additions & 1 deletion context/dox/built/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
Expand Down
4 changes: 3 additions & 1 deletion context/dox/built/tier-0-1-site.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
24 changes: 1 addition & 23 deletions context/dox/built/tier-2-gates.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 <path,...>` (an unknown path exits 2) and, when it loads pages, `--base <url>`. 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 <minutes>`) 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/<ns>/<module>/` selects the pages that import `@northguild/gmt/<ns>/<module>` 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/<base>`. 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-<leg>-<run id>`.
- 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).
Loading
Loading