Refactor: split control-plane/internal/server/server.go (1835 LOC)
Part of the refactor god-files epic.
Evidence
$ wc -l control-plane/internal/server/server.go
1835 control-plane/internal/server/server.go
One file contains route registration for the entire control plane (REST + UI + agentic + admin + memory + DID + MCP + observability). Reading it feels like reading a routing table shipped as prose.
Proposed split
Extract routes_*.go files that each register one route group. The idiomatic Gin pattern is:
routes_core.go — /api/v1/nodes, /api/v1/executions, heartbeat
routes_memory.go — memory read/write/events/vector
routes_workflow.go — workflows, runs, steps
routes_did.go — DID/VC
routes_ui.go — UI/SSE routes (or move to handlers/ui/routes.go)
routes_agentic.go — agentic query/batch/discover
routes_admin.go — admin endpoints
routes_observability.go — webhooks + forwarder
server.go — NewServer, middleware stack, and a single registerRoutes() that calls each group
Each file exposes a single private registerXxxRoutes(r *gin.Engine, deps Deps) function.
Rules for the PR
- No route additions, removals, or path changes.
curl the routes before and after and diff — must be identical.
- A smoke test on
GET /api/v1/nodes and GET /ui/ must still work.
go test ./control-plane/... must pass.
Why this is safe
Pure code movement. The router object is the same; you are only moving r.GET(...) calls.
Why this matters
Adding a new endpoint today means editing the 1800-line server.go. After the split, it means editing the ~150-line file for that domain.
Size: M · Difficulty: intermediate · Language: Go
Part of epic #388 — parent tracker.
How to work on this
Setup
git clone https://github.com/Agent-Field/agentfield.git
cd agentfield
make install # installs Go, Python (via uv), and Node deps
make build # optional — builds the control plane binary
Run the baseline test suite
Before you change anything, run the tests for the language this issue targets so you know what "green" looks like:
- Go control plane:
cd control-plane && go test ./... -count=1
- Go SDK:
cd sdk/go && go test ./... -count=1
- Python SDK:
cd sdk/python && uv run pytest -q
- TypeScript SDK:
cd sdk/typescript && bun test
Package coverage baseline (so you can show improvement in the PR):
go test -cover ./control-plane/internal/...
uv run pytest --cov=agentfield sdk/python/tests
bun test --coverage (TypeScript)
Using Claude Code or another AI coding agent
This repo has a CLAUDE.md at the root that Claude Code and compatible agents will read automatically. A working flow:
cd into the repo and run claude (or open in your IDE's agent).
- Paste this issue URL and say: "Please implement this issue, following every acceptance-criteria checkbox. Do not change source files — only add tests under the target path in the issue. When you're done, run the test suite command from the issue and paste the result."
- Let the agent read existing tests in the same package as a model for style / fixtures — we point to them in the issue.
- Run
make lint before opening the PR.
See the AI-Assisted Contributions guide for testing requirements. Tag your PR with ai-assisted if you used an AI agent.
Claiming this issue
Comment I'd like to work on this and a maintainer will assign it to you. If you're new to open source, issues labelled good first issue or first-timers-only are hand-picked for a smooth first PR — we'll guide you if you get stuck.
Opening the PR
- Branch name:
tests/<short-description> or refactor/<short-description>
- Link this issue in the PR description with
Closes #<number>
- Paste the before/after test output or coverage delta in the PR body
- Keep the diff to the scope in this issue — no drive-by cleanups
Help & questions
- Comment on this issue — we monitor all assigned issues.
- Join the community Discord: run
/gsd-join-discord or check the README for the invite.
- For repo-wide questions, open a discussion with the
help tag.
Refactor: split
control-plane/internal/server/server.go(1835 LOC)Evidence
One file contains route registration for the entire control plane (REST + UI + agentic + admin + memory + DID + MCP + observability). Reading it feels like reading a routing table shipped as prose.
Proposed split
Extract
routes_*.gofiles that each register one route group. The idiomatic Gin pattern is:routes_core.go—/api/v1/nodes,/api/v1/executions, heartbeatroutes_memory.go— memory read/write/events/vectorroutes_workflow.go— workflows, runs, stepsroutes_did.go— DID/VCroutes_ui.go— UI/SSE routes (or move tohandlers/ui/routes.go)routes_agentic.go— agentic query/batch/discoverroutes_admin.go— admin endpointsroutes_observability.go— webhooks + forwarderserver.go—NewServer, middleware stack, and a singleregisterRoutes()that calls each groupEach file exposes a single private
registerXxxRoutes(r *gin.Engine, deps Deps)function.Rules for the PR
curlthe routes before and after and diff — must be identical.GET /api/v1/nodesandGET /ui/must still work.go test ./control-plane/...must pass.Why this is safe
Pure code movement. The router object is the same; you are only moving
r.GET(...)calls.Why this matters
Adding a new endpoint today means editing the 1800-line
server.go. After the split, it means editing the ~150-line file for that domain.Size: M · Difficulty: intermediate · Language: Go
Part of epic #388 — parent tracker.
How to work on this
Setup
Run the baseline test suite
Before you change anything, run the tests for the language this issue targets so you know what "green" looks like:
cd control-plane && go test ./... -count=1cd sdk/go && go test ./... -count=1cd sdk/python && uv run pytest -qcd sdk/typescript && bun testPackage coverage baseline (so you can show improvement in the PR):
go test -cover ./control-plane/internal/...uv run pytest --cov=agentfield sdk/python/testsbun test --coverage(TypeScript)Using Claude Code or another AI coding agent
This repo has a
CLAUDE.mdat the root that Claude Code and compatible agents will read automatically. A working flow:cdinto the repo and runclaude(or open in your IDE's agent).make lintbefore opening the PR.See the AI-Assisted Contributions guide for testing requirements. Tag your PR with
ai-assistedif you used an AI agent.Claiming this issue
Comment
I'd like to work on thisand a maintainer will assign it to you. If you're new to open source, issues labelledgood first issueorfirst-timers-onlyare hand-picked for a smooth first PR — we'll guide you if you get stuck.Opening the PR
tests/<short-description>orrefactor/<short-description>Closes #<number>Help & questions
/gsd-join-discordor check the README for the invite.helptag.