Skip to content

refactor: isolate lossless cut configuration - #4

Merged
anaschatz merged 1 commit into
mainfrom
codex/maintainability-lossless-cut-config
Aug 5, 2026
Merged

refactor: isolate lossless cut configuration#4
anaschatz merged 1 commit into
mainfrom
codex/maintainability-lossless-cut-config

Conversation

@anaschatz

Copy link
Copy Markdown
Owner

Problem

shorts_generator/local/clipper.py owned the import-time parsing of the three lossless-cut cache environment variables alongside cache execution. This made the configuration contract harder to characterize and maintain inside the 7,599-line module.

Scope

  • Add one standard-library-only pure leaf, lossless_cut_config.py.
  • Preserve clipper.py as the compatibility facade and retain all three existing globals and monkeypatch targets.
  • Freeze exact defaults, parsing, types, malformed-value exceptions, path handling, and import-time snapshot behavior with characterization tests.
  • Add an engineering report for the slice.

Explicit non-goals

No changes to video output, FFmpeg arguments/codecs, timestamps, cache keys/schema/paths, hit/miss/pruning behavior, file touching, cleanup, logs, captions, highlights, HookGate, Real-ESRGAN, providers, Node services, APIs, migrations, infrastructure, authentication, or product features.

Dependency boundary

Before:

process environment
        |
        v
clipper.py parsing + facade globals + cache execution

After:

process environment mapping + LOCAL_CACHE_DIR
        |
        v
lossless_cut_config.py (pure parser, standard library only)
        |
        v
clipper.py facade globals + unchanged cache execution

Git identity and size

  • Base: e0513092bc1ccd4ab40c821af84146084c6f5c6f
  • Head: 735afb9aa615b599ed64c9f7cd858b6e812b331c
  • Production delta: +44 net LOC
  • clipper.py: 7,599 -> 7,590 LOC
  • New production module: 53 LOC
  • No new runtime dependency and no import cycle

Characterization evidence

Ten behavioral tests passed against the pre-extraction implementation. The extraction then added the pure-leaf and supplied-mapping boundary assertions, for 11 configuration tests total. They cover:

  • exact defaults and exported types;
  • enabled/disabled allowlist, case, whitespace, empty and unknown values;
  • relative, absolute, empty, spaced, Unicode and home-expanded paths;
  • binary GiB conversion, fractions, scientific notation, the 2 GiB floor and no upper cap;
  • exact ValueError/OverflowError behavior;
  • import-time snapshot and reload semantics;
  • preserved direct clipper.py monkeypatch targets;
  • absence of import-time directory creation.

Focused post-extraction checks:

  • configuration plus lossless planning: 22/22
  • BF editorial/cache patch-point suite: 48/48
  • Python compile, import direction and git diff --check: pass

Full regression results

Gate Baseline Final
npm run lint pass pass
npm run build pass pass
npm test 1,683 pass / 7 skip / 0 fail 1,683 pass / 7 skip / 0 fail
Python discovery 513/513 524/524
Isolated Python modules 52/52 53/53
HookGate quality 96.2981, hard guards pass unchanged
Fixture fingerprint 37ef626b9901ad2eeb1056d47954d88cdf2ede6430cc80e449bd5f9c7a91f9c9 unchanged
Metric fingerprint d62ce934e038d9026263ce2be7efa5f0c6e3ffac8a583d7b23b609540a5f4fe9 unchanged

Limitations and warnings

  • No fresh video fixture was rendered for this configuration-only refactor, so this PR does not claim fresh byte-identical or pixel-identical output.
  • npm audit reports five pre-existing moderate vulnerabilities in transitive Hono adapter/Hono and PostCSS packages; there are no high or critical findings.
  • The authoritative Node test runs required normal host execution because sandboxed Chrome launch/kill returned EPERM; both baseline and final host runs passed.

Next slice

Keep separate from this PR: characterization-first caption command/render planning extraction, retaining caption I/O, subprocess execution, logs, and facade patch points.

@anaschatz
anaschatz merged commit 33338d7 into main Aug 5, 2026
3 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