**Stack:**
- #31232
- #31233
- #31234
- #31235
- #31236
- #31237
`agent/unit.Graph` used gonum's `simple`, `topo`, and `encoding/dot`
packages, which pull in `gonum/mat` and friends (~2 MB) for a graph with
a handful of nodes.
Replace it with forward/reverse adjacency maps, a DFS reachability check
for cycle detection, and a small DOT writer. The existing golden files
are unchanged.
<details>
<summary>Context: binary size investigation</summary>
Measured with full `make build/coder_linux_amd64` builds (zstd `-22
--ultra`) of `main` vs. the whole stack:
| Artifact | Before | After |
|---|---|---|
| `coder` (fat, linux/amd64) | 469 MB | 339 MB |
| `coder-slim` (linux/amd64) | 62 MB | 52 MB |
| Embedded `site/out` | 169 MB | 72 MB |
| Embedded `coder.tar.zst` | 83 MB | 60 MB |
Stack, each PR removes one source of size:
1. Hidden frontend source maps (~97 MB of embedded assets)
2. Slim tarball ordering so zstd `--long` dedupes across OSes (~14 MB on
the embedded archive)
3. `aisdk-go` only supplied two struct types but pulled in `openai-go`
v1 and `genai`
4. `gonum` used only for a tiny DAG in `agent/unit`
5. `gofakeit` root package links every faker; only two word lists are
used
6. Hugo `pageparser` used only to read YAML front matter in `templates
push`
Sizes were attributed with `go-size-analyzer` and an import-graph
dominator pass. Not in this stack: compiling out trivy's module download
resolvers in `coder/trivy` (~29 MB, drops go-getter, GCS, and S3 SDKs),
swagger-ui's bundled source maps (~7 MB), and OPA's embedded historical
capability JSON (~4 MB).
</details>
---
_Generated by Coder Agents on behalf of @kylecarbs._
Replace the external moby/moby/pkg/namesgenerator dependency with an
internal implementation using gofakeit/v7. The moby package has ~25k
unique name combinations, and with its retry parameter only adds a
random digit 0-9, giving ~250k possibilities. In parallel tests, this
has led to collisions (flakes).
The new internal API at coderd/util/namesgenerator eliminates the
external dependnecy and offers functions with explicit uniqueness
guarantees. This PR also consolidates fragmented name generation in a
few places to use the new package.
| Old (moby/moby) | New |
|-------------------------------------|------------------------|
| namesgenerator.GetRandomName(0) | NameWith("_") |
| namesgenerator.GetRandomName(>0) | NameDigitWith("_") |
| testutil.GetRandomName(t) | UniqueName() |
| testutil.GetRandomNameHyphenated(t) | UniqueNameWith("-") |
namesgenerator package API:
- NameWith(delim): random name, not unique
- NameDigitWith(delim): random name with 1-9 suffix, not unique
- UniqueName(): guaranteed unique via atomic counter
- UniqueNameWith(delim): unique with custom delimiter
Names continue to be docker style `[adjective][delim][surname]`. Unique
names are truncated to 32 characters (preserving the numeric suffix) to
fit common name length limits in Coder.
Related test flakes:
https://github.com/coder/internal/issues/1212https://github.com/coder/internal/issues/118https://github.com/coder/internal/issues/1068