feat(docs): emit the canonical public-docs artifact the app renders

MkDocs retires and the Astro app becomes the only public site, so the artifact is
the product and the Markdown stays the source -- the split tools/newsgen already
states for releases. tools/docsite walks the published set and writes
docs/data/generated/docs.json: every page's directory-style url, title, section and
raw Markdown body, plus the sidebar tree derived from the layout.

Three things the artifact has to get right, each of which was wrong in a draft:

- LINKS. The published pages carry relative .md links that MkDocs rewrote at build
  time and nothing else will. Each is rewritten to the target page's url using the
  same function that builds urls, so a link and its target cannot disagree; anchors
  and scheme-qualified links pass through; assets resolve by the same rule and none
  are referenced.
- FRAGMENTS. A link can resolve to a page and still be broken, because a fragment
  matching no heading lands the reader at the top of a long document. Each is
  checked against the target's headings, by the slug rule a table of contents uses.
- REFUSAL. A link whose target the set holds back, or whose fragment matches no
  heading, fails the generator naming the file, the line and the target. This found
  three citations from settled architecture pointing at two PRDs the blanket prds/*
  exclusion withheld -- links that were already 404s on the published site, so the
  exclusion broke citations rather than withholding drafts. Both targets are now
  published, for a reason distinct from the three ratified PRDs already published.

The published set moves out of mkdocs.yml into the generator with its reasons: a
renderer reading the artifact cannot see why a page is absent. docs/data/generated
is accounted for by docsgen's generatedArtifacts, which now names this file beside
contracts.json -- one ownership registry for the directory rather than one per
writer, so neither tool reports the other's artifact as unaccounted.

docs:artifact regenerates; docs:artifact:check reproduces into memory and fails on
drift without touching the tree, wired into task check beside news:check. The
existing docs:site target is MkDocs and was left alone -- a first attempt at that
name silently ran MkDocs and produced nothing.

Verified: task check exit 0, docs:artifact:check reporting 23 pages. The artifact
carries 23 pages, no archive/ inspiration/ or news/ entry, and the five PRDs the
set declares. Coverage: the published set and its count, url derivation, the nav
tree, both refusal paths, and check's no-write guarantee.
This commit is contained in:
sam committed 2026-09-22 12:44:18 +10:00
1 parent fa517fb49e
commit 1b54a18e43
7 files changed
+1168 -24

No files matched your search

+38
View File
@@ -131,6 +131,41 @@ tasks:
cmds:
- go -C tools run -mod=readonly ./newsgen check --repo-root ..
docs:artifact:
desc: Regenerate the canonical public-docs artifact from the Markdown sources
summary: |
Writes docs/data/generated/docs.json: every published page's url, title,
section and raw Markdown body, plus the sidebar tree derived from the
layout. The JSON is the canonical, host-neutral fact set a renderer reads;
the Markdown stays the source. MkDocs was the first renderer and the Astro
app is the second, so the artifact is the product.
The published set lives in tools/docsite/main.go with the reasons for what
is held back -- archive/, inspiration/, news/, most of prds/ and the
credential notes -- because a renderer reading the artifact cannot see why
a page is absent.
The file is committed, so this dirties the tree deliberately: review the
diff and commit it with the page that produced it.
The artifact's keys are a frozen contract: an application is built against
them, so renaming one breaks a consumer this repository does not compile.
cmds:
- go -C tools run -mod=readonly ./docsite --repo-root ..
docs:artifact:check:
desc: Verify the committed public-docs artifact matches the Markdown sources
summary: |
Reproduces the artifact in a temporary directory and fails when the
committed file differs, without modifying the working tree. Runs in
`task check`, so a page edit cannot land without its regeneration.
The generated directory is accounted for by docsgen's generatedArtifacts,
which names this file alongside contracts.json: one registry for the
directory rather than one per writer.
cmds:
- go -C tools run -mod=readonly ./docsite check --repo-root ..
vet:
desc: Run go vet
cmds:
@@ -454,6 +489,9 @@ tasks:
# already freezes. Left out of the gate, a changelog edit would land
# while the published notes silently lag behind it.
- task: news:check
# The public-docs artifact is what the site renders, so a page edit that
# does not reach it publishes a site that disagrees with the repository.
- task: docs:artifact:check
- task: vet
- task: lint
- task: build