00:00 / 00:00

Rinnegan

Configuration & Audit Log

LAPLACE Rinnegan can be configured via a JSON configuration file, environment variables, and command-line flags.

Configuration Precedence

Settings are merged in the following order, from lowest to highest priority:

  1. Built-in defaults (DEFAULT_CONFIG)
  2. Configuration file (rinnegan.config.json in the working directory by default, or the path passed to --config <path>)
  3. Environment variables (LOGIN_SYNC_*, RINNEGAN_*)
  4. Command-line flags (CLI options)

Example Configuration File

Create rinnegan.config.json in your working directory (see apps/rinnegan/rinnegan.config.example.json in the repository):

rinnegan.config.json
{
  "logDir": "logs",
  "reportDir": "reports",
  "timeZone": "Asia/Shanghai",
  "storeUrl": "sqlite:data/rinnegan.sqlite",
  "detector": {
    "windowMs": 3600000,
    "suspectScore": 60,
    "spamScore": 90
  },
  "live": {
    "url": "ws://localhost:8080",
    "rooms": [25034104],
    "includeMirror": false
  },
  "loginSync": {
    "baseURL": "https://login-sync.laplace.cn",
    "refreshMinutes": 30
  },
  "loginFile": "data/bilibili-login.json",
  "ban": {
    "dryRun": false,
    "patterns": ["loop", "burst", "template", "blend"],
    "hours": -1,
    "expireAfterHours": 0,
    "reasonTemplate": "独轮车 ×{count}:{sample}",
    "exemptUids": [],
    "exemptGuards": false,
    "exemptMedalLevel": 0,
    "maxPerMinute": 5,
    "maxPerSession": 100
  },
  "unbanSpendCny": 0,
  "ai": {
    "mode": "off",
    "provider": "jev",
    "protocol": "openrouter",
    "threshold": 0.8,
    "maxPerHour": 120
  }
}

RinneganConfig Reference

Prop

Type

BanConfig Reference

Prop

Type

Environment Variables

Keep tokens and API keys in environment variables rather than committing them to version control:

