BUCKYVERSE

24. Build Pipeline Architecture

Date: 2025-03-05
Updated: 2025-06-02

Status

Accepted

Context

The Codexis book building system must transform LaTeX source content and assets into multiple output formats (PDF, EPUB, HTML, Markdown, etc.) with high reliability, extensibility, and observability. The legacy approach used direct builder modules for each format, but this led to code duplication, inconsistent error handling, and difficulty in adding new features or formats.

To address these issues, the system has migrated to a canonical pipeline architecture for all document builds. The pipeline is now the default and only supported build mechanism, except when explicitly overridden for legacy fallback. This architecture enables modular, staged processing, robust error handling, and easy extensibility.

Decision

We have adopted a formal pipeline framework as the core of the build system. All document builds are orchestrated through this pipeline, which is composed of ordered, composable stages and processors. Direct builder usage is deprecated and only available via disable_pipeline: true in build options.

Pipeline Architecture Overview

Architecture Diagram

Pipeline
  ├── Stage (ScannoDetection)
  ├── Stage (ContentProcessing)
  ├── Stage (AssetManagement)
  ├── Stage (FormatGeneration)
  │     ├── Processor (PDFBuilder)
  │     ├── Processor (EPUBBuilder)
  │     ├── Processor (HTMLBuilder)
  │     └── ...
  ├── Stage (Validation)
  └── Stage (Finalize)

Example Module Layout

lib/codexis/pipeline/
  pipeline.ex           # Pipeline orchestration logic
  stage.ex              # Stage behaviour and base implementation
  processor.ex          # Processor abstraction
  connector.ex          # Connector abstraction
  registry.ex           # PipelineRegistry for registration/config
  config.ex             # PipelineConfig and validation
  executor.ex           # PipelineExecutor for running pipelines
  hooks.ex              # Pre/post execution hooks
  context_utils.ex      # Context manipulation helpers
  error.ex              # Error types and helpers
  telemetry.ex          # Telemetry and logging
  test_helpers.ex       # Test fixtures and mocks

Registry and Configuration

Migration and Compatibility

Testing and Documentation

Supervision and Fault Tolerance

Consequences

Positive

Negative

References