safekeys/docs-hosting [built]
Publish the generated specification docs to Cloudflare Pages at docs.safekeys.ai and dev-docs.safekeys.ai. Two docs audiences deploy as separate projects so internal architecture stays off the public site, and every deploy is built from the same pinned toolchain that CI validates.
Status: built
Why this exists
The specs are the source of truth, but until they are published they only exist on the machine of whoever ran usm generate. Hosting closes that gap: contributors get a browsable architecture and feature reference, and prospective users get the public half of it without the internal design notes alongside. The site is the adoption front door for the open core — the protocol is the product, so it has to be readable. Doing this on Cloudflare Pages keeps it free, global and dependency-free, and matches how USM itself is hosted, so there is one deploy pattern to understand rather than two. The important constraint is audience separation: the same generator produces both doc sets, and the difference between them is a filter. Getting that filter wrong publishes internal design notes, so the deploy must assert the public set contains no developer-only pages rather than trusting the flag.
Design decisions
cloudflare-pages
Decision: Host the docs and site on Cloudflare Pages, matching how USM is hosted.
Rationale: The domain is already on the account and DNS is already managed there, so adding a project needs no new provider. Pages is free at this scale, serves globally, and the deploy is a directory upload rather than a platform the project must learn. Using the same shape as USM means one deploy pattern to maintain across both projects.
Alternatives considered:
- GitHub Pages — rejected: The apex domain is already on Cloudflare, so DNS and TLS would be split across two providers for no benefit.
- A container or VM serving the static site — rejected: Adds an operating system to patch and a cache to configure, for content that is entirely static.
two-projects-per-audience
Decision: Publish the contributor and help docs as two separate Pages projects on separate subdomains.
Rationale: The two audiences differ by exactly one filter, and that filter is the only thing keeping internal architecture notes off the public site. Separate projects make the boundary structural rather than a flag on a build: a mistake in one cannot expose the other, and each can be republished or rolled back independently.
Alternatives considered:
- One project serving both audiences under a path — rejected: The internal pages would sit one directory away from the public ones, so the boundary would rest entirely on the build flag being right.
direct-upload-not-git-integration
Decision: Deploy by uploading the built directory from GitHub Actions, rather than connecting Pages to the repository.
Rationale: The site is generated from specs by a pinned toolchain, so the build must happen where that toolchain is pinned. Letting Pages build from the repository would put the generator version outside the repository's control and outside the CI that validates it, which is the specific drift this project already had to fix once.
Alternatives considered:
- Cloudflare Pages Git integration — rejected: Version selection and build steps would move to the provider's dashboard, unversioned and untested.
correct-canonical-urls-post-build
Decision: Rewrite the generated sitemap's domain after each build as a known workaround.
Rationale: The pinned generator writes a hardcoded sitemap hostname for the help and developer audiences with no configuration or environment override, so a published site would claim to belong to another project. Since the build is regenerated every run, the correction has to be applied every run; it is recorded as a workaround with an upstream report rather than treated as intended behaviour.
Alternatives considered:
- Omit the sitemap until the generator allows configuring it — rejected: Loses discoverability for the whole public site to correct one field.
- Commit a corrected config file — rejected: The generator rewrites it on every build, so the fix would not survive.
marketing-site-deploys-separately
Decision: Wire the docs deploy now and add the marketing site when it is built.
Rationale: The docs exist and build today; apps/safekeys is an empty directory. Splitting the workflows keeps the docs publishing unblocked and means the marketing build, which has a different toolchain and output, cannot break documentation deploys.
Alternatives considered:
- Wait and deploy both together — rejected: Withholds value that is already built, for no technical benefit.
How it works
Publish the contributor docs (publish-contributor-docs)
Build the developer-audience docs and deploy them to dev-docs.safekeys.ai.
- Validate — Every .usm spec validates and the drift gate passes, so only a clean tree deploys.
- Setup — The pinned USM version generates both doc sets; the version is the same one CI gates on.
- Transform — The static site is built, then its canonical URLs are corrected to our domain.
- Send — The built directory is uploaded to the dev-docs Pages project.
- Observe — The deploy is recorded with its commit; the previous deployment remains available for rollback.
Publish the help docs (publish-help-docs)
Build the filtered public-audience docs and deploy them to docs.safekeys.ai.
- Validate — The public set is asserted to contain no developer-only pages before anything is uploaded.
- Transform — The help site is built, then its canonical URLs are corrected to our domain.
- Send — The built directory is uploaded to the help-docs Pages project.
- Observe — A failed audience assertion stops the deploy rather than publishing internal notes.
Provision the hosting (provision-hosting)
The one-time Cloudflare and repository setup a new maintainer must perform.
- Setup — Two Pages projects are created, one per audience.
- Setup — Custom domains are attached to each project, with DNS managed by Cloudflare.
- Setup — Two repository secrets grant the workflow upload permission, scoped to Pages only.
- Observe — A missing secret fails the workflow loudly rather than silently skipping the deploy.
Preview the docs locally (preview-docs-locally)
A maintainer reads both audiences on localhost before publishing.
- Setup — The generate target produces both doc sets.
- Observe — The developer audience is served with live reload while specs are edited.
- Observe — The help audience is served separately, so the filter can be inspected before a public deploy.
Guarantees
audience-separation
The public site must never contain pages intended only for contributors.
Acceptance criteria:
- [ ] The help docs are a filtered set, not a copy
- [ ] Architecture, design and data-model pages are absent from the public build
- [ ] The deploy asserts the filter rather than trusting the flag
- [ ] A failed assertion blocks publication
canonical-urls-are-ours
Published pages must identify themselves as belonging to safekeys.ai.
Acceptance criteria:
- [ ] The sitemap references the safekeys.ai domains, never a third party's
- [ ] No published page advertises another project's canonical URL
- [ ] The correction is applied on every build, because the generator rewrites it
deploy-uses-the-pinned-toolchain
What is published is what CI validated.
Acceptance criteria:
- [ ] The deploy job pins the same USM version as CI
- [ ] The deploy runs only from a passing validation
- [ ] Generated files are not committed, so the site cannot drift from the specs
cache-policy-preserves-freshness
A redeploy must be visible immediately without losing asset caching.
Acceptance criteria:
- [ ] HTML responses revalidate rather than being served stale from the edge
- [ ] Hashed assets are cached immutably
- [ ] Headers are written after the build, since each build clears the output directory
deploy-artifacts-carry-no-secrets
What is uploaded is content only.
Acceptance criteria:
- [ ] The upload token exists only in the workflow environment
- [ ] No credential is embedded in the built site
- [ ] The token is scoped to Pages deployment, not account-wide
rollback-is-possible
A bad publish can be undone without a rebuild.
Acceptance criteria:
- [ ] Each deployment is recorded against its commit
- [ ] A previous deployment can be promoted
- [ ] The workflow can be run manually for a deliberate republish
Test specifications
public-build-excludes-internal-pages
Given:
- audience: "help"
When: publish-help-docs
Then:
- assertion: no architecture directory exists in the public output
- assertion: no design directory exists in the public output
- assertion: the assertion fails the job when an internal page is present
Contracts verified: audience-separation
sitemap-uses-our-domain
Given:
- artifact: "sitemap.xml"
When: publish-contributor-docs
Then:
- assertion: every sitemap location is under safekeys.ai
- assertion: no location references a third-party domain
Contracts verified: canonical-urls-are-ours
deploy-requires-valid-specs
Given:
- spec_state: "one spec edited without regenerating"
When: publish-contributor-docs
Then:
- assertion: the drift gate fails before any upload occurs
Contracts verified: deploy-uses-the-pinned-toolchain
missing-secret-fails-loudly
Given:
- secret: "absent"
When: provision-hosting
Then:
- assertion: the workflow reports the missing credential
- assertion: the deploy does not silently succeed with nothing published
Contracts verified: deploy-artifacts-carry-no-secrets
cache-headers-present
Given:
- artifact: "_headers"
When: publish-contributor-docs
Then:
- assertion: HTML is configured to revalidate
- assertion: hashed assets are configured as immutable
Contracts verified: cache-policy-preserves-freshness
published-site-serves-content
Given:
- url: "https://docs.safekeys.ai"
When: publish-help-docs
Then:
- assertion: a known feature page returns its content
- assertion: the site identifies itself as Safekeys, not another project
Contracts verified: canonical-urls-are-ours
Implementation
- Primary: .github/workflows/docs-deploy.yml
- Test code status: none
See Also
- safekeys/site
- safekeys/deployment-packaging