Repository navigation
chore: clear the fmt and gen pre-commit debt on main - #409
Conversation
One mechanical fmt sweep of what make fmt rewrites on a clean main checkout (24 files: Go import grouping in fork files, Biome on site TS, markdown table padding in docs) plus the make gen output of the same checkout, because swag collects the enum constants of types declared across two files in Go map order and the generated enum order shifts from run to run (codersdk.Experiment, codersdk.ChatContextResourceKind, codersdk.ChatWatchEventKind). No logic changes. Nothing under coderd/database/migrations/chatdmig/nodes is touched. Fork Go lint findings and the fork-ci lint job are left to PR 140.
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Merged at head Gates on this exact head:
Not exercised: a running server. The change is formatting plus regenerated docs, and fork-ci build and chat-tests passed on this head. This PR does not close #407. Two parts are still open: the fork-ci fmt-drift job, which waits on the token |
Refs #407.
What and why
A clean checkout of
mainat 5c8c0e2 failsmake pre-commitin the fork-dev workspace:make fmtrewrites 24 files,make genleaves generated files modified, andmake lintreports 114 golangci-lint issues. This PR clears the fmt and gen debt with no logic changes. It does not fix the lint findings and does not add a lint job to fork-ci: that is PR #140, and this branch keeps clear of it.The fork-ci fmt-drift job is split out of this PR into a patch posted on #407. Pushing a commit that touches
.github/workflows/fork-ci.yamlis rejected because the token Mike uses lacks theworkflowscope, and GitHub checks every pushed commit, so a revert on top does not help. The branch here contains no commit touching any workflow file. Applying the patch on #407 in a follow-up PR adds the fmt job to fork-ci.Changes
chore: pre-commit debt on main, fmt sweep and gen output(single commit, mechanical):caseincoderd/agentapi/context.go: whatmake fmt(gofumpt plus gci viascripts/format_go_file.sh) rewrites on a clean main checkout. 13 Go files.site/src/pages/AgentsPageandsite/src/pages/AISettingsPage: 5 TS files.docs/coder-agents/index.md: 1 file.make genon the same checkout:coderd/apidoc/docs.go,coderd/apidoc/swagger.json,docs/reference/api/general.md,docs/reference/api/schemas.md.Root causes found
make gen nondeterminism
In the repo, not a tool mismatch. The mise shim versions match the versions upstream pins (
mise.toml,mise.lock): swag CLI v1.16.2, and the swag library thatscripts/apidocgen/swaginit/main.gocalls throughgo runis v1.16.6 fromgo.mod(the newest release). Both were confirmed withgolangci-lint version,swag --versionandgo mod download.The cause is in swag itself:
PackagesDefinitions.ParseTypesinpackages.goiteratespkgDefs.files, a Go map keyed by*ast.File, in random order, andcollectConstVariablesappends each package's constants topkg.OrderedConstin that order. Any enum type whose constants span two files of one package gets a random enum order per run. This fork has exactly those, all created by fork files:codersdk.Experiment(codersdk/deployment.go+codersdk/fork_experiments.go)codersdk.ChatContextResourceKind(codersdk/chats.go+codersdk/fork_agent_definitions.go)codersdk.ChatWatchEventKind(codersdk/chats.go+codersdk/fork_chat_watch.go)codersdk.ChatTodoStatusshows the same class of issueEvidence: two back-to-back
go run ./scripts/apidocgen/swaginitruns produced differentswagger.json(sha256 c9dd124b7baf then 5b11cb8dd544). A.github/fork/check-apidoc.shjq filter already sorts three of these enums, added in commit d8a722f, which is why fork-ci did not catch it. The real fix belongs in swag (sortOrderedConstor iterate files deterministically), which is upstream code; this PR only commits one canonical generated output. That committed enum order is one sample from swag's random map order, so a latermake genmay reorder it again; fork-ci's check-apidoc.sh sorts those enums, so CI stays stable. Making the generator output itself deterministic is #410.make lint: 114 issues, not version drift
golangci-lint versionreports v2.0.2, built with go1.26.10.mise.tomlandmise.lockpin the same v2.0.2, and upstream CI installs the identical pin viamise install --lockedwith the same config. So the 114 issues are not version drift. They are pre-existing findings in fork files (about 110 of the 114 mentionfork_), concentrated incoderd/x/chatd/fork_secret_answers.go(29, mostly revive unhandled-error onstrings.Builder),fork_workflow_phases_internal_test.go(12), plus revive get-return, flag-parameter, gosec G115 and gocritic ruleguard findings across other fork files. Upstream's own.golangci.new-code.yamlgate passes with 0 issues (make lint/go/new-codeon this branch: "0 issues."), so these never block new work. Fixing them is PR #140's scope, and this PR leaves every file #140 touches byte-identical to main.Verification on the PR head (84ea060)
All Go, gen and make commands ran as
flock ~/.fork-go.lock <command>in the fork-dev workspace.make fmt, run twice: idempotent, second run rewrites nothing.make gen, run twice on the committed output: no changes either time.make lint/go/new-code: 0 issues.make lint/docs-gen-filter: passes.make lint/actions/actionlint: passes.go run github.com/daixiang0/gci diff --skip-generated -s standard -s default -s "Prefix(github.com/coder,cdr.dev/)"over the same file set: empty.cd site && pnpm run format:check: "Checked 2537 files. No fixes applied."pnpm run check-docs: markdownlint 0 errors, no table formatting applied.cd site && pnpm run lint:types: passes.cd site && pnpm test:ci src/pages/AgentsPage: 185 files, 3164 passed, 2 skipped.git config --worktree coder.pre-commit falsewas set in this worktree only, per the interim rule in chore: clean main fails make pre-commit (fmt, gen and lint debt not gated by fork-ci) #407, and unset again.Not verified
make lintin full still reports the 114 findings; they are out of scope here and owned by ci: lint fork Go code in fork-ci and fix existing findings #140.make pre-commitend to end still stops atlint/go(the 114 findings) and atlint/tslint:compilerfindings (ForkAgentMentionMenu.tsxReact-compiler todo andForkHtmlAttachmentViewer.tsxunmemoized closure, both on untouched main files). Clearing those needs ci: lint fork Go code in fork-ci and fix existing findings #140 for the Go side and a separate frontend PR for the React-compiler side.Overlap with PR #140
Checked with
gh pr diff 140 -R ibetitsmike/coder --name-only. One file appears in both diffs,.github/workflows/fork-ci.yaml, and it reaches this PR only through the split-out patch on #407, not through this branch: the patch adds anfmtjob, #140 adds alintjob afterbuild, in separate hunks. The Go files in both diffs are disjoint except forcoderd/x/chatd/fork_ancestors.go, where this PR changes one import blank line from the fmt sweep and #140 adds a//nolint:revivedoc comment at line 20; separate hunks a normal merge resolves.Scope guardrails
git diff --stat origin/main...HEAD -- coderd/database/migrations/chatdmig/nodesis empty.make fmtdoes to them on clean main:coderd/agentapi/context.go(onecasere-indent),site/src/pages/AgentsPage/*(Biome),docs/coder-agents/index.md(table padding).make genoutput.