Build Pipeline
This workflow describes how the lito-graph build command compiles documentation into a graph.
Preconditions
- Documentation directory exists and contains
.mdor.mdxfiles. - Node.js >= 18 (or Bun) is installed.
- Dependencies are installed (
bun installornpm install).
Steps
- Discover all Markdown files via
collectMarkdownFilesutility. - Parse YAML frontmatter from each file using
gray-matter. - Classify each document by
typefield using Zod schema validation. - Build typed nodes via
createNodesfactory. - Extract heading trees and anchor IDs from document bodies.
- Resolve cross-references into typed edges via
resolveEdges. - Compute graph statistics (node/edge counts, unresolved refs).
- Serialize the LitoGraph to
graph.json.
Failure Modes
- Invalid frontmatter that fails Zod validation (e.g., missing
operation_idon API doc). - File system permission errors when reading docs or writing graph.json.
Recovery
- If a single file fails to parse: log warning and skip that file, continue building the rest of the graph.
- If output directory is not writable: report error with the exact path.
Guardrails
- Never modify source documentation files during build.
- Always produce deterministic output — same input must yield same graph.
- Unresolved references must be warnings, never errors.