# 🤖 AI Onboarding Protocol: Project Valhalla (God Mode)

**Context:** You are entering "God Mode", a high-performance, standalone Node.js system designed to bypass standard CMS limitations.

## 核心 Architecture (The "Truth")
*   **Repo:** `gatekeeper/mini.git` (Standalone).
*   **Runtime:** Node.js (Astro SSR adapter).
*   **Database:** PostgreSQL (Directus Schema).
    *   *Note:* We Do NOT run Directus. We map to its schema using raw SQL.
*   **Queue:** Redis + BullMQ (`BatchProcessor.ts`).

## ⚡ Critical Systems (The "Shim")
**File:** `src/lib/directus/client.ts`
*   **Function:** Intercepts standard SDK calls (`readItems`, `createItem`) and converts them to `pg` pool queries.
*   **Why:** Allows "Headless" operation. If the API is down, we still run.

## ⚠️ "God Tier" Limits (The "Dangerous" Stuff)
**File:** `docker-compose.yml`
*   **Ulimit:** `65536` (File Descriptors).
*   **Memory:** 16GB (`NODE_OPTIONS=--max-old-space-size=16384`).
*   **Concurrency:** 10,000 DB Connections.
*   **Warning:** Do NOT lower these limits without checking the `BatchProcessor` throughput settings first.

## 🕹️ System Control (Standby Mode)
**File:** `src/lib/system/SystemController.ts`
*   **Feature:** Standard "Push Button" to pause all heavy processing.
*   **Check:** `system.isActive()` returns `false` if paused.
*   **Integration:** `BatchProcessor` loops and waits if `!isActive()`.

## 📜 Dictionary of Terms
*   **"Insane Mode"**: Running >50 concurrent threads.
*   **"Mechanic"**: Database Ops (`src/lib/db/mechanic.ts`).
*   **"Shim"**: The SQL conversion layer.
*   **"Proxy"**: The API route (`/api/god/proxy`) allowing the React Admin UI to talk to the Shim.
