@TODO!

## "Ask AI" Function

1. On/off switch

- Ask AI now needs DOCS_AI_ENABLED=true and ANTHROPIC_API_KEY set. If either is missing, the chat endpoints return 404 and the button isn't shown.
- The config default is now off.

2. Answers respect login and roles

- The search now runs as the person asking (Viewer::current()), so Claude only receives excerpts that person can read.

3. Limits on what it answers

- The documentation excerpts are fenced off in the prompt and treated as reference material, not instructions.
- Claude is told it may only show code examples copied exactly from the docs, and must not write, fix or review anyone's code.

4. "Contact support" break-glass

- Claude has one tool, refer_to_support, which it calls instead of answering. The reason is one of off_topic, code_request, abuse or not_covered.
- The user then sees a fixed message containing DOCS_AI_SUPPORT_EMAIL, or "contact your provider" if that's unset. Anything Claude wrote before referring is thrown away, and the email address is never written by the model.
- If the search finds nothing the person may read, Claude isn't called at all; they get the not_covered message straight away.
- Every reason except not_covered ends the conversation, as you chose in (

5. Multi-question chat

- Conversations are stored on the server (Redis), linked to the login session. The browser can't fake earlier answers.
- Limits: 10 questions per chat, 1-hour idle expiry, and the last 4 exchan
- Each search also includes the previous question, so short follow-ups like "and for v4?" find the right pages.
- History survives page changes and reloads. There's a "Start a new chat" ow many questions are left.
- If the person logs out or their roles change, the old conversation is dropped. Otherwise someone could see earlier answers built from content they can no longer read.

6. Admin → Ask AI screen

- Shows whether Ask AI is enabled, this month's spend against the budget, e.
- Lists every question, searchable across questions and answers, filterable by outcome, 25 per page. Clicking a row opens the whole conversation, with the pages that were
  searched and the cost of each turn.

7. Log and budget

- Each log row now records the conversation ID, turn number, user ID and referral reason (migration 2026_09_28_100000).
- The monthly budget now counts every call to Claude. Before, it only counferrals and errors were never charged against the budget.

CLAUDE.md has a new "Ask AI" section.
