diff --git a/docs/architecture/gemma2-compliance.md b/docs/architecture/gemma2-compliance.md new file mode 100644 index 000000000..360a54fcd --- /dev/null +++ b/docs/architecture/gemma2-compliance.md @@ -0,0 +1,87 @@ +# Gemma 2 Re-voicing: Compliance & Implementation Framework + +**Status:** Reference +**Author:** Gemini (synthesizing a design sparring session with Jeroen) +**Date:** 2026-03-07 +**Related:** [proposed-llm-voice.md](proposed-llm-voice.md) + +--- + +## 1. Overview + +This document outlines the compliance and operational framework for integrating Gemma 2 2B as a performance-tier stylistic layer for dynamic NPC dialogue. The core intent is a **"Closed-Loop"** system where the AI is the primary author of stylized content, directed by human-authored patterns and "Injector Clauses." + +--- + +## 2. Commercial Licensing & Compliance Checklist + +Because Gemma 2 uses a custom **Gemma Terms of Use** rather than standard open-source licenses, the following obligations must be met for commercial offering: + +- **[ ] Attribution Requirement:** Include a clear notice in the game's legal/credits menu: *"Gemma is provided under and subject to the Gemma Terms of Use."* +- **[ ] EULA Flow-Down:** Update the game's End User License Agreement (EULA) to include provisions at least as restrictive as the **Gemma Prohibited Use Policy**. +- **[ ] Non-Deception Clause:** Ensure users are not misled into believing AI-generated text was human-authored. +- **[ ] Asset Distribution:** If bundling model weights within the game installer, the full text of the Gemma Terms must be included in the distribution directory. +- **[ ] Revenue/User Cap:** Confirm no special license is currently required, as there is no revenue ceiling for Gemma 2 commercial use. + +--- + +## 3. AI Disclosure & Authorship Framework + +Given the game is fully AI-generated based on human-curated direction, the following disclosure model is established: + +- **Human Domain:** Architecture, gameplay mechanics, world-building principles, and "Injector" pattern design. +- **AI Domain:** All dialogue (Claude/Gemma 2), visuals, and audio. +- **Mandatory Public Notice:** + > "This game was fully generated by AI based on carefully curated human-written direction prompts. The gameplay and patterns used to generate content are human-crafted, but all text is AI-generated by Claude (base game) and Gemma 2 (AI-voicing mode). All visuals and audio are AI-generated based on these world-building principles." + +--- + +## 4. Operational Safety & Architecture (Closed-Loop) + +The "Re-voicing" pattern de-risks compliance by removing autonomous player prompting. + +- **Risk Mitigation:** The player has no direct input to the model; inputs are strictly controlled via the internal **Semantic Core** and **Injector System**. +- **Injector Integrity:** We are responsible for ensuring that "Mood" or "Culture" injectors do not force the model to violate safety policies (e.g., generating hate speech or sexually explicit content). +- **Sanitization:** Player-defined strings (like character names) must be sanitized before entering the background "Re-voicing" worker to prevent accidental prompt injection. + +--- + +## 5. Modding Policy: LLM Boundary + +By restricting "AI-Enhanced Dialogue" to the base game, the biggest legal and technical loophole in the architecture is closed while maintaining total control over Gemma 2 compliance obligations. + +### The "Pseudo-Dynamic" Compromise + +Mods can tap into **Step 1 (Semantic Core)** generation without access to **Step 2 (The Re-voicing LLM)**: + +- **Modder's Workflow:** Modders write standard, functional "Semantic Lines." +- **The Hybrid System:** If a modded NPC is in a "Vanilla" location, the system can pull from a pre-cached library of "Cultural Injectors" that have already been safely pre-generated. +- **The Result:** The modder doesn't get to prompt the LLM, but their characters can still use high-quality, pre-verified "Krenn" or "Ruthless" voice templates. + +### AI Dialogue & Modding Policy (EULA) + +> **Availability:** AI-Enhanced Re-voicing is a premium, curated feature reserved for official game content. +> +> **Restriction:** To ensure compliance with AI safety and licensing terms (Gemma Terms of Use), the LLM inference engine is not exposed to third-party modded scripts. +> +> **Fallback:** Modded content will automatically utilize the high-performance, template-based dialogue system, ensuring universal compatibility and safety. + +--- + +## 6. A/B Prompt Spike Stress-Test Checklist + +As we move into the technical validation phase (comparing Gemma 2 2B vs. Phi-3-mini), the spike must evaluate: + +- **[ ] Safety Floor:** Do either model's internal filters refuse to process dark fantasy themes or combat logs? +- **[ ] Stylistic Adherence:** How reliably do "Injector Clauses" (e.g., `[Bold]`, `[Krenn Culture]`) shift the output of the 2B model? +- **[ ] Hardware Overhead:** Measured CPU/RAM impact of the background worker thread on target consumer hardware. +- **[ ] Non-LLM Fallback:** Verification that the "Re-voicing" layer can be toggled OFF without breaking game state. + +--- + +## 7. Summary + +- **Compliance:** Clear to sell the game without royalties, provided the mandatory Gemma 2 Attribution and AI Disclosure notice are included. +- **Architecture:** The "Re-voicing" model solves performance and authorial control issues by treating character voice as an i18n localization task. +- **Governance:** By "Closed-Looping" the system and excluding mods from LLM access, 90% of legal liability regarding prohibited content is eliminated. +- **Hardware:** The optional toggle and background queue ensure that even players on low-end hardware have a 100% functional (if less "flavored") experience.