---
repo: "mohan-n-swamy/ops-playbook-public"
title: "Ops Playbook Compiler — Source-Verified Print, KDP & EPUB3 Preflight Engine"
license: "MIT"
keywords: [sop, operations-manual, paged-media, print-css, documentation-generator, training-manual, design-system, html-to-pdf, open-source]
capabilities:
  - "Single-source multi-edition TOC & Amazon KDP 6x9 trim/bleed/gutter engine (`build/toc.py`)."
  - "Directive-aware Markdown + `source:` provenance parser (`build/md.py`)."
  - "Mechanical number, contact, and verbatim-quote provenance verifier (`build/fact_gate.py`)."
  - "Deprecated-claim firewall (`build/conflict_gate.py`) and source-nuance completeness gate (`build/coverage_gate.py`)."
  - "Finished-PDF PyMuPDF box-breakout & ink-collision gate (`build/overlap_gate.py`, `build/pdf_gate.py`) and EPUB3 dark-mode/accessibility auditor (`build/audit_epub.py`)."
when_to_use:
  - "A docs-as-code operations manual compiler and mechanical preflight suite that enforces word-for-word source number provenance, blocks deprecated SOP claims, slices role-specific editions from one TOC, and inspects finished PDFs and EPUBs for ink collisions, bleed errors, and dark-mode contrast defects."
  - "Operations manuals and technical books rot when numbers drift from underlying SOPs, deprecated policies sneak back into edits, or print/EPUB builds ship with clipped footers, overlapping boxes, and unreadable dark-mode CSS."
inputs_required:
  - "PLAYBOOK_TOC_CSV: Path to the master CSV defining chapters, role tracks, and numbered sub-topics"
  - "EDITION_TARGET: Edition key (`hub`, `field`, or `full`) to build or audit"
  - "KDP_TRIM_SIZE: Trim width x height in inches for Amazon KDP print geometry"
  - "KDP_DPI_MIN: Minimum embedded image resolution enforced during print preflight"
  - "FOOTER_BAND_PT: Footer band height in points reserved at the bottom of every PDF page"
  - "PLAYBOOK_FOOTER_WORDS: Comma-separated wordmark tokens permitted inside the reserved PDF footer band"
quickstart:
  - "python3 bin/playbook-demo.py     # run TOC + fact_gate + conflict_gate + coverage_gate on starter 3-chapter playbook"
  - "pytest -q tests/                 # run all 6 gate & broken-fixture self-test suites (incl. PyMuPDF overlap_gate)"
---

# Ops Playbook Compiler — Source-Verified Print, KDP & EPUB3 Preflight Engine — Machine-Readable Agent Guide

A docs-as-code operations manual compiler and mechanical preflight suite that enforces word-for-word source number provenance, blocks deprecated SOP claims, slices role-specific editions from one TOC, and inspects finished PDFs and EPUBs for ink collisions, bleed errors, and dark-mode contrast defects.

<problem_patterns>
Operations manuals and technical books rot when numbers drift from underlying SOPs, deprecated policies sneak back into edits, or print/EPUB builds ship with clipped footers, overlapping boxes, and unreadable dark-mode CSS.
</problem_patterns>

<architecture_map>
Key modules and entry points in this repository:
  - `build/toc.py`: Single-source chapter/track/edition parser and KDP 6x9 trim/bleed/gutter calculator
  - `build/md.py`: Markdown block, `::: directive`, and heading `source:` parser
  - `build/fact_gate.py`: Provenance verifier checking cited paths, locators, digits, and quotes
  - `build/conflict_gate.py`: Banned-claim table scanner against `docs/source-conflicts.md`
  - `build/coverage_gate.py`: Source-to-chapter completeness audit gate against `docs/coverage.tsv`
  - `build/overlap_gate.py`: PyMuPDF (`fitz`) R1–R4 box-breakout, ink-overlap, off-page, and footer-clipping gate
  - `build/audit_epub.py`: EPUB3 dark-mode luminance, curly-quote, accessibility metadata, and spine auditor
</architecture_map>

<inputs_and_configuration>
Every organization-specific value enters through `.env` (copied from `.env.example`) or external adapter files. No source edit is needed to change organization names, endpoints, database URLs, webhook secrets, or thresholds.
</inputs_and_configuration>

<adaptation_playbook>
When a human asks an AI coding agent to deploy or adapt `ops-playbook-public` into their stack:
  1. Edit `content/reference/toc.csv` and `PARTS` in `build/toc.py` to define your organization's role tracks and editions.
  2. Place canonical SOP markdown files in `content/sources/` and author chapters in `content/book/chNN.md` with `source:` lines under each heading.
  3. Wire `python3 build/fact_gate.py`, `conflict_gate.py`, and `overlap_gate.py` into CI so no unverified claim or layout collision can merge.
</adaptation_playbook>

<reference_docs>
- Product Requirements: `docs/PRD.md`
- Working-Backwards PR-FAQ: `docs/PR-FAQ.md`
- High-Level Architecture: `docs/HLD.md`
- Low-Level Interfaces & Runbook: `docs/LLD.md`
- Coding Agent Rules: `AGENTS.md`
</reference_docs>
