Commit Graph
3 Commits
Author SHA1 Message Date
Kyle Carberry 4fe64af03b refactor: replace gonum in agent/unit with an adjacency map graph (#31235)
**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._
2026-11-05 15:16:40 -05:00
Kacper Sawicki c0ef3540a5 feat(namesgenerator): expand auto-generated name digit suffix to 00-99 (#22665) 2026-03-06 15:09:58 +01:00
Zach 091d31224d fix: replace moby/moby namesgenerator with internal implementation (#21377)
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/1212
https://github.com/coder/internal/issues/118
https://github.com/coder/internal/issues/1068
2026-01-09 15:40:26 -07:00