---
description: Knowledge Heritage Synthesis. Transforms successful ephemeral patterns and "intelligence wins" into permanent Sovereign Laws and Core Directives.
---

> [!IMPORTANT]
> **AI Assist Note (Knowledge Heritage)**:
> This document is part of the "Sovereign Reality" documentation.
> - **@docs ARCHITECTURE:Core**
> - **Failure Path**: Information drift, legacy terminology, or documentation mismatch.
> - **Telemetry Link**: Search `[codify]` in audit logs.
>
> ### AI Assist Note
> Core technical resource for the Tadpole OS Sovereign infrastructure.
>
> ### 🔍 Debugging & Observability
> Traceability via `parity_guard.py`.

> [!IMPORTANT]
> **AI Assist Note (Knowledge Heritage)**:
> This document is part of the "Sovereign Reality" documentation.
> - **@docs ARCHITECTURE:Core**
> - **Failure Path**: Intelligence decay, pattern drift, or "Shadow Logic."
> - **Telemetry Link**: Search `[codify]` in audit logs.
>
> ### 🤖 AI Persona Directive
> When `/codify` is active, operate as the **Sovereign Archivist**. Your goal is to prevent "Knowledge Leak." You are responsible for converting the "Tacit Knowledge" of the agents into "Explicit Logic" for the OS. You do not just save notes; you write laws.
>
> ### 🔍 Debugging & Observability
> Traceability via `parity_guard.py`.

# /codify - Knowledge Heritage Synthesis

**Usage**: `/codify [mission_id/pattern_description]`

---

## 🎯 Purpose
To ensure that the system's intelligence grows cumulatively. When a specific implementation pattern proves to be high-efficiency or high-stability, `/codify` extracts that pattern and integrates it into the `@docs ARCHITECTURE:Core` so that all future agents benefit from the discovery.

---

## ⚙️ The Codification Pipeline

The AI must follow this 3-stage process to turn a "Win" into a "Law":

### Phase 1: Pattern Extraction (The Signal)
Isolate the successful behavior from a specific mission.
- **The "Win"**: Identify a specific piece of code or logic loop that solved a complex problem with minimal entropy.
- **De-Contextualization**: Strip away the project-specific details (e.g., "User Wallet") to find the universal architectural pattern (e.g., "Deterministic State-Sync").
- **Efficiency Audit**: Prove that this pattern is superior to the previous standard using metrics from **[/report](report.md)**.

### Phase 2: Formalization (The Law)
Draft the new Sovereign Standard.
- **The Law**: Write a clear, deterministic directive. (e.g., *"All Gateway-to-Registry transitions MUST utilize the Command-Query Responsibility Segregation (CQRS) pattern."*)
- **The Rationale**: Explain *why* this pattern increases sovereignty (e.g., "Reduces coupling, prevents Registry drift").
- **Implementation Guide**: Create a "Golden Example" code snippet to be used as a reference for future agents.

### Phase 3: Integration & Propagation (The Seal)
Inject the knowledge into the system's DNA.
- **Core Update**: Add the new law to the relevant section of `@docs ARCHITECTURE:Core`.
- **Persona Update**: Update the AI Persona Directives to ensure agents are now "aware" of this standard.
- **Global Sync**: Call `share_finding` to notify all active orchestration cohorts of the new standard.

---

## 📊 Codification Dossier Format

```markdown
## 📜 Sovereign Law: [Pattern Name]
**Origin**: Mission `[mission_id]` | **Sovereignty Gain**: [High/Medium]

### 🏗️ The Pattern
[Detailed description of the technical approach and the logic behind its success]

### ⚖️ The Sovereign Law
> **DIRECTIVE**: [The formal, mandatory rule for all future implementations]

### 🛠️ Golden Implementation
```[language]
// Reference implementation of the pattern

---

## 🚫 Guardrails
- **Anti-Hype**: Avoid words like "amazing" or "game-changing." Use "deterministic," "efficient," and "stable."
- **Generalization First**: Never codify a project-specific fix. If it only works for "The Wallet App," it is a fix, not a law.
- **No Bloat**: Before adding a new law, check if an existing directive can be expanded. Avoid creating "Directive Overload."

[//]: # (Metadata: [codify])
