Consolidate the duplicated pipeline in clip_manager.py and backend/

Author: MrAnkleManicCreated Jul 7, 2026Updated Jul 7, 2026

The problem

clip_manager.py contains a second, independent implementation of the core pipeline that parallels backend/: its own ClipAsset/ClipEntry/asset discovery, its own run_inference, run_videomama, and alpha-generation orchestration. The CLI/wizard uses the clip_manager path; backend/service.py (built for programmatic/UI use) uses the other.

The two have already diverged in behavior, not just style:

  • Asset attribute naming differs (.type vs .asset_type), so helpers aren't interchangeable.
  • Mask channel handling: clip_manager.run_inference normalizes channels inline, while the backend path routes through validators.normalize_mask_* — edge cases (RGBA masks, 16-bit PNGs) can key differently depending on entry point.
  • Error handling: clip_manager breaks out of a clip on the first failed video read, while backend/service.py records a skip and continues.
  • Fixes tend to land on one side only — e.g. #261 fixes a soft-alpha binarization bug in backend/service.py's VideoMaMa write path that clip_manager's equivalent never had, and conversely resume/skip-existing behaviors have evolved separately.

Every future fix now needs to be written (and reviewed) twice, or the entry points silently drift apart.

Proposed direction

Make backend/ the single implementation and turn clip_manager.py into a thin orchestration layer over CorridorKeyService, in small reviewable steps:

  1. Types first: replace clip_manager's ClipEntry/ClipAsset/scan with imports from backend.clip_state (adapting the .type.asset_type rename). No behavior change intended; existing CLI tests keep passing.
  2. Inference: route clip_manager.run_inference through service.run_inference, mapping InferenceSettingsInferenceParams/OutputConfig and bridging the progress-callback protocols.
  3. Alpha generation: same for GVM / VideoMaMa / BiRefNet orchestration.
  4. Delete the dead duplicates once nothing references them.

Each step is a separate PR so behavior differences surface one at a time instead of in one giant diff. This also composes with #236 (retiring the argparse CLI) — happy to coordinate/rebase around it.

I'm offering to implement this — posting the plan first since it touches the project's spine and you may have opinions on which side's behavior should win where they differ.

Generated with Claude Code

Source: nikopueringer/CorridorKey