Skip to content

chore(ci): gofmt the eight dirty files and turn the gate on (#875) - #882

Merged
xe-nvdk merged 2 commits into
mainfrom
chore/gofmt-and-gate
Sep 16, 2026
Merged

xe-nvdk merged 2 commits into
mainfrom
chore/gofmt-and-gate

Conversation

@xe-nvdk

@xe-nvdk xe-nvdk commented Sep 16, 2026

Copy link
Copy Markdown
Member

Closes #875.

ci.yml carried this note:

gofmt is deliberately NOT gated yet: a handful of pre-existing files (compaction/reconciliation/scheduler) are gofmt-dirty on main. Gate it once that debt is cleared.

The debt was never cleared, while the project instructions told contributors gofmt -l ./internal ./cmd "must return empty". So the instruction was false, and the output was noise people learned to scroll past. Every review in a long session re-triaged the same eight files as pre-existing.

The formatting change is semantics-free

Alignment, plus one blank comment line that gofmt adds when it reflows a doc-comment code block in watcher.go, plus one trailing blank line. Verified by stripping all whitespace from both sides of the diff and comparing what remained, which leaves only the added comment marker.

internal/compaction/scheduler.go           |  8 ++++----
internal/compaction/watcher.go             | 13 +++++++------
internal/reconciliation/diff_test.go       |  2 +-
internal/reconciliation/reconciler.go      | 14 +++++++-------
internal/reconciliation/reconciler_test.go | 16 ++++++++--------
internal/reconciliation/scheduler.go       | 20 ++++++++++----------
internal/scheduler/cq_scheduler_test.go    |  1 -
internal/scheduler/retention_scheduler.go  |  8 ++++----

The gate

Added to the test job before the build, so a formatting-only failure reports in seconds rather than after the race suite, and it names the offending files rather than just exiting non-zero.

Test plan

  • go build ./..., go vet on all three packages, and go test -race ./internal/... entire, all green.
  • The gate passes on this tree.
  • The gate fails on a deliberately misformatted probe file, naming it. A gate that cannot fail is not a gate.

Timing

The issue asked for this to land when nothing was in flight in internal/compaction, internal/reconciliation or internal/scheduler, since a whitespace-only change across a package conflicts with any open branch that touches it. Nothing of mine is open in those packages now.

https://claude.ai/code/session_01So2gKWp5TzF9gu3QKNqdeV

ci.yml carried a note saying gofmt was deliberately not gated because a
handful of pre-existing files in compaction, reconciliation and scheduler were
dirty on main, to be gated once that debt was cleared. It never was, while
CLAUDE.md told contributors the check must return empty — so the instruction
was false and the output was noise people learned to scroll past. Every review
in a long session re-triaged the same eight files as pre-existing.

The formatting change is alignment only, plus one blank comment line gofmt
adds when it reflows a doc-comment code block and one trailing blank line.
Verified by stripping all whitespace from both sides of the diff and comparing
what remains, and by running build, vet and the race suite for all three
packages and then for ./internal/... entire.

The gate itself is verified in both directions: it passes on the formatted
tree, and a deliberately misformatted probe file makes it fail with the file
named. It runs before the build, so a formatting-only failure reports in
seconds rather than after the race suite.

Claude-Session: https://claude.ai/code/session_01So2gKWp5TzF9gu3QKNqdeV
Review pointed out that pkg/ and scripts/ are Go too and were unchecked. They
are clean today, so covering them costs nothing now and closes the hole
permanently — and it matches `make fmt`, which formats the whole tree.

The suggested fix in the failure message widens with it. A narrower suggestion
than the check is the same trap in miniature: a contributor runs what the
message says, sees it pass, and CI still fails.

Verified both ways, including that a misformatted file in pkg/models — outside
the old scope — now fails the gate.

Claude-Session: https://claude.ai/code/session_01So2gKWp5TzF9gu3QKNqdeV
@xe-nvdk

xe-nvdk commented Sep 16, 2026

Copy link
Copy Markdown
Member Author

Review came back clean, and it verified the formatting more rigorously than I had. It re-ran gofmt -w on the eight files as they stand on main and compared byte-for-byte against this branch: identical in all eight, so the diff is exactly gofmt's output with no hand-authored byte in it. It also compared token streams and position-stripped ASTs, and confirmed the watcher.go comment reflow is the Go 1.19+ doc-comment rule rather than an edit.

Took its one substantive suggestion: the gate now covers the whole repository instead of just ./internal ./cmd. pkg/ and scripts/ are Go too and were unchecked. They are clean today, so covering them costs nothing now and closes the hole permanently, and it matches what make fmt already does.

The suggested fix in the failure message widened with it. A fix command narrower than the check would be this same trap in miniature: a contributor runs what the message says, sees it pass, and CI still fails.

Verified that a misformatted file in pkg/models, outside the old scope, now fails the gate.

Two things from the review worth recording for whoever merges this. Open branches need no rebase: the Format step runs on the PR merge ref, so they inherit this fix and go green on their own. And none of the other remote branches touches any of the eight files, so there is no textual conflict to manage.

@xe-nvdk
xe-nvdk merged commit 6a53272 into main Sep 16, 2026
7 checks passed
@xe-nvdk
xe-nvdk deleted the chore/gofmt-and-gate branch September 16, 2026 07:59
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.

ci: gofmt the eight dirty files on main and turn the gate on

1 participant