Skip to content

feat(referrals): add Kilo Pass referrals#3465

Open
jeanduplessis wants to merge 4 commits into
mainfrom
kilopass-referral
Open

feat(referrals): add Kilo Pass referrals#3465
jeanduplessis wants to merge 4 commits into
mainfrom
kilopass-referral

Conversation

@jeanduplessis
Copy link
Copy Markdown
Contributor

@jeanduplessis jeanduplessis commented May 25, 2026

Summary

Adds the Kilo Pass Impact Advocate referral program flow, reward lifecycle, attribution safeguards, and post-launch Kilo Pass bonus behavior.

  • Adds Kilo Pass-specific Impact Advocate configuration, widget/token routing, participant registration, and referral page UI.
  • Records product-scoped referral and affiliate touches, then resolves Kilo Pass paid conversions with referral-priority attribution.
  • Grants double-sided Kilo Pass referral rewards for eligible first monthly Stripe conversions, applies one pending reward per future eligible monthly issuance, and blocks stacking with other bonus-like issuance items.
  • Queues Impact Advocate reward redemptions for Kilo Pass reward allocations so Impact reporting matches the local reward ledger without making Impact the source of truth.
  • Handles Kilo Pass referral adverse-payment cancellation/review flows for refunds, fraud, and chargebacks.
  • Adds operational handling for referral state, including an hourly Kilo Pass referral reward expiration cron and a local script for applying pending referral bonuses during manual testing.
  • Redirects /subscriptions/kilo-pass visitors back to /subscriptions when they do not have a Kilo Pass subscription.
  • Removes the hidden month-2 50% welcome promo cutoff behavior so Kilo Pass matches the production first-month-only promo copy.

Verification

Full end-to-end manual verification of the Kilo Pass referral flow with Impact Advocate, including signup attribution, paid conversion, local reward allocation/application, SALE reporting, and Impact Advocate reward redemption retry behavior.

Visual Changes

image image image Helium 2026-05-26 17 33 27 Helium 2026-05-26 17 33 35

Reviewer Notes

  • Spec alignment: this PR implements and updates behavior governed by .specs/impact-referrals.md, especially Kilo Pass program separation, 30-day attribution, reward expiry, Impact redemption reporting, and first-month-only welcome bonus behavior.
  • Impact redemption is reporting/reconciliation only. The local referral reward ledger remains authoritative for eligibility, application, cancellation, reversal, billing, and access.
  • Operational behavior: Kilo Pass referral reward expiry uses the hourly Vercel cron at /api/cron/kilo-pass-expire-referral-rewards; queued affiliate/Advocate dispatch now also backfills missing Kilo Pass reward redemption rows.
  • Product isolation: Kilo Pass Advocate config is treated as invalid if it reuses KiloClaw/default program or widget IDs.
  • Review focus: attribution resolution for first paid Kilo Pass Stripe invoices, affiliate SALE suppression, referral_bonus mutual exclusion with normal bonus issuance, and Impact Advocate redemption retry/failure states.

@kilo-code-bot
Copy link
Copy Markdown
Contributor

kilo-code-bot Bot commented May 25, 2026

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Executive Summary

Incremental review of 3 changed files (since fcc9a0b1f) — the rename of the Kilo Pass Impact reward unit from 'USD' to 'Kilo Pass Bonus Credits' is consistent across implementation, tests, and spec; no issues found.

Incremental Changes Reviewed (3 files)
  • .specs/impact-referrals.md — spec updated to name the Kilo Pass Bonus Credits unit; changelog entries added
  • apps/web/src/lib/impact/kiloclaw-referrals.tsIMPACT_ADVOCATE_KILO_PASS_REWARD_UNIT constant renamed from 'USD' to 'Kilo Pass Bonus Credits'
  • apps/web/src/lib/impact/kilo-pass-referrals.test.ts — all test fixtures and assertions updated to match the new unit string
Previously Resolved Issues (all confirmed fixed)
File Issue
apps/web/src/app/api/cron/kilo-pass-expire-referral-rewards/route.ts Fixed: isExpectedCronAuthorization uses timingSafeEqual with length guard
apps/web/src/lib/impact/kilo-pass-referrals.ts Fixed: KILO_PASS_REFERRER_REWARD_CAP exported; affiliate cookie fallback comment present
apps/web/src/lib/impact/kiloclaw-referrals.ts Fixed: comment explains expires_at column ignored in favour of touched_at + 30d
apps/web/src/routers/kilo-pass-router.ts Fixed: duplicate constant removed, imported from kilo-pass-referrals.ts

Reviewed by claude-sonnet-4.6 · 471,378 tokens

Review guidance: REVIEW.md from base branch main

Comment thread apps/web/src/routers/kilo-pass-router.test.ts Outdated
Comment thread apps/web/src/routers/kilo-pass-router.test.ts Outdated
Comment thread apps/web/src/routers/kilo-pass-router.ts
Comment thread apps/web/src/lib/impact/kilo-pass-referrals.ts
Comment thread apps/web/src/app/api/cron/kilo-pass-expire-referral-rewards/route.ts Outdated
Comment thread apps/web/src/lib/impact/kiloclaw-referrals.ts
@jeanduplessis jeanduplessis force-pushed the kilopass-referral branch 4 times, most recently from 9af82dc to ec4d5ed Compare May 28, 2026 12:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants