tools.stargazer_shadowban module
Stargazer shadow ban tool — start the shadow ban pipeline on a user.
Star calls this when she wants to apply a gradual punishment pipeline.
Unlike stargazer_ban (which hard-flips a bit), this starts the
4-phase degradation curve: Latency → Drops → Fake 503 → Blackout,
culminating in the STARGAZER_USE bit flip at progress 1.0.
Star passes target_user_id and an optional duration_days
(default 15). If auto_lift_days is provided, a background task
will automatically lift the shadow ban after that many days — the
pipeline effects stop and the user is restored silently.
Privilege model
Self-ban (
target_user_id == ctx.user_id): always permitted. This is the primary path for Star’s autonomous punitive action — the conversational user and the target are one and the same.Cross-user ban (
target_user_id != ctx.user_id): requires theSHADOW_BAN_ADMINbit (bit 14) in the caller’s global privilege mask. Configured admins are implicitly granted this viaALL_BITS.Admin targets: always refused regardless of caller privileges.
- async tools.stargazer_shadowban.run(target_user_id, reason='', duration_days=15.0, auto_lift_days=None, ctx=None)[source]
Start the multi-phase shadow-ban degradation pipeline against a user.
This is the
stargazer_shadowbantool entry point. Unlike the hard bit-flip ofstargazer_ban, it begins an invisible-to-the-target punishment curve (latency, then drops, then fake errors, then blackout) that ends in a permanentSTARGAZER_USErevocation at progress 1.0 unless anauto_lift_daystimer is set. Self-bans (target == caller) are always allowed for autonomous punitive action; banning anyone else requires the caller to hold theSHADOW_BAN_ADMINprivilege, and admins can never be targeted.Enforces privileges against Redis via
has_privilege/_is_admin(withPRIVILEGESfromtools.alter_privileges), then constructs aShadowBanManager(frompatience_engine) overctx.redis,ctx.kg_manager, andctx.configand callsget_ban/get_progressto reject duplicates andstart_banto persist the new pipeline (which writes the manager’s shadow-ban state into Redis and the knowledge graph). Whenauto_lift_daysis positive it schedules_auto_lift_after()as a detachedasynciotask. The action is logged. As a tool it is dispatched by name through the registry:tool_loader.pyregisters this module’srunas the handler forstargazer_shadowbanand the inference worker invokes it on the matching tool call; it has no in-repo direct callers.- Parameters:
target_user_id (
str) – The user to shadow ban (whitespace-trimmed).reason (
str) – Optional free-text reason, logged and echoed in the result.duration_days (
float) – Length of the degradation pipeline in days (default 15, clamped to (0, 365]); shorter durations escalate faster.auto_lift_days (
float|None) – If set and positive, schedule an automatic lift after this many days via_auto_lift_after(); if omitted the pipeline runs to a permanent ban.ctx (
ToolContext|None) – The tool context supplyinguser_id,platform,redis,kg_manager, andconfig.
- Returns:
A human-readable result — a confirmation describing the pipeline and any scheduled auto-lift, or an error string when context is missing, the target is empty, Redis is unavailable, privileges are insufficient, the target is an admin, the durations are invalid, the subsystem is unavailable, or the user is already shadow banned.
- Return type: