Skip to content

refactor: split oversized Go files (>1000 LOC) for clarity#47

Merged
Patel230 merged 7 commits into
mainfrom
refactor/code-clarity
Jun 19, 2026
Merged

refactor: split oversized Go files (>1000 LOC) for clarity#47
Patel230 merged 7 commits into
mainfrom
refactor/code-clarity

Conversation

@Patel230

Copy link
Copy Markdown
Contributor

Summary

Pure mechanical refactor for code clarity only. Splits every Go file over
1000 LOC into smaller, same-package files. Code is moved verbatim — no
behavior, API, or exported-symbol changes
. Build tags and file-level
//nolint directives are preserved on the new files.

Files split (before → after)

Original file Before After (original + new files)
client/cloud_providers_test.go 1896 645 + cloud_providers_vertex_test.go (612) + cloud_providers_bedrock_test.go (663)
client/anthropic_test.go 1539 328 + anthropic_chat_test.go (554) + anthropic_features_test.go (676)
client/openai_test.go 1208 429 + openai_stream_test.go (287) + openai_misc_test.go (518)
client/guardrails_test.go 1078 599 + guardrails_provider_test.go (489)
internal/api/integration_test.go 1090 598 + integration_nodes_test.go (509)
catalog/live/fetchers.go 1349 366 + fetchers_cloud.go (433) + fetchers_providers.go (577)
catalog/v1.go 1015 637 + v1_defaults.go (387)

All resulting files are now well under 1000 LOC. No single function/literal
exceeded 1000 lines, so nothing had to be left oversized.

Grouping rationale

  • Test files: grouped by provider / test area (e.g. Vertex vs Bedrock,
    Chat vs StreamChat vs feature tests, endpoint families). Shared helpers
    remain in the original file.
  • Source files: grouped cohesive functions (cloud vs other provider
    fetchers; default-catalog/legacy-conversion helpers). Registry, shared
    helpers, and AWS SigV4 signing helpers stay in the original.

Verification

  • goimports -w on all touched files.
  • Per-package after each split: go vet, go test, golangci-lint run0 issues.
  • Final, both modules green:
    • Root module (github.com/GrayCodeAI/eyrie): go build ./..., go vet ./..., go test ./... all pass.
    • Nested module (internal/sdk/go, github.com/GrayCodeAI/eyrie/sdk/go): go build/vet/test ./... pass (run with GOWORK=off).
  • CGO not required (no import "C"; modernc sqlite is pure Go).
  • Pre-push hooks (govulncheck, test, vet) passed on push.

One conventional-commit per logical split (7 commits).

Made with Cursor

Patel230 added 7 commits June 19, 2026 20:59
Move Google Vertex AI tests into cloud_providers_vertex_test.go and AWS
Bedrock tests into cloud_providers_bedrock_test.go. Azure and
cross-provider tests remain in cloud_providers_test.go. Pure mechanical
split, no behavior changes.
Move Chat/StreamChat tests into anthropic_chat_test.go and Ping, error,
client-config, and feature tests into anthropic_features_test.go. Message
builder, tool conversion, and shared helpers remain in anthropic_test.go.
Pure mechanical split, no behavior changes.
Move StreamChat tests into openai_stream_test.go and Ping, compat,
image-content, tool-result, and misc client tests into
openai_misc_test.go. Helpers and core Chat tests remain in
openai_test.go. Pure mechanical split, no behavior changes.
Move GuardrailError, ApplyGuardrails, GuardrailProvider, WithGuardrails
option, integration, and enum-value tests into guardrails_provider_test.go.
Core Guardrails, redaction, and rule-definition tests remain in
guardrails_test.go. Pure mechanical split, no behavior changes.
Move node, alias, prompt-from, rate-limit, error-simulation,
content-type, concurrency, and tree endpoint tests into
integration_nodes_test.go. Shared mock providers, helpers, and
health/chat/streaming/auth tests remain in integration_test.go. Pure
mechanical split, no behavior changes.
Move OpenAI/OpenRouter enrichment and cloud-provider (Azure, Bedrock,
Vertex, MiniMax) fetchers into fetchers_cloud.go, and the remaining
per-provider fetchers into fetchers_providers.go. The registry, shared
parsing/pricing/env helpers, and AWS SigV4 signing helpers remain in
fetchers.go. Pure mechanical split, no behavior changes.
Move default catalog construction, legacy ModelCatalog conversion, and
pricing/capability sanitization+validation helpers into v1_defaults.go.
Schema types, parsing, validation, compilation, loading, and lookups
remain in v1.go. Pure mechanical split, no behavior changes.
@Patel230 Patel230 force-pushed the refactor/code-clarity branch from 54abb57 to 24ddc02 Compare June 19, 2026 15:39
@Patel230 Patel230 merged commit abeb727 into main Jun 19, 2026
15 checks passed
@Patel230 Patel230 deleted the refactor/code-clarity branch June 19, 2026 17:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant