Constitutional Guard & Policies
Relevant source files
The following files were used as context for generating this wiki page:
- federation/tamv-digital-nexus/apps/web/src/lib/isabella/constitutionalGuard.ts
- src/pages/wiki/implementacion/CicdPipelines.tsx
- federation/tamv-digital-nexus/scripts/scan-semantics.ts
- federation/tamv-digital-nexus/apps/web/src/lib/constitutionEngine.ts
- federation/tamv-digital-nexus/AGENTS.md
- src/pages/wiki/gobernanza/GobernanzaDatos.tsx
The Constitutional Guard & Policies system within the TAMV ecosystem (specifically the QC-TAMV-IA-01 implementation) serves as a foundational governance layer. Its primary purpose is to ensure that all actions taken by AI systems, human developers, and automated pipelines comply with the Stewarded & Constitutional Autonomous Organization (SCAO) framework. It translates high-level design principles into executable technical invariants, preventing patterns associated with predatory economics, cognitive manipulation, and uncustodied governance.
Sources: federation/tamv-digital-nexus/apps/web/src/lib/isabella/constitutionalGuard.ts:1-10, src/pages/wiki/implementacion/CicdPipelines.tsx:13-18
1. Constitutional Laws (QC-TAMV-01)
The framework is governed by a set of nine core laws (L1–L9) that define non-negotiable technical invariants. These rules ensure structural determinism and separation of concerns across the architecture.
| Law | Name | Invariant Requirement |
|---|---|---|
| L1 | Raíz única | createRoot must exist only in src/main.tsx. |
| L2 | Enrutador único | BrowserRouter is restricted to src/App.tsx. |
| L3 | Diseño único | Layout.tsx must be mounted exactly once in App.tsx. |
| L4 | Correspondencia ruta–page | Each file in src/pages/* must correspond to a single route. |
| L5 | Responsabilidad de page | Pages compose modules/domains; they must not initialize services. |
| L6 | Módulos independientes | src/modules/* cannot import react-router-dom or pages. |
| L7 | Aislamiento visual | Route / cannot show components belonging to /login and vice versa. |
| L8 | Separation of concerns | No layer can assume the responsibilities of another. |
| L9 | Excepciones auditadas | Any exception to L1-L8 requires formal registration in DigyTAMV. |
Sources: src/pages/wiki/implementacion/CicdPipelines.tsx:21-34
2. Constitutional Guard Architecture
The system utilizes a multi-layered approach to enforce compliance, ranging from real-time execution guards to semantic scanners and CI/CD gates.
2.1 Rules Engine and Violation Detection
The ConstitutionalRulesEngine identifies specific violation types through regex pattern matching against actions and code metadata.
The system recognizes several high-level violation types:
- DAO_PATTERN: Prevents decentralized governance without custodians or token-based voting.
- HIDDEN_ECONOMY: Detects hidden fees or automatic renewals without consent.
- AI_SOVEREIGNTY: Blocks autonomous AI decision-making or AI-led governance.
- COGNITIVE_MANIPULATION: Identifies dark patterns and coercive UI designs.
Sources: federation/tamv-digital-nexus/apps/web/src/lib/isabella/constitutionalGuard.ts:17-56
2.2 Execution Guards and Middleware
Constitutional enforcement is integrated directly into the application lifecycle through wrappers and middleware.
constitutionalGuard(action): A synchronous check that throws an error if a violation is detected.executeWithConstitutionalGuard(action): An async wrapper that analyzes the string representation of a function before allowing execution.createConstitutionalMiddleware(): An AI operation middleware that inspects request bodies and returns a403 Forbiddenstatus upon violation detection.
Sources: federation/tamv-digital-nexus/apps/web/src/lib/isabella/constitutionalGuard.ts:74-114
3. Automated Scanning and CI/CD Enforcement
Policy enforcement is extended to the development workflow through static analysis and semantic scanning.
3.1 Semantic Scanner
The scan-semantics.ts utility (QC-TAMV-GOV-01) searches the codebase for intentions rather than just keywords. It flags patterns like "community treasury" or "predatory pricing" unless they are explicitly marked with [HISTORICAL], [EXTERNAL], or [LEGACY].
Sources: federation/tamv-digital-nexus/scripts/scan-semantics.ts:1-45
3.2 Pipeline MD-X5 (Deca-V)
All pull requests must pass a 10-cycle pipeline that includes constitutional linting.
The eslint-plugin-tamv enforces rules such as tamv-constitution/single-root and tamv-constitution/no-dao in "error" mode to prevent merging non-compliant code.
Sources: src/pages/wiki/implementacion/CicdPipelines.tsx:43-69
4. AI Agent Constraints
Autonomous agents operating within the tamv-digital-nexus workspace are subject to strict safety locks. The AGENTS.md configuration defines the following restrictions:
- Safety Locks:
CANON_LOCK=TRUEandCODE_WRITE=RESTRICTED. - Execution Mode:
DOCUMENTAL_ONLY. - Conflict Resolution: Agents must preserve the "Master Canon" and escalate conflicts for human review.
- Mandate: Agents cannot rename canonical modules or change legal wording without a
TODO_REVIEW_LEGALtag.
Sources: federation/tamv-digital-nexus/AGENTS.md:1-25, src/pages/wiki/implementacion/CicdPipelines.tsx:115-125
5. Data Governance and the Ledger
Constitutional compliance is also recorded for auditability. Every operation affecting data is registered in the BookPI ledger, ensuring a "Single Source of Truth" (SSoT) for the ecosystem's state and architectural decisions.
| Component | Governance Function |
|---|---|
| Editorial | Redaction and approval with total traceability. |
| Technical | Versioning, JSON-LD contracts, and CI/CD gates. |
| Ethical | Impact evaluation and compliance with UNESCO/GDPR. |
| PostgreSQL RLS | Row-level security for granular data access control. |
Sources: src/pages/wiki/gobernanza/GobernanzaDatos.tsx:5-45
The Constitutional Guard & Policies system ensures that the TAMV ecosystem remains a "Civilization Written in Code" where technology serves human dignity and territorial sovereignty, rather than autonomous or predatory interests.