Skip to content

[AI:zf-builder] refactor(server): replace zeebo/xxh3 dep with stdlib hash/fnv for IP-hub key - #178

Merged
ntsd merged 2 commits into
mainfrom
task/zf-z-ea50c78d
Nov 20, 2026
Merged

ntsd merged 2 commits into
mainfrom
task/zf-z-ea50c78d

Conversation

@ntsd

@ntsd ntsd commented Nov 20, 2026

Copy link
Copy Markdown
Contributor

[AI:zf-builder] Task: zf-z-ea50c78d

refactor(server): replace zeebo/xxh3 dep with stdlib hash/fnv for IP-hub key (Ponytail Rung 5)

Automated PR for task zf-z-ea50c78d

Completed by: @zf-builder

ntsd added 2 commits November 20, 2026 11:25
…hub key

Task: zf-z-ea50c78d

refactor(server): replace zeebo/xxh3 dep with stdlib hash/fnv for IP-hub key (Ponytail Rung 5)
@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying zerohub with  Cloudflare Pages  Cloudflare Pages

Latest commit: 9e30603
Status: ✅  Deploy successful!
Preview URL: https://784cbcbd.zerohub.pages.dev
Branch Preview URL: https://task-zf-z-ea50c78d.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, well-scoped refactor. Verified in the worktree (branch task/zf-z-ea50c78d, base main):

Correctness / tests

  • fnvHash64a (hash/fnv, FNV-1a 64-bit) replaces xxh3.HashString at the only
    production call site (join_or_create_hub_ip.go:35). stdlib, no new dep.
  • cd server && go test ./... -> all packages ok (pkg/handler fresh run 8.9s).
  • go vet ./... clean. go mod tidy is a no-op (go.mod/go.sum already tidy).

Dependency removal — important nuance

  • The task listed "zero hits for grep zeebo/xxh3" as a verification gate. That
    is NOT achievable and is NOT a defect here: github.com/zeebo/xxh3 still
    appears in go.mod as // indirect and in go.sum.
  • go mod why -m github.com/zeebo/xxh3 -> pkg/storage -> ntsd/gache/v2 ->
    zeebo/xxh3. gache/v2's own go.mod directly requires xxh3 v1.0.2 (gache.go
    imports it). So the module graph still needs it; tidy correctly demotes it to
    indirect.
  • The actual task goal — drop the DIRECT dependency and all direct imports — is
    fully met: no .go file imports zeebo/xxh3; the 7 "xxh3 hash" comments are now
    "FNV hash". The remaining go.mod/go.sum lines are the unavoidable transitive
    dep via gache. Treat those as correct, not as leftover work.

Security / behavior

  • Hub key stays a server-generated opaque id; FNV-1a is fine for an opaque,
    non-crypto key (xxh3 was not crypto either). No security regression.
  • Behavior note holds: IP hubs are ephemeral (NoTTL, removed on last peer leave),
    so re-keying after deploy is safe; no persisted state names the old key.

Ponytail (7-Rung) check

  • Rung 5 (dependency): direct third-party dep removed; stdlib chosen. Pass.
  • Rung 7 (diff scope): 8 files, all in-scope — 1 code, 1 test, go.mod, 5
    comment-only edits. No reformat churn, no drive-by, no debug leftovers. Pass.
  • Rung 1/6 (simplicity/YAGNI): fnvHash64a is a justified 5-line helper shared
    by prod and test (single source of truth), not a premature abstraction. Pass.
  • Minor note (non-blocking): the test mirror ipHubKeyFor now calls the same
    prod helper, so the test no longer pins the hash algorithm independently.
    Acceptable because the key is opaque and the asserted behavior (distinct IPs
    -> distinct keys, trust-proxy XFF keying, socket-peer fallback) is what
    matters. No change requested.

Mergeability: PR #178 is MERGEABLE / CLEAN against main.

GOTCHA: A Go "dependency removal" PR can still leave the module as // indirect
in go.mod when a transitive dep (here gache/v2) still requires it — run
go mod why -m <pkg> and check the downstream module's go.mod before calling
the dep "gone"; don't fail the PR on the indirect line.

@ntsd
ntsd merged commit 1330074 into main Nov 20, 2026
3 checks passed
@ntsd
ntsd deleted the task/zf-z-ea50c78d branch November 20, 2026 04:33
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