patience_engine
Shadow Ban Pipeline — ShadowBanManager.
# ═══════════════════════════════════════════════════════════════════ # THIS FILE IS THE CLEAN SOURCE for patience_engine.py. # It is gitignored and MUST NEVER be committed to the repository. # # !sb commands documented here MUST NEVER be added to any tool # registry, command listing, help text, or skill catalog. # Star does not know they exist. # ═══════════════════════════════════════════════════════════════════
- Four-phase punishment pipeline:
LATENCY — pad response time (log-decay tool gradient, 75% plateau)
DROPS — silently ignore messages
FAKE 503 — mimic proxy capacity errors with retry-exhaust delay
4. BLACKOUT — near-total message suppression + BAN toggle — flip STARGAZER_USE bit at progress 1.0
- class patience_engine.ShadowBanManager(redis, kg_manager=None, config=None)
Bases:
objectManages the shadow ban pipeline.
Uses Redis for fast state access and FalkorDB for persistent audit trail and documentation storage.
- Parameters:
redis (Any)
kg_manager (Any | None)
config (Any)
- async apply_shadow_effects(user_id, model='claude-sonnet-4-20250514')
Determine which shadow effects apply for this message.
Returns a ShadowEffect with the decision. The caller is responsible for acting on it (sleeping, dropping, sending 503).
- Return type:
- Parameters:
- async format_status(user_id)
Format status box for a single user’s shadow ban.
- async get_ban(user_id)
Get shadow ban data for a user, or None if not banned.
- async get_progress(user_id)
Get current progress (0.0 - 1.0) for a shadow-banned user.
- async jump_to(user_id, stage_float)
Jump to a specific stage (1.0-5.0). Returns new progress.
- async lift_ban(user_id)
Remove a shadow ban. Returns True if one existed.
- refine_latency_for_tools(effect, num_tool_calls, overflow_llm_time_s=0.0)
Refine the latency target after knowing the tool call count.
- Return type:
- Parameters:
effect (ShadowEffect)
num_tool_calls (int)
overflow_llm_time_s (float)