Skip to content

Latest commit

 

History

History
292 lines (226 loc) · 38.2 KB

ARCHITECTURE.md

File metadata and controls

292 lines (226 loc) · 38.2 KB

Architecture

This document describes the docs-engine repository as it is today, plus the design decisions recorded for the seams that are decided but not yet built. Refer to the package READMEs for per-package detail.

The engine in one paragraph

Documentation content lives in coder/coder under docs/. This repository is the engine that renders that content: the sync, the remark/rehype transforms, the theme, the UI components, and the Next.js adapter. The engine is implemented as eight @coder/* packages in a pnpm + Turborepo monorepo. The engine holds no content of its own, and nothing here is published to npm; compiled releases go only to this repository's GitHub Releases (see Public releases).

Package graph

Package Responsibility
@coder/docs-config Typed configuration schema and shared content contracts (DocVersion, VersionsProvider, DocSource, Manifest)
@coder/docs-sources Versions/content providers: git refs (createGitRefsProvider) and a local tree (createLocalTreeProvider)
@coder/docs-transforms Pure content transforms, the remark/rehype plugins, and the coderMdxOptions pipeline including the sanitizer
@coder/docs-build The docs sync: syncDocSource materializes a provider DocSource onto disk as a Fumadocs content tree
@coder/docs-ui Framework-agnostic React components (MDX map, OS-aware tabs, brand mark, copyright, version switcher)
@coder/docs-theme Fumadocs token overrides and brand CSS, CSS-only with no build step
@coder/docs-next Fumadocs App Router (Next.js) adapter: page/search route factories, DocsProvider/DocsShell, version routing
@coder/docs-manifest Version manifest: Global Config item schemas, /versions.json assembly, request routing, write client

The workspace dependency edges, verified against each package.json:

docs-sources ────► docs-config ◄──── docs-transforms
                        ▲                   ▲
docs-next ──────────────┤                   │
    │                   └────── docs-build ─┘
    ▼
docs-ui ────► docs-config      docs-theme (no dependencies)
  • @coder/docs-config is the root contract package and depends on no other workspace package.
  • @coder/docs-sources depends on docs-config.
  • @coder/docs-transforms depends on docs-config (for the Manifest and DocSource contracts its pure transforms consume, and the StaticDocsRenderContext a static compile resolves the premium condition against).
  • @coder/docs-build depends on docs-config, docs-transforms, and the version-segment subpath of docs-manifest (for isLineAtLeast, which picks the versions that render the generated REST API reference); its external base for that reference is swagger2openapi and oas-validator.
  • @coder/docs-next depends on docs-config, docs-ui, and the dependency-free version-segment subpath of docs-manifest; its openapi subpath renders the REST API reference with fumadocs-openapi.
  • @coder/docs-ui depends on the zod-free client subpath of docs-config for the DocsRenderContext its runtime Premium/Experimental annotation components read (loading the zod parser only when a fetched context arrives), and on the version-segment subpath of docs-manifest for the runtime version switcher's links; its external base is fumadocs-ui.
  • @coder/docs-theme depends on nothing; it ships plain CSS.
  • @coder/docs-manifest depends on docs-config only.

The three build targets

The same packages serve three deployment shapes.

Offline export

A static, air-gapped bundle for customers whose deployments cannot reach the internet. The createLocalTreeProvider reads a docs tree already on disk (no git, no network), syncDocSource materializes it with local image copies (imageRemote unset), and the Next.js app builds with output: "export" into a self-contained directory. Search is the static index described under "Search" below, so the bundle needs no server, and the consumer pins copyrightYear so the frozen export keeps its build year.

Public docs site

The multi-version site, served by apps/router from a private Vercel Blob archive that holds one build per release line, tag, and main. The createGitRefsProvider clones coder/coder once and loads each version from a detached worktree at its ref, syncDocSource runs once per version with baseUrl: versionBaseUrl(version), and createVersionedDocs resolves each version's prefix (v2.38, @v2.38.1, @main) in the catch-all slug across one Fumadocs source per version. The latest version serves at the site root, and the layout resolves versionSwitcherOptions at build time and renders the @coder/docs-ui VersionSwitcher in the sidebar. The site is a static export, not a server: createVersionedDocs runs in its default static mode, the page sets dynamicParams = false, next.config.mjs sets output: "export", and the exported out/ is plain static files with no framework preset (framework: null in vercel.json). The server mode that createVersionedDocs also offers (it only sets dynamicParams: true) is unused by both apps, so there are no on-demand branch previews; the per-version publishing design in docs/superpowers/specs/ is where previews of unlisted refs are planned. The multi-version build (pnpm build, used locally and checked against the monolithic export by the stitch parity e2e) runs one next build per version, with only that version's content materialized so the other collections compile empty, and stitches the exports into one out/, latest last, so the files every pass emits at the root (404.html, _not-found, the search index) come from the latest version. Each version's images are copied under that version's own URL prefix (syncDocSource's baseUrl): public/@main/images/x.png is served at /@main/images/x.png, and the root version's at /images/x.png. A page only ever references its own version's images, so in the archive every image request is answered from the same version's prefix as the page, never from the mainline. Alongside each version's pages the build emits that version's machine-readable outputs — a per-page Markdown twin at the page's own URL with .md in place of the trailing slash, plus <version base>/llms.txt and <version base>/llms-full.txt — served as plain text with nosniff, and every page links to its own twin through a text/markdown alternate and fumadocs' Copy Markdown and Open actions (apps/docs/README.md, "Markdown twins and llms.txt"). The mainline build alone also emits <base path>/sitemap.xml, listing each mainline page at its canonical URL; the other versions are noindex and publish none (apps/docs/README.md, "Sitemap"). Each entry's <lastmod> comes from git, not the clock: the providers read one git log over the docs tree into DocSource.lastModified, the sync takes the newest date among a page's own file and the files it includes, and a page with any undated source gets no <lastmod>. Preview deployments build only the latest version and main; production builds every listed version.

The per-version publishing platform (spec in docs/superpowers/specs/) replaced the stitched deployment: every version is built on its own and published to the archive, and the stitched coder-docs deployment is retired. The coder-docs Vercel project no longer builds apps/docs: its Root Directory is apps/router, so it is the /docs router, and docs-site previews are prebuilt in GitHub Actions and deployed to it as login-protected previews (README.md, "Vercel projects"). apps/router serves the archive: a Next.js route handler that reads the manifest from Global Config through @coder/docs-manifest, answers each request from the archive prefix the manifest names for that version (assets included, so version builds carry their own version-segment asset prefix), and serves /versions.json. Every version URL uses the classic site's forms, v2.38 for a line, @v2.38.1 for a tag, and @main, built by versionSegment in @coder/docs-manifest for base paths, asset prefixes, links, llms.txt, and the version switcher alike; the mainline answers at v<mainline> and at the base path, with no redirect, and its canonical URL is the unprefixed one. Each manifest entry records its storage layout: layout: "canonical" means its objects sit under versionSegment(id), and an entry published before the field existed has them under @<id>, so the router serves both layouts while the archives are republished. Beta's old @2.38 and @2.38.1 forms serve only while some entry still has the old layout, because pages not yet rebuilt link to them; once every line, tag, and main records canonical they are not-found, never redirected. A page that moved after a version was built still redirects within that version: on a miss inside a version, the router first tries the classic site's dotted spelling of a slug (esr-2.24-2.29-upgrade for esr-2-24-2-29-upgrade), then applies that version's own rules from _redirects.json in its archive prefix (compiled at publish from docs/redirects.json of the commit it was built from), then, under a version prefix, the unversioned rules in apps/router/redirects.json, and redirects only when that version's archive has the new page (apps/router/README.md). coder.com rewrites /docs to the router, and answers the retired /beta-docs paths with a 308 to the same path under /docs.

The publisher builds apps/docs in its single-version mode, selected by DOCS_VERSION_* environment variables, for one coder/coder ref at a time, synced from a sparse docs/ checkout through DOCS_ROOT and built with a per-version Next basePath/assetPrefix under the configured DOCS_BASE_PATH, laid out as the exact URL tree the router serves (apps/docs/README.md, "Single-version builds and the publisher"). Each single-version build uploads to a private Vercel Blob store, docs-versions-archive-docs for the docs site, under an immutable prefix versions/<id>/<sha>/, which the router described above serves directly rather than rewriting to another deployment. A tag's prefix is written once and never rewritten; a line or main gains a new prefix on every publish, and its previous prefix is deleted, after a seven-day grace, once the manifest no longer references it. A GitHub Actions publisher, publish-version.yml, builds and publishes one ref per invocation across two jobs: an untrusted build job with no write-scoped secrets that resolves the ref and runs the version build, and a publish job, bound to the site's environment, that regenerates the plan from its own engine-only checkout, uploads the build to the archive, verifies the upload by reading it back, writes the Global Config manifest in one request, refreshes a public mirror of /versions.json, and prunes unreferenced prefixes. The manifest write is the last step a reader can reach, so a reader never sees a half-uploaded version and a failed run never corrupts anything already live.

Because the base path is baked into every page and asset, the same archive cannot serve two paths, so moving the site from /beta-docs to /docs built a second, independent site: its own router (the coder-docs project, repointed at apps/router), manifest store, archive and mirror stores and GitHub environment. The /beta-docs site was retired once /docs held every line and tag it did, and its entry left the site table. A checked-in site table, apps/docs/scripts/publish/sites.mjs, holds each site's base path, public URL, router URL, environment and analytics flag, and every publish goes to exactly one site: the workflow's site input, else the DOCS_PUBLISH_SITE repository variable, else docs. The table has room for more than one site, but a publish never fans out to several (apps/docs/README.md, "Publishing sites"). The table is checked in rather than kept in variables because the build job binds no environment and could read only repository-level values, one per repository. Publishing is event-driven: coder/coder's docs-publish workflows dispatch publish-version.yml for a branch push that changes docs/ and for every published (non-prerelease) GitHub release, and runs of one ref queue rather than cancel: one runs, a newer dispatch replaces the one pending behind it, and the pending run builds the branch's newest commit when it starts. Engine changes reach published versions through republish-lines.yml: a push to this repository's main that changes what the build reads rebuilds main, the development line and every supported line at once, and a weekly run rebuilds the unsupported lines; both choose lines from the manifest's support matrix, and neither touches a tag. A daily reconciler is the backstop: it compares coder/coder's refs against the manifest and dispatches a publish for any ref that is missing or whose docs content has actually fallen behind (a tag only once its GitHub release is published), while only ever reporting, never automatically rebuilding, a moved tag or an orphan manifest entry, in one tracking GitHub issue. The mainline also carries the code-server docs under code-server/, from a pinned code-server commit (refer to "code-server docs" below).

In-product docs

Docs embedded inline in the Coder dashboard SPA, not in an iframe. Like the offline export, the content is bundled at build time from a local tree, pinned to that release's version. The rendered pages inherit the dashboard's DOM and Content Security Policy, which is why the build-time sanitizer in @coder/docs-transforms is the primary defense for this target (refer to the design decisions below). The @coder/docs-ui components stay framework-agnostic, but DocsShell is Next-only: it renders fumadocs' Next DocsLayout, whose sidebar requires the Next RootProvider. A non-Next host instead composes DocsProvider with options.provider set to fumadocs' provider/base or provider/react-router and supplies its own layout. basePath on the version-routing helpers (versionHref, switchHref, versionSwitcherOptions) prefixes only the version-switcher's own anchors; loader-generated links rely on the host's own base-path handling.

Search

Search works the same way in every target and never runs on a server. createDocsSearchRoute (@coder/docs-next) builds an Orama index at build time through Fumadocs' staticGET, and the static export writes it out as the file api/search. DocsProvider configures the Fumadocs client with type: "static", so the browser downloads that file and runs every query locally. On the public site each build pass indexes only its own version and the stitch keeps the latest pass's file, so public search covers the latest version only; the other versions have no index (refer to the open decision on the search index shape).

With DOCS_SEMANTIC_SEARCH=1, apps/docs/scripts/semantic-index.mjs runs after the stitch (and after next build in apps/offlinedocs) and embeds each section of that api/search file with the Model2Vec static model minishlab/potion-base-8M (MIT), vendored as an int8 table in apps/docs/semantic-model/, so no build downloads a model. It writes api/search-semantic/meta.json (vocabulary, pages, sections) and two content-hashed int8 tables under _next/static/semantic-search/, so they share the immutable caching and asset prefix of the other build assets. With search.hybrid, DocsProvider swaps in a dialog whose client answers from the keyword index at once and fuses in vector results once the semantic index has loaded: vector #1 first, keyword #1 second, then weighted reciprocal rank over both lists. Vector rank carries 0.75 of the weight, except when a keyword hit contains the whole query (ignoring case), where keyword rank carries 0.75 so the keyword hits for an exact term such as a CLI flag or error message come before the vector-only pages. Embedding a query is a WordPiece tokenization, a table lookup, and a mean, in plain JavaScript shared with the build (@coder/docs-next/semantic-search), so there is no model runtime, worker, or CSP change.

The generated REST API reference (pages under reference/api/, not its index page) is indexed by what names an endpoint or schema: the page title and description, the H2 headings (Get workspace metadata by ID, codersdk.Workspace), any text directly under an H2, and each endpoint's `METHOD /path` line, moved up to its H2. Its H3-and-deeper sections (code samples, parameter, response and property tables, example JSON) are left out, as are their headings, which are the same few labels under every endpoint; they were about half of the keyword index. The semantic index already skips the whole API reference.

Search quality

apps/docs/scripts/search-quality.mjs checks a search change against the fixed query set in search-quality-queries.json. run <out> <file> records the top 10 pages of every query for keyword, vector and hybrid search over a built out/, and compare <before> <after> prints overlap@5, overlap@10 and every query whose top 3 changed. Record a run on main, build the change with the same corpus, and compare.

The vendored model's vocabulary is not pruned to the tokens the corpus uses, although that would shrink tokens.i8 from 7.6 MB to between 1.6 and 6 MB. The section vectors stay byte-identical under any such prune, but a query word outside the docs (ipad, neovim, coworker) loses its own row and embeds differently. Pruning to the corpus tokens alone moved the top 3 of realistic queries such as save money on idle machines. Keeping every subword piece and the first 5,000 or more vocabulary rows as well left the realistic queries unchanged, but every such prune, up to 20,000 rows, still moved the top 3 of a query in the words-not-in-the-docs group, and ipad lost its workspace-access pages.

The content pipeline

One version of the docs flows through four stages:

  1. Provider. A VersionsProvider from @coder/docs-sources loads the version into a DocSource: raw .md files, the manifest.json sidebar model, resolved images, and optional redirects. For a version that renders the generated REST API reference, the sync scripts then rewrite that DocSource before syncing it (refer to "The REST API reference" below).
  2. Sync. syncDocSource (@coder/docs-build) validates the source (dead links, broken images, route collisions, stale manifest entries) and writes a Fumadocs content tree: .md files with injected frontmatter, rewritten links and image paths, per-directory meta.json, and copied images. Only pages named by the manifest are emitted.
  3. Compile. fumadocs-mdx compiles the synced tree using createCoderMdxOptions({ renderContext, linkPrefix }) (@coder/docs-transforms/mdx-config), of which coderMdxOptions is the default instance (no static context, no link prefix — the in-product runtime pipeline): the Coder remark stack (GitHub callouts, Coder tabs, <details> accordions, steps), then rehype-raw to reparse the corpus's raw HTML, then the sanitizer, then Shiki highlighting with a fallback language for unbundled fences.
  4. Render. The @coder/docs-next route factories render the compiled MDX body through the @coder/docs-ui component map inside DocsShell, styled by @coder/docs-theme.

The sanitizer (rehypeSanitizeCoderDocs) is the security core of the pipeline. The corpus is untrusted public-contributor Markdown that also renders inside the authenticated dashboard, so the sanitizer strips scripts, iframes, event handlers, inline styles, and dangerous URL schemes immediately after rehype-raw, while preserving the MDX nodes the engine's own plugins emit. This design rests on a .md-only precondition: the sync emits only .md files, which Fumadocs compiles with no JSX or expression parsing, so corpus HTML stays inert text until rehype-raw reparses it into a tree the sanitizer then cleans. Emitting .mdx would let corpus content execute at compile time and bypass the sanitizer entirely. Refer to "Security: the corpus is untrusted" in the @coder/docs-transforms README for the full invariant.

The REST API reference

From 2.24 on, and on main, the REST API reference is built from coder/coder's Swagger 2.0 document rather than from the Markdown pages its generator writes. rendersOpenApi (@coder/docs-build) picks those versions; OPENAPI_MIN_LINE is the oldest line, since older documents repeat operation ids. DOCS_OPENAPI set to 0, false, off or no keeps the Markdown reference for every version, and is the rollback; any value that is not an off or on spelling fails the sync.

The Swagger document is read from the checkout the docs come from, never fetched. Both @coder/docs-sources providers, given apiDocument: SWAGGER_PATH, read coderd/apidoc/swagger.json onto the version's DocSource as apiDocument. The local tree provider reads it beside the docs/ tree, so every checkout a sync runs on, the publisher's and the preview's sparse ones included, has to hold coderd/apidoc as well as docs; the git provider reads it from the worktree it loads the version's docs from, so both come from one commit resolution. A version with no Swagger document keeps its Markdown reference with a warning, except when DOCS_PUBLISH=1, where the sync fails, so a publish never ships the old reference for a version that should have the new one.

withOpenApiReference rewrites the version's DocSource before syncDocSource sees it: applyOpenApiReference converts the document to OpenAPI 3, adds one Markdown stub page per operation under its tag, turns each tag page and the schemas page into lists of links, and adds the setup section to the landing page. Each stub carries _openapi: { method } in its frontmatter; the sync validates that shape and keeps it, and fumadocs-openapi's loader plugin reads it to draw the sidebar's method badge. It also writes the version's reference data, the converted document plus the route of every operation page, the old anchors, the landing cards and the schema rows, to .generated/openapi/<version id>.json (docs.json in the single-version offline export), which the app reads at render time so the document stays out of the server bundle. A generated page whose path or route another page already has fails the sync.

The page route factories take a renderBody hook, which may replace a page's compiled Markdown body, add after it, widen it, or extend its table of contents. createOpenApiRenderBody (@coder/docs-next/openapi) is that hook for the reference: an operation page renders through fumadocs-openapi from the document pruned to that operation and what it reaches, with code samples built on the server; the tag and schemas pages add a client redirect from the old single-page anchors; the landing page adds its cards. fumadocs-openapi's API playground never ships: withoutOpenApiPlayground (@coder/docs-next/next-config) wraps the Next config of apps/docs and apps/offlinedocs and replaces the playground, its OAuth flows and fetcher, and the server proxy with inert stubs in every bundle, and playground:check fails a build whose JavaScript still holds that code. Every $ref must be in-document (#/...) at three points, the Swagger document, the converted document, and the renderer's input, because fumadocs-openapi's bundler fetches or reads any other reference.

Design decisions

These seams are decided and recorded, but not all are implemented yet. Each subsection carries the date its decision was taken.

Context delivery (2026-08-31)

Pages carry deployment context (license tier, enabled experiments, deployment values) to decide how conditional content is framed, not whether it exists. The contract is a DocsRenderContext type in @coder/docs-config, plus a StaticDocsRenderContext whose features is the literal "all" — a static compile cannot express "this flag is off", so it can never strip content from an export. The public site and the offline export compile against STATIC_DOCS_RENDER_CONTEXT (oss, all experiments shown), so every premium block renders with a Premium label and callout and every experimental block renders with an Experimental label, and no runtime context is needed. The in-product target fetches its context from coderd's entitlements and experiments APIs through the dashboard's authenticated session; nothing in the embed overrides it, so the premium presentation cannot be produced without a premium license. Until a fetched context resolves and validates, premium blocks render labelled and experimental blocks render nothing. A context is validated and frozen on arrival.

Authoring convention (2026-08-31)

Conditional content is authored in the corpus as data-attribute divs: <div data-cond="premium"> for edition gating, <div data-feature="<flag>"> for feature-flag gating, and <span data-var="access_url"></span> for deployment-value substitution. A remark plugin rewrites these markers at compile time into annotation components: PremiumNote/PremiumCallout/ExperimentalNote from @coder/docs-ui for a static context, or its runtime Premium/Experimental for the in-product build. A theme rule hides raw markers in stale renderers that predate the plugin, and the sync fails the build on a marker the plugin would not rewrite, naming the file and line. A page overrides the Premium callout text with premium_callout frontmatter (Markdown); the sync validates every data-feature flag against the version's docs/experiments.json, generated in coder/coder from the experiments the code defines. Premium and experimental content is public documentation; only the in-product docs hide an experimental block, and only when the deployment has not enabled its flag.

Version source of truth (2026-08-31)

The decided source of truth is a versions.json on coder/coder's default branch, validated by parseVersions in @coder/docs-config; createGitRefsProviderFromContent in @coder/docs-sources reads it and fails the build loudly when it is missing or malformed. Until coder/coder ships that file, the public site uses the deploy-configuration list in apps/docs/lib/versions.ts, which pins each version to a release tag (v2.36.4, not release/2.36) plus main, and preview deployments narrow that list to the latest version and main.

Offline external links (2026-08-31)

External links in the offline export are kept as-is. They are dead in the air gap but honest about where the content lives, and there is no per-target link policy in the engine.

Embedding shape (2026-08-31)

In-product docs render inline in the dashboard SPA, with no iframe boundary. The docs therefore inherit the dashboard's CSP and DOM, so the build-time sanitizer is the primary in-product defense rather than any serving-layer isolation.

Content Security Policy for the public docs host (2026-09-16)

The public site ships this policy on every page, from the SECURITY map in apps/router/lib/archive.ts on every archive object; apps/docs/vercel.json carries the same policy for a Vercel deployment of the export:

script-src 'self' 'unsafe-inline'; object-src 'none'; base-uri 'self'; form-action 'self'; frame-ancestors 'self'

.svg files, which are corpus images, get sandbox; frame-ancestors 'self' instead, and every response carries X-Content-Type-Options: nosniff and Referrer-Policy: strict-origin-when-cross-origin. The router's vercel.json also sets Permissions-Policy: camera=(), microphone=(), geolocation=(), payment=(), usb=(), X-Frame-Options: SAMEORIGIN, and Cross-Origin-Opener-Policy: same-origin on every response from its own domain. SAMEORIGIN says the same thing as frame-ancestors 'self' for browsers that ignore the CSP directive, and the pages open no cross-origin window that needs window.opener: every target="_blank" link carries rel="noopener". The router's plain 404 and placeholder pages get default-src 'none'; style-src 'unsafe-inline'; frame-ancestors 'self', since they run no script and load nothing.

script-src allows 'unsafe-inline' because a Next static export boots each page from inline scripts and a static host cannot mint per-request nonces. The consequence is stated plainly: this policy does not stop an inline script that reaches a page, so the build-time sanitizer in @coder/docs-transforms is the primary defense for the public site as well as for the in-product target, and the CSP is the second line. The csp:check scripts in both apps enumerate every inline and external script in the built pages and fail the build if one falls outside script-src, which keeps the policy honest about what the pages actually run. object-src 'none', base-uri 'self', and form-action 'self' close the script-free injection paths the policy names. It names no default-src, so img-src, media-src, style-src, connect-src, and frame-src are unrestricted, and what closes those is the sanitizer again rather than the policy: its tag allowlist admits no iframe, object, or embed. It does admit img, video, source, and track with a protocol-checked http(s) src, so a corpus page can load a remote image or screencast and the policy will not stop that request from reporting a reader's address to the host serving it. Naming a default-src is the cheaper half of the hardening path below and does not depend on the hashes. It would also have to allow connect-src https://o4511351204937728.ingest.us.sentry.io, the host the browser error reporting in apps/docs/instrumentation-client.ts posts to, or that reporting goes silent; coder.com's restated copy of the policy needs the same entry.

The site is served through a same-origin rewrite from coder.com, and Vercel applies the coder.com project's own header rules to the proxied responses, replacing any upstream header of the same name. coder.com therefore restates this exact policy for the /docs path (plus its own frame-ancestors list) in its next.config.js; a change to the policy here has to be mirrored there, and "Serving through coder.com" in apps/docs/README.md names both. The same replacement applies to the router's other headers: coder.com's catch-all rule sets its own Permissions-Policy (camera, microphone, and geolocation only) and X-Frame-Options: SAMEORIGIN, so readers on /docs get coder.com's values, while Cross-Origin-Opener-Policy, which coder.com does not set, passes through from the router. The two copies have drifted apart before, so apps/router/scripts/headers-check.mjs checks production weekly from the security workflow, and on demand from its Run workflow button. It fetches the home page, a deeper page, a corpus SVG, a Markdown twin, and llms.txt from the public site, vars.DOCS_SITE_URL (https://coder.com/docs), and compares each response with what the router's own responseHeadersFor returns for that key, with the content type the publish step gives it. Policies are compared as directive sets rather than strings, and coder.com may add origins to frame-ancestors but may not drop any the router names. A scheduled failure opens or updates an issue labelled security-header-drift, and the next passing run closes it. The check is kept out of the publish smoke tests on purpose, because a failure there rolls back a good publish for what is a coder.com problem. Run it locally with pnpm --filter @coder/docs-router headers:check after building the packages, with DOCS_SITE_URL and DOCS_BASE_PATH set; it refuses a site URL whose path is not the base path.

With DOCS_ANALYTICS on (coder.com's consent manager and tag manager, apps/docs/README.md "Analytics"), script-src also names Osano, Google Tag Manager, and the vendors its container injects, as docsContentSecurityPolicy({ analytics: true }) in @coder/docs-config builds it, plus blob: (ANALYTICS_SCRIPT_SCHEMES) for Osano's workers and ZoomInfo's session script; every other directive is unchanged. The policy names no worker-src, so a worker falls back to script-src, and blob: there covers both. It adds nothing an injected script could not already do while 'unsafe-inline' stays, and has to be revisited with the hardening path below. Each vendor is named by origin except jsDelivr, a public CDN for any npm package, which is named only by the one package directory its tag loads (https://cdn.jsdelivr.net/npm/hockeystack@latest/). The router applies that policy to archive responses when its own DOCS_ANALYTICS is on; apps/docs/vercel.json, which cannot vary by environment, keeps the policy above. Widening script-src this way is a security decision and needs sign-off before the flag is turned on anywhere.

The search dialog and the product switcher also push docs_search and docs_product_switch to the container's dataLayer through trackDocsEvent, which pushes only once the GTM container is on the page and otherwise drops the event, so nothing is sent before consent or without the flag (apps/docs/README.md "Analytics"). It adds no origin, so it needs no change to the policy.

Hardening path, not yet taken: the inline scripts in a static export are fixed at build time, so csp:check could emit their SHA-256 hashes and the policy could name them in place of 'unsafe-inline'. That makes the policy a real barrier to injected inline scripts at the cost of regenerating the header on every build and keeping the router's archive headers in step per version. It is the next step if the sanitizer ever has to be weakened, and otherwise a later improvement.

Release schedule (2026-09-30)

The Releases page's release schedule is data, not content: coder/coder authors a <div data-releases-table> marker with a fallback link, and the engine fills it from GitHub. buildReleaseSchedule in @coder/docs-config is the one definition of the rows: stable is the minor of GitHub's latest release, mainline and security support are the released minor lines either side of it (ordered by major, then minor), the ESR set comes from coder/coder's scripts/release_channels/esr_versions.txt, and an ESR drops out 365 days after its first release. The sync gets the schedule once per build (writeReleaseSchedule in @coder/docs-build), and remarkReleasesTable rewrites the marker into ReleasesTable, whose children carry the same rows as a Markdown table for search and the Markdown twin. In a publish, a separate Fetch the release schedule step fetches it with the job's token before the content checkout, and the sync reads that file through DOCS_RELEASE_SCHEDULE_FILE instead of fetching. That keeps the invariant that there is no token in the build step's environment, the step that compiles untrusted content, so never pass that step a token. A publish fails if the fetch does. A tag build is never rebuilt, so on the public site ReleasesTable refreshes from the router's /releases.json, which fetches GitHub at most once an hour per isolate; the offline export keeps its build-time table. Older refs carry a static table between RELEASE_CALENDAR_START/END comments; the sync strips comments, so rewriteLegacyReleaseCalendar turns that region into the marker first, line for line.

Public releases (2026-10-08)

The compiled @coder/* packages and the offline-docs builder kit are published only as GitHub release assets on this repository, never to the npm registry. A v* tag runs release-dist.yml, which builds packages, never an offline export; coder/coder's offlinedocs/ pins the asset URLs in its package.json. The publish job creates the release with its own GITHUB_TOKEN, scoped to contents: write in that job only, in the docs-dist environment. While this repository was private, releases targeted a separate public repository, coder/docs-engine-dist, through a GitHub App; it never published a release. apps/dist-release packs them: every packed manifest keeps "private": true, so an accidental npm publish is refused. Each @coder/* dependency in a packed manifest is pinned to the exact URL of the same release's asset, never a version range, so pnpm never looks for an @coder/docs-* name on the registry. The design and Security's requirements are in docs/superpowers/specs/2026-09-30-public-dist-releases-design.md.

code-server docs (2026-11-16)

The code-server docs, from docs/ of coder/code-server, are a second source of the mainline build only, served unversioned under code-server/. They are not snapshotted into every Coder version: code-server releases on its own schedule, so a copy frozen into each Coder line and tag would show docs unrelated to that Coder release, and a tag is never rebuilt, so a code-server fix could never reach it. The router redirects the old versioned code-server URLs to the unversioned pages.

The mainline syncs a pinned commit, apps/docs/code-server-docs.json, rather than code-server's main. The tree builds with the mainline's strictness, so a defect pushed to code-server would otherwise fail the next Coder publish, and the pin means no code-server change reaches readers without a review in this repository. A bump is a reviewed pull request; it is not automated, because a pull request opened with the job token runs no CI. A change to the pin is a push to main under apps/docs/, so republish-lines.yml rebuilds the supported lines for it, though only the mainline carries the code-server docs.

Freshness is reported, not enforced: the daily reconciler compares the pinned commit's docs/ tree with code-server's main by the same content id it uses for a release line, and keeps its own code-server-pin-behind issue open while the pin is behind, apart from the drift issue, because the pin is behind after most code-server releases and an open drift issue whose body is only edited notifies nobody of a new moved tag or orphan. CI checks a bump before it merges: the pinned commit must be fetchable and on code-server's main, and its docs/ must pass a strict sync.

Open decisions

  • Search index shape for the multi-version site.
  • Versions published before _redirects.json existed have no per-version rules and keep using the engine's one apps/router/redirects.json until they are republished.