mirror of
https://github.com/civitai/civitai.git
synced 2026-09-20 22:08:18 +08:00
fbc82d6a10
* feat(api): agent/API safeguards (post rate limits, key notice, ToS, provenance) Response to moderator concerns about AI agents using the MCP server / public API to post content. The MCP server only wraps APIs that already existed, so these fixes target the underlying open-API surface, not the MCP wrapper. - Post rate limits: post creation was never throttled. Add postRateLimits and apply to post.create / post.createWithImages. New accounts (<24h) capped at 2/hour; 20/day base, scaling to 60 (score >=1000) and 150 (score >=5000). Moderators and dev/test are exempt. Clear user-facing messages on the limit. - API-key responsibility notice: Alert in the key-creation modal stating the user owns everything done with the key (incl. agents), linking the ToS. - Terms of Service: rework prohibited-conduct 11.4 (in tos.md and tos.green.md) to permit authorized API/MCP access with your own credentials within rate limits, while keeping the ban on scraping and stat manipulation (11.9). - Provenance/attribution: Tracker.setProvenance derives how a request was authenticated (web / api-key / oauth) from the tRPC context and tags post/images/comment/bounty ClickHouse events with via + OAuth client id + api-key id (snapshot, survives later deletion). Requires the ClickHouse columns in docs/plans/agents-attribution.sql to be applied before deploy. Planning + decisions recorded in docs/plans/agents-moderation-response.md. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * feat(api): extend provenance to models, versions, reviews, bounty entries, articles Tag more agent-creatable content with `via` provenance: - modelEvent / modelVersionEvent / resourceReview / bountyEntry tracker calls now carry via + viaClientId + viaApiKeyId (same snapshot approach as posts/images). - Articles had no creation event at all: add Tracker.article(), emit it from upsertArticleHandler, and add a new ClickHouse `default.articles` table. - Update the dev ClickHouse bootstrap (init.sh) to match: new articles table + ADD COLUMN IF NOT EXISTS via columns on the eight content-event tables. ClickHouse DDL for prod is in the PR description. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * fix(api): share post rate-limit quota; review cleanups Address PR review: - rateLimit() gains a sharedKey option so post.create and post.createWithImages count against ONE per-user quota (the cache key was per-path, letting an agent hit the daily cap on each entrypoint independently — 40/day instead of 20). - Reword the new-account clamp copy/comment: it's a calendar-day window (isBetweenToday), not a rolling 24h. - Drop em dashes from the API-key responsibility notice. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * feat(api): track article publish/unpublish/delete provenance The articles event table + Tracker.article supported Create/Publish/Update/ Unpublish/Delete, but only Create/Update were emitted. Wire the rest: - upsert detects a real publish transition (reads prior publishedAt): new+published or draft->publish logs Publish; edit-while-published or draft edit logs Update; new draft logs Create. No over-reporting. - unpublishArticleHandler emits Unpublish. - article.delete route emits Delete. (restore is left untracked — its target status is ambiguous.) Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>