Commit graph

4 commits

Author SHA1 Message Date
Ashwin Kumar Sivakumar
eefc0457be fix(test): use a fresh random user per ai_credits_reaper.rs run
All checks were successful
build-and-release / build (catering-services) (push) Successful in 1m31s
build-and-release / build (cron) (push) Successful in 1m54s
build-and-release / build (companies) (push) Successful in 2m7s
build-and-release / build (customers) (push) Successful in 2m53s
build-and-release / build (fitness-trainers) (push) Successful in 1m29s
build-and-release / build (developers) (push) Successful in 1m43s
build-and-release / build (gateway) (push) Successful in 1m35s
build-and-release / build (employees) (push) Successful in 2m15s
build-and-release / build (jobs) (push) Successful in 1m10s
build-and-release / build (graphic-designers) (push) Successful in 2m9s
build-and-release / build (makeup-artists) (push) Successful in 1m35s
build-and-release / build (photographers) (push) Successful in 1m44s
build-and-release / build (job-seekers) (push) Successful in 3m8s
build-and-release / build (payments) (push) Successful in 2m45s
build-and-release / build (social-media-managers) (push) Successful in 2m35s
backend-integration-tests / ai-credits (push) Successful in 50s
build-and-release / build (tutors) (push) Successful in 3m10s
build-and-release / build (ugc-content-creators) (push) Successful in 2m49s
build-and-release / build (video-editors) (push) Successful in 2m48s
build-and-release / build (users) (push) Successful in 4m38s
The fixed UUID (33333333-...) meant every re-run against the same
persistent test database reused the same wallet - any earlier partial
run that panicked before its own capture/release step left
reserved_credits permanently stuck above zero, so this run's fresh
reserve (expected to bring it to exactly 4) actually reads 8, 12, etc.
depending on how many times the suite had previously failed midway.
Matches ai_credits.rs's make_user() pattern (Uuid::new_v4()) instead.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-08-13 22:09:33 +05:30
Ashwin Kumar Sivakumar
85690b3002 fix(test): make ai_credits_reaper.rs resilient to accumulated stale holds
Some checks failed
build-and-release / build (catering-services) (push) Successful in 1m30s
build-and-release / build (employees) (push) Successful in 1m42s
build-and-release / build (cron) (push) Successful in 2m11s
build-and-release / build (companies) (push) Successful in 2m16s
build-and-release / build (gateway) (push) Successful in 39s
build-and-release / build (developers) (push) Successful in 2m49s
build-and-release / build (customers) (push) Successful in 3m0s
build-and-release / build (graphic-designers) (push) Successful in 1m36s
build-and-release / build (jobs) (push) Successful in 1m46s
build-and-release / build (fitness-trainers) (push) Successful in 2m54s
build-and-release / build (job-seekers) (push) Successful in 2m17s
build-and-release / build (photographers) (push) Successful in 1m43s
build-and-release / build (payments) (push) Successful in 2m45s
build-and-release / build (makeup-artists) (push) Successful in 3m6s
build-and-release / build (social-media-managers) (push) Successful in 2m34s
backend-integration-tests / ai-credits (push) Failing after 1m7s
build-and-release / build (tutors) (push) Successful in 2m46s
build-and-release / build (ugc-content-creators) (push) Successful in 3m1s
build-and-release / build (users) (push) Has been cancelled
build-and-release / build (video-editors) (push) Has been cancelled
The sweep query is intentionally global (matches the real cron
reaper), but against a persistent, never-reset test database re-run
many times over a debugging session, other tests' un-captured/
un-released reservations eventually go stale and get picked up
alongside this test's own hold, breaking the exact-match assertion
(observed: 6 expired holds instead of 1). Clear pre-existing stale
'held' rows first, matching the clean slate a continuously-running
production reaper would actually maintain.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-08-13 22:01:24 +05:30
Ashwin Kumar Sivakumar
b48a1dd204 fix(test): self-provision the fixture user in ai_credits_reaper.rs
Some checks failed
build-and-release / build (cron) (push) Successful in 1m0s
build-and-release / build (catering-services) (push) Successful in 1m29s
build-and-release / build (companies) (push) Successful in 1m52s
build-and-release / build (customers) (push) Successful in 2m13s
build-and-release / build (employees) (push) Successful in 2m20s
build-and-release / build (gateway) (push) Successful in 1m1s
build-and-release / build (developers) (push) Successful in 3m9s
build-and-release / build (fitness-trainers) (push) Successful in 2m50s
build-and-release / build (job-seekers) (push) Successful in 1m54s
build-and-release / build (jobs) (push) Successful in 1m55s
build-and-release / build (graphic-designers) (push) Successful in 2m38s
build-and-release / build (makeup-artists) (push) Successful in 2m59s
build-and-release / build (photographers) (push) Successful in 1m52s
build-and-release / build (payments) (push) Successful in 2m45s
backend-integration-tests / ai-credits (push) Failing after 51s
build-and-release / build (social-media-managers) (push) Successful in 2m40s
build-and-release / build (tutors) (push) Successful in 2m51s
build-and-release / build (ugc-content-creators) (push) Successful in 2m53s
build-and-release / build (video-editors) (push) Has been cancelled
build-and-release / build (users) (push) Has been cancelled
expired_hold_is_swept_and_credits_return_to_available used a hardcoded
UUID assuming a matching users row already existed in whatever
database it ran against, but user_ai_subscriptions.user_id has a FK to
users(id) - against a fresh database (like CI's nxtgauge_test) this
failed with a foreign key violation before the actual sweep/release
logic under test ever ran. Provision it inline instead, matching
ai_credits.rs's make_user() pattern.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-08-13 21:52:54 +05:30
Ashwin Kumar Sivakumar
0dd5045676 feat: Complete Ask Ash AI Credits implementation on high-performance branch (Tasks 1-10)
- Task 1: Admin endpoints for wallet management
- Task 2: AI Credits admin UI (pricing.tsx, credit.tsx)
- Task 3: Ollama security (NetworkPolicy, prompt validation, audit)
- Task 4: LiteLLM integration (litellm.rs, migrated AI feature handlers)
- Task 5: Refund architecture (ai_refunds table, endpoints)
- Task 6: Coupons, promotions, referrals (order creation with coupon)
- Task 7: Subscription lifecycle (plan upgrades/downgrades, cron jobs)
- Task 8: Credit expiration enforcement (daily cron task)
- Task 9: Token cost engine (ai_model_cost_config, margin view)
- Task 10: Observability (metrics tables, aggregation function)

Cherry-picked from main branch commit 3c0f45f
2026-07-06 01:49:16 +05:30