videogen/tests/reelforge/test_experiments.py
caelum0x d56639a594
Some checks are pending
build-images / api (push) Waiting to run
build-images / worker-gpu (push) Waiting to run
build-images / web (push) Waiting to run
codeql / Analyze (javascript-typescript) (push) Waiting to run
codeql / Analyze (python) (push) Waiting to run
perf / API hot-path micro-smoke (budgeted) (push) Waiting to run
perf / Desktop engine crates (release build check) (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (comfy-workflow-schema) (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (effects-core) (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (eventbus-types) (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (growth-analytics) (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (trends-schema) (push) Waiting to run
vision2026-ci / API phase modules (ruff + pytest) (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (provider-adapter-kit) (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (publishing-connectors) (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (render-core) (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (shot-template-schema) (push) Waiting to run
vision2026-ci / Python SDK resource tests (push) Waiting to run
vision2026-ci / Desktop engine crates (test + clippy + fmt) (push) Waiting to run
vision2026-ci / Alembic upgrade + drift check (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (caption-engine) (push) Waiting to run
Menivor — open source release (MIT), free to use and fork
Paid, hosted product at menivor.com, now retired as a company project.
Fresh squashed history of the cleaned working tree (secret-scanned,
no .env, no customer data, no outreach logs). Built on
MoneyPrinterTurbo (MIT, harry0703) — see NOTICE.
2026-12-04 02:10:26 +03:00

50 lines
1.6 KiB
Python

"""P7 A/B experiments — retention-weighted 1-body/N-hooks winner selection."""
from __future__ import annotations
from app.domains.publishing.experiments import (
VariantMetrics,
score_variant,
select_winner,
)
def _v(vid, hook, views=1000, comp=0.5, watch=0.5, rewatch=0.1, eng=0.05):
return VariantMetrics(vid, hook, views=views, completion_rate=comp,
avg_watch_frac=watch, rewatch_rate=rewatch, engagement_rate=eng)
def test_retention_dominates_score():
high_retention = _v("a", "hookA", comp=0.9, watch=0.8)
high_views_low_retention = _v("b", "hookB", views=100000, comp=0.2, watch=0.2)
assert score_variant(high_retention) > score_variant(high_views_low_retention)
def test_clear_winner_selected():
variants = [
_v("a", "hookA", comp=0.8, watch=0.7, rewatch=0.2),
_v("b", "hookB", comp=0.4, watch=0.3, rewatch=0.05),
]
res = select_winner(variants)
assert res.conclusive and res.winner_id == "a" and res.winner_hook_ref == "hookA"
def test_inconclusive_when_underpowered():
variants = [_v("a", "hookA", views=50), _v("b", "hookB", views=500)]
res = select_winner(variants)
assert not res.conclusive and "insufficient sample" in res.reason
def test_inconclusive_on_near_tie():
variants = [
_v("a", "hookA", comp=0.61, watch=0.6),
_v("b", "hookB", comp=0.60, watch=0.6),
]
res = select_winner(variants)
assert not res.conclusive and "inconclusive" in res.reason
def test_single_variant_inconclusive():
res = select_winner([_v("a", "hookA")])
assert not res.conclusive