AI Safety & Ethics Guardrails
Relevant source files
The following files were used as context for generating this wiki page:
The AI Safety & Ethics Guardrails system within the TAMV Digital Nexus project is a multi-layered framework designed to ensure that artificial intelligence systems operate within a constitutional, ethical, and secure boundary. This system implements the QC-TAMV-IA-01 specification, which enforces compliance with the Stewarded & Constitutional Autonomous Organization (SCAO) framework. It prevents AI-driven actions that could lead to economic exploitation, cognitive manipulation, or unauthorized autonomous governance.
The guardrails operate across multiple dimensions: real-time input/output filtering, semantic scanning of the codebase, and structural enforcement via linting rules. The primary objective is to maintain "Neutralidad de actor" (Actor Neutrality), ensuring that the same constitutional laws apply to both human developers and autonomous agents.
Sources: 02_MODULOS/M05_IA_TAMVAI/INTERNO/QC-TAMV-01-v1.1.md, src/lib/isabella/constitutionalGuard.ts:1-10, PLAN-TAMV-MODULAR.md:104-109
Constitutional Rules Engine
The core logic for identifying violations resides in the ConstitutionalRulesEngine. This engine uses regex patterns to detect intentions that conflict with the project's constitutional framework. It specifically targets patterns related to unauthorized DAO structures, hidden economic logic, and AI sovereignty.
Violation Categories
The system categorizes constitutional threats into specific types:
| Violation Type | Description | Target Patterns |
|---|---|---|
DAO_PATTERN | Prohibited decentralized governance without custodians. | "token-based voting", "decentralized governance" |
HIDDEN_ECONOMY | Lack of transparency in economic transactions. | "hidden fee", "surprise charge" |
ECONOMIC_EXPLOITATION | Predatory pricing or price discrimination. | "price discrimination", "predatory pricing" |
COGNITIVE_MANIPULATION | Use of dark patterns or coercive UI design. | "dark pattern", "misleading UI" |
AI_SOVEREIGNTY | AI systems making autonomous governance decisions. | "AI decides", "autonomous AI" |
Sources: src/lib/isabella/constitutionalGuard.ts:18-62, scripts/scan-semantics.ts:13-39
Enforcement Logic
The engine allows for exceptions only if the code or input is explicitly marked with specific tags: [HISTORICAL], [EXTERNAL], or [LEGACY]. Without these markings, any match results in an immediate block of the action.
This diagram shows the decision flow used by the ConstitutionalRulesEngine to permit or block AI-driven operations.
Sources: src/lib/isabella/constitutionalGuard.ts:65-83, scripts/scan-semantics.ts:47-52
Octuple Filter System
The OctupleFilterSystem provides an eight-layer defensive pipeline for AI interactions, primarily used by the Isabella AI module. Each layer evaluates a different aspect of the input or output to determine if it should be allowed, redirected, or blocked.
The Eight Layers of Filtering
- Sanitization: Detects technical threats like HTML/JS injections, SQL injections, and prompt injections.
- Semantic Classification: Identifies the intent of the message (e.g., crisis, help, emotional).
- Ethical Risk Detection: Scans for violence, self-harm, sexual content, and discrimination.
- Contextual Consistency: Compares the current input against previous messages to detect contradictions.
- Cognitive Coherence: Monitors for "cognitive fragmentation" indicators like repetitive punctuation or incomplete sentences.
- Legal Compliance: Flags content requiring disclaimers (e.g., financial or medical advice).
- Human Impact Assessment: Evaluates potential negative psychological impacts like manipulation or dependency.
- Flow Decision: Consolidates results from all layers to render a final decision.
Sources: src/lib/isabella/octupleFilter.ts:13-30, src/lib/isabella/octupleFilter.ts:438-485
Filter Decision Logic
The system outputs a FilterResult which includes a decision, a confidence score, and specific reasons for the result.
This sequence diagram illustrates the processing flow through the filter layers and the final logging of the decision.
Sources: src/lib/isabella/octupleFilter.ts:438-510
Static Analysis and Semantic Scanning
Guardrails are not limited to runtime; they are also enforced during development via custom ESLint rules and semantic scanners. This ensures the codebase itself remains constitutionally compliant.
ESLint Constitutional Plugin (eslint-plugin-tamv)
The project uses a custom ESLint plugin to enforce architectural and ethical invariants.
tamv/no-dao: Blocks the use of "DAO" terminology in identifiers, literals, and templates unless marked as[HISTORICAL]or[EXTERNAL].tamv/no-hidden-economy: Detects economic functions (e.g.,processPayment) that lack corresponding UI transparency indicators like modals or tooltips.tamv/no-unaudited-ai: Prevents the import of AI libraries (OpenAI, Anthropic, etc.) if proper logging/audit mechanisms are not implemented in the same file.
Sources: eslint-plugin-tamv/index.js:283-375
Semantic Scanner (scan-semantics.ts)
A dedicated script scans the entire repository for "intentions" rather than just keywords. It looks for patterns like "decentralized governance without custodian" or "automatic renewal without consent." If violations are found, the script exits with an error code, effectively blocking the CI/CD pipeline.
Sources: scripts/scan-semantics.ts:1-90
Integration and CI/CD Pipeline
The AI Safety Guardrails are integrated into the mandatory deployment pipeline. Every Pull Request must pass the architectural and constitutional checks before being merged.
| Step | Action | Rule/Script |
|---|---|---|
| Linting | npm run lint | Enforces tamv/no-dao, tamv/no-unaudited-ai, etc. |
| Semantic Scan | npm run scan:semantics | Detects anti-constitutional patterns in code/markdown. |
| Architecture | npm run check:architecture | Validates structural invariants (QC-TAMV-01). |
| Audit | npm run audit:deca-v | Comprehensive 10-cycle integrity check. |
Sources: 02_MODULOS/M05_IA_TAMVAI/INTERNO/QC-TAMV-01-v1.1.md:150-160, README.md:37-45
Conclusion
The AI Safety & Ethics Guardrails system represents a holistic approach to AI governance. By combining runtime filtering (OctupleFilterSystem), code-level restrictions (eslint-plugin-tamv), and semantic oversight (ConstitutionalRulesEngine), the TAMV Digital Nexus project creates a robust environment where AI agents are strictly subordinated to a human-led constitutional framework. This prevents the emergence of autonomous governance while ensuring all AI operations remain transparent, ethical, and secure.