Phase 1 | Priority: P0 | Status: Not Started | Covers: FR-003
Objective
Modify the sign-up flow to capture referral code from the /join/[CODE] URL, validate it, and persist attribution to the new user record.
Acceptance Criteria
- Referral code extracted from URL param or cookie (survives redirect to sign-up form)
- Code validated against referral_codes table (reject invalid/revoked codes)
- referred_by set on new user record upon successful sign-up
- Fires referee_signup_attributed analytics event
- Self-referral blocked (user can't use own code)
Dependencies
Depends on: referred_by migration + referral_codes table. Blocks: reward grant service.