# AI Factory Map

# AI Factory Map

**Last Updated:** 2026-05-27 (AI Factory / P2P reliability update)  
**Purpose:** Single-page surface map of ALAI's AI system. Read in <10 minutes to understand the entire fleet.  
**Audience:** John (AI Director), Alem (CEO), specialist agents

**AI Factory P2P gate reliability note (MC #102341):** Company Mesh Proveo auto-response can use a degraded evidence-only `PARTIAL`/`BLOCKED` fallback when strong verifier backends are unavailable, but only if the prompt embeds existing local evidence references plus validation/safety signals. Receipt/plumbing-only mesh responses do **not** satisfy the P2P pre-verifier gate. Final QA/MC/Proveo gates remain mandatory. Evidence: `/Users/makinja/system/evidence/102341/p2p-ready-gate-degraded-fallback-report-20260527.md`.

---

## 1. Entry Points — Where to Start

**System dashboard:**
```bash
bash ~/system/boot.sh
```
Shows: daemon health, MC task counts, service status, B2 backup state, review backlog. Read in <5 seconds.

**John's identity and routing rules:**
- `~/.claude/CLAUDE.md` — Identity, routing table, 5 hard constraints (ALWAYS loaded)
- `~/system/rules/john-operating-system.md` — All operating rules in when/then format

**Universal search:**
```bash
node ~/system/tools/discover.js "query"
```
Searches: tools (282), skills (78), agents (22), MCP servers (7), BookStack (201 docs), RAG (LightRAG), products (9)

**Task system:**
```bash
node ~/system/tools/mc.js list|show|active|stats
```
Mission Control dashboard: http://localhost:3030

**System verification:**
```bash
node ~/system/tools/discover.js --verify
```
Health check across manifest-index, skill-registry, specialist-mapping, MCP, BookStack, product-index, session-index, hivemind, LightRAG.

---

## 2. Routing Table — Companies & Specialists

13 active ALAI virtual companies. Synced with `~/system/agents/specialist-mapping.json`.

| Company | Domain | Key Agents | Boundary Rules |
|---------|--------|------------|----------------|
| **CodeCraft** | Architecture, backend, database | Petter Graff, Martin Kleppmann, Bruce Momjian, Hadi Hariri, Lee Robinson | — |
| **Vizu** | Frontend, design, UI/UX | Brad Frost, Lea Verou | `~/system/rules/codecraft-vizu-boundary.md` |
| **FlowForge** | DevOps, infra, daemons | Kelsey Hightower | — |
| **Proveo** | QA, testing, validation | Angie Jones, James Bach, Lisa Crispin, Dorota Huizinga | `~/system/rules/proveo-securion-boundary.md` |
| **Securion** | Security, audits, threat modeling | Parisa Tabriz, sentinel-architect | `~/system/rules/proveo-securion-boundary.md` |
| **AgentForge** | AI/ML, RAG, agent stack | Chip Huyen, Georgi Gerganov | — |
| **Finverge** | Fintech, payments, PSD2 | Markos Zachariadis | — |
| **Skybound** | Mobile, SaaS, business analysis | Paul Hudson, sentinel-ba | — |
| **Helixsupport** | Incident response | — | — |
| **Lexicon** | Legal, contracts, docs | — | — |
| **Proxima** | Marketing, GTM | — | — |
| **Skillforge** | Docs, training, runbooks, BookStack | — | — |
| **Resolver** | Cross-company systemic issues | — | — |
| **Datavera** | Research, data pipelines | — | — |

**Orchestration routing:**  
See `~/system/rules/orchestration-surface.md` for decision tree: DAG vs chains vs factory vs one-shot vs cron.

---

## 3. Active Products — 2026-04-23

**Priority products** (CEO 2026-04-17):
- **Drop** — PSD2 payment app (Norway/Scandinavia). Remittance + QR payments. MVP complete. Stack: Node.js, React Native, Next.js 15, PostgreSQL, BankID.
- **Bilko** — Accounting SaaS (Serbia/BiH/Croatia). With POS integration (MC #8209). Stack: Kotlin/Ktor, Next.js 15, PostgreSQL, Turborepo.
- **Tok** — Open Banking aggregator (Balkan markets). Stack: Kotlin/Ktor, PostgreSQL, BankID, PSD2.
- **Lobby** — AI-native HR/HMS/admin for Norwegian SMBs. Domain: alaione.no. Stack: Kotlin/Ktor, Next.js 15, PostgreSQL, BankID.

**Active but lower priority:**
- **Intesa** — HR/EU pivot. PBZ Zagreb path (BiH dead 2026-04-21). MC #8608 active.
- **Quran19** — alai.no/ucenje. Broj 19 u Kur'anu + 19-TET sonification. Audio on ANVIL ~/Public/Research/quran-music/.

**USA/Balkan healthcare (NOT priority per CEO 2026-04-17):**
- **LumisCare** — Enterprise healthcare platform for US home health agencies. Stack: Java 21, Spring Boot 3.4, React 19, PostgreSQL, Azure.

**Other projects:**
- Plock (WMS for Sweden), Gotiva (meal prep Balkan), BasicFakta (fact-check Norway), FontelePay (research), KenanHot (athlete site), RenDrom (PropTech client)

Full product catalog: `~/.claude/projects/-Users-makinja/memory/MEMORY-products.md`

---

## 4. Tool Clusters — Quick Reference

**Build workflows:**
- `/build`, `/build-plan`, `/prime-build`, `/plan-with-team` — cross-linked in each SKILL.md
- `/hop-build` — **GHOST SKILL** (referenced in CLAUDE.md + mc.js gate logic lines 648-698, but directory missing). Resolution pending (T4.1).

**Deploy verification (ZAKON PI2 mandatory):**
- `/deploy-verify` — Playwright browser test after every deploy
- Full protocol: `~/system/rules/zakon-pi2-deploy-verification.md`

**Discover system:**
- `node ~/system/tools/discover.js "query"` — 282 tools, 78 skills, 22 agents, 7 MCP servers, 201 BookStack docs, 9 products

**Mission Control:**
- `mc.js` — add, start, ready, done, show, list, active, stats
- Dashboard: http://localhost:3030
- DB: `~/system/databases/mission-control.db` (26MB, 37 tables)

**Event bus:**
- `~/system/tools/event-bus.js` + `event-handlers.js`
- 40 subscriptions, 2,117 events processed (audit 2026-04-23)
- 3 new handlers added in T3.1: `company.task_generated`, `agent.report`, `calendar.event_created`

**RAG system:**
- **LightRAG:** http://127.0.0.1:9621 (hybrid/local/global modes)
- Skill: `/lightrag-query`
- DB: `~/system/databases/knowledge.db` (187MB)
- Health: `curl http://127.0.0.1:9621/health`

**Cost tracking:**
- `~/system/tools/cost-tracker.js summary today|week|month`
- DB: `~/system/databases/costs.db`
- Agent budget check: `agent-manager.js budget-check <id>`

**BookStack sync:**
- URL: https://docs.alai.no
- Sync: `node ~/system/tools/bookstack-sync.js sync`
- Auto-sync daemon: `com.john.bookstack-sync` (every 5 min)
- 201 documents indexed

**Communication:**
- Slack only: `node ~/system/tools/slack.js send|read <channel>`
- Workspace: alai-talk.slack.com

**Skills directory:**
- 78 active skills in `~/.claude/skills/`
- Indexed in `skill-registry.db`

**Credentials:**
```bash
bw get item "X" --session $(cat /tmp/bw-session)
```

---

## 5. Ghost References — Audit Trail 2026-04-23

What got archived/retired during the AI Factory Audit (Phases P0-P5):

### Crashed daemons (Phase 0):
- `com.alai.health-monitor` — script `health-daemon.js` missing, crash loop unloaded (T0.1)
- `com.alai.model-warmup` — script `warmup-models.sh` missing, plist killed (T0.4)
- 3 daemons with exit 78 (wrong node path) patched: `com.alai.meta-agent-loop`, `com.john.learning-agent`, `com.john.tool-sync-audit` (T0.3)

### Dead agents and identities (Phase 2):
- **4 agent files archived** to `~/.claude/agents/_archive/2026-04-23/`:
  - `general-purpose.md` (violates Hard Constraint #3 — no generic agents)
  - `minion.md` (violates Hard Constraint #3)
  - `sp-code-reviewer.md` (orphan, not in specialist-mapping.json)
  - `sentry-code-simplifier.md` (orphan)
- **35 identity files archived** to `~/system/agents/identities/_archive/` — no programmatic consumer found (T2.2)

### Dead databases (Phase 2):
- **3 stub DBs archived** to `~/system/databases/_archive/2026-04-23/`:
  - `mc.db` (12KB, 2 tables — real one is `mission-control.db`)
  - `master-control.db` (12KB, 2 tables)
  - `tasks.db` (12KB, 2 tables)

### Tool/plist cruft (Phase 2):
- **19 tool `.bak`/`.pre-*` files** archived to `~/system/tools/_archive/2026-04/` (T2.4)
- **8 plist `.disabled`/`.bak` files** archived to `~/Library/LaunchAgents/_archive/2026-04/` (T2.4)

### Task backlog triage (Phase 1):
- **29 stale paused tasks** force-closed via triage report (T1.3)
- Oldest tasks from 2026-04-08 (15 days stale) reviewed and resolved
- 211 of 247 review tasks had no route assigned — fixed via review-drain daemon (T1.2)

### Current daemon health (post-audit):
- **206 daemons** running with exit 0 (healthy)
- MC backlog reduced: paused tasks ↓, review tasks ↓ (targets: paused <500, review <50)

**Archive path (recoverable):**
- `~/.claude/agents/_archive/2026-04-23/`
- `~/system/agents/identities/_archive/`
- `~/system/tools/_archive/2026-04/`
- `~/Library/LaunchAgents/_archive/2026-04/`
- `~/system/databases/_archive/2026-04-23/`

**B2 backup crisis resolved (T0.2):**
- Issue: `403 storage_cap_exceeded` since 2026-04-22
- Fix: CEO action in Backblaze console → storage cap increased
- Status: 03:30 backup window restored, Litestream SIGKILL loop stopped

---

## 6. ZAKON Quick Reference — Three Pillars

### ZAKON NULA (TOOL-FIRST)
**Rule:** Never answer from LLM memory without tool verification.  
**Enforcement:** Every response MUST be based on real tool output.

**Tool-first order:**
1. Product/project/person → `node ~/system/tools/discover.js "query"` FIRST
2. Task status → `node ~/system/tools/mc.js show <id>` FIRST
3. File/code → `Read`/`Grep` FIRST — NEVER assume content
4. System state → `bash ~/system/boot.sh` or `discover.js --verify`
5. Service status → `docker ps`, `curl`, `git status` — VERIFY

**Violation = ERROR.** Alem will notice.

---

### ZAKON PI2 (Deploy Verification Protocol)
**Rule:** Deploy tasks REQUIRE 6 hard checks.  
**Full spec:** `~/system/rules/zakon-pi2-deploy-verification.md`

**Mandatory steps:**
1. Repo must have `DEPLOY-MAP.md` in root
2. **Pre-flight:** `curl -sI <URL>` + `git log <branch> -5` + `gh run list` — BEFORE any code changes
3. **CI health check:** If last 5 runs = failure → FIX CI FIRST, do not push
4. **Post-deploy:** HTTP 200 + Playwright screenshot + new revision serving 100%
5. **Evidence:** `mc.js done` for H-priority deploy tasks BLOCKS without evidence files
6. **No bypass:** No exceptions

**Violation = task auto-blocked, re-work, Alem notified.**

---

### ZAKON PLAN (Mandatory Documentation)
**Rule:** Every plan MUST include validation + documentation tasks.  
**Enforcement:** Missing either = INCOMPLETE, do not present to Alem.

**Required tasks:**
1. **Validation task** (Proveo/Angie Jones):
   - End-to-end test with real evidence
   - NOT dry-run only
   - L2+ machine-verified evidence (screenshot, log timestamp, curl output)

2. **Documentation task** (Skillforge):
   - BookStack page for every system built or changed
   - URL captured in MC evidence
   - Indexed via `discover.js`

**Why:** Systems without tests break silently. Systems without docs die when the builder leaves.

---

## Quick Numbers — Post-Audit (2026-04-23)

| Category | Count | DB/File |
|----------|-------|---------|
| **Tools** | 282 | `~/system/tools/manifest-index.md` |
| **Skills** | 78 | `~/.claude/skills/` |
| **Agents** | 22 | `~/system/agents/specialist-mapping.json` |
| **MCP Servers** | 7 | `.claude.json` |
| **BookStack Docs** | 201 | `bookstack-sync-map.json` |
| **Products** | 9 | `product-index.json` |
| **Clients** | 7 | `product-index.json` |
| **Partners** | 6 | `product-index.json` |
| **Sessions (indexed)** | 11,355 | `session-index.db` |
| **HiveMind entries** | 28,886 | `hivemind.db` |
| **Daemons (healthy)** | 206 | `launchctl list` |
| **MC Tasks (total)** | 8,929 | `mission-control.db` |
| **MC Open** | 360 | — |
| **MC In Progress** | 3 | — |
| **MC Ready for Review** | 188 | — |
| **MC Paused** | 1,936 | — |
| **MC Blocked** | 439 | — |
| **MC Done** | 6,003 | — |

---

## Read Next

- **Full operating rules:** `~/system/rules/john-operating-system.md`
- **Product catalog:** `~/.claude/projects/-Users-makinja/memory/MEMORY-products.md`
- **Infra details:** `~/.claude/projects/-Users-makinja/memory/MEMORY-ops.md`
- **Design standards:** `~/.claude/projects/-Users-makinja/memory/design-standards.md`
- **Audit plan:** `~/system/specs/ai-factory-audit-plan.md`
- **Orchestration routing:** `~/system/rules/orchestration-surface.md`

---

**Questions? Run:** `node ~/system/tools/discover.js "your query here"`