> ## Documentation Index
> Fetch the complete documentation index at: https://docs.tuturuuu.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Chat safety and Mira AI data consent

> How people report and block others in chat, report Mira responses, and allow or revoke sharing their content with Google Gemini.

## Decision

Decision (2026-11-28): both store-review requirements below ship before the public store submission.

* **User-generated content** (Apple 1.2, Play UGC and AI-generated content policies). People can report a user or a message and block a user in chat. They can also report a Mira response.
* **Third-party AI data sharing** (Apple 5.1.2(i)). Mira sends nothing to Google Gemini until the person allows it in a disclosure step. The choice is stored per user on the server and can be revoked in Settings.

Both rules are enforced on the server. Client checks only improve the experience.

## Blocking

| Rule | Where it's enforced |
| - | - |
| Blocks are per user and apply across every workspace. | `private.chat_user_blocks` |
| A direct conversation between the pair is frozen: no new message of any kind (user, assistant or system), no edit and no reaction. A send returns `403` with `chat_blocked`. Soft deletes still work. | Triggers on `private.chat_messages` (insert and content update) and `private.chat_message_reactions`, so every write path is covered |
| Only someone the blocker can meet in chat (a shared workspace, friend request or conversation) can be blocked. An unknown id answers like an unrelated one, so the route isn't an account-existence check. | `private.chat_users_can_meet` |
| Neither person can start a DM with the other or add the other to a group. | `private.chat_can_invite_user` |
| Friend requests between the pair are dropped silently. The send still returns `{queued:true}`, so a block (or whether an email has an account) is never revealed. Accepting across a block is refused. Blocking also ends the friendship and any pending request. | Triggers on `private.chat_friend_requests`, plus `private.chat_block_user` |
| The blocker doesn't see the blocked person's messages (group conversations included), search hits, conversation previews (external inbox included), directory entries or friend requests, and gets no push for their group messages. A single-message reaction read returns `404` for a blocked sender's message, and reaction summaries in reaction reads and receipts leave out blocked reactors. | Web API read routes and `notifyChatMessageRecipients`, via `apps/web/src/lib/chat/safety.ts` |
| Realtime events aren't filtered on the server. The mobile client drops incoming messages from blocked senders. | `apps/mobile/lib/features/chat` |
| The blocked person isn't notified. | |

Hiding is one-way: content is hidden for the person who blocked. Sending and inviting are refused in both directions.

**Known limits:** message pages are filtered after the database applies `limit`, so a page can come back shorter than requested. A conversation's shared-content panel (files and links) isn't filtered yet.

## Reports

`POST /api/v1/workspaces/{wsId}/chat/reports` takes one of these subjects:

* `user`: allowed only when the reporter shares a workspace, a friend request or a conversation with that person.
* `message`: someone else's user message in a conversation the reporter can open, addressed from any workspace the conversation is reachable in.
* `ai_response`: a Mira reply. That's an `ai-chat-*` / `legacy-ai-*` conversation owned by the reporter, or an assistant message in a native conversation the reporter can open.

The server finds the message and **snapshots its content from the database**. Reports never trust text supplied by the client, and a snapshot survives a later edit or delete. Each reporter has one open report per subject (a repeat returns the existing report) and at most 30 reports an hour (`429`). An optional `alsoBlock` blocks the sender that SQL resolved, never an id sent by the client.

Reports land in `private.chat_content_reports`. Verified Tuturuuu staff review them in the dashboard's **Chat reports** inbox, next to Product feedback, through `GET` and `PATCH /api/v1/chat-reports`. The route uses the product-feedback staff gate and the same `PRODUCT_FEEDBACK_STAFF_INBOX_ENABLED` switch as the inbox page (`503 {message: "Unavailable"}` while it's off), and the SQL functions re-check the canonical registry (`private.assert_product_feedback_staff`: an active infrastructure employee) on every call.

