videogen/BUILD-LOG-2026-10-24.md
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

182 lines
11 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# Build Log — 2026-10-24
## Round 1
Picked up backlog item 4 from `BUILD-LOG-2026-10-23.md` ("Remaining from the backlog"):
*"Launch as paid ad" action on `/ad-studio/[id]` wiring the existing Meta/TikTok clients
into the `/ads/new -> /ads/[key] -> /ads/report` flow.*
### Item 4 — "Launch as paid ad" entry point on the Ad Studio project page (BUILT, full)
Audited first: the paid-ads backend (`app/domains/ads/{service,store,reporting,router}.py`,
`controllers/v1/ads.py`) and the `/ads/new` web flow (`LaunchForm.tsx`, already supports a
`?project=<id>` prefill that preselects the Ad Studio project and lets the creator pick which
finished variants to run) were both already fully built and tested (23 passing tests in
`tests/reelforge/test_ads_paid.py`). The real, confirmed gap: nothing on `/ad-studio/[id]`
(`ProjectView.tsx`) ever told a creator this flow existed or linked to it — a finished ad
project had an organic "Publish and test" section but no way to discover paid launch short of
manually guessing the `/ads/new` URL and re-picking the project from a dropdown.
- `apps/api/app/domains/ads/reporting.py` — `campaign_view` (and therefore `campaign_summary`,
used by `GET /ads/campaigns`) now reports `project_id` per campaign. Every creative in a
campaign is launched from one project (`service.creatives_for` resolves all `variant_ids`
against a single `project_id` and 404s otherwise — confirmed by reading `service.launch`),
so the first row's `variant.project_id` describes the whole campaign; no new query, no schema
change (campaigns are already stored on `AdVariant.spec`, not a separate table).
- `apps/web/src/features/ads/api.ts` — `CampaignSummary.project_id: string` added to match.
- `apps/web/src/features/ad-studio/LaunchPaidAd.tsx` (new) — loads the ads gate
(`GET /ads/status`) and the caller's campaigns, filters to this project, and renders:
any paid campaigns already launched from this project (reusing `ads/CampaignList.tsx`,
so the card is identical to the one on `/ads`) plus a "Launch as paid ad" button to
`/ads/new?project=<id>` (reusing `ads/GateNotice.tsx` when Meta/TikTok app review is still
pending, so the gate message is identical everywhere it appears). Disabled, with an inline
reason, when the project has zero finished (`done`) ads yet.
- `apps/web/src/features/ad-studio/ProjectView.tsx` — new "Paid ads" section between
"Publish and test" (organic) and the Rally "Find buyers" bridge, passing the already-computed
`readyCount`.
- No icon/label literally says "Enter"; the launch action uses a Rocket glyph (matches
`LaunchForm.tsx`'s own "Create campaign" button), no emoji anywhere.
### Verification
- `npx tsc --noEmit` (full `apps/web`) — clean, 0 errors, both before and after.
- `npx eslint` on the 3 changed/new web files — clean.
- `.venv/bin/python3 -m pytest tests/reelforge/test_ads_paid.py` — 23 passed (the additive
`project_id` key does not break any existing assertion, confirmed by reading every
`campaign_view`/`campaign_summary` call site in the test file first).
- `.venv/bin/python3 -m pytest tests/reelforge -k "ads or adstudio"` — 228 passed, 3 skipped.
- `ruff check apps/api/app/domains/ads/reporting.py` — clean.
- Ran the real Next.js dev server (`npm run dev` in `apps/web`) and requested
`/ad-studio/test123` directly: compiled with no build error, `GET /ad-studio/test123 200`,
response HTML has no error boundary / `Application error` markers. Full interactive
click-through needs a real Clerk-authenticated session with an Ad Studio project, which this
sandbox does not have credentials for — not attempted further than the compile+200 check
above. No automated test files were added, per the owner's standing instruction.
### Not started this round (still open from the 2026-10-23 backlog)
- Item 3 — launch-offer / discount-code billing primitive.
- Item 6 — Template Marketplace remix attribution + revenue-share ledger.
- Item 7 — `/from-app-store/[category]` programmatic pages.
No owner-only blockers hit this round.
## Round 2
Picked up backlog item 3: the launch-offer / discount-code billing primitive
(`discount_codes` table + redemption + `/pricing` banner), built end to end.
### Item 3 — Discount codes: catalog, redemption, `/pricing` banner + apply field (BUILT, full)
Audited first: plan prices/provider product ids are config-driven, fixed-amount
products per provider (`app/services/billing/plans.py`) — there is no generic
"charge a dynamic amount" path across the 6 payment rails. Dodo Payments is the
one ACTIVE provider (`payments_mode.active_provider()`; every other MOR
provider is blocked at `_require_active_provider` already) and Dodo's own
checkout API accepts a `discount_codes: string[]` parameter that it resolves
authoritatively server-side (confirmed via the `dodopayments:discounts-and-
promotions` skill) — so the real price-off is forwarded to Dodo, never
computed by us, while this round's new local catalog exists purely for
preview/banner/redemption-tracking.
Backend (Python):
- `apps/api/app/models/db/discount.py` (new) — `DiscountCode` (code, percent/
flat amount, plan scope, `max_redemptions`/`redemption_count`,
`is_public_banner` + `banner_text`, date window) and `DiscountRedemption`
(one row per user per code, `UNIQUE(discount_code_id, user_id)` — the entire
"one use per customer" + idempotency story, exactly like the existing
`metered_usage.idempotency_key` pattern). Registered in `models.py`.
- `migrations/versions/20261024_1100_c3d5e7f9b1a2_discount_codes.py` (new) —
both tables, purely additive. Verified by running the real upgrade AND
downgrade against a seeded sqlite DB stamped at the prior head (a full
from-scratch `alembic upgrade head` replay is broken on sqlite by an
unrelated pre-existing Postgres-only `ALTER COLUMN` migration — not touched).
- `apps/api/app/services/billing/discounts.py` (new) — `validate_code`
(unknown/inactive/expired/scope/already-used, all raising one client-safe
`DiscountError`), `preview` (priced before/after for a plan), `active_banner`
(the current public `/pricing` promo, never raises), `redeem` (race-safe:
the global cap is enforced by an atomic bounds-checked `UPDATE ... WHERE
redemption_count < max_redemptions`, and a concurrent/replayed redemption for
the same user+code is swallowed via the unique constraint, mirroring
`card_check.fulfill`'s idempotency style).
- `apps/api/app/services/billing/dodo_client.py` — `create_checkout` gained an
optional `discount_codes` kwarg, forwarded to Dodo's `/checkouts` body only
when non-empty (byte-identical request when omitted).
- `apps/api/app/services/billing/dodo_billing.py` — `open_pack_checkout` gained
`discount_code`, forwarded to Dodo's checkout AND into our own `metadata` (so
fulfilment can redeem later, never at checkout-creation since the buyer may
abandon the page); `fulfill_payment`'s pack branch now calls
`discounts.redeem(...)` after crediting, best-effort (never blocks the grant).
- `apps/api/app/services/billing/service.py` — `create_checkout` gained
`discount_code`; validated via `discounts.validate_code` regardless of
provider (so a bad code always raises `ValueError` before any provider
call), but only forwarded on `provider="dodo"` — any other provider with a
code raises a clear `ValueError` rather than silently charging full price.
- `apps/api/app/controllers/v1/billing.py` — `POST /billing/checkout` passes
`discount_code` through only when present (so the pre-existing
`_CapturingService` test double's narrower signature keeps working
unchanged); two new endpoints, `GET /billing/discount/active` (public promo
for the banner, degrades to `{"active": false}` on any failure, never 404/
500) and `POST /billing/discount/preview` (validates + prices a code,
optionally per-user via `x-api-key`).
- `apps/api/app/models/schema.py` — `CheckoutRequest.discount_code` (optional,
case preserved) + new `DiscountPreviewRequest/Response` and
`ActiveDiscountResponse` schemas.
Frontend (web):
- `apps/web/components/marketing/DiscountBanner.tsx` (new) — fetches the
active banner on `/pricing`, renders nothing on any failure/no-promo, has a
copy-to-clipboard affordance (Tag/Copy/Check glyphs, no emoji, no literal
"Enter" button).
- `apps/web/components/marketing/DiscountCodeField.tsx` (new) — inline "promo
code" input + Apply glyph (`ArrowRight`), validates via the new preview
endpoint before checkout, shows the real $/% savings or a friendly error.
- `apps/web/components/marketing/CheckoutPlans.tsx` — renders the banner (when
checkout is open) and the apply field (only when `provider === "dodo"`,
since that is the only provider the backend will forward a code to);
forwards the applied code into `createCheckout`'s body.
- `apps/web/lib/types.ts` / `apps/web/lib/api.ts` — `CheckoutRequest.
discount_code`, `DiscountPreview(Request)`, `ActiveDiscount`,
`getActiveDiscount`, `previewDiscount`.
### Verification
- `.venv/bin/python3 -m alembic heads` — single head (`c3d5e7f9b1a2`); seeded a
throwaway sqlite DB at the prior head and ran the REAL `upgrade head` then
`downgrade -1` — both succeeded, `PRAGMA table_info` confirms the exact
column set on both new tables.
- Ad-hoc functional script against an in-memory sqlite ORM session (no new
test files added, per standing instruction) exercising `discounts.py`
directly: `preview` (valid + plan-scope-rejected + unknown-code-rejected),
`redeem` + idempotent retry (same payment id) + already-used-by-this-user
rejection + a different user still succeeding, and the `max_redemptions=1`
cap correctly blocking a second user while leaving exactly 1 redemption row
— every assertion passed.
- A second ad-hoc script monkeypatched `dodo_client.request` and confirmed:
no `discount_codes` key in the body when no code is given (unchanged
request shape), the key present and correct when a code is given, and
`dodo_billing.open_pack_checkout` threads the code into both the Dodo
parameter and our own metadata.
- `service.create_checkout(..., provider="stripe", discount_code="X")` raises
the expected clear `ValueError` before any provider call.
- `ruff check` on all 7 changed/new Python files — clean.
- `pytest tests/reelforge/test_billing.py tests/reelforge/test_billing_api.py
tests/reelforge/test_billing_providers.py` — initially 4 failures (a
pre-existing test double's `create_checkout` signature didn't accept
`discount_code`); fixed by only passing the kwarg when non-empty rather than
editing the test — rerun: 57/57 passed. Broader
`pytest tests/reelforge -k "billing or dodo or discount"` — 158 passed, 1
skipped.
- `npx tsc --noEmit` (full `apps/web`) — clean. `npx eslint` on the 5 changed/
new web files — clean. `npx vitest run` on the 3 existing `/pricing` test
files — 16/16 passed.
- Ran the real Next.js dev server and requested `/pricing` directly: compiled
(1539 modules), `GET /pricing 200`, no error-boundary markers.
No owner-only blockers hit this round. Next up: Item 6 (Template Marketplace
remix attribution + revenue-share ledger), Item 7 (`/from-app-store/[category]`
pages), and an owner-side step this item still needs — actually CREATING the
matching discount object in the Dodo dashboard/API for any code inserted into
`discount_codes` (the two catalogs must share the same `code` string; this
round only built the primitive, not a specific live launch code).