Split internal/handlers/source_management.go along its three CRUD seams #274

Open
opened 2026-08-24 02:18:07 +02:00 by clawbot · 0 comments
Collaborator

internal/handlers/source_management.go is roughly 1,970 lines and holds the source, entrypoint and target CRUD for the whole application.

Filing this because the cost stopped being theoretical. During the 1.0.0 push, #221, #211 and #262 were three independent, non-overlapping units that all had to be serialised against each other purely because they touched this one file. That serialisation was a real schedule cost paid three times, and it will be paid again by anything that follows.

It also concentrates risk: the defect in #262 sat about twenty lines below commitWebhook, which handles the identical GORM transaction idiom correctly. In a smaller file the inconsistency would have been obvious.

Definition of done:

  • Split into source_*.go, entrypoint_*.go and target_*.go along the existing CRUD seams.
  • PURE CODE MOVEMENT. No function body may differ from its original, no signature may change, no behaviour may change. If a move seems to require a behaviour change, stop and file that separately rather than folding it in.
  • Shared helpers land in whichever file makes them least surprising to find, or a clearly named shared file — do not scatter them.
  • make check green.
  • The reviewer should be able to verify this by diffing function bodies before and after, so keep the commit free of any other change. Do not reformat, do not rename, do not fix anything you notice along the way — file it instead.

Not milestoned: no behaviour change, so it does not block the tag. Worth doing early after it, while the seams are still clean.

`internal/handlers/source_management.go` is roughly 1,970 lines and holds the source, entrypoint and target CRUD for the whole application. Filing this because the cost stopped being theoretical. During the 1.0.0 push, https://git.eeqj.de/sneak/webhooker/issues/221, https://git.eeqj.de/sneak/webhooker/issues/211 and https://git.eeqj.de/sneak/webhooker/issues/262 were three independent, non-overlapping units that all had to be serialised against each other purely because they touched this one file. That serialisation was a real schedule cost paid three times, and it will be paid again by anything that follows. It also concentrates risk: the defect in https://git.eeqj.de/sneak/webhooker/issues/262 sat about twenty lines below `commitWebhook`, which handles the identical GORM transaction idiom correctly. In a smaller file the inconsistency would have been obvious. Definition of done: - Split into `source_*.go`, `entrypoint_*.go` and `target_*.go` along the existing CRUD seams. - PURE CODE MOVEMENT. No function body may differ from its original, no signature may change, no behaviour may change. If a move seems to require a behaviour change, stop and file that separately rather than folding it in. - Shared helpers land in whichever file makes them least surprising to find, or a clearly named `shared` file — do not scatter them. - `make check` green. - The reviewer should be able to verify this by diffing function bodies before and after, so keep the commit free of any other change. Do not reformat, do not rename, do not fix anything you notice along the way — file it instead. Not milestoned: no behaviour change, so it does not block the tag. Worth doing early after it, while the seams are still clean.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: sneak/webhooker#274