Skip to content

chore(referrals): retire the KiloClaw referral program - #5393

Open
jobrietbergen wants to merge 1 commit into
mainfrom
chore/remove-kiloclaw-referral-program
Open

chore(referrals): retire the KiloClaw referral program#5393
jobrietbergen wants to merge 1 commit into
mainfrom
chore/remove-kiloclaw-referral-program

Conversation

@jobrietbergen

Copy link
Copy Markdown
Contributor

Why

Fresh KiloClaw instance provisioning is closed, so no account can make a first paid KiloClaw subscription payment. No KiloClaw referral can ever be earned again, and the program's attribution logic was still suppressing affiliate SALE reporting on KiloClaw renewals. This retires the KiloClaw Advocate referral program and leaves Kilo Pass as the only live referral program.

What changed

  • No new KiloClaw referral state. KiloClaw referral touches, Advocate participants, conversions, reward decisions, and rewards are no longer created. getImpactAdvocateConfig only resolves the Kilo Pass program, and /api/impact-advocate/token rejects product=kiloclaw instead of silently serving a Kilo Pass token. The retired program ID 51699 and its widget path are still rejected if a Kilo Pass misconfiguration points at them.
  • Shared machinery extracted. lib/impact/kiloclaw-referrals.ts is replaced by lib/impact/referral-attribution.ts (winning-touch resolution) and lib/impact/referral-delivery.ts (conversion reports, Advocate redemption queue, reward-bearing config checks) used by Kilo Pass.
  • Affiliate tracking preserved. Renewals of existing KiloClaw subscriptions still report affiliate SALEs, now enqueued directly instead of gated on referral attribution — in the Stripe invoice handler, the credit-billing path, and the kiloclaw-billing lifecycle worker (process_paid_conversion side effect replaced by enqueue_affiliate_event). Affiliate touch parsing keeps the KiloClaw product scope; referral touch parsing now returns null when a URL targets no live program.
  • UI removed. /claw/refer, the "Refer & Earn" sidebar entry, ReferralRewardsSummary/ReferralRewardStatusCard, and the referralRewards billing payload are gone. The admin surface moved from /admin/kiloclaw-referrals to /admin/impact-referrals, defaults to Kilo Pass, and keeps a "KiloClaw (retired)" option so support can still read retained history.
  • Data close-out. Migration 0221_retire_kiloclaw_referral_rewards cancels pending/earned KiloClaw free-month rewards with review_reason = 'kiloclaw_referral_program_retired' and fails their queued Advocate redemptions so the shared sweep stops retrying forever. Already-applied free months are not reversed and historical rows are retained.
  • Config/env. IMPACT_ADVOCATE_KILOCLAW_PROGRAM_ID / IMPACT_ADVOCATE_KILOCLAW_WIDGET_ID removed; ENVIRONMENT.md updated. Referral seed topics and helpers removed.
  • Spec. .specs/impact-referrals.md gains a KiloClaw retirement section (69a–69g) and changelog entry; the old KiloClaw rules are retained as history.

Verification

  • pnpm --filter web typecheck, scripts/typecheck-all.sh --changes-only, pnpm lint, pnpm format:check — pass
  • pnpm --filter web test --testPathPatterns="(impact|referral|kiloclaw|billing-side-effects|dispatch-affiliate-events|billing-types|stripe)" — 73 suites, 1286 tests pass
  • pnpm --filter kiloclaw-billing test — 186 tests pass (lifecycle stubs/assertions updated for the side-effect rename)
  • pnpm --filter @kilocode/db test, pnpm test:dev-local, pnpm test:web-env — pass
  • Migration applied locally via pnpm test:db

Not run: the full pnpm test and full-repo typecheck.

Fresh KiloClaw provisioning is closed, so no account can make a first paid
KiloClaw subscription payment and no KiloClaw referral can ever be earned.
Remove the KiloClaw Advocate referral program and keep Kilo Pass as the only
live referral program.

- Stop creating KiloClaw referral touches, participants, conversions, reward
  decisions, and rewards; KiloClaw Advocate config no longer resolves and the
  Advocate token endpoint rejects `product=kiloclaw`.
- Split the shared referral machinery out of `kiloclaw-referrals.ts` into
  `referral-attribution.ts` and `referral-delivery.ts` for Kilo Pass.
- Report KiloClaw affiliate SALEs directly for renewals of existing
  subscriptions instead of routing them through referral attribution, in both
  the web Stripe/credit paths and the billing lifecycle worker.
- Drop the KiloClaw refer page, sidebar entry, and referral reward UI; rename
  the admin investigation surface to Impact referrals with KiloClaw retained
  read-only for support history.
- Migration 0221 cancels unapplied KiloClaw rewards and terminates their queued
  Advocate redemptions. Applied free months and historical records stand.
@kilo-code-bot

kilo-code-bot Bot commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Executive Summary

