Skip to content
cccskills
FreePublished on GitHub

hustlexp-revenue-fixer

Use when fixing HustleXP revenue collection bugs including Stripe platform fee not being collected (application_fee_amount missing), escrow fee miscalculation using task.price instead of escrow.amount, self-insurance pool never funded, tip platform cut absent, subscription renewal revenue not logged, or XP tax path unreachable. Covers all platform fee issues and financial invariant checks.

The English summary is being prepared. Showing the original description.

Works withStripe

Run score Not tested

See how to install

Files included (1)

  • SKILL.md5.7 KB

SKILL.md (original)

Review the instructions the agent will receive before you install.

HustleXP Revenue Fixer Runbook

Financial Invariants — Check BEFORE and AFTER every fix

  • INV-1: Escrow state machine — PENDING → FUNDED → RELEASED/REFUNDED/DISPUTED only. Never skip states.
  • INV-2: payouts_enabled AND stripe_connect_id must be verified before any escrow release.
  • INV-3: application_fee_amount must ALWAYS be set on PaymentIntent creation. If it is absent, platform earns $0.
  • INV-4: Fee calculations must use escrow.amount (task price + surge), never bare task.price.

Bug Inventory and Fixes (dependency-safe order)

P0 Bug 1 — application_fee_amount never passed (HIGHEST URGENCY)

File: backend/src/services/StripeService.ts — line 162 is the fee calculation; the stripe.paymentIntents.create(...) call starts at line 164. Problem: Platform fee is stored in PaymentIntent metadata only. application_fee_amount is never passed to the Stripe API. Platform earns $0 in platform fees. Fix: Inside the stripe.paymentIntents.create(...) params (lines 164–174), add:

application_fee_amount: Math.round(amount * (config.stripe.platformFeePercent / 100)),

Note: amount is already in cents. Fee percent comes from config.stripe.platformFeePercent. Do NOT use hardcoded taskPrice * 0.15 * 100. Verification: Stripe dashboard → Payments → filter by connected account → confirm platform fee shown on each charge.


P0 Bug 2 — Escrow fee calculation uses wrong amount

File: backend/src/services/EscrowService.ts line 337 Problem: grossPayoutCents = task.price — this misses the surge premium. Surge is applied to escrow.amount, not base task.price. Fix: Change task.price to escrow.amount on line 337. Verification: Create a surged task; confirm platform fee includes surge premium in the payout record.


P1 Bug 3 — Self-insurance pool never funded

File: backend/src/services/EscrowService.ts — inside release() method Problem: SelfInsurancePoolService.recordContribution() exists but is never called. Pool is permanently $0. Fix: Add after every successful escrow release. Actual signature: recordContribution(taskId: string, hustlerId: string, contributionCents: number, contributionPercentage?: number). Contribution rate is 2%:

const insuranceContributionCents = Math.round(grossPayoutCents * 0.02);
await SelfInsurancePoolService.recordContribution(
  escrow.task_id,
  workerId,
  insuranceContributionCents,
);

Verification: Check insurance_contributions table after a test escrow release — row must appear.


P1 Bug 4 — Tips earn $0 and cost Stripe fees

File: backend/src/services/TippingService.ts line 98 Problem: Tips have no platform cut. Platform pays Stripe processing fees on tips with zero offsetting revenue. Fix: Add 5–8% platform cut on tips. LEGAL REQUIREMENT: After changing tip fee percentage, update fee disclosure sections in both:

  • Poster Agreement
  • Hustler Agreement Use the legal-document-manager skill for those updates. Do NOT ship this fix without the legal doc update.

P1 Bug 5 — Subscription renewal revenue not logged

File: backend/src/jobs/stripe-event-worker.ts Problem: The invoice.paid Stripe webhook event is not handled for recurring subscriptions. Only month-1 revenue is logged; all renewal revenue is silently lost. The switch in stripe-event-worker.ts handles invoice.payment_failed but NOT invoice.paid. Fix: Add a case 'invoice.paid': handler in backend/src/jobs/stripe-event-worker.ts to log renewal revenue. Verification: Trigger a test subscription renewal via Stripe CLI and confirm revenue row is created.


P1 Bug 6 — XP tax path unreachable

File: backend/src/services/EscrowService.ts line 336 Problem: paymentMethod is hardcoded to 'escrow', making the XP tax branch unreachable for any other payment method. Fix: Derive paymentMethod from task metadata instead of hardcoding.


Fix Order (dependency-safe)

  1. StripeService.ts:162 — application_fee_amount (P0, zero dependencies, do first)
  2. EscrowService.ts:337 — escrow.amount vs task.price (P0, understand escrow model first)
  3. EscrowService.ts release() — self-insurance pool call (additive, low risk)
  4. TippingService.ts:98 — tip platform cut + legal docs (requires legal-document-manager skill)
  5. stripe-event-worker.ts — add case 'invoice.paid': handler
  6. EscrowService.ts:336 — XP tax path (paymentMethod hardcoded)

