From 5994d9692105f06c4752f028603b0980018dc6b8 Mon Sep 17 00:00:00 2001 From: Steve Dudenhoeffer Date: Sat, 8 Aug 2026 03:06:21 -0400 Subject: [PATCH] =?UTF-8?q?refactor(llamaswap):=20drop=20initImageFilename?= =?UTF-8?q?=20=E2=80=94=20one=20caller=20left,=20and=20it=20was=20a=20rena?= =?UTF-8?q?me=20of=20imageFilename?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The 2/4 finding is right: after writeImagePart started passing an explicit filename stem, initImageFilename had no caller in video.go, and its "conditioning frame" doc no longer described its one remaining user (lipsync.go's avatar image). A one-line wrapper that survives only to be misdescribed is not indirection worth keeping. lipsync now calls imageFilename(mime, "frame") directly, and imageFilename's doc lists the real bases — including WHY the video keyframes need distinct ones: a backend that stages uploads by filename would otherwise have the second overwrite the first. Not taken: consolidating the first/last-frame rationale to a single canonical site. The copies address different readers — the wire encoding (provider), the contract's undetectable-support caveat (videogen), and the mode table (README) — and last round's finding was a doc pointing at a note that did not exist. Trading duplication for cross-references is what produced that. Co-Authored-By: Claude Opus 5 (1M context) Claude-Session: https://claude.ai/code/session_01PLjgrxvHjm1sJgUu9zBPH9 --- provider/llamaswap/faceswap.go | 8 +++++--- provider/llamaswap/lipsync.go | 2 +- provider/llamaswap/video.go | 7 ------- 3 files changed, 6 insertions(+), 11 deletions(-) diff --git a/provider/llamaswap/faceswap.go b/provider/llamaswap/faceswap.go index 8434ce8..294a765 100644 --- a/provider/llamaswap/faceswap.go +++ b/provider/llamaswap/faceswap.go @@ -207,10 +207,12 @@ func parseSwapReport(header string) []imagegen.SwappedFace { // imageFilename picks a multipart filename for an image part. The shim reads // bytes, not names, but a plausible extension keeps server-side sniffing and // request logs honest. base distinguishes the parts of a multi-file form -// ("target"/"source") so a log line says which one was malformed. +// ("target"/"source", "frame"/"frame_last") so a log line says which one was +// malformed — and, for the video keyframes, so a backend that stages uploads +// by filename cannot have the second overwrite the first. // -// initImageFilename (video.go) is this function with base fixed to "frame" -// and delegates here — two copies of one extension table is how they drift. +// Every caller routes through here: two copies of one extension table is how +// they drift. func imageFilename(mimeType, base string) string { if base == "" { base = "image" diff --git a/provider/llamaswap/lipsync.go b/provider/llamaswap/lipsync.go index 279aa3b..2d594c8 100644 --- a/provider/llamaswap/lipsync.go +++ b/provider/llamaswap/lipsync.go @@ -56,7 +56,7 @@ func (m *lipsyncModel) Lipsync(ctx context.Context, req videogen.LipsyncRequest, // hand (mirrors videoModel.Generate). var buf bytes.Buffer w := multipart.NewWriter(&buf) - fw, err := w.CreateFormFile("image", initImageFilename(req.Image.MIME)) + fw, err := w.CreateFormFile("image", imageFilename(req.Image.MIME, "frame")) if err != nil { return nil, fmt.Errorf("llama-swap: build lipsync form: %w", err) } diff --git a/provider/llamaswap/video.go b/provider/llamaswap/video.go index f74a35b..a694977 100644 --- a/provider/llamaswap/video.go +++ b/provider/llamaswap/video.go @@ -147,13 +147,6 @@ func singleVideoResult(provider, model, verb string, raw []byte, contentType str return &videogen.Result{Video: videogen.Video{Data: raw, MIME: mimeType}}, nil } -// initImageFilename picks the multipart filename hint for the conditioning -// frame from its MIME subtype. The name is provider-chosen (never -// caller-supplied), so no sanitization is needed. -func initImageFilename(mimeType string) string { - return imageFilename(mimeType, "frame") -} - // writeImagePart attaches one conditioning frame under the given field name, // with a filename derived from nameStem. Shared by the first- and last-frame // parts so the two cannot drift in how they encode, which is the usual way a