Repository navigation
🐛 fix(docs): carry curated glossary rows through regeneration (GLOSSARY-MARKER-01) - #341
Merged
Merged
Conversation
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 Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Problem
hack/gen-glossary.pyrewritesdocs/GLOSSARY.mdbetween<!-- BEGIN AUTO-CRD -->/<!-- END AUTO-CRD -->, andCONTRIBUTING.md:306tells contributors to run it.Hand-written prose lived inside that block — a curated row explaining that
httpis 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 (missingallowedStaticRefNamespaces).Second defect: silent truncation
The generator sliced
fields[:8], dropping the tail for 5 of 11 kinds:That made the invariant "a CRD gains a field ⇒ the gate reds naming it" false for the trailing position.
Fix
CURATED_DESCRIPTIONSoverride map in the generator, with acheck_overrideshard error that fires before any write if a key stops matching a real CRD field (override rot cannot silently pass).hack/test/glossary_drift_test.sh, proving regeneration is a byte-exact no-op.lintjob inci.yaml(not onlyhack/docs/verify.sh): the Docs workflow path filter lists siblinghack/testscripts individually, so a commit touching onlyhack/gen-glossary.pytriggered no run at all — exactly its own motivating change class.Ensure PyYAML is availablemirrors the existingEnsure yq is availablestep.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 okpython3 hack/gen-glossary.py && git diff docs/GLOSSARY.md→ emptybash hack/test/repo_root_links_wiring_test.sh→ passbash hack/test/dist_ci_wiring_test.sh→ passbash hack/test/sonar_ko_ci_wiring_test.sh→ passtask lint:shell→ exit 0go test ./test/docs/→ okpython3 -m unittest discover -s test/docs→ 29 tests, OKgrep -c "task docs:verify" .github/workflows/docs.yaml→ 1Note for reviewers:
ci.yamlco-editThis lane and
CI-CONTRIBFILTER-01both touch thelintjob. The rebase preserved both step sets, theirs first, in this order:Verify repo-root Markdown links resolve (CI-CONTRIBFILTER-01)(theirs)Verify the repo-root link gate stays wired into a job that runs(theirs)Ensure PyYAML is available(this lane)Glossary generator drift meta-tests …(this lane)git diff --numstat main...HEAD -- .github/workflows/ci.yamlis22 0— 22 insertions, zero deletions or modifications, so none of the other lane's lines were displaced.git range-diffacross the rebase reports=for all six commits.Six files, zero Go files.