Skip to content

ci: gate documentation coverage and examples - #546

Merged
godofecht merged 1 commit into
mainfrom
docs/example-ratchet
Aug 18, 2026
Merged

godofecht merged 1 commit into
mainfrom
docs/example-ratchet

Conversation

@godofecht

@godofecht godofecht commented Aug 18, 2026 •

Copy link
Copy Markdown
Contributor

Fifth of the wiki series. Turns on the gates the earlier PRs built.

Two jobs

doc-coverage runs check_doc_coverage.py and is deliberately ungated by paths. A new keyword, attribute or subcommand added under src/ must not land undocumented just because the PR touched no markdown, and since the feature list is read out of the compiler, the job notices.

doc-examples compiles every ```flow block. 359 of 751 do not build today, so a hard gate would mean fixing all of them in one unreviewable change. Instead the failing set is recorded in docs/generated/example-status.json and grandfathered.

Why the ratchet holds

Ledger rows are keyed by path#sha256(block)[:12]. Editing a grandfathered block produces a key the ledger has never seen, so its exemption evaporates and the new text has to compile. Existing debt is inherited; new and edited content is not. That is the whole scheme, and it has its own test.

Debt that has since been paid off is reported, not failed:

examples: 751   unverified: 359   ledger: 357

12 example(s) now compile that the ledger lists as failing. Refresh it with:
    python3 scripts/check_doc_examples.py --write-ledger

Failing an unrelated PR because somebody else fixed a doc example would teach people to regenerate the ledger without reading it, which is precisely how a ratchet stops meaning anything.

Verified by running it, not by inspection

A new broken block:

1 example(s) do not compile and are not in the ledger:
    docs/getting-started.md:158 [parse] FlowSyntaxError: Expected TokenType.IDENTIFIER, got TokenType.ARROW at line 1, column 18

A new or edited example has to compile. Tag it `expect-error` if it is meant to fail,
or ignore="reason" if it cannot be checked.

The same block tagged expect-error: passes. Editing a block the ledger grandfathers: fails again, as it must.

Also fixed

A bug in the failure path itself. The missing-ledger message called LEDGER.relative_to(ROOT), which raises ValueError when the ledger is anywhere else — so the error handler crashed instead of reporting. Caught by the test written for it.

Ledger refreshed for the block #539 added, and it now writes one row per distinct block, since text repeated within a page shares a key and always verifies identically.

Validation

  • Unit suite 1496 passed, 2 skipped (5 new, all on the ratchet)
  • --check-ledger clean on main
  • check_doc_coverage.py clean
  • ruff check src clean
  • ci.yml parses; both jobs are in the ci-ok aggregator with the right required-ness

Two jobs, and a ratchet so the example one can be turned on today rather
than after 359 fixes.

doc-coverage runs check_doc_coverage.py and is deliberately ungated. A new
keyword, attribute or subcommand added under src/ must not land undocumented
just because the pull request touched no markdown, and the feature list is
read from the compiler, so the job knows.

doc-examples compiles every ```flow block. The examples that do not build
today are recorded in docs/generated/example-status.json and grandfathered.
Rows are keyed by a hash of the block's own text, so editing one produces a
key the ledger has never seen and the new text has to compile. Existing debt
is inherited; new and edited content is not.

Debt that has since been paid off is reported, not failed. Failing an
unrelated pull request because someone else fixed a doc example would teach
people to regenerate the ledger without reading it, which is exactly how a
ratchet stops meaning anything.

Verified end to end rather than by inspection: a new broken block fails and
names the file, line, stage and diagnostic; the same block tagged
expect-error passes; and editing a block the ledger grandfathers makes it
fail again. That last one is the property the whole scheme rests on, and it
has its own test.

Also fixed a bug in the failure path itself: the missing-ledger message
called relative_to(ROOT), which raises when the ledger is anywhere else.

Both jobs join the ci-ok aggregator. Ledger refreshed for the block #539
added: 751 examples, 359 unverified.

Unit 1496 passed, ruff clean on src.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@godofecht
godofecht merged commit 4395cb7 into main Aug 18, 2026
21 checks passed
@godofecht
godofecht deleted the docs/example-ratchet branch August 18, 2026 10:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant