Skip to content
wiki.fftac.org

11 User AI Architecture - Source Excerpt 01 - User AI Architecture

Back to 11 User AI Architecture

Summary

This source excerpt begins near User AI Architecture and preserves the surrounding evidence from Wiki.FFTAC.org/raw/system-archives/anti-christ.org/docs-archive/2026-05-10/docs/11-user-ai-architecture.md.

**Source path:** Wiki.FFTAC.org/raw/system-archives/anti-christ.org/docs-archive/2026-05-10/docs/11-user-ai-architecture.md

# User AI Architecture

This is the internal architecture guide for the signed-in AI Engine. It is not public site content.

## Current Contract

The AI Engine is a focused member-facing console, not a public anonymous form.

Implemented behavior:

- guests see an account gate and cannot submit prompts
- signed-in users use nonce-protected AJAX for chat and key management
- browser-side conversation history is stored locally in `localStorage`
- server-side requests include sanitized recent conversation context
- users can save an encrypted personal OpenAI API key for larger token use
- the configured Foundation key is limited to short prompts, low output, and stricter rate limits
- the server applies hidden persona system prompts before the user prompt and conversation context; admins can override flavor text and prompts in `Settings -> FFTAC AI Engine`
- the server applies a second hidden inquiry-protocol prompt so users can combine a personality flavor with a distinct method of analysis
- the console exposes visible prompt lanes that load a starter prompt and pair it with the most fitting persona/protocol
- the AI page renders command-map, prompt-lane, response-contract, and handoff-route sections so users can understand the surface without exposing hidden prompts
- the console can expand into a fullscreen work surface for longer sessions
- the console shows prompt and local-context pressure against the active Foundation-key or personal-key limits
- users can keep a browser-local workspace brief and deliberately add it into the visible prompt when they want that context sent
- users can copy, export, and import the browser-local transcript without creating a server-side chat archive
- users can export transcripts as JSON for restoration or Markdown for editorial review
- users can save, restore, and delete named local session snapshots in the same browser, including the current workspace brief
- assistant output is rendered as safe structured text, including headings, lists, blockquotes, inline code, fenced code blocks, and code-copy controls
- assistant answers expose follow-up actions that can drill deeper, build a research handoff, or turn an answer into a public-note drafting prompt
- users can copy an assistant output or share it into a WordPress post as a private draft, pending journal-review item, or public profile post
- AI output remains a bounded inquiry aid, not doctrine, prophecy, advice, or final authority

## Main Files

- AI plugin bootstrap:
  `wp-content/plugins/fftac-ai-engine/fftac-ai-engine.php`
- AI page:
  `wp-content/themes/antichrist-engine/template-ai-engine.php`
- AI content, copy, starters, command-map records, response-contract records, handoff routes, workspace-brief labels, flavor metadata, inquiry-protocol metadata, persona prompts, and protocol prompts:
  `wp-content/plugins/fftac-ai-engine/inc/ai-content.php`
- AJAX handlers, key policy, encryption, prompt sanitization, Responses API payloads, AI output sharing, and notices:
  `wp-content/plugins/fftac-ai-engine/inc/ai-engine.php`
- localized AJAX URL, nonce, and UI labels:
  `wp-content/themes/antichrist-engine/functions.php`
- chat history, browser-local workspace briefs, session usage meters, transcript copy/export/import, JSON and Markdown transcript exports, named local session snapshots, prompt-lane controls, safe rich transcript rendering, fullscreen state, key save/delete, starter prompts, protocol cards, follow-up prompt actions including research handoffs, output copy/share actions, and analytics events:
  `wp-content/themes/antichrist-engine/assets/ts/theme.ts`
- compiled WordPress-served script:
  `wp-content/themes/antichrist-engine/assets/js/theme.js`
- AI console styling:
  `wp-content/themes/antichrist-engine/assets/css/theme.css`
- tests:
  `tests/cases/FoundationHelpersTest.php`
  `tests/cases/FoundationContentTest.php`
  `tests/cases/TemplateTagsAndThemeTest.php`

## Access And Security

The live AI form is account-gated. The old anonymous postback is no longer the working path.

Controls:

