Skip to content

Latest commit

 

History

History
139 lines (115 loc) · 7.07 KB

sync_issues_docs.md

File metadata and controls

139 lines (115 loc) · 7.07 KB

testing / sync_issues_docs.sh

Revision: 11 Last modified: 2026-12-04T14:04:20Z

Overview

scripts/testing/sync_issues_docs.sh is the single doc-sync entry point for the workable-items document set. §11.4.22 / §11.4.60 require one command that brings the whole set back into sync from the SQLite single source of truth so no human has to remember stage order — and until 2026-12-03 no such scripts/ entry point existed (a sync_issues_docs.sh was expected but absent), which is how the committed summaries drifted 581/12 against a database holding 569/24 open/closed items.

Three stages, in this exact order; any stage failure stops the run:

Stage Command Writes
1. trackers workable-items sync db-to-md docs/Issues.md, docs/Fixed.md
2. summaries scripts/testing/generate_summaries.sh docs/Issues_Summary.md, docs/Fixed_Summary.md
3. formats workable-items export --formats (gated) .html / .pdf / .docx siblings

Stage 3 never fakes an export. It resolves the one formats-export switch (scripts/formats_export_lib.sh) and probes for pandoc / weasyprint; when the switch is OFF or a tool is missing it prints an explicit honest line, leaves the Markdown as canonical, and the run still exits 0 (§11.4.6).

Prerequisites

  • bash, python3, the workable-items engine binary (resolution order as in generate_summaries.sh: $WORKABLE_ITEMS_BIN → scripts/workable-items/bin/workable-items → PATH).
  • docs/workable_items.db.
  • Stage 3 only: the formats switch ON and pandoc (and weasyprint for PDF) on PATH.

Usage examples

# full sync: trackers -> summaries -> gated formats
scripts/testing/sync_issues_docs.sh

# staleness gate (implies --skip-trackers; writes nothing, but DOES verify
# the HTML/PDF siblings read-only: exit 1 when stale, exit 7 when unverifiable)
scripts/testing/sync_issues_docs.sh --check

# regenerate the summaries only, leaving docs/Issues.md and docs/Fixed.md alone
scripts/testing/sync_issues_docs.sh --skip-trackers --skip-formats

# one-run switch override for the formats stage
DOCS_EXPORT=1 scripts/testing/sync_issues_docs.sh

Exit codes: 0 success (including an honest formats skip) · 1 stale (--check only: a summary OR an HTML/PDF sibling) · 2 usage / missing binary · 3 stage 1 failed · 4 stage 2 failed · 5 missing input · 6 stage 3 failed · 7 formats UNVERIFIED (--check only: the switch is OFF or the exporter's toolchain is absent, so the .html/.pdf legs were NOT verified — deliberately not 0, because a run that could not verify must not inherit the compliance the skipped stage implied).

Edge cases

  • --check mutates nothing but verifies everything it can. It forces --skip-trackers (no tracker rewrite) and passes --check to the exporter, which compares mtimes and writes nothing. It exits 1 when a sibling is missing or older than its .md, and 7 when the format legs cannot be verified at all (switch OFF, toolchain absent). Earlier revisions exited 0 unconditionally here — a green --check that had checked no format artefact was the silent-green defect this stage now refuses.
  • Trackers mid-write elsewhere. --skip-trackers protects Issues.md / docs/Fixed.md when another owner is writing them; the summaries are still regenerated from the database, which is the source of truth either way.
  • Formats switch OFF. Operator order 2026-10-26 sets config/formats_export.conf to formats_export=false. A normal run reports stage 3/3 formats: SKIPPED (UNVERIFIED) naming the source and exits 0 (the .md files are complete and nothing is faked); --check exits 7 instead, because a check must not report compliance it could not verify. This repository opts in through docs/context/doc_export.policy (enabled=1), so the exports are produced here.
  • Switch ON but tools absent. Reports SKIPPED (UNVERIFIED) naming the missing tools (exporter exit 4); nothing is written. --check exits 7.
  • Stage 3 never lies about what it did. It prints EXPORTED (with the exporter's own count line) when it wrote siblings, CHECK PASS for a read-only verification, and SKIPPED with a reason ONLY when it produced and checked nothing.
  • Engine absent. Exit 2 with the resolution instructions; nothing is written.
  • Database absent. Exit 5; the Markdown is never parsed to compensate.

Internal behaviour

  1. Parse flags; validate DB + docs dir; resolve the engine.
  2. Stage 1 (unless skipped): sync db-to-md --db <db> --out-dir <docs>; non-zero is a hard stop (3).
  3. Stage 2: generate_summaries.sh --write (or --check), forwarding --db, --docs-dir, --quiet; staleness exits 1, other failures 4.
  4. Stage 3 (unless skipped): delegate to scripts/testing/export_docs_formats.sh, which owns the switch, the class set and the pandoc/weasyprint legs for ALL eight §11.4.60 classes (the engine's export --formats covers only the four tracker docs). Its exit code is mapped explicitly: 0 → EXPORTED/ CHECK PASS; 1 → exit 1 (stale siblings); 3 (switch OFF) and 4 (toolchain absent) → SKIPPED (UNVERIFIED), and under --check exit 7; other → stage failure (6).

The switch is read from exactly one place — this script does not re-implement the precedence (env DOCS_EXPORT > docs/context/doc_export.policy > config/formats_export.conf > false); export_docs_formats.sh asks scripts/formats_export_lib.sh.

Related scripts

  • scripts/testing/generate_summaries.sh — stage 2 (the summaries).
  • scripts/testing/generate_summaries.py — §11.4.44 header reconciler.
  • scripts/formats_export_lib.sh — the single formats-switch reader.
  • scripts/testing/export_docs_formats.sh — stage 3's exporter (all eight §11.4.60 classes) + its guide docs/scripts/export_docs_formats.md.
  • scripts/gates/cm_docs_composite_sync.sh — the §11.4.60 parity gate (+ paired mutation test) and docs/scripts/cm_docs_composite_sync.md.
  • docs/notes/export-toolchain.md — measured toolchain, before/after evidence.
  • scripts/workable-items/cmd/workable-items/export.go — export / sync db-to-md implementations.
  • docs/scripts/generate_summaries.md — the stage-2 companion guide.

Last verified

2026-12-04 — stage 3 re-pointed at export_docs_formats.sh: a full run reports stage 3/3 formats: EXPORTED with the exporter's count, --check reports CHECK PASS on a fresh tree (exit 0), exits 1 with a backdated sibling, and exits 7 with DOCS_EXPORT=0 (UNVERIFIED). All eight class instances have .html + .pdf siblings that validate clean.

2026-12-03 — --check on the real tree: exit 0 after regeneration, exit 1 before it. --skip-trackers --skip-formats regenerated both summaries and stage 3 printed EXPORT STEP SKIPPED -- formats switch is OFF (source: constitution-default) with exit 0. The full pipeline (stage 1 rewriting docs/Issues.md + docs/Fixed.md) was deliberately NOT executed in this session because those two files are outside the task's write scope.