ci: enforce gofmt, and format the files that were failing it - #12
Merged
Merged
Conversation
Four files have been unformatted on main: src/kg/add_observation.go, helpers.go, perf.go, and src/markitdown/converter/openai.go. Nothing checked, so it went unnoticed — CI built, vetted, and tested, but never looked at formatting. Both halves land together on purpose. Adding the gate alone would turn main red; formatting alone would drift back the next time someone skipped gofmt. The changes are whitespace only — struct tag alignment and one blank line — with no semantic difference. None of the open PRs touch these four files, so their merge refs pick up the formatted versions without conflict. The gate runs first in each module leg: it is the cheapest signal and the most irritating one to discover after a full test run. `gofmt -l` prints offending files and exits 0 whether or not it finds any, so the assertion is that its output is empty, not its exit code — verified by dropping a deliberately misformatted file in and confirming the check fails on it. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
VERDICT: approve
Review Summary
- Files reviewed:
.github/workflows/ci.yml,src/kg/add_observation.go,src/kg/helpers.go,src/kg/perf.go,src/markitdown/converter/openai.go - Overall verdict: APPROVE
Critical Issues (must fix before merge)
None.
Major Issues (should fix)
None.
Minor Issues (optional)
.github/workflows/ci.yml:59-66— The newFormatstep relies onset -e(GH Actions' defaultbash -eo pipefail) to fail the job ifgofmt -l .itself errors (e.g. a file with a parse error), since a failing command substitution in an assignment (unformatted=$(gofmt -l .)) still trips-e. This does fail safe today, but the failure would surface as a generic "Process completed with exit code 1" rather than the custom::error title=gofmt::annotation. Not a defect, just a readability nit if you ever want a more explicit message for that path (e.g.gofmt -l . > /tmp/out || { echo "::error::gofmt failed to parse one or more files"; exit 1; }).
Security Findings
None.
Positive Observations
- The
gofmt -lexit-code pitfall (it exits 0 regardless of findings) is correctly avoided by asserting on output emptiness rather than exit status — and the PR description explicitly documents that this was verified with a deliberately misformatted file. - The new
Formatstep correctly inherits the job'sdefaults.run.working-directory: src/${{ matrix.module }}, sogofmt -l .is properly scoped per module leg rather than accidentally linting the whole monorepo (which would matter given the three independentgo.mods with different Go versions). - All four reformatted files are genuinely whitespace-only changes (struct tag column alignment, one blank line added/removed) — no semantic drift, confirmed by reading the full diff context.
- Bundling the gate and the fix in one PR (rather than adding the gate first) avoids an immediate red
main, and the PR body correctly reasons about which open PRs could conflict. - Self-validating: CI already ran and passed (
kglib,kg,markitdownallSUCCESS) with the new gofmt gate active, confirming no other unformatted files lurk elsewhere in any of the three modules.
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.
Four files have been sitting unformatted on
main, unnoticed because nothing checked. CI built, vetted, and tested — but never looked at formatting.src/kg/add_observation.gosrc/kg/helpers.gosrc/kg/perf.gosrc/markitdown/converter/openai.goBoth halves land together on purpose. Adding the gate alone turns
mainred; formatting alone drifts back the next time someone skipsgofmt.The formatting change
Whitespace only — struct tag alignment and one blank line, no semantic difference. All three modules build and test green on CI's go1.26.2.
None of the open PRs (#4, #5, #7, #11) touch these four files, so their merge refs pick up the formatted versions without conflict.
The gate
Runs first in each module leg — cheapest signal, and the most irritating one to discover after a full test run.
gofmt -lprints offending files and exits 0 either way, so the assertion is that its output is empty, not its exit code. Verified by dropping a deliberately misformatted file in and confirming the check fails on it — a naivegofmt -l . && ...would have silently passed.🤖 Generated with Claude Code