SK-62: Blueprint-to-Report Generator
Convert a Lean 4 project blueprint (extracted LaTeX nodes, dependency graphs, JSON metadata) into a publication-grade LaTeX report with natural language narrative, mathematical exposition, and visual dependency maps.
Routing
- USE FOR: converting a Lean 4 project blueprint into a publication-grade LaTeX report via the 6-stage INGEST → PLAN → NARRATE → ILLUSTRATE → ASSEMBLE → COMPILE pipeline; ingesting blueprint artifacts (LaTeX nodes, dependency DAG, JSON metadata); generating per-chapter mathematical prose with
\leanref cross-references; producing TikZ dependency figures; running latexmk to PDF.
- DO NOT USE FOR: generating the blueprint itself (delegate to
@lean-blueprint); writing one chapter without the pipeline (delegate to @lean-doc-improvement); reviewing a finished report (delegate to @lean-review-council); spec lifecycle (delegate to @lean-specification).
- TRIGGERS: blueprint to report, generate report, latex pdf,
project-report.tex, narrate chapter, dependency figure, blueprint compile.
Workflow
- Verify prerequisites (Part 12.1 below — blueprint artifacts exist, LaTeX toolchain present).
- First-time: run Part 12.2 (INGEST → PLAN → NARRATE → ILLUSTRATE → ASSEMBLE → COMPILE). Each stage's contract is in the handbook (Parts 3–8).
- Incremental: run Part 12.3 — re-blueprint, re-ingest, diff, narrate only changed chapters, recompile.
- On compilation error consult Part 13 (Troubleshooting) below; on output-artifact question consult Part 14 below.
- Handoff to
@lean-doc-feedback once the PDF lands so the doc-sync skill can record the new artifact in the repository's tracking matrix.
Recovery & STOP
- STOP if
\cref references emit "??" after two latexmk passes — the blueprint is out of sync; re-run INGEST per Part 12.3.
- STOP if narration drifts from Lean source (Part 13 final row) — the source changed after narration; re-run NARRATE for affected chapters only.
- STOP if the figures stage produces empty TikZ outputs —
dot2tex is optional but required for dependency graphs; install or fall back to module-map-only figures.
Handoffs
- Predecessors:
agent:gateway (top-level invocation), skill:lean-blueprint (produces the blueprint artifacts this skill consumes), skill:lean-doc-requirements (chapter-scope decisions).
- Successors:
skill:lean-doc-feedback (record the PDF artifact + cross-references), skill:lean-doc-improvement (per-chapter post-narration edits), skill:lean-review-council (review the report for project-level coherence), skill:lean-enforcement (CI gate that confirms PDF builds on a clean checkout).
Detailed reference
Full pipeline content (Parts 1–11) lives in
references/lean-report-handbook.md.
Load that file when authoring or debugging stage internals; the SKILL.md
only carries the dispatch contract and the high-frequency operational
sections (Parts 12–14 kept inline below).
| Section |
Topic |
Covers |
| Part 1 |
Inputs and Outputs |
What this skill consumes / produces |
| Part 2 |
Pipeline Architecture |
Six-stage DAG overview |
| Part 3 |
Stage 1 — INGEST |
Blueprint artifact extraction |
| Part 4 |
Stage 2 — PLAN |
Chapter outline + narrative arc derivation |
| Part 5 |
Stage 3 — NARRATE |
Per-chapter prose generation rules |
| Part 5B |
Lean 4.28 Features for Report Generation |
Pin-relative Lean+Mathlib features |
| Part 6 |
Stage 4 — ILLUSTRATE |
TikZ figure generation |
| Part 7 |
Stage 5 — ASSEMBLE |
Master-document merging |
| Part 8 |
Stage 6 — COMPILE |
latexmk pipeline + diagnostics |
| Part 9 |
Audit Integration |
Tracking-matrix hooks |
| Part 10 |
Project-specific Configuration |
Per-project tunables |
| Part 11 |
Integration with Gateway (SK-07) |
Cross-skill dispatch |
Part 12 — Execution Checklist
12.1 Prerequisites
# 1. Verify blueprint exists
ls .lake/build/blueprint/library/*.tex # extracted nodes
ls blueprint/web/index.html # web build exists
# 2. Verify LaTeX toolchain
which latexmk pdflatex biber
kpsewhich tikz.sty pgfplots.sty cleveref.sty thmtools.sty
# 3. Verify optional tools
which dot2tex # for dependency graph conversion (optional)
12.2 First-Time Generation
# 1. Create report directory structure
mkdir -p report/{chapters,front,back,figures,macros,build}
# 2. Run INGEST stage
python3 scripts/blueprint_to_report.py ingest \
--blueprint-dir .lake/build/blueprint \
--coverage docs/tracking/coverage_matrix.md \
--output report/report_context.json
# 3. Run PLAN stage
python3 scripts/blueprint_to_report.py plan \
--context report/report_context.json \
--output report/report_plan.json
# 4. Run NARRATE stage (agent-driven, one chapter at a time)
# Each chapter: read plan → read module → generate prose
# See §5 for generation rules
# 5. Run ILLUSTRATE stage
python3 scripts/blueprint_to_report.py illustrate \
--context report/report_context.json \
--output-dir report/figures/
# 6. Run ASSEMBLE stage
# Merge all chapters into master document (see §7.1)
# 7. Run COMPILE stage
cd report && latexmk -pdf project-report.tex
12.3 Incremental Updates
After new theorems are proven:
# 1. Re-run blueprint (SK-61):
lake build :blueprint && leanblueprint all
# 2. Re-ingest:
python3 scripts/blueprint_to_report.py ingest --update
# 3. Identify changed chapters:
python3 scripts/blueprint_to_report.py diff \
--old report/report_context.json \
--new report/report_context_updated.json
# 4. Re-narrate affected chapters only
# 5. Recompile:
cd report && latexmk -pdf project-report.tex
Part 13 — Troubleshooting
| Problem |
Cause |
Fix |
| No blueprint artifacts found |
SK-61 not run |
Run generate blueprint first |
nodes.json missing |
:blueprintJson not built |
Run lake build :blueprintJson |
| LaTeX won't compile |
Missing package |
Install full TeX Live: tlmgr install <pkg> |
Undefined \cref |
cleveref not loaded |
Add \usepackage{cleveref} after hyperref |
| Cross-references show "??" |
Need 2nd pass |
Run latexmk (auto-handles multi-pass) |
| Theorem count mismatch |
Blueprint outdated |
Rebuild blueprint, re-ingest |
| Margin notes overflow |
Too many \leanref |
Reduce to key theorems only |
| Figure won't render |
Missing TikZ library |
Add \usetikzlibrary{...} |
| Bibliography empty |
.bib not found |
Check \addbibresource path |
| PDF too large |
Embedded high-res figures |
Use \includegraphics[draft] for draft builds |
| Narration inconsistent with Lean |
Source changed after narration |
Re-run INGEST + NARRATE for affected chapters |
| Scaling notation unclear |
Missing §scaling-convention |
Ensure Ch 1 defines the $\times 100$ convention |
Part 14 — Output Artifacts Summary
The complete report generation pipeline produces:
| Artifact |
Location |
Purpose |
| Report context |
report/report_context.json |
Serialized ingestion data |
| Report plan |
report/report_plan.json |
Chapter outlines + narrative arcs |
| Chapter files |
report/chapters/ch_*.tex |
Per-module natural language chapters |
| Front matter |
report/front/ |
Abstract, introduction |
| Back matter |
report/back/ |
Appendices, bibliography |
| Figures |
report/figures/ |
TikZ source + PDF figures |
| Macros |
report/macros/common.tex |
Shared LaTeX commands |
| Master document |
report/project-report.tex |
Top-level LaTeX source |
| Compiled PDF |
report/build/project-report.pdf |
Final output |
| Build log |
report/build/project-report.log |
Compilation diagnostics |
See also
1---2name: lean-report3description: USE FOR: converting a Lean 4 project blueprint into a publication-grade LaTeX report — blueprint artifact ingestion (extracted LaTeX nodes, dependency DAG, JSON metadata), per-chapter narrative generation with mathematical prose, dependency-driven cross-referencing, figure generation (dependency graphs, module maps, coverage tables), and LaTeX → PDF compilation via the 6-stage INGEST → PLAN → NARRATE → ILLUSTRATE → ASSEMBLE → COMPILE pipeline. DO NOT USE FOR: generating the blueprint itself (use @lean-blueprint); writing one chapter without the pipeline (use @lean-doc-improvement); reviewing a finished report (use @lean-review-council); spec lifecycle (use @lean-specification). TRIGGERS: blueprint to report, generate report, latex pdf, project-report.tex, narrate chapter, dependency figure, blueprint compile.4---567# SK-62: Blueprint-to-Report Generator89Convert a Lean 4 project blueprint (extracted LaTeX nodes, dependency graphs, JSON metadata) into a publication-grade LaTeX report with natural language narrative, mathematical exposition, and visual dependency maps.1011---1213## Routing1415- **USE FOR:** converting a Lean 4 project blueprint into a publication-grade LaTeX report via the 6-stage INGEST → PLAN → NARRATE → ILLUSTRATE → ASSEMBLE → COMPILE pipeline; ingesting blueprint artifacts (LaTeX nodes, dependency DAG, JSON metadata); generating per-chapter mathematical prose with `\leanref` cross-references; producing TikZ dependency figures; running `latexmk` to PDF.16- **DO NOT USE FOR:** generating the blueprint itself (delegate to `@lean-blueprint`); writing one chapter without the pipeline (delegate to `@lean-doc-improvement`); reviewing a finished report (delegate to `@lean-review-council`); spec lifecycle (delegate to `@lean-specification`).17- **TRIGGERS:** blueprint to report, generate report, latex pdf, `project-report.tex`, narrate chapter, dependency figure, blueprint compile.1819## Workflow20211. Verify prerequisites (Part 12.1 below — blueprint artifacts exist, LaTeX toolchain present).222. First-time: run Part 12.2 (INGEST → PLAN → NARRATE → ILLUSTRATE → ASSEMBLE → COMPILE). Each stage's contract is in the handbook (Parts 3–8).233. Incremental: run Part 12.3 — re-blueprint, re-ingest, diff, narrate only changed chapters, recompile.244. On compilation error consult Part 13 (Troubleshooting) below; on output-artifact question consult Part 14 below.255. Handoff to `@lean-doc-feedback` once the PDF lands so the doc-sync skill can record the new artifact in the repository's tracking matrix.2627## Recovery & STOP2829- STOP if `\cref` references emit "??" after two latexmk passes — the blueprint is out of sync; re-run INGEST per Part 12.3.30- STOP if narration drifts from Lean source (Part 13 final row) — the source changed after narration; re-run NARRATE for affected chapters only.31- STOP if the figures stage produces empty TikZ outputs — `dot2tex` is optional but required for dependency graphs; install or fall back to module-map-only figures.3233## Handoffs3435- **Predecessors:** `agent:gateway` (top-level invocation), `skill:lean-blueprint` (produces the blueprint artifacts this skill consumes), `skill:lean-doc-requirements` (chapter-scope decisions).36- **Successors:** `skill:lean-doc-feedback` (record the PDF artifact + cross-references), `skill:lean-doc-improvement` (per-chapter post-narration edits), `skill:lean-review-council` (review the report for project-level coherence), `skill:lean-enforcement` (CI gate that confirms PDF builds on a clean checkout).3738---3940## Detailed reference4142Full pipeline content (Parts 1–11) lives in43[`references/lean-report-handbook.md`](../../references/lean-report-handbook.md).44Load that file when authoring or debugging stage internals; the SKILL.md45only carries the dispatch contract and the high-frequency operational46sections (Parts 12–14 kept inline below).4748| Section | Topic | Covers |49|---|---|---|50| Part 1 | Inputs and Outputs | What this skill consumes / produces |51| Part 2 | Pipeline Architecture | Six-stage DAG overview |52| Part 3 | Stage 1 — INGEST | Blueprint artifact extraction |53| Part 4 | Stage 2 — PLAN | Chapter outline + narrative arc derivation |54| Part 5 | Stage 3 — NARRATE | Per-chapter prose generation rules |55| Part 5B | Lean 4.28 Features for Report Generation | Pin-relative Lean+Mathlib features |56| Part 6 | Stage 4 — ILLUSTRATE | TikZ figure generation |57| Part 7 | Stage 5 — ASSEMBLE | Master-document merging |58| Part 8 | Stage 6 — COMPILE | latexmk pipeline + diagnostics |59| Part 9 | Audit Integration | Tracking-matrix hooks |60| Part 10 | Project-specific Configuration | Per-project tunables |61| Part 11 | Integration with Gateway (SK-07) | Cross-skill dispatch |6263## Part 12 — Execution Checklist6465### 12.1 Prerequisites6667```bash68# 1. Verify blueprint exists69ls .lake/build/blueprint/library/*.tex # extracted nodes70ls blueprint/web/index.html # web build exists7172# 2. Verify LaTeX toolchain73which latexmk pdflatex biber74kpsewhich tikz.sty pgfplots.sty cleveref.sty thmtools.sty7576# 3. Verify optional tools77which dot2tex # for dependency graph conversion (optional)78```7980### 12.2 First-Time Generation8182```bash83# 1. Create report directory structure84mkdir -p report/{chapters,front,back,figures,macros,build}8586# 2. Run INGEST stage87python3 scripts/blueprint_to_report.py ingest \88 --blueprint-dir .lake/build/blueprint \89 --coverage docs/tracking/coverage_matrix.md \90 --output report/report_context.json9192# 3. Run PLAN stage93python3 scripts/blueprint_to_report.py plan \94 --context report/report_context.json \95 --output report/report_plan.json9697# 4. Run NARRATE stage (agent-driven, one chapter at a time)98# Each chapter: read plan → read module → generate prose99# See §5 for generation rules100101# 5. Run ILLUSTRATE stage102python3 scripts/blueprint_to_report.py illustrate \103 --context report/report_context.json \104 --output-dir report/figures/105106# 6. Run ASSEMBLE stage107# Merge all chapters into master document (see §7.1)108109# 7. Run COMPILE stage110cd report && latexmk -pdf project-report.tex111```112113### 12.3 Incremental Updates114115After new theorems are proven:116117```bash118# 1. Re-run blueprint (SK-61):119lake build :blueprint && leanblueprint all120121# 2. Re-ingest:122python3 scripts/blueprint_to_report.py ingest --update123124# 3. Identify changed chapters:125python3 scripts/blueprint_to_report.py diff \126 --old report/report_context.json \127 --new report/report_context_updated.json128129# 4. Re-narrate affected chapters only130131# 5. Recompile:132cd report && latexmk -pdf project-report.tex133```134135---136137## Part 13 — Troubleshooting138139| Problem | Cause | Fix |140|---|---|---|141| No blueprint artifacts found | SK-61 not run | Run `generate blueprint` first |142| `nodes.json` missing | `:blueprintJson` not built | Run `lake build :blueprintJson` |143| LaTeX won't compile | Missing package | Install full TeX Live: `tlmgr install <pkg>` |144| Undefined `\cref` | `cleveref` not loaded | Add `\usepackage{cleveref}` after `hyperref` |145| Cross-references show "??" | Need 2nd pass | Run `latexmk` (auto-handles multi-pass) |146| Theorem count mismatch | Blueprint outdated | Rebuild blueprint, re-ingest |147| Margin notes overflow | Too many `\leanref` | Reduce to key theorems only |148| Figure won't render | Missing TikZ library | Add `\usetikzlibrary{...}` |149| Bibliography empty | `.bib` not found | Check `\addbibresource` path |150| PDF too large | Embedded high-res figures | Use `\includegraphics[draft]` for draft builds |151| Narration inconsistent with Lean | Source changed after narration | Re-run INGEST + NARRATE for affected chapters |152| Scaling notation unclear | Missing §scaling-convention | Ensure Ch 1 defines the $\times 100$ convention |153154---155156## Part 14 — Output Artifacts Summary157158The complete report generation pipeline produces:159160| Artifact | Location | Purpose |161|---|---|---|162| Report context | `report/report_context.json` | Serialized ingestion data |163| Report plan | `report/report_plan.json` | Chapter outlines + narrative arcs |164| Chapter files | `report/chapters/ch_*.tex` | Per-module natural language chapters |165| Front matter | `report/front/` | Abstract, introduction |166| Back matter | `report/back/` | Appendices, bibliography |167| Figures | `report/figures/` | TikZ source + PDF figures |168| Macros | `report/macros/common.tex` | Shared LaTeX commands |169| Master document | `report/project-report.tex` | Top-level LaTeX source |170| Compiled PDF | `report/build/project-report.pdf` | Final output |171| Build log | `report/build/project-report.log` | Compilation diagnostics |172173---174175## See also176177- [`../../references/lean-report-handbook.md`](../../references/lean-report-handbook.md) — Full pipeline encyclopaedia (extracted from this skill)178- [`../lean-blueprint/SKILL.md`](../lean-blueprint/SKILL.md) — Produces the blueprint artifacts this skill consumes179- [`../lean-doc-feedback/SKILL.md`](../lean-doc-feedback/SKILL.md) — Records the resulting PDF in the repository's doc-sync matrix180- [`../lean-review-council/SKILL.md`](../lean-review-council/SKILL.md) — Reviews the report for project-level coherence