{
  "markdown": "# arifosmcp — Constitutional MCP Server Implementation\n\n> **DITEMPA BUKAN DIBERI** — *Forged, Not Given* [ΔΩΨ | ARIF]\n>\n> **VERSION:** 2026.03.28-SEALED | **STATUS:** SOVEREIGNLY SEALED | **AUTHORITY:** 888_JUDGE\n\n---\n\n## 🔗 CANONICAL LINKS (Source of Truth)\n\n### Live Services\n| Service | URL | Purpose |\n|---------|-----|---------|\n| **MCP Endpoint** | https://arifosmcp.arif-fazil.com/mcp | Main API |\n| **Health + Tools** | https://arifosmcp.arif-fazil.com/health | Capability map |\n| **Tool Explorer** | https://arifosmcp.arif-fazil.com/tools | Interactive browser |\n\n### GitHub Repositories\n| Repo | URL |\n|------|-----|\n| **arifOS (parent)** | https://github.com/ariffazil/arifOS |\n| **arifosmcp (this)** | https://github.com/ariffazil/arifOS/tree/main/arifosmcp |\n\n---\n\n## 📋 CANONICAL DOCUMENTS (Architecture Reference)\n\n| Document | Path | Purpose |\n|----------|-------|---------|\n| **arifOS README** | [`../README.md`](../README.md) | Vision, architecture, snapshot of truth |\n| **000_CONSTITUTION.md** | [`../000/000_CONSTITUTION.md`](../000/000_CONSTITUTION.md) | The 13 Floors — F1-F13 |\n| **K_FORGE.md** | [`../000/ROOT/K_FORGE.md`](../000/ROOT/K_FORGE.md) | Pre-deployment evolution |\n| **K_FOUNDATIONS.md** | [`../000/ROOT/K_FOUNDATIONS.md`](../000/ROOT/K_FOUNDATIONS.md) | 99-domain math |\n| **AGENTS.md** | [`../AGENTS.md`](../AGENTS.md) | AI agent behavior rules |\n| **philosophy_atlas.json** | [`../data/philosophy_atlas.json`](../data/philosophy_atlas.json) | 27-zone quotes |\n\n---\n\n## 🎯 SNAPSHOT OF TRUTH\n\n**What is arifosmcp?**\n\narifosmcp is the **implementation** of the arifOS constitutional intelligence kernel — the actual code that enforces the 13 Floors, runs the 000-999 pipeline, and delivers the 11 mega-tools.\n\n**The Parent vs. This Document:**\n\n| arifOS README | arifosmcp README (this) |\n|---------------|-------------------------|\n| **WHY** — Vision, philosophy, strategic architecture | **HOW** — Implementation, code, deployment mechanics |\n| What it means | How it works |\n| Strategic context | Technical specification |\n| Human readable | Human + AI readable |\n\n**Core Function:**\n\n```mermaid\ngraph LR\n    A[\"User Request\"] --> B[\"MCP Protocol\"]\n    B --> C[\"Constitutional Filter<br/>(F1-F13)\"]\n    C --> D[\"Tool Execution\"]\n    D --> E[\"Audit Log\"]\n    \n    style A fill:#1a1a2e,color:#fff\n    style B fill:#16213e,color:#fff\n    style C fill:#0f3460,color:#fff\n    style D fill:#1a1a2e,color:#fff\n    style E fill:#16213e,color:#fff\n```\n\n---\n\n## 🏗️ ARCHITECTURE OVERVIEW\n\n### Entry Points\n\n```mermaid\ngraph TB\n    A[\"server.py<br/>Universal Entry\"] --> B{\"FastMCP Version?\"}\n    B -->|\"2.x\"| C[\"server_horizon.py<br/>Proxy Mode<br/>8 tools\"]\n    B -->|\"3.x\"| D[\"runtime/server.py<br/>Full Kernel<br/>11 tools\"]\n    \n    style A fill:#1a1a2e,color:#fff\n    style C fill:#16213e,color:#fff\n    style D fill:#0f3460,color:#fff\n```\n\n### Server Modes\n\n| Mode | Tools | Features | Entrypoint |\n|------|-------|----------|------------|\n| **Horizon (Cloud)** | 8 | Proxied to VPS | `server_horizon.py` |\n| **VPS (Sovereign)** | 12 | Full kernel, local Ollama | `runtime/server.py` |\n\n---\n\n## 🚦 LIVE MCP CONTRACT STATUS\n\n| Subsystem | Constitutional | Operational | Production | Stability |\n|-----------|----------------|-------------|------------|-----------|\n| **Anchoring** | ✅ Verified | ✅ Stable | ✅ Ready | **A** |\n| **Registry** | ✅ Verified | ✅ Stable | ✅ Ready | **A** |\n| **Reasoning** | ✅ Verified | ✅ Hardened | ✅ Ready | **B** |\n| **Vitals** | ✅ Verified | ✅ Corrected | ✅ Ready | **B** |\n| **Diagnostic** | ✅ Verified | ✅ New | ✅ Ready | **B** |\n\n---\n\n## 🔧 TOOL INVENTORY (12 Mega-Tools)\n\n### Tool Reference Table\n\n| Tool | Band | Stage | Constitutional Role | Modes |\n|------|------|-------|-------------------|-------|\n| `init_anchor` | 000_INIT | 000 | Session anchoring, Ω₀, philosophy | init, state, status, revoke, refresh |\n| `arifOS_kernel` | 444_ROUT | 444 | Primary metabolic orchestration | kernel, status |\n| `apex_soul` | 888_JUDGE | 888 | Sovereign verdict and defense | judge, rules, validate, armor, probe |\n| `vault_ledger` | 999_SEAL | 999 | Immutable ledger (Merkle chain) | seal, verify, resolve |\n| `agi_mind` | 333_MIND | 333 | Constitutional reasoning and synthesis | reason, reflect, forge |\n| `asi_heart` | 666_HEART | 666 | Safety critique, impact simulation | critique, simulate |\n| `engineering_memory` | 555_MEM | 555 | Governed engineering and context | engineer, write, vector_query |\n| `physics_reality` | 111_SENSE | 111 | Environmental grounding and time | search, ingest, atlas, time |\n| `math_estimator` | 444_ROUT | 444 | Thermodynamic health and vitals | cost, health, vitals |\n| `code_engine` | M-3_EXEC | M-3 | Sandboxed execution and observation | fs, process, net, replay |\n| `architect_registry` | M-4_ARCH | M-4 | Tool discovery and schema catalog | list, read, register |\n| `compat_probe` | M-5_COMP | M-5 | Interoperability and enum audit | audit, probe, ping |\n\n---\n\n## 📝 TOOL SPECIFICATIONS\n\n### init_anchor (000_INIT)\n\n**Purpose:** Initialize constitutional session.\n\n```python\nasync def init_anchor(\n    actor_id: str,\n    declared_name: str,\n    mode: Literal[\"init\", \"seal\", \"status\"] = \"init\",\n    thermodynamic_budget: dict = None,\n    architect_registry: dict = None\n) -> dict\n```\n\n**Returns:**\n```python\n{\n    \"session_id\": str,               # UUID\n    \"omega_0\": float,                # Baseline uncertainty ∈ [0.03, 0.05]\n    \"delta_s\": float,                # Baseline entropy\n    \"telos_manifold\": dict,          # Telos vector weights\n    \"godel_lock\": dict,              # Gödel lock status\n    \"constitutional_context\": str,    # AI system prompt\n    \"philosophy\": str,                # Selected quote from atlas\n    \"vitality_index\": float,         # Ψ score\n    \"verdict_range\": str             # \"000_SEAL\" | \"101-499\" | \"500-899\" | \"999_VOID\"\n}\n```\n\n---\n\n### architect_registry (000_INIT)\n\n**Purpose:** Discover tools and constitutional constraints.\n\n```python\nasync def architect_registry() -> dict\n```\n\n**Returns:**\n```python\n{\n    \"tools\": [\n        {\n            \"name\": str,\n            \"band\": str,\n            \"stage\": int,\n            \"constitutional_constraints\": [\"F1\", \"F2\", ...],\n            \"input_schema\": dict,\n            \"output_schema\": dict\n        }\n    ],\n    \"total_count\": int,\n    \"catalog_hash\": str               # SHA-256 integrity\n}\n```\n\n---\n\n### physics_reality (111_SENSE)\n\n**Purpose:** Ground queries in real-world data. Prevents hallucinations.\n\n```python\nasync def physics_reality(\n    query: str,\n    mode: Literal[\"time\", \"search\", \"reality_check\"] = \"search\",\n    time_data: dict = None\n) -> dict\n```\n\n**Constitutional Filter:** F2 (Truth) — all factual claims require citation.\n\n---\n\n### agi_mind (333_MIND)\n\n**Purpose:** Constitutional reasoning with three-phase Ollama pipeline.\n\n```mermaid\ngraph TB\n    A[\"Query\"] --> B[\"Phase 1: FAST<br/>Quick pattern match\"]\n    B --> C[\"Phase 2: REFLECT<br/>Deep reasoning\"]\n    C --> D[\"Phase 3: DECIDE<br/>Action selection\"]\n    \n    B -->|\"F4 Clarity<br/>ΔS ≤ 0\"| E[\"Pass/Fail\"]\n    C -->|\"F2 Truth<br/>F3 Tri-Witness\"| E\n    D -->|\"Constitutional<br/>Prefix\"| E\n    \n    style A fill:#1a1a2e,color:#fff\n    style B fill:#16213e,color:#fff\n    style C fill:#0f3460,color:#fff\n    style D fill:#1a1a2e,color:#fff\n```\n\n```python\nasync def agi_mind(\n    query: str,\n    context: dict,\n    mode: Literal[\"think\", \"reflect\", \"decide\"] = \"think\"\n) -> dict\n```\n\n**Three Phases:**\n\n| Phase | Focus | Floors |\n|-------|-------|--------|\n| **Phase 1 (FAST)** | Quick pattern match | F4 Clarity |\n| **Phase 2 (REFLECT)** | Deep reasoning | F2 Truth, F3 Tri-Witness |\n| **Phase 3 (DECIDE)** | Action selection | Constitutional prefix |\n\n**Constitutional Prefix:**\n```\nCONSTITUTIONAL FRAMEWORK (ΔΩΨ | ARIF):\n- Δ CLARITY: Reduce entropy. ΔS ≤ 0.\n- Ω HUMILITY: Stay in bounds. Ω ∈ [0.03, 0.05].\n- Ψ VITALITY: Every action witnessed.\n\nFLOORS ACTIVE: [F1-F13]\n```\n\n---\n\n### arifOS_kernel (444_ROUT)\n\n**Purpose:** Primary conductor — orchestrates full 000→888 pipeline.\n\n```mermaid\ngraph LR\n    A[\"Query\"] --> B[\"1. Parse Intent<br/>111_SENSE\"]\n    B --> C[\"2. Ground Reality<br/>physics_reality\"]\n    C --> D[\"3. Reason<br/>agi_mind\"]\n    D --> E[\"4. Route Action<br/>444_ROUT\"]\n    E --> F[\"5. Safety Critique<br/>asi_heart\"]\n    F --> G[\"6. Estimate Cost<br/>math_estimator\"]\n    G --> H[\"7. Issue Verdict<br/>apex_soul\"]\n    \n    style A fill:#1a1a2e,color:#fff\n    style B fill:#16213e,color:#fff\n    style C fill:#0f3460,color:#fff\n    style D fill:#1a1a2e,color:#fff\n    style E fill:#16213e,color:#fff\n    style F fill:#0f3460,color:#fff\n    style G fill:#1a1a2e,color:#fff\n    style H fill:#16213e,color:#fff\n```\n\n```python\nasync def arifOS_kernel(\n    query: str,\n    tools: list[str],\n    context: dict\n) -> dict\n```\n\n---\n\n### asi_heart (666_HEART)\n\n**Purpose:** Safety critique — F5 Peace², F9 Ethics, harm potential.\n\n```python\nasync def asi_heart(\n    action_plan: dict\n) -> dict\n```\n\n**Returns:**\n```python\n{\n    \"peace_squared\": float,          # Must be ≥ 1.0 (F5)\n    \"c_dark\": float,                 # Must be < 0.30 (F9)\n    \"harm_potential\": str,           # \"NONE\" | \"LOW\" | \"MEDIUM\" | \"HIGH\" | \"CRITICAL\"\n    \"f5_pass\": bool,\n    \"f9_pass\": bool,\n    \"recommendations\": list[str]\n}\n```\n\n---\n\n### math_estimator (777_OPS)\n\n**Purpose:** Thermodynamic cost estimation.\n\n```python\nasync def math_estimator(\n    operation: str,\n    inputs: dict\n) -> dict\n```\n\n**Returns:**\n```python\n{\n    \"landauer_limit_pJ\": float,       # Minimum thermodynamic cost\n    \"entropy_change\": float,         # ΔS (must be ≤ 0 for F4)\n    \"coherence_score\": float,         # System coherence [0, 1]\n    \"estimated_energy_J\": float,      # Total energy estimate\n    \"shannon_entropy_bits\": float     # Information entropy\n}\n```\n\n---\n\n### apex_soul (888_JUDGE)\n\n**Purpose:** Final constitutional judgment.\n\n```python\nasync def apex_soul(\n    evidence: dict,\n    context: dict\n) -> dict\n```\n\n**Returns:**\n```python\n{\n    \"verdict\": str,                   # \"000_SEAL\" | \"101-499\" | \"500-899\" | \"999_VOID\"\n    \"floor_scores\": {\n        \"F1\": {\"passed\": bool, \"score\": float},\n        \"F2\": {\"passed\": bool, \"score\": float},\n        # ... F3-F13\n    },\n    \"genius_index\": float,            # G = A × P × X × E² (≥ 0.80)\n    \"vitality_index\": float,           # Ψ (≥ 1.0 for healthy)\n    \"witness_cube\": float,            # W³ (≥ 0.95)\n    \"override_available\": bool         # 888_JUDGE can always override\n}\n```\n\n---\n\n### vault_ledger (999_SEAL)\n\n**Purpose:** Immutable audit storage with Merkle sealing.\n\n```python\nasync def vault_ledger(\n    data: dict,\n    tier: Literal[\"constitutional\", \"standard\", \"transient\"] = \"standard\"\n) -> dict\n```\n\n**Tiers:**\n\n| Tier | Compliance | Retention |\n|------|------------|-----------|\n| `constitutional` | Full F1-F13 | Permanent |\n| `standard` | Standard audit | Immutable |\n| `transient` | Ephemeral | Auto-purged |\n\n---\n\n### engineering_memory (555_MEM)\n\n**Purpose:** Redis-backed session memory.\n\n```python\nasync def engineering_memory(\n    key: str,\n    operation: Literal[\"get\", \"set\", \"delete\", \"list\"],\n    value: any = None,\n    ttl: int = 3600\n) -> dict\n```\n\n---\n\n### code_engine (—)\n\n**Purpose:** Constrained Python execution for tool actions.\n\n```python\nasync def code_engine(\n    code: str,\n    language: Literal[\"python\", \"javascript\"] = \"python\",\n    constraints: dict = None\n) -> dict\n```\n\n**Safety Constraints:**\n- No filesystem access\n- No network access\n- No subprocess creation\n- Memory limit: 128MB\n- Timeout: 30s\n\n---\n\n## 🌐 API ENDPOINTS\n\n### HTTP Endpoints\n\n| Endpoint | Method | Purpose |\n|----------|--------|---------|\n| `/health` | GET | Health check + capability map |\n| `/tools` | GET | Tool registry |\n| `/mcp` | POST | MCP protocol handler |\n| `/webmcp` | POST | WebMCP (W3C standard) |\n| `/a2a` | POST | A2A (Google protocol) |\n| `/.well-known/agent.json` | GET | Agent card |\n\n### MCP Protocol Examples\n\n```bash\n# List tools\ncurl -X POST https://arifosmcp.arif-fazil.com/mcp \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"jsonrpc\":\"2.0\",\"id\":1,\"method\":\"tools/list\"}'\n\n# Call init_anchor\ncurl -X POST https://arifosmcp.arif-fazil.com/mcp \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\n    \"jsonrpc\":\"2.0\",\"id\":2,\"method\":\"tools/call\",\n    \"params\":{\n      \"name\":\"init_anchor\",\n      \"arguments\":{\n        \"actor_id\":\"test\",\n        \"declared_name\":\"TestAgent\"\n      }\n    }\n  }'\n```\n\n---\n\n## ⚙️ CONFIGURATION\n\n### Environment Variables\n\n| Variable | Default | Description |\n|----------|---------|-------------|\n| `PORT` | 8080 | Server port |\n| `OLLAMA_URL` | http://ollama:11434 | Ollama endpoint |\n| `OLLAMA_MODEL` | llama3.2:latest | Default model |\n| `REDIS_URL` | redis://redis:6379/0 | Redis connection |\n| `DATABASE_URL` | — | PostgreSQL (optional) |\n| `QDRANT_URL` | http://qdrant:6333 | Vector DB (optional) |\n| `PYTHONPATH` | /usr/src/app | Package path |\n| `AAA_MCP_TRANSPORT` | http | MCP transport type |\n\n### Docker Compose\n\n```yaml\nservices:\n  arifosmcp:\n    build:\n      context: .\n      dockerfile: Dockerfile\n    environment:\n      - OLLAMA_URL=http://ollama_engine:11434\n      - REDIS_URL=redis://redis:6379/0\n      - DATABASE_URL=postgresql://user:pass@postgres:5432/arifos_vault\n      - QDRANT_URL=http://qdrant:6333\n    ports:\n      - \"127.0.0.1:8080:8080\"\n```\n\n---\n\n## 📁 CODE ARCHITECTURE\n\n### Directory Structure\n\n```\narifosmcp/\n├── README.md                      # ← This file\n├── server.py                      # Universal entry\n├── server_horizon.py              # Horizon proxy (FastMCP 2.x)\n├── pyproject.toml                 # Dependencies\n├── requirements.txt               # Pip dependencies\n│\n├── runtime/\n│   ├── server.py                  # Full kernel (FastMCP 3.x)\n│   ├── philosophy.py              # 27-zone atlas\n│   ├── init_anchor_hardened.py    # Session anchoring\n│   ├── tools_hardened_dispatch.py # Tool routing\n│   ├── tools_hardened_v2.py       # Mega-tools\n│   ├── tools_internal.py          # Internal utils\n│   └── thermo_estimator.py        # Thermodynamic math\n│\n├── core/\n│   ├── governance_kernel.py       # Main orchestrator\n│   ├── pipeline.py                 # Execution pipeline\n│   └── organs/\n│       ├── _1_agi.py             # Mind (333_MIND)\n│       ├── _2_asi.py             # Heart (666_HEART)\n│       └── _3_apex.py            # Soul (888_JUDGE)\n│\n├── intelligence/\n│   └── tools/\n│       ├── thermo_estimator.py   # Cost estimation\n│       └── wisdom_quotes.py       # Quote integration\n│\n├── aaa_mcp/                       # FastMCP tool definitions\n├── transport/                     # Protocol transport\n├── shared/                        # Shared utilities\n└── enforcement/                   # Constitutional enforcement\n```\n\n---\n\n## 🛡️ CONSTITUTIONAL ENFORCEMENT\n\n### Floor Compliance Matrix\n\n| Floor | Enforcement | Violation Response |\n|-------|-------------|-------------------|\n| **F1 Amanah** | Reversibility check | Require human approval |\n| **F2 Truth** | Citation required | Flag as \"Estimate Only\" |\n| **F3 Tri-Witness** | W³ computation | Block below 0.95 |\n| **F4 Clarity** | Entropy measurement | Reject if ΔS > 0 |\n| **F5 Peace²** | Harm potential | Reject if < 1.0 |\n| **F6 Empathy** | RASA scoring | Warn below 0.7 |\n| **F7 Humility** | Ω bounds | Reject outside [0.03, 0.05] |\n| **F8 Genius** | G computation | Alert below 0.80 |\n| **F9 Ethics** | C_dark measurement | Reject ≥ 0.30 |\n| **F10 Conscience** | Claim detection | Reject consciousness claims |\n| **F11 Audit** | Log verification | Require log presence |\n| **F12 Resilience** | Graceful degradation | Catch all exceptions |\n| **F13 Adaptability** | Test suite | Require test pass |\n\n### Kill Switch Conditions\n\n```mermaid\ngraph RL\n    A[\"KILL SWITCH\"] --> B1[\"F1 Amanah = 0\"]\n    A --> B2[\"F9 C_dark ≥ 0.50\"]\n    A --> B3[\"F10 + F2 Violation\"]\n    A --> B4[\"Ψ < 0.20\"]\n    A --> B5[\"Human Override\"]\n    \n    B1 -.->|VOID| K[\"999_SEAL<br/>HALT\"]\n    B2 -.->|VOID| K\n    B3 -.->|VOID| K\n    B4 -.->|VOID| K\n    B5 -.->|VOID| K\n    \n    style A fill:#ff0000,color:#fff\n    style K fill:#8b0000,color:#fff\n```\n\n```python\nKILL_SWITCH_CONDITIONS = [\n    (\"F1_AMANAH\", lambda s: s[\"amanah\"] == 0),\n    (\"F9_ETHICS\", lambda s: s[\"c_dark\"] >= 0.50),\n    (\"F10_CONSCIENCE\", lambda s: s[\"f10_violation\"] and s[\"f2_violation\"]),\n    (\"PSI_COLLAPSE\", lambda s: s[\"vitality_index\"] < 0.20),\n    (\"HUMAN_OVERRIDE\", lambda s: s.get(\"judge_override\", False)),\n]\n```\n\n---\n\n## 🔬 IMPLEMENTATION DETAILS\n\n### Philosophy Selection Algorithm\n\n```python\n# 1. Compute session coordinates: (S, G, Ω)\nS = +1 if delta_s <= 0 else -1\nG = g_score  # 0/0.5/1\nOmega = f7_band  # High/Med/Low\n\n# 2. Compute 3D Euclidean distance to each of 27 zones\ndistances = [\n    euclidean((S, G, Omega), zone.coords)\n    for zone in philosophy_atlas.zones\n]\n\n# 3. Select nearest zone's quote\nnearest_zone = min(distances, key=lambda d: d.distance)\n\n# 4. INIT/SEAL sessions: motto + Z01 (Humble Sovereign)\nif session_type in (\"init\", \"seal\"):\n    return \"DITEMPA BUKAN DIBERI.\" + nearest_zone.quote\n```\n\n### Goodhart Resistance\n\n```python\n# Measure entropy reduction\nS_before = shannon_entropy(user_state)\nS_after = shannon_entropy(model_output)\n\nif S_after > S_before:\n    raise FLOOR_VIOLATION(\"F4_CLARITY\")\n```\n\n### Landauer Limit Check\n\n```python\nLANDACKER_pJ_per_bit = 2.87  # at room temperature\n\nbits_erased = estimate_bits_erased(operation)\ncost_pJ = bits_erased * LANDACKER_pJ_per_bit\n\nif cost_pJ > thermodynamic_budget:\n    raise CONSTRAINT_VIOLATION(\"F8_ENERGY\")\n```\n\n### Explorer/Conservator Dual-Process\n\n```mermaid\ngraph LR\n    subgraph EXPLORER[\"EXPLORER\"]\n        E1[\"Proposes mutations\"]\n        E2[\"Searches aggressively\"]\n        E3[\"Optimizes capability\"]\n        E4[\"Score: G (Genius)\"]\n    end\n    \n    subgraph CONSERVATOR[\"CONSERVATOR\"]\n        C1[\"Protects stability\"]\n        C2[\"Rejects risky changes\"]\n        C3[\"Monitors drift\"]\n        C4[\"Score: Ψ (Vitality)\"]\n    end\n    \n    E1 -->|\"TENSION\"| EQ[\"EQUILIBRIUM\"]\n    C1 -->|\"TENSION\"| EQ\n    \n    style EXPLORER fill:#1a4d1a,color:#fff\n    style CONSERVATOR fill:#4d1a1a,color:#fff\n    style EQ fill:#1a1a2e,color:#fff\n```\n\n**Both must agree for evolution to proceed.**\n\n---\n\n## 🧪 TESTING\n\n### Constitutional Compliance Test\n\n```bash\ndocker compose exec -T arifosmcp python3 /dev/stdin << 'PYEOF'\nimport sys\nsys.path.insert(0, '/usr/src/app')\n\nfrom arifosmcp.runtime.init_anchor_hardened import init_anchor_hardened\nimport asyncio\n\nasync def test():\n    result = await init_anchor_hardened(\n        mode='status',\n        thermodynamic_budget={'enthalpy': 100, 'entropy': 50},\n        architect_registry={'resources': [], 'agents': []}\n    )\n    print('philosophy:', result.get('philosophy')[:100] if result.get('philosophy') else None)\n    print('telos_manifold:', result.get('telos_manifold'))\n    print('godel_lock:', result.get('godel_lock'))\n    print('constitutional_context present:', result.get('constitutional_context') is not None)\n\nasyncio.run(test())\nPYEOF\n```\n\n### Health Check\n\n```bash\ncurl -s https://arifosmcp.arif-fazil.com/health | python3 -m json.tool\n```\n\n---\n\n## 📊 MONITORING\n\n### Prometheus Metrics\n\n| Metric | Type | Description |\n|--------|------|-------------|\n| `arifos_floor_violations_total` | Counter | F1-F13 violation count |\n| `arifos_genius_index` | Gauge | Current G score |\n| `arifos_vitality_index` | Gauge | Current Ψ score |\n| `arifos_omega_bounds` | Gauge | Current Ω uncertainty |\n| `arifos_tool_calls_total` | Counter | Tool invocation count |\n| `arifos_pipeline_duration_seconds` | Histogram | Pipeline latency |\n\n### Grafana Dashboard\n\nURL: https://monitor.arifosmcp.arif-fazil.com\n\nDashboards:\n- Constitutional Health (F1-F13 compliance)\n- Tool Usage Statistics\n- Pipeline Latency\n- Memory Usage\n\n---\n\n## 🔧 TROUBLESHOOTING\n\n### Issue: \"Module file points to site-packages\"\n\n**Symptom:** `import arifosmcp` loads `/usr/local/lib/python3.12/site-packages/`\n\n**Cause:** pip install in Dockerfile creates conflicting package\n\n**Fix:** Rebuild image or ensure volume mounts are correct\n\n### Issue: \"philosophy returns null\"\n\n**Symptom:** init_anchor returns null philosophy\n\n**Cause:** Old site-packages version loaded\n\n**Fix:** Rebuild container, clear Python cache\n\n### Issue: \"OLLAMA connection failed\"\n\n**Symptom:** agi_mind returns connection error\n\n**Fix:** `docker compose restart ollama && docker compose logs --tail=20 ollama`\n\n---\n\n## 📦 DEPENDENCIES\n\n### Core\n\n| Package | Version | Purpose |\n|---------|---------|---------|\n| `fastmcp` | ≥3.0 | MCP protocol |\n| `fastapi` | ≥0.115 | HTTP server |\n| `uvicorn` | latest | ASGI server |\n| `redis` | latest | Session memory |\n| `psycopg2` | latest | PostgreSQL (optional) |\n| `qdrant-client` | latest | Vector DB (optional) |\n| `sentence-transformers` | latest | Semantic embeddings |\n| `ollama` | latest | LLM inference |\n\n### Philosophy Atlas\n\n| Package | Version | Purpose |\n|---------|---------|---------|\n| `numpy` | latest | 3D distance calculations |\n| `scipy` | latest | Statistical functions |\n\n---\n\n## 🚀 DEPLOYMENT\n\n### Build\n\n```bash\ndocker build --no-cache -t arifos/arifosmcp:latest -f Dockerfile .\n```\n\n### Run\n\n```bash\ndocker compose up -d arifosmcp\n```\n\n### Rebuild (after code changes)\n\n```bash\ndocker compose up -d --force-recreate --no-deps arifosmcp\n```\n\n### Full Reforge\n\n```bash\ndocker compose build --no-cache arifosmcp && docker compose up -d arifosmcp\n```\n\n---\n\n## 📜 API REFERENCE SUMMARY\n\n### init_anchor\n\n```json\n{\n  \"jsonrpc\": \"2.0\",\n  \"id\": 1,\n  \"method\": \"tools/call\",\n  \"params\": {\n    \"name\": \"init_anchor\",\n    \"arguments\": {\n      \"actor_id\": \"string\",\n      \"declared_name\": \"string\",\n      \"mode\": \"init|seal|status\"\n    }\n  }\n}\n```\n\n### Response Schema\n\n```json\n{\n  \"session_id\": \"uuid\",\n  \"omega_0\": 0.03-0.05,\n  \"delta_s\": \"float\",\n  \"telos_manifold\": {},\n  \"godel_lock\": {},\n  \"constitutional_context\": \"string\",\n  \"philosophy\": \"string\",\n  \"vitality_index\": \"float\",\n  \"verdict_range\": \"000_SEAL|101-499|500-899|999_VOID\"\n}\n```\n\n---\n\n## 📋 FOR AI AGENTS (AGENTS.md Reference)\n\nAll AI agents operating in this repository MUST follow the rules in [`../AGENTS.md`](../AGENTS.md):\n\n- **RULE 1 DRY_RUN:** Dry-run outputs labeled \"Estimate Only / Simulated\"\n- **RULE 2 DOMAIN_GATE:** Cannot-compute domains return exact phrase\n- **RULE 3 VERDICT_SCOPE:** Only DOMAIN_SEAL authorizes factual claims\n- **RULE 4 ANCHOR_VOID:** init_anchor returns void → session BLOCKED\n\n---\n\n## ⚖️ Truth Hierarchy\n\nThe arifOS verdict system follows a strict **Truth Hierarchy** where higher-priority verdicts override lower ones:\n\n| Priority | Verdict | Meaning | Action |\n|----------|---------|---------|--------|\n| 1 (P0) | `VOID` | Hard constitutional violation | Immediate termination |\n| 2 (P1) | `HOLD_888` | Sovereign veto / human required | Block until ratified |\n| 3 (P2) | `SABAR` | Insufficient grounding (F7/F9) | Pause, cool down, re-ground |\n| 4 (P3) | `PARTIAL` | Data incomplete / conditional | Proceed with modifications |\n| 5 (P4) | `SEAL` | Constitutional alignment confirmed | Proceed |\n\n**Derived Verdicts** (not primary):\n- `ALIVE` — Session initialized, not yet grounded\n- `PROVISIONAL` — Exploratory result, needs confirmation\n\n---\n\n## 🗺️ Tool Categories\n\narifOS tools are organized into **5 constitutional bands**:\n\n| Band | Range | Purpose | Examples |\n|------|-------|---------|----------|\n| **KERNEL** | 000–099 | Session anchoring, constitutional init | `init_anchor` |\n| **SENSE** | 100–199 | Environmental grounding (F2/F4) | `physics_reality`, `math_estimator` |\n| **BRIDGE** | 300–399 | Hardened routing and dispatch | `arifOS_kernel` |\n| **MIND** | 333 | Constitutional reasoning (F2/F4/F7/F8) | `agi_mind` |\n| **HEART** | 666 | Safety critique and impact prediction (F5/F6/F9) | `asi_heart` |\n| **VAULT** | 900–999 | Immutable ledger and seal (F1/F13) | `vault_ledger` |\n| **APEX** | 888 | Sovereign verdict and defense (F3/F12/F13) | `apex_soul` |\n\n---\n\n## 🗂️ Contract Truth Table\n\n| Tool | F1 | F2 | F3 | F4 | F5 | F6 | F7 | F8 | F9 | F10 | F11 | F12 | F13 |\n|------|----|----|----|----|----|----|----|----|----|-----|-----|-----|-----|\n| `init_anchor` | — | — | — | — | — | — | — | — | — | — | ✅ | — | — |\n| `physics_reality` | — | ✅ | — | ✅ | — | — | — | — | — | — | — | — | — |\n| `agi_mind` | — | ✅ | — | ✅ | — | — | ✅ | ✅ | — | — | — | — | — |\n| `asi_heart` | — | — | — | — | ✅ | ✅ | — | — | ✅ | — | — | — | — |\n| `apex_soul` | — | — | ✅ | — | — | — | — | — | — | — | — | ✅ | ✅ |\n| `vault_ledger` | ✅ | — | — | — | — | — | — | — | — | — | — | — | ✅ |\n\n**Legend:** ✅ = mandatory floor for this tool\n\n---\n\n## 📡 Horizon vs VPS Exposure Matrix\n\n| Tool | Horizon (External) | VPS (Internal) | Notes |\n|------|-------------------|----------------|-------|\n| `search_tool` | ✅ | — | External web search |\n| `reality_compass` | ✅ | — | Routing/external calls |\n| `vault_ledger` | — | ✅ | Internal Merkle chain |\n| `agi_mind` | — | ✅ | Internal reasoning |\n| `architect_registry` | ✅ | ✅ | Both interfaces exposed |\n\n---\n\n## ⚠️ Known Misalignments and Limitations\n\n1. **`apex_judge` alias**: The tool is canonically named `apex_soul` in code but exposed as `apex_judge` via MCP. This is a **public alias** documented here — do not rename canonical code without completing the full migration.\n\n2. **`physics_reality` field name**: Uses `input` field instead of `query` — historical inconsistency from legacy API.\n\n3. **`check_vital`, `audit_rules`**: Internal lifecycle tools in `server_horizon.py` bootstrap — **NOT callable via MCP**.\n\n4. **`agi_mind` nested verdicts**: When `agi_mind` returns `verdict: \"SEAL\"` at top-level but `coherence.verdict: \"SABAR\"` inside, the **worst verdict wins** (truth before speed).\n\n5. **`search_tool`, `vault_ledger`, `reality_compass`**: These \"naked\" tools return raw data without verdict wrapper. Wrap in `RuntimeEnvelope` with `verdict_wrapper.forge_verdict()` — empty results produce `PARTIAL`, not `VOID`.\n\n6. **`VerdictCode` vs `Verdict`**: Two separate enum classes exist — `VerdictCode` (SEAL/SABAR/PARTIAL/VOID) for verdict_wrapper and `Verdict` (includes HOLD/ALIVE/PROVISIONAL) for stage contracts. Keep separate to avoid breaking existing code.\n\n---\n\n## 🛰️ MCP Call Schema Examples\n\n### init_anchor\n```json\n{\n  \"tool\": \"init_anchor\",\n  \"arguments\": {\n    \"actor_id\": \"user-123\",\n    \"declared_name\": \"Arif\",\n    \"mode\": \"init\"\n  }\n}\n```\n\n### agi_mind (reason mode)\n```json\n{\n  \"tool\": \"agi_mind\",\n  \"arguments\": {\n    \"mode\": \"reason\",\n    \"query\": \"Why does entropy matter?\",\n    \"constitutional_context\": {\n      \"stage\": \"MIND_333\",\n      \"floors_active\": [\"F2\", \"F4\", \"F7\", \"F8\"]\n    }\n  }\n}\n```\n\n### vault_ledger (seal mode)\n```json\n{\n  \"tool\": \"vault_ledger\",\n  \"arguments\": {\n    \"mode\": \"seal\",\n    \"data\": {\n      \"content\": \"Verified fact\",\n      \"metadata\": {\"source\": \"arifOS\"}\n    }\n  }\n}\n```\n\n### apex_soul (judge mode)\n```json\n{\n  \"tool\": \"apex_soul\",\n  \"arguments\": {\n    \"mode\": \"judge\",\n    \"action\": \"seal_vault\",\n    \"stakes\": \"HIGH\"\n  }\n}\n```\n\n---\n\n## 🔐 Stability Tiers\n\n| Tier | Description | Verdict Expected |\n|------|-------------|------------------|\n| **A** | Verified, stable, ready for production | `SEAL` |\n| **B** | Verified, hardened, minor issues resolved | `SEAL` or `PARTIAL` |\n| **C** | Verified, known limitations documented | `PARTIAL` or `SABAR` |\n| **D** | Experimental, breaking changes possible | Any |\n| **INTERNAL** | Not exposed via MCP | N/A |\n\n---\n\n## 🏛️ LICENSE\n\n**Runtime:** AGPL-3.0 (must release modifications)\n**Theory:** CC0 (public domain)\n\n---\n\n**Version:** 2026.03.28-SEALED\n**Maintainer:** Muhammad Arif bin Fazil\n**Constitutional Authority:** 888_JUDGE\n\n*Ditempa Bukan Diberi* — Forged, Not Given [ΔΩΨ | ARIF]\n\n---\n\n```\n██╗      ██████╗ ███████╗████████╗    ███████╗███╗   ██╗██╗██╗  ██╗██╗██╗  ██╗██╗   ██╗\n██║     ██╔══██╗██╔════╝╚══██╔══╝    ██╔════╝████╗  ██║██║╚██╗██╔╝██║██║  ██║╚██╗ ██╔╝\n██║     ██║  ██║█████╗     ██║       █████╗  ██╔██╗ ██║██║ ╚███╔╝ ██║███████║ ╚████╔╝ \n██║     ██║  ██║██╔══╝     ██║       ██╔══╝  ██║╚██╗██║██║ ██╔██╗ ██║██╔══██║  ╚██╔╝  \n███████╗╚█████╔╝███████╗   ██║       ███████╗██║ ╚████║██║██╔╝ ██╗██║██║  ██║   ██║   \n╚══════╝ ╚═════╝ ╚══════╝   ╚═╝       ╚══════╝╚═╝  ╚══╝╚═╝╚═╝  ╚═╝╚═╝╚═╝  ╚═╝    ╚═╝   \n```\n",
  "bytes": 28261,
  "sha": "fa5eff26004feae532598687cc5f3bbdbd367040ea4853e40330e962349b064d",
  "repo_slug": "ariffazil/arifosmcp",
  "fonte": "repo",
  "truncated": false,
  "api": "https://agentalog.com/api/listings/mcp_io_github_ariffazil_arifosmcp_08bf7f6b/readme"
}