- `wp_ajax_antichrist_engine_ai_chat` handles signed-in chat requests
- `wp_ajax_antichrist_engine_ai_key` handles signed-in personal-key save/delete requests
- `wp_ajax_antichrist_engine_ai_share` handles signed-in output-to-post sharing
- `wp_ajax_nopriv_*` handlers return auth-required JSON and do not process prompts
- requests require `check_ajax_referer('antichrist_engine_ai', 'nonce', false)`
- prompts and history are scalar/JSON sanitized with an AI-specific plain-text sanitizer that preserves code-like characters, length-capped, and reduced to recent user/assistant messages
- hidden persona and protocol prompts live server-side and are never rendered into the browser transcript
- API keys are never returned to the browser after saving
- personal keys are encrypted in user meta with server-side secrets
- OpenSSL is preferred when available; the fallback remains server-keyed and authenticated so plaintext is not stored
- rate limits are separate for Foundation-key chat, user-key chat, and key-management actions

## Key Policy

There are two key sources.

Foundation key:

- read from the `OPENAI_API_KEY` constant, the matching hosting environment variable, the encrypted `Settings -> FFTAC AI Engine -> FFTAC Foundation OpenAI API key` field, or the `antichrist_engine_ai_api_key` filter
- stored admin-entered keys are encrypted in WordPress options and only the final four characters are shown as a status hint
- intended only for short launch-safe prompts
- default prompt limit: 900 characters
- default context limit: 2,400 characters
- default output cap: 700 tokens
- default rate limit: 3 requests per hour per account/network fingerprint

Personal user key:

- saved by the signed-in user through the AI console
- stored encrypted in user meta
- never displayed back; only the final four characters are shown as a hint
- default prompt limit: 4,000 characters
- default context limit: 12,000 characters
- default output cap: 2,200 tokens
- default rate limit: 20 requests per hour per account/network fingerprint

When a request exceeds Foundation-key limits and no personal key is saved, the AJAX response tells the user to save their own key for larger token use.

The client-side session meter follows the same active-key distinction. Without a personal key it shows Foundation-key prompt/context limits. After a user saves a personal key, the meter updates to the larger personal-key limits without reloading the page.

User instructions shown in the console:

- create an OpenAI API key in the user's OpenAI account
- paste it into the Personal API Key field
- save it
- remove it any time from the same panel

## Persona Flavors

The visible dropdown label is a flavor choice. The actual persona prompt is private server-side instruction.

Current flavors:

- `adversary`: Adversarial Reframe
- `recovery`: Recovery Deconstruction
- `research`: Dossier Builder
- `algorithmic`: Algorithmic Eschatology
- `governance`: Governance Ethics
- `historian`: Historical Excavator
- `briefing`: Public Briefing Editor

Each persona has:

- visible label
- user-facing summary
- mode, best-for guidance, output shape, and boundary metadata
- starter prompt button
- hidden `system_prompt`

Change checked-in default persona data in `antichrist_engine_foundation_ai_default_personas()` inside `wp-content/plugins/fftac-ai-engine/inc/ai-content.php`. Use `Settings -> FFTAC AI Engine` for admin-managed overrides to visible labels, summaries, mode/boundary metadata, starter prompts, and hidden persona system prompts.

## Inquiry Protocols

The visible protocol deck is separate from the persona flavor. Personas define voice and posture. Protocols define the operation the AI should perform.

Current protocols:

- `authority_audit`: Counterfeit Authority Audit
- `fear_decoder`: Fear Script Decoder
- `systems_map`: Systems Translation Map
- `evidence_ledger`: Evidence Ledger
- `public_note`: Public Note Forge
- `counterclaim_drill`: Counterclaim Drill

Each protocol has:

- visible label
- user-facing summary
- mode, best-for guidance, output shape, and starter prompt
- hidden `system_prompt`

Change protocol data in `antichrist_engine_foundation_ai_protocols()` inside `wp-content/plugins/fftac-ai-engine/inc/ai-content.php`. The default protocol is `authority_audit`.

## Prompt Lanes

Prompt lanes are visible user guidance. They do not add hidden instructions by themselves; they load a better starter prompt and switch the console to the persona/protocol pairing that best fits the lane.

Current pairings:

- Recovery Lane: `recovery` persona with `fear_decoder`
- Research Lane: `research` persona with `evidence_ledger`
- Algorithmic Lane: `algorithmic` persona with `systems_map`