task fmt still cannot produce gci's custom-order import grouping #1524

Closed
opened 2026-10-27 13:40:45 +00:00 by sam · 0 comments
Owner

Follow-up to archie-core-ebzk. That bead fixed two ways task fmt could not satisfy task lint (gofumpt version drift, and a missing -extra). A third remains, and it is the general shape of all three: formatting has two owners, so only the rules they happen to share are safe to rely on.

task fmt runs the standalone gofumpt (gofumpt -extra -w .). task lint enforces the formatters: block from .golangci.yml — gofumpt (extra-rules) plus goimports plus gci. gci is configured custom-order: true with prefix(github.com/samcharles93/archie-core), so it puts archie-core imports in their own trailing section. gofumpt has no knowledge of that prefix and sorts alphabetically within a group.

REPRO (module + a config mirroring the repo's formatters block):

package p

import (
    "fmt"
    "github.com/zzz/x"
    "github.com/samcharles93/archie-core/internal/secret"
)

golangci-lint fmt --config <repo-style>.yml --diff   # demands this

import (
    "fmt"

    "github.com/zzz/x"

    "github.com/samcharles93/archie-core/internal/secret"
)

but gofumpt -extra -w . produces this, and leaves it there on every re-run:

import (
    "fmt"

    "github.com/samcharles93/archie-core/internal/secret"
    "github.com/zzz/x"
)

So task fmt writes something task lint rejects, and re-running task fmt cannot move it. Any contributor who adds a third-party import sorting after github.com/samcharles93 into the same group as an archie-core import gets a red gate whose documented repair does nothing. golangci-lint fmt does fix it, but nothing tells them to run that, and the gate's own documentation names task fmt.

Impact today is latent: the committed tree is clean (golangci-lint run ./... reports 0 issues), so no gate is red. The defect is the contract, not the current content.

Options, needing a decision:

  1. Point task fmt at golangci-lint fmt, so fmt and lint share one engine, one config and one version. Then fmt can always converge lint by construction, and the gofumpt/golangci-lint version pairing stops mattering for the gate. Costs: deploy.yml's inline quality-gate step runs gofumpt -w . directly (not task fmt) and CI does not install golangci-lint at all, so CI would need to run golangci-lint fmt too; and the pin documented in Dockerfile/AGENTS.md becomes about the preview command rather than the gate.
  2. Drop gci (and goimports, if nothing needs it) from formatters.enable, leaving gofumpt as the single formatting authority. Cheaper, but gives up the grouping rule the repo's import style already follows, and gci's grouping would then be unenforced.

Related, not fixed here: CI's quality gate never runs golangci-lint run at all — it runs gofumpt, go fix, proto, vet, build and test — so no CI surface can catch any of this class of drift. That is a separate gap from the one above.

Close reason

Implemented one configured formatting writer, protected Yaegi secret engines from goimports, and added a read-only PR quality gate; task check passes.


Imported from beads archie-core-q288 · GitHub #954 · type bug · priority P3 · created 2026-09-19 · closed 2026-09-19

Follow-up to archie-core-ebzk. That bead fixed two ways `task fmt` could not satisfy `task lint` (gofumpt version drift, and a missing `-extra`). A third remains, and it is the general shape of all three: formatting has two owners, so only the rules they happen to share are safe to rely on. `task fmt` runs the standalone gofumpt (`gofumpt -extra -w .`). `task lint` enforces the `formatters:` block from `.golangci.yml` — gofumpt (extra-rules) plus goimports plus gci. gci is configured `custom-order: true` with `prefix(github.com/samcharles93/archie-core)`, so it puts archie-core imports in their own trailing section. gofumpt has no knowledge of that prefix and sorts alphabetically within a group. REPRO (module + a config mirroring the repo's formatters block): package p import ( "fmt" "github.com/zzz/x" "github.com/samcharles93/archie-core/internal/secret" ) golangci-lint fmt --config <repo-style>.yml --diff # demands this import ( "fmt" "github.com/zzz/x" "github.com/samcharles93/archie-core/internal/secret" ) but `gofumpt -extra -w .` produces this, and leaves it there on every re-run: import ( "fmt" "github.com/samcharles93/archie-core/internal/secret" "github.com/zzz/x" ) So `task fmt` writes something `task lint` rejects, and re-running `task fmt` cannot move it. Any contributor who adds a third-party import sorting after `github.com/samcharles93` into the same group as an archie-core import gets a red gate whose documented repair does nothing. `golangci-lint fmt` does fix it, but nothing tells them to run that, and the gate's own documentation names `task fmt`. Impact today is latent: the committed tree is clean (`golangci-lint run ./...` reports 0 issues), so no gate is red. The defect is the contract, not the current content. Options, needing a decision: 1. Point `task fmt` at `golangci-lint fmt`, so fmt and lint share one engine, one config and one version. Then `fmt` can always converge `lint` by construction, and the gofumpt/golangci-lint version pairing stops mattering for the gate. Costs: `deploy.yml`'s inline quality-gate step runs `gofumpt -w .` directly (not `task fmt`) and CI does not install golangci-lint at all, so CI would need to run `golangci-lint fmt` too; and the pin documented in `Dockerfile`/AGENTS.md becomes about the preview command rather than the gate. 2. Drop gci (and goimports, if nothing needs it) from `formatters.enable`, leaving gofumpt as the single formatting authority. Cheaper, but gives up the grouping rule the repo's import style already follows, and gci's grouping would then be unenforced. Related, not fixed here: CI's quality gate never runs `golangci-lint run` at all — it runs gofumpt, go fix, proto, vet, build and test — so no CI surface can catch any of this class of drift. That is a separate gap from the one above. ### Close reason Implemented one configured formatting writer, protected Yaegi secret engines from goimports, and added a read-only PR quality gate; task check passes. --- _Imported from beads `archie-core-q288` · GitHub #954 · type bug · priority P3 · created 2026-09-19 · closed 2026-09-19_
sam added the lowbug labels 2026-10-27 13:40:45 +00:00
sam self-assigned this 2026-10-27 13:40:45 +00:00
sam closed this issue 2026-10-27 13:40:45 +00:00
sam added a new dependency 2026-10-27 13:42:26 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Reference: sam/archie#1524