Skip to content

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.

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)"]
  • Connections (ai-connections): Each connection picks one of 10 ProviderDriver drivers (openrouter, gemini, anthropic, openai, deepseek, mistral, xai, ollama, openai-compatible, deepl) and holds one or more encrypted API keys rotated via KeyStrategy (failover or round_robin).
  • Model Discovery (ModelDiscoveryService): Fetches live /models catalogs from your connected providers and lets you toggle capabilities (Chat, JSON Schema, Stream, Translate, Vision, Image Gen, Embedding).
  • 7 ModelTier Routes: 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 by task:*, template:*, or blueprint:*, paired with FieldScopeMatcher read/write allowlists.
  • Brand Voices (ai-voices): Tone profiles specifying target audience, style guidelines, and banned phrases.
  • Glossaries (ai-glossaries): Protected brand terms and Source => Target translation 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.

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)

Every tool exposed to internal agents (AgentRunner) or external MCP clients (McpServer) is registered through CapabilityRegistry (AiCapabilityProviderInterface):

  • Built-in providers: PagesCapabilityProvider, EntriesCapabilityProvider, and KnowledgeCapabilityProvider.
  • 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.

Next steps