refactor(llamaswap): drop initImageFilename — one caller left, and it was a rename of imageFilename
CI / Tidy (pull_request) Successful in 9m40s
CI / Build & Test (pull_request) Successful in 11m38s

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) <[email protected]>
Claude-Session: https://claude.ai/code/session_01PLjgrxvHjm1sJgUu9zBPH9
This commit is contained in:
2026-08-08 03:06:21 -04:00
co-authored by Claude Opus 5
parent 588e092465
commit 5994d96921
3 changed files with 6 additions and 11 deletions
+5 -3
View File
@@ -207,10 +207,12 @@ func parseSwapReport(header string) []imagegen.SwappedFace {
// imageFilename picks a multipart filename for an image part. The shim reads // imageFilename picks a multipart filename for an image part. The shim reads
// bytes, not names, but a plausible extension keeps server-side sniffing and // bytes, not names, but a plausible extension keeps server-side sniffing and
// request logs honest. base distinguishes the parts of a multi-file form // 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" // Every caller routes through here: two copies of one extension table is how
// and delegates here — two copies of one extension table is how they drift. // they drift.
func imageFilename(mimeType, base string) string { func imageFilename(mimeType, base string) string {
if base == "" { if base == "" {
base = "image" base = "image"
+1 -1
View File
@@ -56,7 +56,7 @@ func (m *lipsyncModel) Lipsync(ctx context.Context, req videogen.LipsyncRequest,
// hand (mirrors videoModel.Generate). // hand (mirrors videoModel.Generate).
var buf bytes.Buffer var buf bytes.Buffer
w := multipart.NewWriter(&buf) 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 { if err != nil {
return nil, fmt.Errorf("llama-swap: build lipsync form: %w", err) return nil, fmt.Errorf("llama-swap: build lipsync form: %w", err)
} }
-7
View File
@@ -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 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, // writeImagePart attaches one conditioning frame under the given field name,
// with a filename derived from nameStem. Shared by the first- and last-frame // 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 // parts so the two cannot drift in how they encode, which is the usual way a