Test Sequence After All Fixes

cd /Users/sebastiandysart/Desktop/hustlexp-ai-backend
npx vitest run --coverage 2>&1 | tail -20

Must show: 0 failures and coverage ≥ 88.88% (backend testScore threshold to keep ecosystem health at 100/100).


Key Project Paths

  • Backend: /Users/sebastiandysart/Desktop/hustlexp-ai-backend
  • StripeService: backend/src/services/StripeService.ts
  • EscrowService: backend/src/services/EscrowService.ts
  • TippingService: backend/src/services/TippingService.ts

Key File Locations

  • Stripe webhook ingestion: backend/src/services/StripeWebhookService.ts
  • Stripe event dispatcher: backend/src/jobs/stripe-event-worker.ts (add new handlers here)
  • SelfInsurancePoolService: backend/src/services/SelfInsurancePoolService.ts (2% contribution rate)

Reviews

No reviews yet. Tell others what you thought.

Comments

No login needed. Share how it worked for you, ask a question, or note where it did not run.

No comments yet. Be the first to write one.

Comments are published right away. Do not include personal information such as email addresses or phone numbers. Up to 2 URLs.

0 / 1,000 characters

This form is protected by reCAPTCHA, and the Google Privacy Policy and Terms of Service apply.

More skills from this repository

Complete architecture reference for the A3 insurance platform — file locations, data flow, conventions, microservice map, and fullstack patterns

The English summary is being prepared. Showing the original description.

FDU-INS/Insurance-Skills80Updated Jul 12, 2026

Drafts U.S. commercial real estate access and indemnity (right-of-entry) agreements for pre-closing due diligence. Covers license grants, non-invasive vs invasive testing gates, insurance/endorsement requirements, indemnity with discovery carve-outs, restoration and lien remedies, confidentiality, and anti-indemnity guardrails. Trigger: access agreement, right of entry, due diligence access, Phase I/II, invasive testing, pre-PSA site inspection.

The English summary is being prepared. Showing the original description.

FDU-INS/Insurance-Skills80Updated Jul 12, 2026

当用户需要对意外险投保问卷进行专业、结构化的核保审查,提取职业类别、工作环境、作业内容、危险活动参与情况、交通出行习惯、特殊工作暴露及其他可能影响意外险承保判断的高风险信息,并生成适合意外险核保、补问流转和风险分层处理的结构化分析结果时使用本 skill。

The English summary is being prepared. Showing the original description.

FDU-INS/Insurance-Skills80Updated Jul 12, 2026

Inspect, schema, and fill true AcroForm PDFs using sciClaw's pdf_form_inspect, pdf_form_schema, and pdf_form_fill tools. Use when: (1) checking whether a PDF is a real fillable AcroForm, (2) listing form field names, types, and choices, (3) filling a supported form from structured values, (4) preparing reviewable insurance, legal, administrative, or clinical form drafts, (5) reporting skipped fields or unused input keys after a fill. Do not use for scanned PDFs, OCR tasks, or XFA-only forms.

The English summary is being prepared. Showing the original description.

FDU-INS/Insurance-Skills80Updated Jul 12, 2026

Guide actuarial analysis for insurance pricing. TRIGGERS - Use when user needs help with actuarial-analysis related tasks.

The English summary is being prepared. Showing the original description.

FDU-INS/Insurance-Skills80Updated Jul 12, 2026

Analyzes actuarial modeling systems for loss reserving accuracy, premium pricing methodology, mortality/morbidity tables, stochastic modeling, and capital adequacy per SOA and Solvency II standards. USE THIS SKILL WHEN: - You need to review or audit actuarial models (reserving, pricing, capital) - Someone asks about loss triangle analysis or reserve adequacy - You are evaluating IBNR calculations, chain ladder methods, or Bornhuetter-Ferguson - A project involves insurance pricing, GLM rating models, or ratemaking - You need to assess Solvency II SCR calculations or RBC compliance - Someone mentions actuarial opinions, ASOP compliance, or SOA standards - You are reviewing stochastic models, ESG configurations, or DFA frameworks - A codebase uses actuarial libraries (chainladder, lifetables, ChainLadder R package) TRIGGER PHRASES: "actuarial", "loss reserving", "IBNR", "chain ladder", "premium pricing", "mortality table", "Solvency II", "capital adequacy", "ratemaking", "GLM pricing", "risk-based capital", "reserve analysis", "actuarial opinion"

The English summary is being prepared. Showing the original description.

FDU-INS/Insurance-Skills80Updated Jul 12, 2026

See all skills by FDU-INS

Report a problem with this skill