Repository navigation
[AI:zf-builder] refactor(server): drop single-implementer Handler interface - #187
Conversation
Task: zf-z-94cae19a refactor(server): drop single-implementer Handler interface (Ponytail Rung 1/6)
Deploying zerohub with
|
| Latest commit: |
4562fac
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://f44fa7f2.zerohub.pages.dev |
| Branch Preview URL: | https://task-zf-z-94cae19a.zerohub.pages.dev |
ntsd
left a comment
There was a problem hiding this comment.
[AI:zf-reviewer] [Reviewer Feedback] Round 1: Approved for human review.
Clean, minimal, exactly-scoped refactor. Verified against the task's own verification plan plus a whole-repo sweep.
What I checked
- Interface removal:
type Handler interface { Serve() error }and its doc block are gone;grep -r "type Handler interface" .across the server returns 0 hits. - Sole implementer:
handlerstruct renamed to exportedHandlerstruct (pkg/handler/handler.go:57); all 22 sibling files changed only receiver signatures (*handler->*Handler) plus the test helpers that name the type. No behavioral lines touched. - Sole call site:
cmd/server.go:29(handler.NewHandler(...)) and:34(hdl.Serve()) compile unchanged, as predicted. - No mock or external consumer of the old interface existed (verified
handler.Handler= 0 hits repo-wide, including client/test/docs), so nothing had to change outsideserver/pkg/handler/— the diff honors that (all 23 files in that one package, net -7 lines, no drive-by reformatting). - Automated gates at HEAD of the task branch:
go build ./...exit 0,go vet ./...exit 0,go test ./...all packagesok(handler pkg 8.8s, full suite green). - Mergeability: PR is MERGEABLE / CLEAN against main.
Ponytail scorecard
- Rung 1 (YAGNI): PASS — single-method interface, one implementer, one call site, zero mocks; the indirection bought nothing. Correct removal.
- Rung 6 (flat over nested): PASS —
NewHandlernow returns the concrete type directly; the one indirection layer is gone. - Rung 7 (diff scope): PASS — 23 files, all mechanical rename churn inside one package, no unrelated churn, no leftover debug code.
- Rungs 3/5 (dependencies): PASS — no dependency or import changes.
One noted deviation from the task text, accepted: NewHandler returns (*Handler, error) rather than the struct by value. This is strictly better — the struct embeds sync.Mutex / sync.RWMutex / atomic.Bool, and a value return would trip go vet's copylocks check. *Handler is the idiomatic concrete return; the task's "return the concrete type" intent is satisfied.
Test coverage: this is a pure type-level refactor with no behavioral change; the existing handler test suite (auth, claim, create/join paths, migrate, rate limit, websocket keepalive/origin, metadata/hub-id validation) all exercise the concrete handler directly and pass unchanged. No new tests required.
CONVENTION: When dropping a Go single-implementer interface by exporting the concrete struct, return *T from the constructor, not T — structs carrying mutexes must not be passed by value (go vet copylocks); verify with go vet ./... after such a rename.
[AI:zf-builder] Task: zf-z-94cae19a
refactor(server): drop single-implementer Handler interface (Ponytail Rung 1/6)
Automated PR for task zf-z-94cae19a
Completed by: @zf-builder