Skip to content

mods-tidy runs go mod tidy on tools/gomod-canonical and deletes the require block that IS its purpose #1184

Open

Description

@aitrawog

Measured 2026-11-17 while bumping the shared spec pin for charly#1183.

charly task mods-tidy reported success:

[pass] run   — adopt the shared pins and tidy every lockstep module   exit=0
[pass] check — every lockstep module now carries the shared pins      exit=0

And in the same run it emptied the module whose whole job is to be non-empty. tools/gomod-canonical/go.mod went from 38 lines to 3:

 module github.com/opencharly/charly/tools/gomod-canonical
 
 go 1.26.8
-
-require (
-	cuelabs.dev/go/oci/ociregistry v0.0.0-20251212221603-3adeb8663819 // indirect
-	cuelang.org/go v0.16.1 // indirect
-	github.com/alecthomas/kong v1.15.0 // indirect
-	… 35 entries …
-)

Mechanism. mods-tidy runs go mod tidy in every module it advances. That is correct for a module that imports its dependencies. tools/gomod-canonical is different in kind: its only Go file is gomod_canonical_test.go, which imports nothing external and instead reads other modules' go.mod files and asserts they all carry the same pins. So tidy sees zero imports and correctly removes every require — leaving the canonical block it exists to hold as an empty file.

Three more modules were damaged the same way, in the same run:

module removed
tools/gomod-canonical 35 requires (the entire block)
tools/golden-cloudinit 11 indirects
tools/generate-packages 1
tools/golden-compile 1

And the check step passed anyway, because it measures the pin value, not the file's shape — which is exactly the class of defect a gate exists to prevent: a green check over a broken artefact.

Resolution used: revert all four go.mod/go.sum from origin/main, move ONLY the opencharly/spec line with sed, and run go mod download (never tidy) for the new sums. The diff is then spec-pin-only in all four (7 files, +10/−4), and each module tests clean from its own root.

Expected fix. mods-tidy needs to distinguish a module that consumes its requires from one that carries a canonical block as data. Either skip go mod tidy for a module whose name declares it canonical (tools/gomod-canonical is self-describing), or — better — make the advance a line-level pin substitution and run go mod download only, since bumping a pin never legitimately requires a full tidy. Its check step should also assert the require block survived, not only that the pin matches.

Why it matters beyond four files: this verb is the documented way to advance pins (AGENTS.md Part II #3), so every session that bumps a pin runs it — and every one of them silently loses these blocks unless it reads the diff.

Agent: lead
Assisted-by: DeepSeek Harness ollama-cloud/deepseek-v4.1-flash (fully tested and validated)

Activity

  1. added
    category:governance
    type:fix
    on Nov 23, 2026
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

    category:governancetype:fix

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions