Core Concepts
AI is organized into five clean architectural layers so editors, administrators, and developers can govern models, prompts, data access, and external agents independently.
Runtime Architecture
Section titled “Runtime Architecture”flowchart TD
A["Editor UI / PHP API / Public Chat / MCP Client"] --> B["UsageGovernance (5 RBAC perms + PII Scrubbing + Caps)"]
B --> C["EditorialEngine / AgentRunner / McpServer"]
C --> D["Rules + Brand Voices + Glossaries + FieldScopeMatcher"]
C --> E["CapabilityRegistry (Pages, Entries, Knowledge, Custom)"]
E --> F["Vector Store (SQLite / File / Qdrant / InMemory)"]
C --> G["Model Router (7 ModelTiers + Backup Chain)"]
G --> H["10 ProviderDrivers (SecretBox + Failover / Round-Robin)"]
H --> I["Telemetry & Audit (ai_usage_logs, ai_conversations, ai_mcp_logs)"]
1. Providers, Key Pools & 7 Model Tiers
Section titled “1. Providers, Key Pools & 7 Model Tiers”- Connections (
ai-connections): Each connection picks one of 10ProviderDriverdrivers (openrouter,gemini,anthropic,openai,deepseek,mistral,xai,ollama,openai-compatible,deepl) and holds one or more encrypted API keys rotated viaKeyStrategy(failoverorround_robin). - Model Discovery (
ModelDiscoveryService): Fetches live/modelscatalogs from your connected providers and lets you toggle capabilities (Chat, JSON Schema, Stream, Translate, Vision, Image Gen, Embedding). - 7
ModelTierRoutes: Instead of hardcoding model IDs in templates or assistants, code targets semantic tiers (fast,balanced,reasoning,vision,image,embedding,private) mapped in Routing & Governance (ai-settings) with an optional backup route chain.
2. Grounded Editorial System (Rules, Voices, Glossaries & Assistants)
Section titled “2. Grounded Editorial System (Rules, Voices, Glossaries & Assistants)”- Editorial Rules (
ai-rules): Reusable Markdown guardrails scoped globally or bytask:*,template:*, orblueprint:*, paired withFieldScopeMatcherread/write allowlists. - Brand Voices (
ai-voices): Tone profiles specifying target audience, style guidelines, and banned phrases. - Glossaries (
ai-glossaries): Protected brand terms andSource => Targettranslation pairs enforced across localizations and audits. - Assistants (
ai-assistants&AbstractAssistant): Combine a model tier, ordered rules, a brand voice, a glossary, allowed templates/fields, and allowed tools into a specialized copilot runnable in Page Edit, Entry Edit, Editorial Sandbox, Public Chat, or MCP.
3. Storage Blueprints & Telemetry Tables
Section titled “3. Storage Blueprints & Telemetry Tables”AI persists all configuration in 7 Entries blueprints (AiBlueprints) and high-volume append-only telemetry in 3 dedicated SQL tables (AiTables):
| Storage Layer | Identifiers | Purpose |
|---|---|---|
7 Entries Blueprints |
ai-connections, ai-settings, ai-assistants, ai-rules, ai-voices, ai-glossaries, ai-mcp-keys |
Versioned configuration, encrypted key pools, assistants, rules, voices, glossaries, and hashed MCP access keys |
3 AiTables SQL Tables |
entries_tbl_ai_usage_logs (ai_usage_logs), entries_tbl_ai_conversations (ai_conversations), entries_tbl_ai_mcp_logs (ai_mcp_logs) |
Token/cost/latency ledger, editorial & chat conversation transcripts, and MCP JSON-RPC audit trails |
| Local Vector DB | site/assets/cache/ai/vectors.sqlite (ai_vectors) |
Default SqliteVectorStore semantic embeddings (swappable to NeuronFileVectorStore, QdrantVectorStore, or InMemoryVectorStore) |
4. Capabilities, RAG & MCP Governance
Section titled “4. Capabilities, RAG & MCP Governance”Every tool exposed to internal agents (AgentRunner) or external MCP clients (McpServer) is registered through CapabilityRegistry (AiCapabilityProviderInterface):
- Built-in providers:
PagesCapabilityProvider,EntriesCapabilityProvider, andKnowledgeCapabilityProvider. - Every tool declares a
RiskClass(read-only, propose-only, write, or destructive) enforced against both the acting ProcessWire user’s permissions and the MCP key’s write policy.