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.
3.2 KiB
ReelForge marketplace — execution phases
Follows
PROVIDER_MARKETPLACE_PLAN.md. The catalog, wallet, routing domains, thePOST /jobsreserve/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-retryableProviderErrorfails hard; exhausting the route raisesRoutingError(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 gainssettle_job_actualso 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.