Pipes and Filters Pattern (Pipeline Architecture)

An architecture that divides data processing into a sequence of independent processing stages (filters) connected by standardized data conduits (pipes), making each stage loosely coupled and easy to unit-test.

General Meaning

Exemplified by Unix command-line pipelines (cat file | grep pattern | sort), the Pipes and Filters architecture decomposes a complex workflow into single-purpose components called filters.

Each filter reads structured input, transforms or validates it, and writes structured output to a pipe (such as a file or JSON stream) that feeds the next filter, without needing to know how neighboring filters are implemented internally.

Why It Matters

  • Breaking down complex workflows into manageable steps: Isolates complexity inside individual stages that are easy to understand and maintain.
  • Independent testing and swappability per stage: Allows any filter's algorithm or AI model to be unit-tested or replaced without touching other stages.
  • Easy inspection and resumption via intermediate state: Saving intermediate JSON files to disk simplifies debugging and lets interrupted runs resume from the last completed step.

How the Site Factory Uses It

The Site Factory's automated site-building engine (HONBU/engine/) implements a five-filter pipeline: (1) Collect (collect.py) fetches source HTML/documents into data/ while respecting robots.txt and rate limits; (2) Extract (extract.py) uses local LLMs to draft candidate rows into state/candidates.json; (3) Check Sources (check_sources.py) deterministically verifies that every extracted number and municipality name matches the source quote verbatim; (4) Build (build.py) compiles verified state/records.json and the design.json blueprint into static HTML (site/) and Wrangler config; and (5) Review (review.py) inspects site/ for banned expressions, ad PR labels, CSP headers, and broken links, outputting findings[].

All filters are written in standard-library Python and communicate via JSON files and a strict exit code contract (0 = OK, 1 = findings present, 2 = broken input, 75 = time slice reached, continue next run).

Caveats & Operational Rules

  • Never share hidden mutable state between filters: Communicating via in-memory globals destroys loose coupling; pass data strictly through defined files and JSON contracts.
  • Never ignore an upstream error and continue downstream: Always check each step's exit code and halt the pipeline immediately if an upstream filter fails.

Related Terms

References

  • Book: Mark Richards & Neal Ford, *Fundamentals of Software Architecture*, Chapter 13 (Pipeline Architecture Style)

Verified: 2026-11-08