Snapshots are kept until a retention job scrubs resolved reports. That job isn't built yet; until it ships, resolved snapshots stay in place. The app promises review and removal of content that breaks the community guidelines, without a fixed response time.

## Mira AI data consent

* Storage: `private.user_ai_data_consent` holds the current decision (provider `google_gemini`, `policy_version`, `granted_at`, `withdrawn_at`). `private.user_ai_data_consent_events` is the append-only audit log.
* API: `GET` and `PUT /api/v1/users/me/ai-data-consent`, with `{granted, source, policyVersion}`. The current policy version is `2026-11-28`. An Allow for any other version returns `400`; the server always stores its own current version. A stored Allow counts only for the current version, so a new disclosure asks again.
* Default: not allowed. A failed lookup also counts as not allowed.
* Withdrawal (`granted: false`) also revokes every AI temp-auth token the user holds, so no cached token outlives the decision.
* Enforcement. Each of these returns `403 {code: "ai_consent_required"}` without consent:

  * native AI conversation sends, before the message is stored: Mira chats, first messages and native `type = ai` conversations. If the conversation can't be loaded to check its type, the send returns `503` instead of being stored;
  * the shared Gemini chat handler (`createPOST`, for any native request, Mira mode or not), the chat summary route, the conversation title route and the Mind AI route (`/api/ai/mind`);
  * AI memory writes and searches that embed text with Gemini: `POST` and `GET ?q=` on `/api/v1/workspaces/{wsId}/ai/memory/items`, and `PATCH` on `.../items/{memoryId}`. Listing, reading and deleting memories need no consent;
  * Worlds draft generation (`POST /api/v1/workspaces/{wsId}/worlds/generation`), AI report narratives (`POST /api/v1/workspaces/{wsId}/users/reports/{reportId}/generate`), citation fixes (`POST /api/v1/cite/ai/fix-ref`) and Notes voice jobs (`POST /api/v1/workspaces/{wsId}/notes/voice-jobs`, checked before the upload is read and again before each background Gemini step);
  * AI temp-token minting for native callers (`/api/ai/temp-auth/token`), since a temp token carries no bearer;
  * the Live token mints (`/api/v1/assistant/live/token` always, `/api/v1/live/token` for native callers) and the Live tool routes. Live audio and video go straight from the device to Google, so the token is the server-side gate;
  * satellite Gemini routes: Calendar audio transcription and image event extraction (`POST /api/v1/calendar/audio`, `.../image`); Hive NPC runs, interactions, research pair queues, workflow runs and admin simulation ticks (`POST /api/v1/hive/servers/{serverId}/npcs/{npcId}/run`, `.../interactions`, `.../research-sessions/{sessionId}/run-pair-queue`, `.../workflows/{workflowId}/run`, `.../simulate`); the AI Studio saved-key playground (`POST /api/v1/workspaces/{wsId}/ai/playground`); the Infrastructure translation route (`POST /api/ai/translate`) and external-thread drafts (`POST /api/v1/infrastructure/ai-agents/external-threads/{threadId}/draft`). Task creation (`POST /api/v1/workspaces/{wsId}/tasks` and the plan, template and Meet follow-up paths built on it) still creates the task but skips its Gemini embedding without consent. The task-embedding database webhook (`POST /api/v1/webhooks/tasks/embedding`) has no caller provenance, so it embeds only for a task creator with stored consent;
  * external-app sessions stamped consent-required on the external AI APIs: Web's `/api/v1/external-ai/chat/completions` and `.../audio/speech`, and every metered AI Studio execution (`/v1/responses`, `/v1/chat/completions`, `/v1/embeddings`, `/v1/images/generations`, `/v1/audio/speech`). They answer in the OpenAI error shape with `code: "ai_consent_required"`. AI Studio API keys and first-party grants are developer credentials, not app sessions, and are not consent-gated;
  * Meet assistant prompts: Web's gateways `POST /api/v1/workspaces/{wsId}/meetings/{meetingId}/assistant`, `.../assistant/review` (`POST` only; reading reviews needs no consent) and `.../assistant/personal`, checked before a Meet session is minted. Meet's own routes check again: `POST /api/meet-call/{meetingId}/assistant`, `.../assistant/personal`, and `.../assistant/review` when an `approve` or `deny` resumes a Gemini turn. The token Web mints for Meet carries the consent-required stamp below when the caller is native, so Meet re-checks it.
  * Meet's other Gemini entry points, each refusing in the room with the same `403` JSON: Private Mira Live (`POST /api/meet-live/{meetingId}` `start` and `resume`, which mint the Gemini Live session token; `stop` and the policy, choice and share actions need no consent), document assist (`POST /api/meet-call/{meetingId}/document` with `action: "assist"`), Mira poll drafts and summaries (`.../polls`, `mira_draft` and `mira_summarize`), Quiz Arena board generation (`.../quiz-arena`, `mira_generate_board` unless it asks for the starter board), Mira form drafts (`.../forms`, `mira_draft`), form results summaries (`POST .../forms/results`), live activity drafts (`POST .../live-activities/mira-draft`) and programming help (`POST .../programming?mira` with `action: "analyze"`). Meeting transcription checks the uploader or host: `POST /api/meet-ai/{wsId}/{meetingId}` `start` and `draft`, audio uploads (`.../chunks`, room and per-speaker capture) and opening a per-speaker stream (`.../self/open`). `finish` always stops capture and checks consent only before the transcript goes to Gemini for notes, so the session ends and its notes stay pending. Web proxies none of these routes, so they need no Web gateway check.

  The mobile Live eligibility pre-check reports `reason: "ai_consent_required"`.
  Room Mira's context can include other participants' room chat messages; they are covered by the [room Mira notice](https://docs.tuturuuu.com/platform/features/meet-mira-host-consent.md#room-mira-notice-and-the-askers-own-consent), and only the person asking needs this consent.
* App sessions (`ttr_app_*`). Anyone signed in can mint a cross-app handoff straight through Supabase, so an app session is treated as a browser session only when its handoff carries a browser origin transfer: a short-lived token signed by the server, bound to the user and target app, stored in the handoff's `session_data.aiConsentTransfer`. Only server routes that authenticated a cookie session write it: `POST /api/v1/auth/cross-app-return` and `generateAssuredCrossAppToken` (`/api/auth/generate-app-tokens`, `/api/cli/auth/start`). When it is missing or invalid, `/api/v1/auth/cross-app-token/verify` and the satellite and CLI exchanges in `packages/auth/src/cross-app/server.ts` stamp the access and refresh tokens with the `ai:consent-required` scope and return `aiConsentRequired: true`. Refreshes (`/api/v1/auth/cross-app-session/refresh`, `/api/cli/auth/refresh`) keep the stamp. A request that carries a stamped session, as a bearer token (any capitalization of the `Bearer` scheme) or in a cookie, follows the native rule everywhere `requiresAiDataConsent` runs. Every cookie value is checked both raw and URL-decoded, the way the app-session reader decodes it, so an encoded session cookie cannot skip the stamp. The stamp is signed into the token, so removing it invalidates the session. Unstamped app sessions already in circulation keep the browser exemption until their refresh tokens expire.
* AI temp-auth tokens (`x-tuturuuu-ai-temp-auth`). A token minted by a native caller is bound to consent: every validation re-checks the stored decision and treats the token as revoked without it, wherever the token is accepted. A token minted by a browser session follows the browser exemption below.
* Shared helpers: `packages/ai/src/chat/ai-data-consent.ts` (request gate), `packages/utils/src/ai-consent-session.ts` (native-caller detection, the app-session stamp and the browser origin transfer), `packages/meet-core/src/features/call/server/ai-data-consent.ts` (Meet's room gate), `packages/meet-core/src/features/meeting-ai/server/ai-data-consent.ts` (Meet transcription's gate) and `packages/utils/src/ai-data-consent-store.ts` (stored-decision lookup, shared with the temp-auth validator in `packages/utils/src/ai-temp-auth.ts`).
* Mobile: the consent sheet appears before the first text send, voice message, attachment upload or Live start (camera and screen included). Settings › Privacy has a switch to revoke. The on-device model needs no consent.

**Intentional exception:** the server requires consent from native clients, meaning bearer-token requests other than `ttr_app_*` app-coordination tokens, plus app sessions stamped consent-required as described above. Unstamped app sessions come from browser sign-ins (the satellite proxy attaches them from the first-party app-session cookie) and registered external apps; the native apps authenticate with Supabase bearer tokens and never call the cross-app handoff routes. A caller who repackages their own session as browser cookies is treated as a browser; the person doing that is the consent subject. Browser sessions keep the exemption. In the web dashboard, Settings › Mira › Personality › Mira data privacy records or withdraws the same account-level choice for mobile. The iOS and Android apps are the store-distributed surfaces this decision covers.

## Regression coverage

* Database: `apps/database/supabase/tests/chat-user-safety-and-ai-consent.sql`. It covers DM refusal across a block, silent friend-request drops, report authorization and snapshots, consent defaults, revoke and the append-only audit log.
* Web API: `chat/blocks/route.test.ts`, `chat/reports/route.test.ts`, `chat-reports/route.test.ts` (inbox switch), `conversations/[conversationId]/messages/route.safety.test.ts` (Mira refuses without consent, fails closed, blocked send `403`, blocked senders hidden), `conversations/[conversationId]/reactions/route.test.ts` and `conversations/route.test.ts` (blocked reactors and previews hidden), and `users/me/ai-data-consent/route.test.ts` (policy pinning, temp-auth revocation on withdrawal). The Live `token` and `eligibility` route tests, `ai/memory/items/[memoryId]/route.test.ts`, `worlds/generation/route.test.ts`, `users/reports/[reportId]/generate/route.test.ts`, `notes/voice-jobs/route.test.ts`, `lib/cite/api/fix-ref.test.ts` and `src/__tests__/ai-temp-auth-routes.test.ts` cover the consent refusal.
* Satellites and external AI: `apps/calendar/src/app/api/v1/calendar/ai-credit-policy.test.ts`, Hive `workflows/[workflowId]/run/route.test.ts`, AI Studio `ai/playground/route.test.ts` and `lib/public-api.test.ts`, Web `lib/external-ai/auth.test.ts`, `packages/tasks-api/src/server/tasks/dispatch-task-embedding.test.ts`, Meet `features/meeting-ai/server/followup-{create,task}.test.ts`, and Tasks `webhooks/tasks/embedding/route.test.ts`.
* Shared gate: `packages/ai/src/chat/ai-data-consent.test.ts`; consent-bound temp-auth tokens: `packages/utils/src/__tests__/ai-temp-auth.test.ts`.
* App-session stamp: `packages/utils/src/ai-consent-session.test.ts`, `packages/auth/src/cross-app/server-ai-consent.test.ts`, `packages/auth/src/cross-app/generate-server.test.ts`, `auth/cross-app-return/route-ai-consent.test.ts`, `auth/cross-app-token/verify/route-ai-consent.test.ts` and `auth/cross-app-session/refresh/route.test.ts`.
* Meet: `meetings/[meetingId]/assistant/ai-consent.test.ts` (Web gateways), `packages/meet-core/src/features/call/server/ai-data-consent.test.ts`, `meet-call/[meetingId]/assistant/route-ai-consent.test.ts`, `assistant/personal/route.test.ts`, `meet-call/[meetingId]/route-ai-consent.test.ts` (document, polls, Quiz Arena, forms, form results, live activity and programming routes), `meet-live/[meetingId]/route-ai-consent.test.ts` and `features/meeting-ai/server/ai-data-consent.test.ts` (transcription start, draft, finish and audio upload).
* Mobile widget tests: `apps/mobile/test/features/chat/` and `apps/mobile/test/features/assistant/`.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.