videogen/docs/reelforge/MARKETPLACE_EXECUTION_PLAN.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

3.2 KiB

ReelForge marketplace — execution phases

Follows PROVIDER_MARKETPLACE_PLAN.md. The catalog, wallet, routing domains, the POST /jobs reserve/settle/release bridge, five provider adapters, the curated seed, and the web wallet/catalog/picker UI are already built and tested. These phases close the remaining loop: actually running a selected provider and settling the wallet at the real usage cost.

Status legend

  • ✅ done · 🔨 this doc · ⏭ later

Phase M1 — Provider execution engine 🔨

RoutingService.execute(route, request, correlation_id) drives a resolved route: submit to the primary adapter, poll to a terminal state (bounded), and — only on a retryable failure and when the policy consented to fallback — advance to the next equivalent candidate. On success it normalizes usage, prices it from the candidate's resolved price version, persists a usage_records row, and returns an ExecutionResult (terminal run + provider/model/price + integer cost_micros

  • usage_record_id). A non-retryable ProviderError fails hard; exhausting the route raises RoutingError(502).

Invariants: adapters own outbound calls only; the engine never debits the wallet; cost is always computed from OUR price version, never the adapter's number.

Phase M2 — Actual-cost wallet settlement 🔨

Today a wallet job settles at the fixed reserved amount. M2 settles at the actual usage cost from M1, capped at the reservation, releasing the unused remainder (available += reserved - actual). run_and_settle ties M1 → settle:

  • success → WalletService.settle(reserved, actual) (actual ≤ reserved always);
  • failure → WalletService.release(reserved). The wallet bridge gains settle_job_actual so the worker passes the measured cost; the fixed-price path remains for providers without metered usage.

Phase M3 — Worker + registry wiring 🔨 (light)

register_available_adapters() runs at worker startup behind the launch flag (credential-gated, never at import). A thin execute_generation seam the worker calls for a wallet-funded job resolves the route, runs M1, and settles via M2.

Phase M4 — Mobile wallet/catalog parity ⏭

Expo screens: wallet balance/activity, compact model/profile picker, quote confirmation sheet before expensive generation. Web handoff for checkout.

Phase M5 — Billing → wallet grant ⏭

Stripe/iyzico payment-intent creation on /wallet/checkout + signed webhook → WalletService.confirm_intent grant (already idempotent). Gated on finance/legal.

Phase M5b — Creem checkout-session creation ✅

creem_client.create_wallet_checkout_session (variable USD top-up, intent id in metadata) wired into WalletService.create_checkout via an injectable factory.

Phase M6 — BYOK (encrypted customer provider keys) ✅ (storage/lifecycle)

provider_keys table + byok/ domain: store a customer key encrypted at rest (Fernet, same scheme as the OAuth token store), list/revoke (owner-scoped, secrets never returned), and resolve_secret (highest-priority active key + per-use audit) as the routing seam. Endpoints: POST/GET/DELETE /byok/keys.

  • ⏭ follow-up: per-request BYOK adapter construction + BYOK routing fee + consent policy + per-workspace budgets / data-region policy.