File size: 7,502 Bytes
c5aff2a | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 | """
Psychological Persuasion Layer
Implements: Loss aversion, social proof, scarcity, authority
"""
import random
from typing import Dict, List
class PsychologyEngine:
"""Applies psychological principles to demo presentation"""
def __init__(self):
# Loss aversion scenarios
self.loss_scenarios = {
"high": [
"Data breach ($3.9M average cost)",
"Service disruption ($300k/hour)",
"Compliance fines (up to $20M)"
],
"medium": [
"Data corruption (24h recovery time)",
"Performance degradation (50% slower)",
"Security vulnerability exposure"
],
"low": [
"Minor configuration drift",
"Increased operational overhead",
"Manual review delays"
]
}
# Social proof statements
self.social_proofs = {
"oss": [
"92% of Enterprise users report reduced incidents",
"Fortune 500 companies save $2.3M annually with mechanical gates",
"Developers report 15 minutes saved per decision"
],
"trial": [
"Join 1,000+ developers using ARF",
"50+ companies started with trial and upgraded",
"Average user prevents 3 high-risk actions weekly"
],
"professional": [
"Trusted by 200+ scale-ups",
"Teams report 92% faster incident response",
"40% reduction in on-call alerts"
],
"enterprise": [
"Deployed at 50+ Fortune 500 companies",
"99.9% reliability across 1M+ decisions",
"SOC 2 certified with zero findings"
]
}
# Authority signals
self.authority_signals = [
"SOC 2 Type II Certified",
"GDPR & CCPA Compliant",
"ISO 27001 Certified",
"99.9% SLA Guarantee",
"24/7 Dedicated Support",
"On-prem Deployment Available"
]
# Scarcity messages
self.scarcity_messages = {
"trial": [
"⏳ Limited time: {days} days remaining in trial",
"🎁 Free trial ends soon - upgrade to keep mechanical gates",
"⚠️ Trial license expires in {days} days"
],
"starter": [
"💰 Special pricing: First 3 months at 50% off",
"👥 Limited seats available at current price",
"⏰ Offer ends this quarter"
]
}
def generate_loss_aversion_message(self, risk_score: float) -> Dict:
"""Generate loss aversion framing based on risk"""
if risk_score > 0.7:
category = "high"
elif risk_score > 0.4:
category = "medium"
else:
category = "low"
scenarios = self.loss_scenarios[category]
selected = random.sample(scenarios, min(3, len(scenarios)))
return {
"title": f"🚨 Without Enterprise, you risk:",
"points": selected,
"category": category,
"risk_score": risk_score
}
def generate_social_proof(self, license_tier: str) -> str:
"""Generate tier-specific social proof"""
proofs = self.social_proofs.get(license_tier, self.social_proofs["oss"])
return random.choice(proofs)
def generate_scarcity_message(self, license_tier: str, days_remaining: int = 14) -> str:
"""Generate scarcity messaging"""
if license_tier in self.scarcity_messages:
messages = self.scarcity_messages[license_tier]
message = random.choice(messages)
return message.format(days=days_remaining)
return ""
def generate_authority_signals(self, count: int = 3) -> List[str]:
"""Generate authority signals"""
return random.sample(self.authority_signals, min(count, len(self.authority_signals)))
def apply_prospect_theory(self, risk_score: float) -> float:
"""
Apply Kahneman & Tversky's Prospect Theory:
- Losses loom larger than gains (λ ≈ 2.25)
- Value function is concave for gains, convex for losses
"""
# For losses (risk > 0), apply convex weighting
if risk_score > 0:
# Diminishing sensitivity for losses
perceived_risk = risk_score ** 0.88
# Loss aversion coefficient (losses feel 2.25x worse)
perceived_risk *= 2.25
else:
# For gains, apply concave weighting
perceived_risk = -((-risk_score) ** 0.88)
return min(1.0, max(0.0, perceived_risk))
def generate_psychological_insights(self, risk_score: float, recommendation: str, license_tier: str) -> Dict:
"""Generate comprehensive psychological insights"""
return {
"loss_aversion": self.generate_loss_aversion_message(risk_score),
"social_proof": self.generate_social_proof(license_tier),
"scarcity": self.generate_scarcity_message(license_tier),
"authority": self.generate_authority_signals(2),
"perceived_risk": self.apply_prospect_theory(risk_score),
"recommendation_impact": self._assess_recommendation_impact(recommendation),
"tier_motivation": self._generate_tier_motivation(license_tier, risk_score)
}
def _assess_recommendation_impact(self, recommendation: str) -> str:
"""Assess psychological impact of recommendation"""
if "BLOCKED" in recommendation or "HIGH RISK" in recommendation:
return "high_anxiety"
elif "REQUIRES APPROVAL" in recommendation or "MODERATE RISK" in recommendation:
return "moderate_concern"
else:
return "low_concern"
def _generate_tier_motivation(self, current_tier: str, risk_score: float) -> Dict:
"""Generate motivation to upgrade from current tier"""
if current_tier == "oss":
return {
"target_tier": "trial",
"value_prop": "Get mechanical gates for free",
"motivation": "fear_of_loss",
"urgency": "high" if risk_score > 0.5 else "medium"
}
elif current_tier == "trial":
return {
"target_tier": "starter",
"value_prop": "Keep mechanical gates after trial",
"motivation": "fear_of_loss",
"urgency": "high"
}
elif current_tier == "starter":
return {
"target_tier": "professional",
"value_prop": "Get 24/7 support and advanced gates",
"motivation": "aspiration",
"urgency": "medium"
}
elif current_tier == "professional":
return {
"target_tier": "enterprise",
"value_prop": "Enterprise features and dedicated support",
"motivation": "authority",
"urgency": "low"
}
else:
return {
"target_tier": None,
"value_prop": "You have the highest tier",
"motivation": None,
"urgency": None
} |