Reviewed the KiloClaw referral retirement across conversion, billing, migration, and UI paths at HEAD 8c029e3e76045312199fffef5d7596aea1264337 with high confidence that live KiloClaw referral state is no longer created and affiliate SALE reporting remains intact.

Files Reviewed (57 files)
  • .specs/impact-referrals.md
  • CONTRIBUTING.md
  • ENVIRONMENT.md
  • apps/storybook/stories/Sidebar.stories.tsx
  • apps/web/src/app/(app)/claw/components/billing/ReferralRewardStatusCard.test.ts
  • apps/web/src/app/(app)/claw/components/billing/ReferralRewardStatusCard.tsx
  • apps/web/src/app/(app)/claw/components/billing/ReferralRewardsSummary.test.ts
  • apps/web/src/app/(app)/claw/components/billing/ReferralRewardsSummary.tsx
  • apps/web/src/app/(app)/claw/components/billing/SubscriptionCard.tsx
  • apps/web/src/app/(app)/claw/components/billing/billing-types.test.ts
  • apps/web/src/app/(app)/claw/components/billing/billing-types.ts
  • apps/web/src/app/(app)/claw/refer/page.tsx
  • apps/web/src/app/(app)/components/PersonalAppSidebar.tsx
  • apps/web/src/app/(app)/subscriptions/kilo-pass/refer/page.tsx
  • apps/web/src/app/admin/api/users/[id]/kiloclaw-referral-eligibility/route.test.ts
  • apps/web/src/app/admin/api/users/[id]/kiloclaw-referral-eligibility/route.ts
  • apps/web/src/app/admin/components/AppSidebar.tsx
  • apps/web/src/app/admin/components/ImpactReferralsInvestigation.test.ts
  • apps/web/src/app/admin/components/ImpactReferralsInvestigation.tsx
  • apps/web/src/app/admin/impact-referrals/page.tsx
  • apps/web/src/app/admin/kiloclaw-referrals/page.tsx
  • apps/web/src/app/api/cron/dispatch-affiliate-events/route.test.ts
  • apps/web/src/app/api/cron/dispatch-affiliate-events/route.ts
  • apps/web/src/app/api/impact-advocate/token/route.ts
  • apps/web/src/app/api/internal/kiloclaw/billing-side-effects/route.test.ts
  • apps/web/src/app/api/internal/kiloclaw/billing-side-effects/route.ts
  • apps/web/src/components/referrals/ImpactAdvocateReferralCard.test.ts
  • apps/web/src/components/referrals/ImpactAdvocateReferralCard.tsx
  • apps/web/src/components/referrals/ImpactAdvocateReferralCard.utils.ts
  • apps/web/src/components/subscriptions/kiloclaw/KiloClawDetail.tsx
  • apps/web/src/lib/config.server.ts
  • apps/web/src/lib/impact/advocate.test.ts
  • apps/web/src/lib/impact/advocate.ts
  • apps/web/src/lib/impact/kilo-pass-referrals.test.ts
  • apps/web/src/lib/impact/kilo-pass-referrals.ts
  • apps/web/src/lib/impact/kiloclaw-referrals.test.ts
  • apps/web/src/lib/impact/kiloclaw-referrals.ts
  • apps/web/src/lib/impact/referral-attribution.ts
  • apps/web/src/lib/impact/referral-delivery.ts
  • apps/web/src/lib/impact/referral-utils.test.ts
  • apps/web/src/lib/impact/referral-utils.ts
  • apps/web/src/lib/impact/referral.test.ts
  • apps/web/src/lib/impact/referral.ts
  • apps/web/src/lib/kiloclaw/credit-billing.ts
  • apps/web/src/lib/kiloclaw/stripe-handlers.ts
  • apps/web/src/lib/stripe/index.ts
  • apps/web/src/routers/admin-router.ts
  • apps/web/src/routers/admin/impact-referrals-router.test.ts
  • apps/web/src/routers/admin/impact-referrals-router.ts
  • apps/web/src/routers/kiloclaw-router.test.ts
  • apps/web/src/routers/kiloclaw-router.ts
  • dev/seed/AGENTS.md
  • dev/seed/kiloclaw/referrals-cap-boundary.ts
  • dev/seed/kiloclaw/referrals-happy-path.ts
  • dev/seed/kiloclaw/referrals-pending-referrer.ts
  • dev/seed/kiloclaw/referrals-support-override.ts
  • dev/seed/lib/kiloclaw-referrals.ts
  • packages/db/src/migrations/0221_retire_kiloclaw_referral_rewards.sql
  • packages/db/src/migrations/meta/_journal.json
  • services/kiloclaw-billing/src/lifecycle.test.ts
  • services/kiloclaw-billing/src/lifecycle.ts

Reviewed by grok-4.6 · Input: 368.5K · Output: 30.7K · Cached: 1.4M

Review guidance: REVIEW.md from base branch main

@jobrietbergen
jobrietbergen requested a review from jrf0110 August 21, 2026 16:15
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.

1 participant