[AAASM-4310] 📝 (docs): Add mdBook shared metadata generator to prevent docs drift - #1461
Conversation
Introduce metadata/docs.yaml as the single source of truth for docs values that are not already encoded in Cargo.toml (protocol version, canonical URLs, installer endpoints). The generator script added in a following commit reads this file plus Cargo.toml to produce checked-in mdBook include snippets, and the docs CI drift check will guard against silent edits. Refs: AAASM-4310 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
scripts/generate_docs_metadata.py reads Cargo.toml [workspace.package].version
plus metadata/docs.yaml and emits checked-in Markdown snippets under
docs/src/generated/ that mdBook pages consume via {{#include ...}}.
The generator uses only the Python 3.11+ stdlib (tomllib + a tiny scalar-only
YAML parser) so the docs CI drift check does not need PyYAML installed. Each
generated snippet carries a "DO NOT EDIT" banner as a warning to future
maintainers editing the file directly.
Refs: AAASM-4310
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Check in the initial output of scripts/generate_docs_metadata.py. Checking
these files in — rather than generating them at mdBook build time — keeps
docs CI Python-free at build time and makes drift visible in code review:
any change to Cargo.toml or metadata/docs.yaml must be paired with a matching
snippet update, or the drift check added in a following commit fails.
Each snippet is single-purpose (version, version-tag, protocol-version,
repo-url, docs-url, install) so pages can compose them via {{#include}} at
their exact position.
Refs: AAASM-4310
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Swap two high-drift literals for mdBook {{#include}} references to the
newly generated snippets:
* docs/src/releases.md — the "latest tag is a pre-release (…)" callout
now includes generated/version-tag.md instead of hard-coding a stale
tag string (was pinned at v0.0.1-beta.4 while Cargo.toml is at rc.3).
The parenthetical publish date is dropped from the sentence because
GitHub Releases is already named as the source of truth for dates.
* docs/src/versioning.md — the "current protocol version" callout now
includes generated/protocol-version.md instead of hand-writing
`protocol/v1`.
Both use mdBook's line-anchored include syntax (:2) so the DO NOT EDIT
banner on line 1 of each snippet is elided from the rendered page. The
generator docstring is updated to document this convention as the
sanctioned way to consume a snippet.
This is a deliberately narrow first pass. Historical values (compat
matrix rows, per-release notes, install-example pins already checked
by scripts/check-docs-versions.sh) are left literal — replacing those
would break either historical accuracy or the existing drift check.
Refs: AAASM-4310
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Add two steps to the Docs workflow that run before `mdbook build docs`:
1. Regenerate docs/src/generated/ from Cargo.toml + metadata/docs.yaml.
2. Fail with an actionable message if `git diff --exit-code` on that
directory is non-empty.
Extend the `pull_request` / `push` path filters to also trigger on changes
to metadata/**, scripts/generate_docs_metadata.py, and Cargo.toml so a
version bump or metadata edit that skips the docs directory still runs
the drift check.
Failing before the mdbook build step keeps the CI log clean — the drift
error message points at the exact file to regenerate, and the runner does
not waste time compiling a stale site.
Refs: AAASM-4310
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Document how to add or update a shared docs value under the Development
section: what belongs in metadata/docs.yaml vs Cargo.toml vs the generated
snippet directory, the {{#include ...:2}} consumption convention, and the
explicit list of things that must NOT be templated (historical release
notes, compat matrix rows, and the install-example pins guarded by
scripts/check-docs-versions.sh).
Linked from SUMMARY.md under Development so the note is discoverable
from the same section as Local Development and Consuming the Shared
Crates.
Refs: AAASM-4310
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Claude Code review — AAASM-4310CI status: 9/9 required checks green, 1 skipped (branch-conditional). AC coverage vs Jira AAASM-4310:
Side-effect assessment: zero runtime code touched — FE validation: N/A — mdBook is a static docs generator with no interactive frontend. Verdict: Ready to approve and merge. 6 clean atomic gitmoji commits, all AC met. |
The metadata file was pointing at the GitHub Pages mirror (`ai-agent-assembly.github.io/agent-assembly/latest/`). Per ADR-0008 (SaaS host-routing) and root README.md, the canonical published docs host is `docs.agent-assembly.com`; the Pages deployment is the upstream mirror the CDN pulls from and must not be surfaced to readers. Update the source of truth so the generated snippet points readers at the correct URL.
Claude Code re-review — AAASM-4310 (post canonical-URL fix)CI status: all 10 required checks green (9 pass, 1 skipped — branch-conditional). mdBook build, drift check, verify-documented-commands, CodeQL (go/js/py/rust), SonarCloud all pass. New commits since last review (2):
Fixes an issue caught in review: Side effects: none. Only FE validation (Playwright, mdBook static site):
Verdict: ready to approve and merge. 8 clean atomic gitmoji commits. |
Description
Adds a shared-metadata generator for the mdBook docs site so high-drift
values (workspace runtime version, wire protocol version, canonical URLs,
one-line installer command) are sourced from a single source of truth
instead of being duplicated across Markdown pages.
Jira: https://lightning-dust-mite.atlassian.net/browse/AAASM-4310
What changed
metadata/docs.yaml— the single source of truth for docs valuesthat are not already encoded in
Cargo.toml(protocol version, canonicalURLs, installer endpoints).
scripts/generate_docs_metadata.py— readsCargo.toml[workspace.package].version+metadata/docs.yamland writes checked-inMarkdown snippets under
docs/src/generated/. Uses only the Python 3.11+standard library (
tomllib+ a tiny scalar-only YAML parser) so docs CIdoes not need PyYAML installed.
docs/src/generated/*.md— the generator's initial output. Each filestarts with a
<!-- Generated by ... DO NOT EDIT. -->banner; pagesconsume the value with mdBook's line-anchored include syntax
(
\{{#include generated/version-tag.md:2}}) so the banner is elided fromthe rendered output.
docs/src/releases.mdanddocs/src/versioning.md— the "latest tag" and"current protocol version" callouts now reference generated snippets
instead of hard-coded literals.
releases.mdpreviously namedv0.0.1-beta.4whileCargo.tomlwas already at0.0.1-rc.3..github/workflows/docs.yml— adds a drift-check job step that runs thegenerator and fails on any diff in
docs/src/generated/. Path filtersextended to trigger on
metadata/**,scripts/generate_docs_metadata.py,and
Cargo.tomlso a bare version bump still runs the check.docs/src/development/shared-docs-metadata.md— maintainer notedocumenting how to add or update a shared value, linked from
SUMMARY.md.Why
Duplicated version / URL literals in docs regularly drift on release. The
existing
scripts/check-docs-versions.shcatches drift in a fixed set ofinstall-example lines when driven from
release-tag-cut, but does nothingfor the many other places these values appear. This generator plus the docs
CI drift check makes forgotten updates fail mechanically instead of shipping.
Option A vs Option B
The ticket allows either an mdBook preprocessor (Option A) or a
generated-snippet pipeline (Option B). Option B was chosen because:
docs/book.tomlpreprocessor chain already containsmdbook-mermaidand a custom
last-changedpreprocessor. Adding a third preprocessorwould grow that chain's failure surface without giving reviewers a
diffable artifact.
exactly which values changed on a version bump.
drift), which keeps
mdbook build docsfast and self-contained.docs/theme/last-changed.pypreprocessor is single-purpose;a "vars" preprocessor would be a second thing to keep in sync with
mdBook's preprocessor JSON protocol.
Deliberately out of scope
accuracy).
installation.mdandREADME.md— thoseare already guarded by
scripts/check-docs-versions.shat release-tagcut, and replacing them with includes would break that check.
compatibility.md— each row is ahistorical record for one release.
Type of Change
Breaking Changes
Related Issues
Testing
Ran the ticket's validation trio locally:
Also simulated drift by editing
metadata/docs.yaml, re-ran the generator,and confirmed the CI drift check would fail with an actionable message
before mdbook build runs. Reverted the drift test.
Checklist
Closes AAASM-4310