Skip to content

docs: regen cli.md for gc prompt + add freshness guardrail#2071

Open
hexsprite wants to merge 2 commits into
gastownhall:mainfrom
hexsprite:docs/regen-cli-md-for-gc-prompt
Open

docs: regen cli.md for gc prompt + add freshness guardrail#2071
hexsprite wants to merge 2 commits into
gastownhall:mainfrom
hexsprite:docs/regen-cli-md-for-gc-prompt

Conversation

@hexsprite
Copy link
Copy Markdown
Contributor

Summary

Two things:

  1. docs/reference/cli.md regengc prompt and gc prompt synth were added to the CLI without running go run ./cmd/genschema. The pre-commit hook silently regenerates that file when staged Go changes touch CLI definitions, so the drift was leaking onto unrelated PRs as a stowaway diff (caught while opening test(cmd/gc): cut managed-dolt + stale-key delay overhead in city runtime tests #2069).

  2. Guardrail: TestCLIDocsFreshness in cmd/gc — walks the live cobra tree and asserts every non-hidden command has a ## <path> heading in docs/reference/cli.md. Runs under go test ./... (so make test in pre-commit + CI both catch it). Structural rather than byte-equal: cobra lazily registers completion/help only on Execute, which the in-test render path skips, so a strict byte-equal check produces false positives.

How drift used to slip through

Pre-commit hook flow when Go files are staged:

go run ./cmd/genschema       # regen cli.md if drifted
git add docs/reference/cli.md   # auto-stage onto whatever you're commiting

If cli.md was already drifted (someone added a CLI command and didn't regen), the next contributor's unrelated commit picks up the regen + the auto-stage, polluting their PR. TestCLIDocsFreshness fails at the source before the commit lands.

Test plan

  • go test -run TestCLIDocsFreshness ./cmd/gc/... — passes with current tree
  • Confirmed test catches drift: deleted ## gc prompt from cli.md, test failed with missing sections for 2 commands: [gc prompt gc prompt synth]
  • Pre-commit pipeline green (make check-docs, make vet, make test, dashboard rebuild)

Why it's a separate PR

Pure docs + test guardrail change. Allows #2069 (test cleanup for managed-dolt-spawning tests) to land with only its actual diff once this merges and that branch rebases off main.

hexsprite added 2 commits May 13, 2026 10:00
`gc prompt` and `gc prompt synth` were added to the CLI without
regenerating docs/reference/cli.md from cmd/genschema. The pre-commit
hook auto-regenerates this file when staged Go changes touch CLI
definitions, so the drift surfaced on an unrelated PR's commit.

Run: `go run ./cmd/genschema`
Adds TestCLIDocsFreshness, which walks the live cobra tree and asserts
every non-hidden command has a heading in docs/reference/cli.md. The
prior pre-commit hook silently regenerated cli.md and stapled it to
whichever commit happened to touch Go files, so CLI drift leaked onto
unrelated PRs. This catches the drift in CI/pre-commit and points at
the right fix: go run ./cmd/genschema.

Structural rather than byte-equal — cobra registers `completion`/`help`
only on Execute, which the in-test render path skips.
@hexsprite hexsprite requested a review from csells as a code owner May 13, 2026 16:20
@github-actions github-actions Bot added the status/needs-triage Inbox — we haven't looked at it yet label May 13, 2026
@randy-release-manager randy-release-manager Bot added kind/chore Internal improvement (refactor, tests, CI, tooling) priority/p2 Medium — real problem, workaround exists and removed status/needs-triage Inbox — we haven't looked at it yet labels May 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/chore Internal improvement (refactor, tests, CI, tooling) priority/p2 Medium — real problem, workaround exists

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant