Skip to content

[AI:zf-builder] refactor(server): drop single-implementer Handler interface - #187

Merged
ntsd merged 2 commits into
mainfrom
task/zf-z-94cae19a
Nov 21, 2026
Merged

ntsd merged 2 commits into
mainfrom
task/zf-z-94cae19a

Conversation

@ntsd

@ntsd ntsd commented Nov 21, 2026

Copy link
Copy Markdown
Contributor

[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

ntsd added 2 commits November 21, 2026 16:29
Task: zf-z-94cae19a

refactor(server): drop single-implementer Handler interface (Ponytail Rung 1/6)
@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying zerohub with  Cloudflare Pages  Cloudflare Pages

Latest commit: 4562fac
Status: ✅  Deploy successful!
Preview URL: https://f44fa7f2.zerohub.pages.dev
Branch Preview URL: https://task-zf-z-94cae19a.zerohub.pages.dev

View logs

@ntsd ntsd left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[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: handler struct renamed to exported Handler struct (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 outside server/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 packages ok (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 — NewHandler now 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.

@ntsd
ntsd merged commit fede8b9 into main Nov 21, 2026
3 checks passed
@ntsd
ntsd deleted the task/zf-z-94cae19a branch November 21, 2026 09:37
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