Skip to content

refactor(encode): Phase 2 — promote encoders to pkg/audio/encode (gate met) - #142

Merged
chrisuthe merged 2 commits into
mainfrom
refactor/split-phase2-promote-encoders
Jun 12, 2026
Merged

chrisuthe merged 2 commits into
mainfrom
refactor/split-phase2-promote-encoders

Conversation

@chrisuthe

Copy link
Copy Markdown
Member

Phase 2 of the three-repo split (2 of 3 promotions) — and it completes the Phase 2 gate.

Change

Promote the Opus/FLAC encoders from internal/server to a public pkg/audio/encode, and repoint the three pkg/sendspin users.

  • opus_encoder.go / flac_encoder.go (+ tests) moved verbatim (git mv, history preserved), package server → package encode, plus a doc.go (matching pkg/audio/decode).
  • role_player.go, server.go, server_client.go: import pkg/audio/encode, reference encode.{Opus,FLAC}Encoder / encode.New{Opus,FLAC}Encoder.

Why this finishes the gate

The encoders turned out to be the only thing pkg/sendspin used from internal/server (the source decoders and TUI are used solely by cmd/sendspin-server). So this PR drops the SDK's internal/server dependency entirely:

go list -deps ./pkg/...  →  ZERO sendspin-go/internal/ packages

Phase 2 gate ("SDK has zero cross-boundary internal/ imports") is met after discovery (#141) + this PR. internal/server (sources + TUI) is now used only by cmd, so it can stay private to the future server-CLI repo.

Note: third promotion downgraded to optional

The planned pkg/audio/source promotion is no longer required for the boundary — only cmd imports the sources, not the SDK. Whether to promote them becomes a product decision (does the SDK ship built-in file/MP3/FLAC/HLS sources for library consumers, or are sources a CLI concern?). Captured in the plan; decide before/with Phase 3.

Verification

  • go build ./..., full go test -race ./... (10 packages) — green. gofmt + lint clean. go doc ./pkg/audio/encode renders.
  • CGO/opus note: the encoders use opus.Encoder (not opus.Stream), so the -tags=nolibopusfile behavior is unchanged by the move — same as when they lived in internal/server.

The Opus and FLAC encoders were the ONLY thing pkg/sendspin used from
internal/server (the source decoders and TUI are used solely by the server
CLI). Promoting them to a public package therefore drops pkg/sendspin's
internal/server dependency entirely.

- Move opus_encoder.go / flac_encoder.go (+ tests) verbatim from
  internal/server to pkg/audio/encode (package server -> encode); add doc.go.
- Repoint role_player.go, server.go, server_client.go: import
  pkg/audio/encode and reference encode.{Opus,FLAC}Encoder /
  encode.New{Opus,FLAC}Encoder.

Phase 2 GATE MET: go list -deps confirms pkg/ now imports ZERO internal/
packages. internal/server (sources + TUI) is used only by cmd/sendspin-server
now, so it can stay private to the future server-CLI repo.

Phase 2 of the three-repo split.
@chrisuthe
chrisuthe merged commit 0c2390c into main Jun 12, 2026
7 checks passed
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