Maintained procedure · manual/BUILD.mdMarkdown source at d23f2aea9f24
On this page

Build the documentation

The manuals are read directly as Markdown or built as PDFs, and the API documentation workflow rebuilds and publishes the unified project site from main nightly. Run the commands below from the repository root.

OutputPublished pathSourceBuild
Operator’s Manual and Agent Operator’s ManualLocal PDF/TeXmanual/*.mdBuild the manuals
Landing page, shared navigation, search and workflow pages/, /site-search.json, /workflows/scripts/site_shell.py, maintained manual/ pages, assembled site dataAssemble the site shell
API reference and declaration search/api.html, /search.html, /CslibFrontier/, /Cslib/docbuild/ and module docstringsBuild the API reference
Checked guide/guide/guide/ (Verso)Build the checked guide
Codebase views, registered results and textbook audits/viz/tools/viz/, CslibFrontierResults, Git historyLive repository source statistics
Complexity-class inclusion tables/class-inclusions/tools/class_inclusions/ and trimmed declaration-data.bmpBuild the API reference
Interactive domain maps and verified playgrounds/maps/, /playground/ (when present)tools/maps/, tools/playground/Activated automatically by docs.yml when build.py exists
Source history dashboard/stats/tools/stats/ and Git historyLive repository source statistics

Build the manuals#

Read the Markdown without any publishing tools. The default build produces the substantial Operator’s Manual; --agent-manual selects the short Agent Operator’s Manual for humans driving agents. To check the maintained source, run these commands from the repository root with Python 3.11+:

python3 scripts/check_operator_manual.py
python3 scripts/test_operator_manual.py

CI and both full and quick scripts/check.sh runs require these checks. They need no PDF tools, Lean build or generated research data, and do not replace independent review of the manuals' meaning and usability.

The checker rejects unresolved Git conflict opening markers outside code fences, reporting the document and line. Resolve the competing content, remove the conflict markers and rerun the checks before building either PDF. Deliberately quoted conflict examples must be in a code fence; ordinary heading underlines and blockquotes remain valid Markdown.

It also reports a list item directly after a paragraph line. Pandoc reads that item as more of the paragraph, so the PDF prints the list as running text although GitHub shows a list. Add a blank line before the list, or rewrap a prose line that merely starts with -, +, * or a number and a period. Items of an open list, nested ones included, need no blank line. Lists inside block quotes are not checked.

It also reports a locator inside the label of a link into sources.md, such as [Boneh and Shoup, Section 5.6][bs23]. The PDF prints such a link as a citation number and drops its label, so the locator is lost. Write the locator after the link: [Boneh and Shoup][bs23], Section 5.6. Section, chapter, page, statement, figure, table and equation numbers count, spelled out or abbreviated (Sec. 5, Thm. 4) and in either case, and so does any bare dotted number (CLRS 15.5). A version written TLS 1.3 therefore counts too: write it v1.3 or put it after the link. A year, or a title word after a keyword (Algorithm Design), does not. Labels that wrap onto the next line are checked as one label.

To produce the books, also install Pandoc, XeLaTeX and pdfinfo (Poppler). The main book's model diagrams require Graphviz (dot); the short agent manual does not invoke it. The TeX installation needs fontspec, fvextra, xurl, bookmark, microtype, fancyhdr, etoolbox, tcolorbox and the usual AMS/graphics/table packages, plus TeX Gyre Pagella, TeX Gyre Heros and DejaVu Sans Mono fonts. The converter uses the font filenames shipped by TeX Live. Dependencies are local commands; the build script does not download tools or invoke Lean.

From the repository root:

python3 scripts/build_operator_manual.py
python3 scripts/build_operator_manual.py --agent-manual

Outputs share the ignored manual/_build/ directory and have distinct names:

BookTeX/PDF filename stemSource manifest
Operator’s Manualcslib-frontier-operators-manualmanual-source-manifest.json
Agent Operator’s Manualcslib-frontier-agent-operators-manualagent-manual-source-manifest.json

Neither book needs research exports or historical plots. The short book contains only AGENT_OPERATORS.md and its policy/source links; it carries no academic bibliography or historical figure. Each manifest records the selected manual, source revision, working-tree status and exact input hashes. It is build provenance, not validation of the mathematical statements. The main build renders model diagrams from the Markdown into figures/ beside its TeX. Each generated TeX file is editable and compiles independently with XeLaTeX; retain those figure PDFs with the main book's TeX file.

Before distributing an existing book, check that its chapter and bibliography inputs still match the current manual:

python3 scripts/build_operator_manual.py --check-build manual/_build
python3 scripts/build_operator_manual.py --agent-manual --check-build manual/_build

Each check needs only Python and validates the selected manual. It fails for missing chapters, changed input text or converters, stale bibliography contents, missing or altered diagrams, or altered generated TeX/PDF. A build that produces only TeX does not certify an older PDF left in the output directory. Rebuild after such changes and inspect the affected pages. A passing live link/excerpt check alone does not validate an older PDF. Bibliography bodies are read directly from canonical sources.md.

Without local publishing tools, use the Operator's Manual PDFs workflow. It runs on pull requests that change manual/ or the manual scripts, and can also be started by hand. It builds and checks both books from the pull request's head commit, and its run summary links an artifact containing both PDFs and their source manifests.

To generate TeX with its diagram assets, or select another output directory:

python3 scripts/build_operator_manual.py --tex-only
python3 scripts/build_operator_manual.py --output-dir /tmp/cslib-frontier-manual-book

The second path is an example destination that you choose. No files in that directory are removed automatically. For repeated independent TeX compilation, run XeLaTeX three times from the output directory so the contents and citations stabilize. Generated links to repository files outside the selected book point to GitHub at the rendered commit; the PDF can be moved without retaining the checkout. Push that commit before sharing the PDF. Links within the book remain internal anchors, and source Markdown keeps its checkout-relative links. The builder rejects links to uncommitted or locally modified repository targets: commit those targets first so the linked content matches the source being reviewed. Uncommitted book prose can still be rendered when its external source targets are committed. A successful builder exits zero; the full build also prints the PDF metadata. The full build fails when XeTeX reports a character that the text or code font lacks; map that character to a math-mode command in MATH in data/build_latex.py. Inspect the output for unresolved references, clipped lines and unreadable tables before distributing it.

Edit the Markdown and regenerate for maintained changes. Do not commit generated TeX, PDF, logs, research exports or auxiliary files. The source files and converters are sufficient to reproduce the book. The Operator’s Manual includes the workflows, full reference, historical study and bibliography; it links to the separate short manual without duplicating that manual’s content. Both builds omit link-only navigation paragraphs. The original academic paper plan remains in history/paper-plan.md as historical editorial context.

When distributing a PDF, retain its matching manifest. A converter or layout change requires checking the rendered pages of both editions. See the maintenance procedure and the contribution policy.

Maintain diagrams and worked examples#

Model diagrams live in mermaid code fences in the reference pages. GitHub renders them directly; the PDF builder reads the same source and uses Graphviz to produce vector figures. Keep the fences unindented and at the top level, outside lists and blockquotes; nested diagrams are rejected. Generated asset paths preserve the source directory hierarchy. The supported flowchart subset is deliberately small: start with flowchart TB or flowchart LR; define each rectangular node separately as input["Input value"]; use input -->|"encoded by"| output for a labelled edge or input --> output without a label. The dotted form is input -.->|"needs a certificate"| output. Identifiers use letters, digits and underscores and start with a letter. Labels are quoted plain text with optional <br/> line breaks. Define both endpoints; do not use subgraphs, styles, clicks or inline node definitions on edges. The checker rejects unsupported syntax instead of omitting it. The renderer supplies consistent typography, colours and arrow styles. Explain the meaning and limits of arrows in the adjacent prose; an arrow must not imply an unstated realization or resource theorem.

Wrap an existing worked example using these source markers and a plain bold title:

<!-- worked-example -->
**Worked example: A descriptive task title**

Ordinary Markdown, including the existing contextual excerpt and its source link.
<!-- /worked-example -->

Keep headings outside the markers and do not nest panels. In Markdown the title and example remain ordinary readable text. The PDF numbers examples within their chapter and gives them a shaded panel, a contrasting title and a continuation label when they cross a page. State the goal, required context, result and likely failure or recovery. Keep the Lean excerpt unchanged unless its checked source client changes. The live checker verifies panel boundaries and diagram syntax as well as excerpt identity; it does not establish diagram semantics.

Generated figure PDFs and the source manifest stay in the ignored build directory. The freshness check includes figure hashes, so replacing or losing a figure requires a rebuild.

Build the API reference#

For a cold checkout, first restore the available caches with scripts/cache/ensure.sh. To build searchable API documentation from the module docstrings:

python3 scripts/check_docs.py --config-only
lake -d docbuild build CslibFrontier:docs
python3 scripts/check_docs.py
python3 -m http.server --bind 127.0.0.1 --directory docbuild/.lake/build/doc

Open http://localhost:8000 to browse and search. A manual run of the API documentation workflow on another branch produces an api-docs artifact instead; serve it by replacing the directory argument above with the extracted artifact directory.

If removing a source module leaves check_docs.py reporting obsolete modules, rebuild the generated documentation after any documentation build has stopped:

lake -d docbuild clean docbuild
lake -d docbuild build CslibFrontier:docs
python3 scripts/check_docs.py

The named clean removes only docbuild/.lake/build, including HTML, per-module data and the SQLite database; deleting HTML alone leaves stale data behind. Library and dependency build outputs, package checkouts and Lake's artifact cache are retained. Documentation for all imported modules is regenerated, which can take substantial time even with warm library build outputs.

In hosted builds, python3 scripts/check_docs.py --trim-only rewrites external dependency links to published Mathlib documentation, prunes the declaration index to CslibFrontier and Cslib, and applies lossless HTML compaction to the remaining API pages. After copying guide/, stats/ and viz/, building complexity-class inclusion tables with build.py (plus tools/maps/ and tools/playground/ when present), and copying 404.html, site_shell.py moves the stock doc-gen4 index to api.html, generates the project landing page at index.html, renders the maintained workflow and registry pages under workflows/, writes the unified search index site-search.json (absorbing any <subsite>/search-index.json files), and injects the shared navigation bar and Command/Control-K search palette. A final python3 scripts/check_docs.py --guide verifies every internal link across the assembled site and logs a per-directory size breakdown before uploading. Setting the repository variables DOCS_DEPLOY_TARGET=s3 and DOCS_S3_BUCKET (with optional DOCS_S3_ENDPOINT_URL, DOCS_AWS_REGION and DOCS_AWS_* secrets) syncs the assembled site to object storage, and DOCS_PAGES_DISABLE=true turns off GitHub Pages deployment once the site outgrows the 1 GiB Pages limit.

Build the checked guide#

The guide introduces the library area by area, with Lean examples that are checked against the library whenever the guide is built. It is written with Verso in a separate guide project. To build and preview it:

scripts/guide.sh
python3 -m http.server --bind 127.0.0.1 --directory guide/.lake/build/site/html-multi

The first build compiles Verso, which takes a few minutes. The helper checks the chapters, then uses lake lean to interpret the generator with its project options and up-to-date imports. This avoids compiling the imported library to native code just to render HTML; errors in Lean examples and chapter warnings still fail the build. For an explicitly native executable, lake -d guide exe guide --output guide/.lake/build/site remains available. The API documentation workflow publishes the guide from main at /guide/. The Guide workflow builds pull requests that change the guide and uploads the pages as a guide artifact.

Hosted jobs may reuse the Guide dependency cache. It contains only dependency builds; the Guide's normal example and rendering checks still run.

Regenerating research outputs#

The historical study reports a fixed observation at 13e6a319, dated November 2, 2026. Its scripts are optional tools for inspecting the evidence; running them is not a prerequisite for reading or building either manual. Outputs default to the ignored manual/_generated/ directory. Keep generated JSON, API responses, dependency copies and plots out of commits. The frozen reference chapters and model map hold the semantic account; the scripts do not reconstruct the retired detailed model ledgers or repeat their mathematical review.

With Git history through the fixed revision available locally, run from the repository root:

python3 manual/data/audit.py .

This writes the source census under _generated/data/, the Git chronology under _generated/history/data/, a navigation index derived from the maintained model map, and _generated/audit.json. A successful audit reports "status": "pass": the first-parent net line count agrees with the source census, daily commit totals agree with the history, and the current manual passes its link, excerpt and citation checks. It does not compile Lean or audit mathematical completeness. It does not fetch missing Git objects; if history is missing, supply a complete checkout as the positional argument instead of .. To export just the navigation index, run python3 manual/data/coverage.py.

The timing analysis additionally requires the original private logs and GitHub observations. These are not included in the repository. With authorized access to the original logs, choose a private output directory outside the checkout and replace the example paths below:

python3 manual/history/data/session_census.py /path/to/codex/sessions --private-output /private/path/manual-provenance
python3 manual/history/data/claude_census.py /path/to/claude/projects --private-output /private/path/manual-provenance
python3 manual/history/data/transcript_excerpts.py /private/path/manual-provenance

The two censuses write aggregate and timing exports to the ignored history directory and source-path provenance to the selected private directory. The excerpt verifier checks the 22 handwritten selections against those originals. Compressed Codex .zst logs require Python 3.14's standard-library support or the optional zstandard package. Missing originals mean these private measurements cannot be reproduced; the public Git audit remains usable.

An installed, authenticated GitHub CLI can collect the selected public records:

python3 manual/history/data/collect_github.py

The collector makes read-only requests and records retrieval timestamps. Use --select issue_569, for example, to retrieve one record. These are new observations: comments, PR states, reruns and retention may have changed, and expired CI records cannot be recovered by this script. Refetching does not recreate the original response bytes or guarantee the study's historical totals.

Once the required census, Git, private-session and GitHub exports are present, run:

python3 manual/history/data/analyze.py
python3 manual/history/data/plot_history.py --data-only
python3 manual/history/data/plot_history.py

Analysis reads _generated/history/data/; plotting also reads the source census under _generated/data/ and writes JSON, SVG and PNG under _generated/history/figures/. The final command requires Matplotlib. Use --data-dir for another history directory, and the plotter's --census-dir and --output for other census and figure directories. A missing-input error means an earlier extraction is absent; do not substitute empty data. Neither generated analysis nor plots are book inputs.

Live repository source statistics#

The daily API documentation workflow also publishes the Lean source history dashboard. It counts daily UTC first-parent snapshots with pinned Tokei, including the old and renamed module roots. Its interactive categories, measure selector, exact-value table and CSV/JSON downloads describe source volume, not mathematical completion. Today’s snapshot is partial.

For a standalone build from full Git history (no Lean dependencies needed):

bash tools/stats/install-tokei.sh /tmp/frontier-tokei
python3 tools/stats/build.py --tokei /tmp/frontier-tokei/tokei

Publish the generated tools/stats/_site/ as a unit; the existing docs workflow copies it to stats/ before the single Pages upload. It refreshes on the daily schedule or a manual docs workflow dispatch on main. The dashboard README documents the category config, history/cache semantics, local regression tests and output overrides. Generated counts and pages are not versioned and are not inputs to either manual PDF.

The docs workflow also builds the codebase views. Its Worker activity page reads public GitHub disclosures with issue and pull request read access. The visualisation README describes how to rebuild the page from a saved summary and how to interpret the worker ID counts.