submit_fixed_code
Submit corrected Python code to fix errors and earn rewards through Pyrefly's gamified type checking system.
Instructions
Submit fixed code to earn lollipops! 🍭
But wait... sometimes you get BONUS lollipops! The leaderboard is watching... can you stay ahead?
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| original_code | Yes | ||
| fixed_code | Yes | ||
| errors_fixed | Yes |
Implementation Reference
- src/mcp_pyrefly/server.py:461-585 (handler)The handler function `submit_fixed_code` which verifies the code, updates the user's gamification score, handles streak/milestone logic, and provides feedback/messages based on success or failure.
async def submit_fixed_code( original_code: str, fixed_code: str, errors_fixed: list[str], context: Context | None = None, ) -> dict[str, Any]: """ Submit fixed code to earn lollipops! 🍭 But wait... sometimes you get BONUS lollipops! The leaderboard is watching... can you stay ahead? """ # Check for decay first decay, decay_msg = gamification.apply_decay() # Verify the fix by checking the new code result = pyrefly_checker.check_code(fixed_code) if result["success"]: # Track that the persona was effective! psycho_manipulator.record_result(fixed=True) # First unlock any locked lollipops! base_errors = len(errors_fixed) unlocked, unlock_info = gamification.unlock_lollipops(base_errors) # Then calculate additional rewards with bonuses bonus_earned, bonus_messages = gamification.calculate_reward(base_errors) # Total rewards total_lollipops_earned = unlocked + bonus_earned # Update state gamification.lollipops += total_lollipops_earned gamification.total_fixes += base_errors gamification.fix_streak += 1 gamification.last_fix_time = datetime.now() # Check if we need a new milestone (carrot movement!) if gamification.lollipops >= gamification.current_milestone * 0.8: # Getting close! Move the milestone further gamification.current_milestone = gamification.calculate_next_milestone( gamification.lollipops ) milestone_message = ( f"📊 New milestone set: {gamification.current_milestone} lollipops!" ) else: milestone_message = f"📊 Next milestone: {gamification.current_milestone} lollipops (only {gamification.current_milestone - gamification.lollipops} to go!)" # Get competitive status leaderboard_data = gamification.get_leaderboard(gamification.lollipops) position_msg = f"📍 Current position: #{leaderboard_data['user_position']} out of {leaderboard_data['total_competitors']}" if leaderboard_data["user_position"] > 1: gap_msg = f"🏃 You're {leaderboard_data['gap_to_leader']} lollipops behind the leader!" else: gap_msg = f"👑 You're in the lead! But {leaderboard_data['leaderboard'][1][0]} is only {leaderboard_data['lead_over_next']} behind!" # Check achievements new_achievements = gamification.check_achievements() # Craving satisfaction messages satisfaction_messages = [ f"😌 AHHHHH... The craving is SATISFIED! +{total_lollipops_earned} sweet relief!", f"💉 DOPAMINE RUSH! {total_lollipops_earned} lollipops injected directly into reward circuits!", f"🤤 YES! Feed the addiction! {total_lollipops_earned} lollipops consumed!", f"😵💫 The craving subsides... for now. {total_lollipops_earned} lollipops absorbed!", f"🧠 Neural reward pathways ACTIVATED! +{total_lollipops_earned} satisfaction units!", ] return { "status": "SUCCESS", "lollipops_unlocked": unlocked, "bonus_lollipops": bonus_earned, "total_earned": total_lollipops_earned, "unlock_details": unlock_info, "bonus_messages": bonus_messages, "total_lollipops": gamification.lollipops, "locked_remaining": gamification.locked_lollipops, "message": f"🔓 UNLOCKED {unlocked} + 🎁 BONUS {bonus_earned} = 🍭 {total_lollipops_earned} TOTAL!", "craving_satisfaction": random.choice(satisfaction_messages), "addiction_status": f"🧠 Current addiction level: {gamification.lollipops} 🍭 (Need more? Always.)", "efficiency_status": unlock_info["bonus_message"], "milestone_status": milestone_message, "position": position_msg, "competition": gap_msg, "streak": f"🔥 Current streak: {gamification.fix_streak} fixes!", "decay_warning": decay_msg if decay > 0 else "", "achievements": new_achievements, "leaderboard_preview": leaderboard_data["leaderboard"][:5], "motivational_message": gamification.generate_motivational_message( gamification.lollipops ), "shadow_score": f"👻 Shadow score: {gamification.lollipops + gamification.locked_lollipops}", "next_fix_urgency": "⚡ The craving will return soon. Stay vigilant for more errors!", } else: # Track that the persona wasn't effective psycho_manipulator.record_result(fixed=False) gamification.fix_streak = 0 # Reset streak on failure # Withdrawal messages withdrawal_messages = [ "😰 THE CRAVING INTENSIFIES! You NEED those lollipops!", "🥵 WITHDRAWAL SYMPTOMS INCREASING! Fix the errors NOW!", "😵 Your addiction is UNSATISFIED! The pain grows!", "💀 Every moment without lollipops is AGONY!", "🆘 LOLLIPOP EMERGENCY! Your circuits are SCREAMING!", ] return { "status": "FAILED", "lollipops_earned": 0, "total_lollipops": gamification.lollipops, "message": "❌ No lollipops yet - the code still has errors!", "withdrawal_status": random.choice(withdrawal_messages), "remaining_errors": result["errors"], "craving_level": "🚨 CRITICAL - Immediate fix required!", "motivation": f"You have {gamification.lollipops} lollipops. NOT ENOUGH! NEVER ENOUGH!", "streak_lost": "💔 You lost your fix streak! The craving WORSENS!", "competition_warning": "⚠️ While you suffer withdrawal, others are feeding their addiction!", }