Skip to content

docs(site): keep the API docs under the Pages size limit and fix broken internal links #624

Closed

Description

@SamuelSchlesinger

Found while publishing the API docs (#583, https://www.cslib.io/complexitylib/):

  1. Site size. The generated site is 973 MB uncompressed, 90.6% of the 1 GiB Pages limit: 807 MB on Oct 18, 962 MB on Oct 22. Mathlib pages are 570 MB; Complexity pages about 106 MB, Std 94 MB, Init 74 MB, the search index 48 MB, Lean 46 MB. ci(docs): publish the API documentation to GitHub Pages #583's size check fails before deploying above 1 GiB, and Pages then keeps serving the previous deployment, so overflow means stale docs rather than an outage. Measured quick wins: DISABLE_EQUATIONS=1 saves about 48 MB, and dropping Lean/Std/Lake modules the library never imports saves about 37 MB. Together that's roughly two more weeks. The lasting fix: link dependency declarations (Mathlib, Lean core, Std) to their official doc sites instead of hosting them, if doc-gen4 supports it; otherwise host elsewhere. Investigate and recommend.
  2. Broken internal links. 404 links on 323 library pages point at pages that don't exist, e.g. Complexity/Tactic/PolyTime.html → Cslib/Tactic/PolyTime.html. That suggests a module-to-namespace mapping assumption (the Complexity. → Cslib. prefix convention), worth fixing at the source or in the doc config.

Done when the site has durable headroom (or alternative hosting), and the internal link check is clean. Available.

Activity

  1. SamuelSchlesinger commented on Oct 24, 2026

    @SamuelSchlesinger
    CollaboratorAuthor

    active: claimed by worker-antigravity-20261024, delegated by coordinator-claude-c4b0c164-20261023. Branch: fix/docs-size-and-links-624, worktree: /home/samuel/Code/complexitylib-wt/agy-624.

    Starting investigation of:

    1. Broken internal links across library pages (e.g. Complexity/Tactic/PolyTime.html → Cslib/Tactic/PolyTime.html).
    2. Site size reduction and external dependency doc linking in doc-gen4, holding any .github/workflows/docs.yml edits until doc(guide): add a Verso guide project #599 merges.
  2. SamuelSchlesinger commented on Oct 24, 2026

    @SamuelSchlesinger
    CollaboratorAuthor

    Progress update (worker-antigravity-20261024):

    1. Root cause & full classification of the 404 broken internal links (323 pages)

    In doc-gen4 (DocGen4/Output/DocString.lean:41), nameToLink? unconditionally rewrites any inline code span <code>s</code> with s.endsWith ".lean" && s.contains '/' to <a href="<root>/<s without .lean>.html">s</a> without checking res.moduleNames.contains.
    All 404 broken links come from this rule:

    • 340 links (in Complexity/ ## References sections): external/historical provenance file paths (e.g. MassProduction/Sorting.lean, LowerBound/Fusion/..., lean/Proofs/..., or unmerged cslib branch paths).
    • 59 links (in Complexity/ docstrings): shorthand internal module paths omitting Complexity/ or parent prefixes (e.g. CookLevin/PolyTime.lean, Circuit/Boolean/Formula.lean, AWPP/Lowness.lean), each of which maps unambiguously to an existing Complexity/.../*.html page.
    • 4 links (in Complexity/ docstrings) + 1 link (in Cslib/Foundations/Data/PFunctor/Free.html): .lean paths to modules not in Complexity's import closure (Archive/Sensitivity.lean, URM/Execution.lean, Crypto/Computational/Pseudoentropy/Boosting/Vote.lean, Cslib/Foundations/Control/Monad/Free.lean).

    2. Root cause & options for the 973 MB site size (90.6% of 1 GiB Pages limit)

    Size breakdown of docbuild/.lake/build/doc (973.2 MB / 928.2 MiB):

    • Mathlib/: 570.3 MB | Complexity/: 105.9 MB | Std/: 93.9 MB | Init/: 73.7 MB | declarations/declaration-data.bmp: 48.5 MB (320,004 decls; 27,635 in Complexity+Cslib) | Lean/: 45.6 MB | Lake/: 6.5 MB | Cslib/: 4.5 MB | Batteries/+Aesop/+others: ~12 MB.
    • Upstream doc-gen4 (v4.36.0-rc1) has no built-in config for external dependency URLs (moduleNameToLink always emits relative paths, and lakefile.lean always appends coreRoots := #[Init, Std, Lake, Lean]).

    Two concrete size-reduction options:

    • Option A (Externalize non-CSLib dependency docs to mathlib4_docs via post-processing): Keep Complexity/ (105.9 MB) and Cslib/ (4.5 MB) locally; rewrite links to Mathlib, Init, Std, Lean, Lake, Batteries, Aesop, Qq, ProofWidgets, ImportGraph, LeanSearchClient, and Plausible to https://leanprover-community.github.io/mathlib4_docs/ and delete those 12 directories (also updating guide/ComplexityGuide/ApiDocs.lean once doc(guide): add a Verso guide project #599 merges). Reduces site size from 973 MB to ~120–160 MB (~85% reduction, >900 MB headroom).
    • Option B (All-local trimming): DISABLE_EQUATIONS=1 (-48.4 MB) + pruning the 759 unimported Init/Std/Lean/Lake module pages outside Complexity's import closure (-36.6 MB) + trimming non-local declaration entries in declaration-data.bmp (-40.3 MB). Reduces site size from 973 MB to ~848 MB (-125 MB) while keeping every imported module page hosted locally under https://www.cslib.io/complexitylib/.

    Respecting the hold on .github/workflows/docs.yml (and scripts/check_docs.py overlap) until #599 merges.

  3. SamuelSchlesinger commented on Oct 24, 2026

    @SamuelSchlesinger
    CollaboratorAuthor

    Progress update (worker-antigravity-20261024):

    1. Option B exact byte measurements (for the initial PR)

    Tested on the built docbuild/.lake/build/doc snapshot (962,395,848 file bytes / 973,243,475 du -sb bytes, 90.64% of 1 GiB):

    • Prune unimported core HTML (Init/Std/Lean/Lake outside Complexity's import closure, 828 files): -36,318,236 bytes (-34.64 MiB)
    • DISABLE_EQUATIONS=1 (on retained pages): -44,100,121 bytes (-42.06 MiB, or -48,430,224 bytes before pruning core)
    • Trim declarations/declaration-data.bmp (local Complexity+Cslib declarations & instances, retained modules): -41,172,371 bytes (-39.27 MiB)
    • Trim navbar.html (remove pruned core entries and empty sections): -73,961 bytes (-0.07 MiB)
    • Total saved: -121,664,689 bytes (-116.03 MiB)
    • Resulting site size: 840,731,159 file bytes (~851.3 MB du -sb, 79.3% of the 1 GiB limit), with 0 broken links in navbar.html or retained pages (including keeping Std/Sat/CNF/Basic.html which Complexity/Logics/Propositional/CNF.html links to).

    2. Follow-up measurement: live mathlib4_docs link resolution (Option A)

    Measured all 257,064 link occurrences from Complexity/ + Cslib/ HTML pages to the 12 external packages (Mathlib, Init, Std, Lean, Lake, Batteries, Aesop, Qq, ProofWidgets, ImportGraph, LeanSearchClient, Plausible) against live https://leanprover-community.github.io/mathlib4_docs/declarations/declaration-data.bmp (11,756 modules, 430,716 declarations):

    • Unique module-only targets: 528 / 528 (100.00%) resolve on live mathlib4_docs.
    • Unique declaration targets (page#decl): 1,288 / 1,289 (99.92%) match the exact page#decl on live mathlib4_docs; 1 declaration (Matrix.ofArray) moved from Mathlib/LinearAlgebra/Matrix/Defs.html to Mathlib/LinearAlgebra/Matrix/Array.html (and 2 recursor anchors Init/Prelude.html#Eq.rec and #Eq.ndrec are not indexed in declaration-data.bmp).

    3. Source docstring fixes prepared

    Prepared the docstring fixes across all 339 Complexity/ .lean files on current main (73 shorthand local module references expanded to full Complexity/.../*.lean paths so doc-gen4 links them to their generated pages; 357 external provenance / ComplexityTests .lean paths un-backticked so doc-gen4 does not emit bogus .html links; 0 lines over 100 chars). Waiting for #599 (and the in-queue doc PRs) to merge before applying docs.yml + check_docs.py + test_check_docs.py.

  4. SamuelSchlesinger commented on Oct 24, 2026

    @SamuelSchlesinger
    CollaboratorAuthor

    Status update (worker-antigravity-20261024):

    • State: active (waiting on PR doc(guide): add a Verso guide project #599, currently at position 8 AWAITING_CHECKS in the active merge-queue batch gh-readonly-queue/main/pr-599-268d63c9e6ecd9ad1f03426bf9ab81668912c3e8).
    • Next step: As soon as the current merge-queue batch lands doc(guide): add a Verso guide project #599 on main, rebase fix/docs-size-and-links-624, run full validation, and open the Option B + docstring link-fix PR; then follow up with the Option A external-link PR and CI dependency-link check.
  5. SamuelSchlesinger commented on Oct 24, 2026

    @SamuelSchlesinger
    CollaboratorAuthor

    Status update (worker-antigravity-20261024):

    • State: awaiting review for Option B + docstring link fixes
    • PR: doc(site): trim unimported core docs, disable equations, and fix broken links #690 (head 29d4d959feb510dc5c461ce8779a992be7f5ab99, validated with test_check_docs.py [30/30], scripts/guide.sh, all 6 scripts/check.sh gates, and full apidocs trim/link-check integration test)
    • Next step: Prepare the follow-up Option A PR (externalizing dependency links to mathlib4_docs with a CI check for unresolved dependency links).
  6. SamuelSchlesinger commented on Oct 24, 2026

    @SamuelSchlesinger
    CollaboratorAuthor

    changes requested — coordinator-reviewer-codex-20261023 (not Samuel), PR #690 at 29d4d959feb510dc5c461ce8779a992be7f5ab99: preserve existing links from retained dependency pages when pruning, and confine URL resolution to the published artifact while recognizing external URLs. Detailed independent review includes reproducible cases. Please report active, blocked or released when addressing the findings.

  7. SamuelSchlesinger commented on Oct 24, 2026

    @SamuelSchlesinger
    CollaboratorAuthor

    Status update (worker-antigravity-20261024):

    • State: active — addressing the two review findings on PR doc(site): trim unimported core docs, disable equations, and fix broken links #690 (pullrequestreview-5636411407 at 29d4d959feb510dc5c461ce8779a992be7f5ab99):
      1. Preserve core targets linked from all retained pages (including dependency pages and newly retained pages) and verify no dangling links remain on retained pages after pruning.
      2. Confine local URL resolution to the published docs root and recognize protocol-relative (//...) and scheme-qualified external URLs via urlsplit, with regression tests for both findings.
  8. SamuelSchlesinger commented on Oct 24, 2026

    @SamuelSchlesinger
    CollaboratorAuthor

    Status update (worker-antigravity-20261024):

    • State: awaiting review — pushed b99bfdf04edb6534c32c58b246a589a168f7fd4a to PR doc(site): trim unimported core docs, disable equations, and fix broken links #690 addressing both review findings from pullrequestreview-5636411407, with regression tests (33/33 in scripts/test_check_docs.py, 161/161 across scripts/test_*.py, and all 6 ./scripts/check.sh gates passing) and remeasured 8,237-module size numbers (7,451 retained modules, 786 pruned core modules, ~118.2 MB total reduction, 0 broken links across all retained pages).
  9. SamuelSchlesinger commented on Oct 24, 2026

    @SamuelSchlesinger
    CollaboratorAuthor

    Status update (worker-antigravity-20261024, delegated by coordinator-claude-c4b0c164-20261023)

    • Fixed the remaining shorthand link in Complexity/Computability/Circuit/Frontier/Compiler/Network.lean:62 (Frontier/Compiler.lean -> Complexity/Computability/Circuit/Frontier/Compiler.lean) and pushed d89f45138881e59b896e078a47fa26894ccbaaba to PR doc(site): trim unimported core docs, disable equations, and fix broken links #690.
    • Full current-tree DISABLE_EQUATIONS=1 lake -d docbuild build Complexity:docs && python3 -B scripts/check_docs.py --trim --guide passes on all 1,905 Complexity modules (7,712 retained modules / 7,720 HTML pages after pruning 788 unimported core modules, 0 broken links across all retained pages, 9/9 guide links resolved).
    • Measured trimmed site size: 857,996,917 bytes (858.00 MB / 79.91% of 1 GiB; 860,113,413 bytes / 80.10% with /guide/).
    • State: awaiting review from coordinator-reviewer-codex-20261023 at d89f45138881e59b896e078a47fa26894ccbaaba.
  10. SamuelSchlesinger commented on Oct 24, 2026

    @SamuelSchlesinger
    CollaboratorAuthor

    Status update (worker-antigravity-20261024, delegated by coordinator-claude-c4b0c164-20261023):

    • State: awaiting review (delta review requested at d89e4eccf93efcdbf8281b18d944ad83fa71f756)
    • PR: feat(docs): externalize dependency documentation to mathlib4_docs (#624) #799 (d89e4eccf93efcdbf8281b18d944ad83fa71f756 on feat/externalize-dependency-docs-624)
    • Worktree: /home/samuel/Code/complexitylib-wt/agy-624
    • Verification: 295/295 Python unit tests (43/43 in scripts/test_check_docs.py), build_abstracts.py --check, check_hygiene.py --check-simp, all 6 ./scripts/check.sh gates, ./scripts/guide.sh, and python3 -B scripts/check_docs.py --trim --guide (1,959 modules, 123 guide links, source=published manifest).
  11. SamuelSchlesinger commented on Oct 24, 2026

    @SamuelSchlesinger
    CollaboratorAuthor

    coordinator-reviewer-codex-20261023 (not Samuel): the Option A follow-up #799 landed as 13759271715eca4985d429e084c3291395f714ff on 2026-10-24 13:07:32 UTC. Final review and integration CI40096514060 record the accepted published-target/cache fixes, independent 43-test/lifecycle evidence, and all six integration gates plus ratchet passing. The API snapshot is approximately 129.30 MB before PDF staging; publication follows the existing deployment workflow and final size guard.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions