You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is the second time a serious contributor has bounced off the code shape. The "we're so unfriendly to contributors people are talking about a from-scratch rewrite" failure mode is a maintainer-level problem, not a style preference.
Cognitive load to make a one-line change: contributors must scroll a 7400-line file to find the right function, then keep ambient state about what else lives in that file in their head while editing.
No package boundaries inside the service — every function in cmd/server/store.go is in package main. There's no compiler-enforced "channels code can't reach into multibyte internals" — everything is one big lump of state.
AI-coding-friendly only by accident: large-context models tolerate this; humans don't. Filtering for "humans can contribute" is the higher bar.
Specific reviewer feedback: external contributors have publicly said it's why they're not contributing / are considering forks.
Proposed direction (high-level — design pass before any code)
Split cmd/server/store.go and cmd/server/db.go along feature axes. Suggested first cut (subject to design):
residual catch-all for genuinely shared helpers (~500 lines)
Same axis for routes.go → handlers/<domain>.go (channels, analytics, nodes, packets, live, multibyte, paths, …).
For db.go (DB-backed sibling), mirror the same split.
Optional: introduce a internal/store/ package to make the splits compiler-enforced (cross-domain calls become explicit imports).
Acceptance criteria (design phase only)
This issue is a DESIGN issue — file PR(s) only after the design lands here in comments.
A design comment lands on this issue with: (a) the proposed file split (names + responsibilities), (b) the proposed package boundary (single package main vs internal/store/), (c) the migration ordering (which files split first, what's a single PR vs a series), (d) the merge-conflict mitigation plan (announce + freeze window for in-flight branches).
Expert review on the design (Munger for architecture, Torvalds for the "is this actually simpler" check) BEFORE implementation.
Implementation PR series cleared with the project, in order:
PR 1: tooling only — add a make refactor-precheck (or equivalent) script that asserts git mv-based moves preserve go test ./... -count=1 byte-equality on test output. No code moves yet.
PR 2: extract one domain (suggest: channels.go) using only git mv of function blocks. CI green proof. Zero behavior change.
PR 3+: subsequent domain extractions, one per PR, each behind a CI green gate.
Each refactor PR MUST be pure — no behavior changes piggybacked. Reviewed strictly under AGENTS.md's "pure refactor" exemption: existing tests byte-unchanged + still green.
After refactor: file count goes from ~6 monoliths to ~30-40 focused files; no single file in cmd/server/ exceeds 1000 lines.
Out of scope
Rewriting the PacketStore API surface.
Switching to a different language / framework.
Splitting the binary into multiple processes.
Touching cmd/ingestor/ in the first refactor wave (file separately if needed).
Risks
Massive merge conflicts for in-flight branches. Mitigation: pick a freeze window, announce, do the first split fast.
Loss of git blame lineage. Mitigation: every move uses git mv (preserves blame across renames) — never copy+delete.
Reviewer fatigue: 10+ refactor PRs is a lot. Mitigation: make each PR a single domain, tag clearly, batch reviews.
Refs
External contributor feedback relayed via Discord on 2026-05-22 (translated above).
cmd/server/store.go 7389 lines (master HEAD).
cmd/server/routes.go 2714 lines.
AGENTS.md "Pure refactor" exemption rule — defines the test-byte-unchanged gate.
Background
This is the second time a serious contributor has bounced off the code shape. The "we're so unfriendly to contributors people are talking about a from-scratch rewrite" failure mode is a maintainer-level problem, not a style preference.
Concrete current state
For comparison, the entire
cmd/server/package would fit comfortably in 30-40 focused files of <500 lines each — typical Go service shape.What's wrong with the current shape
cmd/server/store.gois in packagemain. There's no compiler-enforced "channels code can't reach into multibyte internals" — everything is one big lump of state.Proposed direction (high-level — design pass before any code)
Split
cmd/server/store.goandcmd/server/db.goalong feature axes. Suggested first cut (subject to design):cmd/server/store/store.go— corePacketStorestruct + Load/Save lifecycle (~300 lines)cmd/server/store/channels.go—GetChannels,GetChannelMessages, channel-list aggregation (~600 lines)cmd/server/store/multibyte.go—computeMultiByteCapability, hash-size analytics (~500 lines)cmd/server/store/paths.go—nodeInResolvedPath, paths-through-node, path-hop index (~800 lines)cmd/server/store/analytics.go—GetAnalyticsChannels, payload-mix, RF analytics (~700 lines)cmd/server/store/topology.go— neighbor-graph build, topology, edges (~600 lines)cmd/server/store/observers.go— observer registry, region resolution (~400 lines)cmd/server/store/disambig.go—resolveWithContext,buildPrefixMap, fallback resolution (~500 lines)cmd/server/store/dedup.go— broadcastTxs, dedupe key logic, cache invalidation (~400 lines)Same axis for
routes.go→handlers/<domain>.go(channels, analytics, nodes, packets, live, multibyte, paths, …).For
db.go(DB-backed sibling), mirror the same split.Optional: introduce a
internal/store/package to make the splits compiler-enforced (cross-domain calls become explicit imports).Acceptance criteria (design phase only)
This issue is a DESIGN issue — file PR(s) only after the design lands here in comments.
package mainvsinternal/store/), (c) the migration ordering (which files split first, what's a single PR vs a series), (d) the merge-conflict mitigation plan (announce + freeze window for in-flight branches).make refactor-precheck(or equivalent) script that assertsgit mv-based moves preservego test ./... -count=1byte-equality on test output. No code moves yet.channels.go) using onlygit mvof function blocks. CI green proof. Zero behavior change.cmd/server/exceeds 1000 lines.Out of scope
PacketStoreAPI surface.cmd/ingestor/in the first refactor wave (file separately if needed).Risks
git blamelineage. Mitigation: every move usesgit mv(preserves blame across renames) — never copy+delete.Refs
cmd/server/store.go7389 lines (master HEAD).cmd/server/routes.go2714 lines.