Skip to content

chore: clean main fails make pre-commit (fmt, gen and lint debt not gated by fork-ci) #407

Open

Description

@ibetitsmike

Coder Agents acted on behalf of @ibetitsmike.

Problem

Clean main at 5c8c0e2 fails make pre-commit in the fork-dev workspace. Because the shared repo config opts into the hook (coder.pre-commit = true), no commit that stages a Go, TS or site/ file can pass it.

Evidence from a clean detached checkout of 5c8c0e2:

  • make fmt rewrites 30 files. This is real format debt, not drift:
    • Go import grouping in fork files: coderd/x/chatd/fork_workflow*.go, fork_ancestors.go, fork_chat_todos.go, coderd/database/migrations/fork_chatd.go, codersdk/fork_chat_todos.go and others.
    • Mis-indented TS in site/src/pages/AgentsPage/hooks/useConversationEditingState.ts and ChatPageContent.tsx.
    • Table padding in docs/coder-agents/index.md.
  • make gen leaves coderd/apidoc/docs.go, coderd/apidoc/swagger.json, docs/reference/api/general.md and docs/reference/api/schemas.md modified. swagger.json differs between two runs.
  • make lint reports 114 golangci-lint issues. These may come from linter version drift between the mise shim and upstream's pin.

fork-ci does not run make fmt, a golangci-lint pass or a check for unstaged changes after gen. That is how the debt landed.

Interim rule (lead decision, 2026-11-21)

Workstreams may set the hook's documented opt-out in their own worktree only (git config --worktree coder.pre-commit false). They never use --no-verify. They run targeted checks on their own files and list the results in the PR body.

Plan

  1. Pin or align the local toolchain: golangci-lint and swag versions against upstream's pins.
  2. Make make gen deterministic, so two runs produce identical swagger.json.
  3. Do one mechanical fmt sweep PR with no logic changes. It must not touch any chatdmig node under coderd/database/migrations/chatdmig/nodes.
  4. Add a fork-ci step that fails on fmt drift, and on gen drift for fork files.
  5. Re-check that make pre-commit passes on clean main, then drop the interim rule.

Acceptance

  • make pre-commit passes on a clean main checkout in fork-dev.
  • fork-ci fails a PR that introduces fmt drift.

Activity

  1. ibetitsmike commented on Nov 21, 2026

    @ibetitsmike
    OwnerAuthor

    Coder Agents acted on behalf of @ibetitsmike.

    Scope note: fork Go lint in fork-ci is covered by Mike's draft #140 (issue #123). This issue does not add a golangci step or fix lint findings. It only reports the cause of the 114 local issues. Its scope is gen determinism, the fmt sweep and a fork-ci fmt-drift check. Workstream: child 0426a1a1, branch mike/issue-407-precommit-debt.

  2. ibetitsmike commented on Nov 21, 2026

    @ibetitsmike
    OwnerAuthor

    Coder Agents acted on behalf of @ibetitsmike.

    Split-out deliverable from PR #409 (issue #407): a fmt job for fork-ci that fails a PR when formatting drifts. It is posted here as a patch because pushing a commit that touches .github/workflows/fork-ci.yaml is rejected with the current token (no workflow scope), and GitHub checks every pushed commit, so the change cannot ride along in #409.

    diff --git a/.github/workflows/fork-ci.yaml b/.github/workflows/fork-ci.yaml
    --- a/.github/workflows/fork-ci.yaml
    +++ b/.github/workflows/fork-ci.yaml
    @@ -123,6 +123,60 @@ jobs:
             run: pnpm test:ci src/pages/AgentsPage
             working-directory: site
     
    +  # Fails when a PR introduces formatting drift: Go files the fork's Go
    +  # formatter (gofumpt plus gci import grouping, what scripts/format_go_file.sh
    +  # and make fmt run) would rewrite, site files Biome would rewrite, and
    +  # markdown tables the docs formatter would rewrite. It never lints, so it
    +  # stays clear of the lint job PR 140 adds to this workflow. Cheap: no Go
    +  # build, no tests.
    +  fmt:
    +    runs-on: ubuntu-latest
    +    permissions:
    +      contents: read
    +    timeout-minutes: 15
    +    steps:
    +      - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
    +        with:
    +          persist-credentials: false
    +      - uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
    +        with:
    +          go-version-file: go.mod
    +      # gci is what scripts/format_go_file.sh applies on top of gofumpt;
    +      # both are pinned as Go tools in go.mod, the same ones make fmt runs
    +      # in this repository.
    +      - name: Check Go formatting
    +        run: |
    +          unformatted=$(find . \
    +            -not \( \( -path '*/.git/*' -o -path './build/*' -o -path './vendor/*' -o -path './.coderv2/*' -o -path '*/node_modules/*' -o -path '*/out/*' -o -path './coderd/apidoc/*' -o -path '*/.next/*' -o -path '*/.terraform/*' -o -path './_gen/*' \) -prune \) \
    +            -type f -name '*.go' -print0 | \
    +            xargs -0 grep -ZL '^// Code generated .* DO NOT EDIT\.$' | \
    +            xargs -0 go run mvdan.cc/gofumpt -l)
    +          if [ -n "$unformatted" ]; then
    +            echo "Go files need gofumpt (run make fmt):"
    +            echo "$unformatted"
    +            exit 1
    +          fi
    +          unformatted=$(find . \
    +            -not \( \( -path '*/.git/*' -o -path './build/*' -o -path './vendor/*' -o -path './.coderv2/*' -o -path '*/node_modules/*' -o -path '*/out/*' -o -path './coderd/apidoc/*' -o -path '*/.next/*' -o -path '*/.terraform/*' -o -path './_gen/*' \) -prune \) \
    +            -type f -name '*.go' -print0 | \
    +            xargs -0 grep -ZL '^// Code generated .* DO NOT EDIT\.$' | \
    +            xargs -0 go run github.com/daixiang0/gci diff --skip-generated -s standard -s default -s "Prefix(github.com/coder,cdr.dev/)")
    +          if [ -n "$unformatted" ]; then
    +            echo "Go files need import grouping (run make fmt):"
    +            echo "$unformatted"
    +            exit 1
    +          fi
    +      - name: Set up mise tools
    +        uses: ./.github/actions/setup-mise
    +        with:
    +          install-args: "node pnpm"
    +      - name: Install pnpm dependencies
    +        uses: ./.github/actions/pnpm-install
    +      - name: Check site formatting
    +        run: pnpm run format:check
    +        working-directory: site
    +      - name: Check docs table formatting
    +        run: pnpm run check-docs
    +
       build:
         runs-on: ubuntu-latest
         permissions:
           contents: read

    The job adds, after the build job: gofumpt over every non-generated Go file using the Makefile's FIND_EXCLUSIONS, gci diff with the same sections scripts/format_go_file.sh writes, pnpm run format:check (Biome) on site/, and pnpm run check-docs for the markdown tables. It never lints, so it stays clear of the lint job PR #140 adds to this same workflow, and it writes nothing to the repo. All four checks pass locally on #409's head.

    Apply with git apply from a branch based on main. The follow-up PR that applies it should re-run make lint/actions/actionlint, which passes with this hunk.

  3. ibetitsmike commented on Nov 21, 2026

    @ibetitsmike
    OwnerAuthor

    Coder Agents acted on behalf of @ibetitsmike.

    #409 merged as 58f9009 (2026-11-21 11:46Z). It clears the fmt and gen debt on main. Still open here: the fork-ci fmt-drift job, which waits on the token workflow scope or on Mike applying the patch above. golangci findings are draft #140's scope. Enum order determinism is #410. make pre-commit still stops at lint/go and at two React-compiler findings, so the interim worktree opt-out rule stays.

  4. ibetitsmike commented on Nov 21, 2026

    @ibetitsmike
    OwnerAuthor

    Coder Agents acted on behalf of @ibetitsmike.

    #414 merged as e24f7e7 (closes #410, deterministic apidoc enum order). This removes the swagger gen nondeterminism part of the pre-commit debt. Still open here: the fork-ci fmt-drift patch, which waits on the token workflow scope, and the golangci findings, which are draft #140 scope.

  5. ibetitsmike commented on Nov 22, 2026

    @ibetitsmike
    OwnerAuthor

    Coder Agents acted on behalf of @ibetitsmike.

    Decision from Mike (2026-11-22, in the maintainer chat): we do not have to run the full make pre-commit suite that this issue tracks as failing. The interim rule is now the standing rule: workstreams set git config --worktree coder.pre-commit false in their own worktree only, run targeted checks for what they touch, and list them in the PR body. fork-ci and Codex still gate every merge. The shared config is not changed.

    Still open here: the fork-ci fmt-drift job (patch in issuecomment-7061919690), which waits on the token workflow scope. golangci findings stay draft #140's scope.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions