refactor: migrate UUID generation and parsing to Go 1.27 stdlib by dgageot · Pull Request #4404 · docker/docker-agent · GitHub
Skip to content

refactor: migrate UUID generation and parsing to Go 1.27 stdlib - #4404

Merged
dgageot merged 1 commit into
mainfrom
refactor/uuid-stdlib-migration
Sep 23, 2026
Merged

dgageot merged 1 commit into
mainfrom
refactor/uuid-stdlib-migration

Conversation

@dgageot

@dgageot dgageot commented Sep 23, 2026

Copy link
Copy Markdown
Member

Go 1.27's standard library gained a uuid package that covers the cases most call sites actually need, so the project no longer has to pull in github.com/google/uuid for the common path of generating a random ID or parsing one back.

Every call site that generated a random UUID now uses the standard library's uuid.NewV4().String(), and every place that parsed a UUID string uses the standard library's uuid.Parse or uuid.MustParse instead of the Google package. The github.com/google/uuid dependency remains in pkg/model/provider/base/opencode.go, which still needs uuid.NewSHA1 to derive stable, deterministic OpenCode IDs from a namespace: the stdlib has no UUIDv5 support, so that one usage is unchanged. pkg/userid/userid.go keeps a small compatibility helper so every legacy persisted-ID form the old Google parser accepted still parses correctly, with no rewriting or rotation of existing stored IDs. pkg/evaluation/eval.go still reads the first four bytes of the UUID as big-endian to keep its decimal evaluation names stable.

Tests were added for the v4 bit layout, the legacy persisted-ID compatibility forms, the evaluation name format, and a check that the OpenCode SHA1-derived IDs stay stable. task build, task test, task lint, and git diff --check all pass on this branch, which is cut directly from main and carries only this UUID migration commit.

Use crypto/rand-backed stdlib uuid.NewV4().String() for random UUIDs and stdlib parsing instead of github.com/google/uuid, wherever the stdlib can express the behavior.

github.com/google/uuid is kept only in pkg/model/provider/base/opencode.go for uuid.NewSHA1, since the stdlib has no UUIDv5 support; the namespace and resulting IDs are unchanged.

pkg/userid/userid.go keeps a compatibility helper that preserves every legacy persisted-ID form the Google parser accepted, without rewriting or rotating existing IDs. pkg/evaluation/eval.go keeps reading the first 4 UUID bytes as big-endian to preserve existing decimal evaluation names.

Added tests covering v4 bit layout, legacy persisted-ID forms, the evaluation name format, and the OpenCode UUIDv5 fallback.

Signed-off-by: David Gageot <david.gageot@docker.com>
@dgageot
dgageot requested a review from a team as a code owner September 23, 2026 13:48
@aheritier aheritier added area/tools For features/issues/fixes related to the usage of built-in and MCP tools area/providers/openai For features/issues/fixes related to the usage of OpenAI models area/providers/anthropic For features/issues/fixes related to the usage of Anthropic models area/sessions For features/issues/fixes related to session lifecycle (resume, persistence, export) area/providers For features/issues/fixes related to LLM providers (Bedrock, LiteLLM, Qwen, custom, etc.) area/cli CLI commands, flags, output formatting area/mcp MCP protocol, MCP tool servers, integration area/testing Test infrastructure, CI/CD, test runners, evaluation area/providers/gemini Google Gemini provider support kind/refactor PR refactors code without behavior change area/runtime Runtime engine, agent loop execution, tool dispatch, loop detection labels Sep 23, 2026
@dgageot
dgageot added this pull request to the merge queue Sep 23, 2026
Merged via the queue into main with commit b2d7bb1 Sep 23, 2026
15 checks passed
@dgageot
dgageot deleted the refactor/uuid-stdlib-migration branch September 23, 2026 14:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/cli CLI commands, flags, output formatting area/mcp MCP protocol, MCP tool servers, integration area/providers/anthropic For features/issues/fixes related to the usage of Anthropic models area/providers/gemini Google Gemini provider support area/providers/openai For features/issues/fixes related to the usage of OpenAI models area/providers For features/issues/fixes related to LLM providers (Bedrock, LiteLLM, Qwen, custom, etc.) area/runtime Runtime engine, agent loop execution, tool dispatch, loop detection area/sessions For features/issues/fixes related to session lifecycle (resume, persistence, export) area/testing Test infrastructure, CI/CD, test runners, evaluation area/tools For features/issues/fixes related to the usage of built-in and MCP tools kind/refactor PR refactors code without behavior change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants