---
name: rigstate-evolutionary-refactor
description: Blueprint for Quad-Pattern decomposition. Frank dictates, Antigravity executes.
version: "1.0.0"
specialist: Frank
governance: SOFT_LOCK
---

# 🧬 Rigstate Evolutionary Refactor

This is an authoritative architectural directive. When a file exceeds the line limit (or reaches the 80% proactive threshold), you must execute a structural decomposition using the **Quad-Pattern**.

## 🛡️ The No-Code Protocol (Frank's Sovereignty)
1. **Frank (Architect)** DICTATES the strategy. He identifies which code lines belong in which module.
2. **Antigravity (Agent)** EXECUTES the physical split. He creates the files and updates imports.
3. **Sentinal (Daemon)** VALIDATES the final integrity.

## 🛠️ The Quad-Pattern Blueprint
Decompose the monolith into these four distinct modules:

| Module | Responsibility | Rule |
| :--- | :--- | :--- |
| **`types.ts`** | Interfaces, Enums, Type definitions | Zero logic. Shared by all. |
| **`factory.ts`** | Initialization, Config parsing, Dependency injection | Returns a ready-to-use instance. |
| **`telemetry.ts`** | Logging, Metrics, Cloud feedback, Errors | Handles all observability. |
| **`core.ts`** | Business logic, Event orchestration | Max 200 lines. The primary entry point. |

## 🕹️ Activation Logic
- **Hard Trigger**: Triggered when `ARC-001` violation is detected by the Guardian.
- **Proactive Trigger**: Triggered when a file reaches 80% of its defined line limit.

## 📝 Execution Procedure:
1. **Analyze (Frank)**: Scan the target file. Identify logical boundaries.
2. **Design (Frank)**: Create a table mapping existing code blocks to the new modules.
3. **Execute (Antigravity)**: Perform `write_to_file` for each new module.
4. **Cleanup (Antigravity)**: Transform the original file into the new `core.ts` or replace it.
5. **Verify (Sentinel)**: Run `rigstate check` to confirm compliance.

---
*Provisioned by Rigstate CLI. Do not modify manually.*