Environment VariableConfig PathDescription
LOGIN_SYNC_TOKENloginSync.tokenuuid@password token from the LAPLACE Login Sync browser extension.
LOGIN_SYNC_URLloginSync.baseURLCustom Login Sync server URL (leave empty to use the official public server).
LOGIN_SYNC_AUTH_KEYloginSync.authKeyAuthentication key for a self-hosted Login Sync server.
RINNEGAN_LOGIN_FILEloginFileFile path where rinnegan login stores QR code login cookies (default data/bilibili-login.json).
RINNEGAN_EVENT_URLlive.urlLAPLACE Event Fetcher or Event Bridge WebSocket URL.
RINNEGAN_EVENT_TOKENlive.tokenEvent source bridge token (BRIDGE_TOKEN on Fetcher or --auth on Bridge).
RINNEGAN_ROOMSlive.roomsComma-separated list of live room IDs to monitor.
RINNEGAN_STORE_URLstoreUrlBan store connection URL (sqlite:<path>, postgres://…, redis://…, or memory:).
RINNEGAN_LOG_DIRlogDirDirectory for daily JSONL audit logs (default logs).
RINNEGAN_REPORT_DIRreportDirDirectory for offline analysis reports (default reports).
RINNEGAN_TIMEZONEtimeZoneTime zone used to parse --since/--until and display timestamps (default Asia/Shanghai, UTC+8).
RINNEGAN_AI_MODEai.modeAI review mode: off, confirm, or assist.
RINNEGAN_AI_PROVIDERai.providerAI review provider: jev or llm.
RINNEGAN_AI_PROTOCOLai.protocoljev endpoint protocol: openrouter or typesafe.
RINNEGAN_AI_BASEai.apiBaseBase URL for the AI API.
RINNEGAN_AI_API_KEYai.apiKeyAPI key for the AI review provider.
RINNEGAN_AI_MODELai.modelAI model identifier.
RINNEGAN_AI_THRESHOLDai.thresholdProbability threshold ((0, 1], default 0.8) required for the AI reviewer to approve a ban.

CLI Options Summary

Common Options

OptionDescription
-c, --config <file>Path to JSON configuration file (defaults to ./rinnegan.config.json if present).
-r, --room <ids>Filter to these room IDs (comma-separated or repeated).
--window <minutes>Sliding detection window in minutes (default 60).
--spam-score <n>Score threshold for spam verdict (default 90).
--suspect-score <n>Score threshold for suspect verdict (default 60).
--include-mirrorAlso evaluate mirrored cross-room danmaku.
--log-dir <dir>Audit log directory (default ./logs).
--timezone <zone>Time zone for --since/--until and displayed timestamps, default Asia/Shanghai (UTC+8).
--login-sync-token <u@p>LAPLACE Login Sync uuid@password token (takes precedence over QR login).
--login-sync-url <url>Custom Login Sync server URL (default https://login-sync.laplace.cn).
--login-file <path>QR login cookie file path (default data/bilibili-login.json).
--store <url>Ban store connection URL (default sqlite:data/rinnegan.sqlite).
-h, --helpPrint command help.
-v, --versionPrint version.

offline Options

OptionDescription
--since <time>Only analyze messages at or after this time (such as 2026-10-20 20:00).
--until <time>Only analyze messages at or before this time.
--top <n>Maximum users shown per category in the terminal summary (default 30).
--samples <n>Message samples shown per cluster in the terminal summary (default 3).
--spam-onlyShow only spam users in terminal output, hiding suspect and 手动融入 users.
--report-dir <dir>Report output directory (default ./reports).
--no-reportSkip writing JSON, Markdown, and HTML report files.

live, bans, and unban Options

OptionDescription
-u, --url <ws>live event source WebSocket URL (default ws://localhost:9696; Event Fetcher bridge mode is typically ws://host:8080).
-t, --token <token>live event source token (BRIDGE_TOKEN on Fetcher or --auth on Bridge).
--dry-runlive / unban simulate without calling the ban or unban API.
--patterns <list>live patterns eligible for banning: loop,burst,template,blend (all by default; flood is never banned).
--ban-hours <n>live bilibili ban duration in hours (-1 for permanent).
--expire-after <hours>live automatically lift bans placed by Rinnegan after n hours (0 disables).
--reason <template/text>live ban reason template, or unban manual lift reason.
--exempt-uid <ids>live whitelisted user UIDs (comma-separated or repeated).
--exempt-guardslive exempt guard members (舰长 / 提督 / 总督).
--exempt-medal <n>live exempt users wearing a fan medal at or above level n (0 disables).
--max-per-minute <n>live safety brake: maximum bans per room per minute (default 5).
--max-bans <n>live safety brake: maximum bans per run (default 100).
--unban-spend <cny>live automatically lift a user's ban once they spend this much CNY in the room (0 disables).
--ai <mode>live AI review mode: off, confirm, assist.
--ai-provider <kind>live AI review engine: jev (default) or llm.
--ai-protocol <proto>live jev endpoint protocol: openrouter (default) or typesafe.
--ai-model <id> / --ai-base <url> / --ai-threshold <0-1>live AI model identifier, base URL, and approval threshold (default 0.8).
--verbose / --status <sec>live log every suspect change / status line interval in seconds (default 60, 0 disables).
--remote / --local / --limit <n>bans show bilibili silent list only / local records only / local row limit (default 100).
--uid <ids> / --session <id>unban target user UIDs, or revert every real ban from an audit session.

Audit Log and Credential Scrubbing

During every run, Rinnegan appends structured records synchronously to a daily JSONL audit file at logs/audit-YYYY-MM-DD.jsonl.

Record Format and Event Types

Each JSON line includes standard metadata along with the event payload:

  • ts: ISO 8601 timestamp
  • session: UUID of the current run session
  • mode: Execution mode (offline, live, or admin)
  • event: Lifecycle event identifier:
    • Session & Rooms: session-start, session-error, session-end, room-ready, room-unmanaged, connection, credentials-refresh
    • Detection & Review: detection, review, review-error, veto
    • Enforcement & Unban: ban, ban-failed, skip, brake, unban, unban-failed, spend, user-block
    • Errors: lifecycle-error, store-error, enforce-error

Automatic Credential Redaction

Before writing any line to disk, the audit logger recursively traverses the record and replaces the value of any key matching the following names (case-insensitive, ignoring underscores and hyphens) with "[redacted]", so audit logs can be safely archived or shared for debugging:

  • cookie, cookies, sessdata, bili_jct, csrf, csrf_token
  • token, refreshtoken, refresh_token
  • apikey, api_key, authkey, auth_key, password

Last updated on November 29, 2026

Tech otakus destroy the world