Skip to content

🐛 fix(docs): carry curated glossary rows through regeneration (GLOSSARY-MARKER-01) - #341

Merged
konih merged 6 commits into
mainfrom
lane/glossary-marker-01-r4
Aug 30, 2026
Merged

konih merged 6 commits into
mainfrom
lane/glossary-marker-01-r4

Conversation

@konih

@konih konih commented Aug 30, 2026

Copy link
Copy Markdown
Collaborator

Problem

hack/gen-glossary.py rewrites docs/GLOSSARY.md between <!-- BEGIN AUTO-CRD --> / <!-- END AUTO-CRD -->, and CONTRIBUTING.md:306 tells contributors to run it.

Hand-written prose lived inside that block — a curated row explaining that http is a reserved snapshot type rejected by admission — so running the documented command silently destroyed curated documentation, and nothing regenerated-and-diffed to notice. The committed file was also already stale (missing allowedStaticRefNamespaces).

Second defect: silent truncation

The generator sliced fields[:8], dropping the tail for 5 of 11 kinds:

Kind Fields
SnapshotSink 16
DatabaseSink 15
EventSink 14
ClusterInventory 12
Target 10

That made the invariant "a CRD gains a field ⇒ the gate reds naming it" false for the trailing position.

Fix

  • A CURATED_DESCRIPTIONS override map in the generator, with a check_overrides hard error that fires before any write if a key stops matching a real CRD field (override rot cannot silently pass).
  • Truncation removed, so every field is emitted.
  • A new drift gate, hack/test/glossary_drift_test.sh, proving regeneration is a byte-exact no-op.
  • The gate is wired into the lint job in ci.yaml (not only hack/docs/verify.sh): the Docs workflow path filter lists sibling hack/test scripts individually, so a commit touching only hack/gen-glossary.py triggered no run at all — exactly its own motivating change class. Ensure PyYAML is available mirrors the existing Ensure yq is available step.

Verification

Reviewed independently (round 3, fresh reviewer) → APPROVE, highest finding P2, none blocking. Reviewer exercised 19 mutations; regeneration produced sha256 0c0ab39b… on three consecutive runs, byte-identical to the committed file.

Re-run by the integrator on this rebased head:

  • bash hack/test/glossary_drift_test.sh → 12 assertions, all ok
  • python3 hack/gen-glossary.py && git diff docs/GLOSSARY.md → empty
  • bash hack/test/repo_root_links_wiring_test.sh → pass
  • bash hack/test/dist_ci_wiring_test.sh → pass
  • bash hack/test/sonar_ko_ci_wiring_test.sh → pass
  • task lint:shell → exit 0
  • go test ./test/docs/ → ok
  • python3 -m unittest discover -s test/docs → 29 tests, OK
  • grep -c "task docs:verify" .github/workflows/docs.yaml → 1

Note for reviewers: ci.yaml co-edit

This lane and CI-CONTRIBFILTER-01 both touch the lint job. The rebase preserved both step sets, theirs first, in this order:

  1. Verify repo-root Markdown links resolve (CI-CONTRIBFILTER-01) (theirs)
  2. Verify the repo-root link gate stays wired into a job that runs (theirs)
  3. Ensure PyYAML is available (this lane)
  4. Glossary generator drift meta-tests … (this lane)

git diff --numstat main...HEAD -- .github/workflows/ci.yaml is 22 0 — 22 insertions, zero deletions or modifications, so none of the other lane's lines were displaced. git range-diff across the rebase reports = for all six commits.

Six files, zero Go files.

konih added 6 commits August 30, 2026 10:38
Hand-written prose lived inside the AUTO-CRD markers of docs/GLOSSARY.md, so
`python3 hack/gen-glossary.py` -- the command CONTRIBUTING.md tells
contributors to run -- silently destroyed it. The `http` row on
KollectSnapshotSink carried a deliberate disambiguation ("reserved snapshot
type that is rejected by admission; do not confuse it with the Inventory HTTP
read API") that regeneration replaced with the CRD's own, misleading text.

Decision: teach the generator to carry curated overrides (option C).
  A. Moving the note outside the markers was rejected: the auto row would then
     assert something false, with its correction exiled to another section.
  B. Adding a drift gate alone was rejected as actively harmful: a gate over a
     block containing hand-written prose converts a silent loss into a forced
     one, because deleting the prose becomes the way to go green.
  C. A CURATED_DESCRIPTIONS map keyed by (kind, field) keeps the curated text
     adjacent to the row it qualifies and makes regeneration idempotent. A key
     that no longer matches a real CRD field is a hard error, so the map
     cannot rot unnoticed.

Two further repairs in the same block:
- the committed block was already stale: KollectClusterScope was missing
  `allowedStaticRefNamespaces`.
- the per-kind table truncated at eight fields and dropped the rest without
  trace, so five of eleven kinds hid fields and a CRD could gain a ninth field
  invisibly. The omitted names are now listed after the table.

The header emitted into the block now says where curated text belongs, so the
next contributor does not re-create the trap.
Nothing checked the result of `python3 hack/gen-glossary.py`. The committed
AUTO-CRD block could drift from the generator output in either direction, and
hack/gen-glossary.py had no covering assertion at all -- the CR-REFERENCE.md
dead-link fix shipped verified only by execution.

The gate asserts the committed block equals a fresh generation, that
regeneration is idempotent, that the curated `http` disambiguation survives it,
and that every markdown link the generator emits resolves to a real docs page
(generically, not by matching the one filename that broke).

Two fixtures prove it reds rather than merely passing: injecting a spec field
into KollectSnapshotSink -- at a name sorting into the table and at one sorting
past it -- must red naming that field, and a generator patched to emit a
deleted page must red naming the dead target.

Every generator run happens in a scratch ROOT built with `cp`, never a symlink:
the generator derives its write target from `__file__.resolve()`, so a
symlinked copy would resolve back to the real worktree and let a fixture
overwrite the real docs/GLOSSARY.md. The gate re-hashes that file at the end to
prove no run escaped.

Wired into hack/docs/verify.sh alongside the other docs-truth contracts, above
the success line.
check_overrides() is what makes the curated override map safe: a key that
stops matching a real CRD field is a hard error, so the map cannot rot and a
deleted field cannot make its curated text vanish quietly. That branch shipped
with no covering assertion, which is the same gap this lane exists to close.

The fixture patches a scratch copy of the generator to hold a key for a field
that does not exist, then asserts the run fails, that the message names the
offending key, and that the scratch glossary is byte-identical afterwards --
the generator must refuse before writing, not leave a half-updated file.

Verified discriminating: with check_overrides() disabled the fixture reds.
Review follow-ups on the glossary gate and its generator. Each new branch is
covered by a fixture proven to red when the code behind it is ablated.

check_overrides only caught STALE keys, while the comment above the map claimed
it would confirm nothing was left dangling once a CRD description was corrected.
It would not: with the schema caught up, output is byte-identical and the guard
stays green, leaving a dead override reading as load-bearing. The guard now
fails on redundant keys too, and the comment says what it actually does.

A spec field carrying no description was invisible to both the page and the
gate -- the curated lookup and the omitted-field list sat behind `if desc:`.
Such fields are now named in the trailing sentence. All eleven kinds are fully
documented today, so the rendered glossary is byte-identical.

Gate fixes:
- marker checks were `grep -qF`, so a marker with a trailing space passed while
  extract_block's exact `$0 ==` skipped it, producing an empty block and a
  misleading "block is stale" failure. A duplicated pair was worse:
  patch_glossary splits on the FIRST pair, so a second block would survive
  every regeneration, while extract_block concatenated both on both sides of
  the diff and matched. Now exactly one pair, counted on exact lines.
- the "no fixture touched the real glossary" check was a terminal statement,
  unreachable once any earlier check called fail() -- precisely the run in
  which an escape is most likely. It is now a trap.
- the dead-link fixture did not isolate what it claimed: `rm -f docs/crds/*.md`
  red it on its own and the sed contributed nothing. The per-kind pages now
  stay in place, so the redirected link is the only dead target.
GM-01. The gate was composed only into hack/docs/verify.sh, which the Docs
workflow reaches through a path filter that enumerates sibling hack/test
scripts individually. Neither hack/test/glossary_drift_test.sh nor
hack/gen-glossary.py was listed, so a generator-only commit -- and an edit to
the gate itself -- triggered no workflow at all. Commit 2eef5a4, the
CR-REFERENCE link fix this gate was written for, touched hack/gen-glossary.py
and nothing else: the gate would not have covered its own motivating PR.

Adding the two path-filter entries is not sufficient on its own, because
hack/docs/verify.sh is a `set -e` chain and the pre-existing
docs_launch_truth_test.sh failure above it starves everything below. So the
gate also runs unconditionally in ci.yaml's lint job, per the LAB-DEKIND
precedent documented there for this exact defect class, next to the sonar_ko_*
glob that already carries the other hack/gen-glossary.py check. The path-filter
entries are kept as well, and the verify.sh composition stays -- it is correct,
just currently starved.

The lint job installs only Go tooling and shellcheck, so PyYAML is ensured
first, mirroring the "Ensure yq is available" step and its reasoning: a missing
module would red the job for a reason unrelated to the glossary.

dist_ci_wiring_test.sh and sonar_ko_ci_wiring_test.sh green before and after.
The scratch cleanup was a `[[ -n ... ]] && rm -rf ...` compound sitting last
before `exit`. Behaviour was already correct because the status is captured on
entry, but under `set -e` that made the trap's exit path depend on statement
order rather than saying so. An `if` block does not.
@codecov

codecov Bot commented Aug 30, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@sonarqubecloud

Copy link
Copy Markdown

@konih
konih merged commit 1ab0843 into main Aug 30, 2026
34 checks passed
@konih
konih deleted the lane/glossary-marker-01-r4 branch August 30, 2026 08:51
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