Add spam prevention, superuser system, and LLM relevance checking

- Thread creation rate limit: 1 per 7 min per user/IP via API
- is_superuser column on User model with alembic migration
- Superusers bypass namespace-scoped is_moderator() checks
- super_fly_required now checks is_superuser instead of hardcoded names
- /topsecret/users admin page to promote/demote superusers
- Spam scoring module with 6 signals (link density, patterns, duplicates,
  new account velocity, IP reputation, content length)
- Hard threshold (0.8) rejects, soft threshold (0.5) holds for moderation
- LLM relevance checking via Hermes (hermes.ai.unturf.com) on every
  message when enabled, including embed mode parent page URL context
- Admin API endpoints: GET /api/v1/admin/namespaces, recent-nodes
- Spam hunting scripts: scan.py, disable_spam.py, promote_superuser.py
- Updated Python client with admin methods
This commit is contained in:
russell@unturf.com 2026-02-02 09:19:16 -05:00
parent 8d836dae34
commit 66964f736a
20 changed files with 1208 additions and 9 deletions

View file

@ -46,6 +46,19 @@ api.enabled = true
api.rate_limit.read_requests = 120
api.rate_limit.write_requests = 30
api.rate_limit.window = 60
api.rate_limit.create_thread_requests = 1
api.rate_limit.create_thread_window = 420
###
# spam detection.
###
spam.enabled = true
spam.hard_threshold = 0.8
spam.soft_threshold = 0.5
spam.llm.enabled = true
spam.llm.endpoint = https://hermes.ai.unturf.com/v1/chat/completions
spam.llm.model = adamo1139/Hermes-3-Llama-3.1-8B-FP8-Dynamic
spam.llm.timeout = 5
###
# custom app configuration.