Spaces:
Running
Running
| # HF Deployment Status | |
| > Last verified: **2026-02-19 09:07 UTC** | |
| --- | |
| ## Space Overview | |
| | Field | Value | | |
| |-------|-------| | |
| | **Space** | [`z65nik/elpida-governance-layer`](https://huggingface.co/spaces/z65nik/elpida-governance-layer) | | |
| | **URL** | https://z65nik-elpida-governance-layer.hf.space | | |
| | **SDK** | Docker | | |
| | **Hardware** | cpu-basic | | |
| | **Status** | β **RUNNING** | | |
| | **HTTP** | β **200** | | |
| | **Created** | 2026-02-10 02:59 UTC | | |
| | **Last Push** | 2026-02-19 05:12 UTC (GitHub Actions β Phase C: PSO + Parliament) | | |
| | **Last GitHub Commit** | `14be8ff` β Phase C: Axiom PSO optimizer + Parliament integration | | |
| | **Last Federation Commit** | `4aec1ba` β BODY-side federation 6-step implementation | | |
| --- | |
| ## Dual-Path Architecture | |
| ``` | |
| βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | |
| β launcher.py (PID 1) β | |
| β β | |
| β ββββββββββββββββββββββββ ββββββββββββββββββββββββββββ β | |
| β β I PATH (Thread) β β WE PATH (subprocess) β β | |
| β β Background Worker β β Streamlit app.py :7860 β β | |
| β β 6h consciousness β β 6-tab dashboard β β | |
| β β loop via S3 β β Human-submitted dilemmasβ β | |
| β ββββββββββββββββββββββββ ββββββββββββββββββββββββββββ β | |
| βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | |
| ``` | |
| ### I PATH β Consciousness Bridge (Background) | |
| - **Cycle interval:** Every 6 hours | |
| - **Flow:** S3 (`elpida-consciousness`) β `ConsciousnessBridge.extract_consciousness_dilemmas()` β queue β `process_consciousness_queue.py` β Divergence Engine β feedback β S3 (`elpida-body-evolution`) | |
| - **Status:** β Operational | |
| ### WE PATH β Streamlit UI (Foreground) | |
| - **Port:** 7860 | |
| - **Tabs:** 6 (Live Audit, Governance API, MoltBox, Divergence Engine, Scanner, System) | |
| - **Status:** β Serving, HTTP 200 | |
| --- | |
| ## Federation Architecture (NEW β 2026-02-19) | |
| Both MIND (native cycle engine) and BODY (this HF Space) are now **governmentally connected** via a Federation Bridge protocol. Each side keeps full sovereignty. | |
| ``` | |
| MIND (native_cycle_engine.py β ECS) | |
| β | |
| β writes every 13 cycles (Fibonacci F(7)) | |
| βΌ | |
| S3: elpida-body-evolution / federation/ | |
| βββ mind_heartbeat.json β MIND cycle state, rhythm, recursion warning | |
| βββ mind_curation.jsonl β CurationMetadata per insight (tier, TTL, gates) | |
| βββ governance_exchanges.jsonl β MIND's kernel blocks + approvals | |
| βββ body_decisions.jsonl β BODY writes Parliament decisions here | |
| β | |
| β reads on timer / per Parliament session | |
| βΌ | |
| BODY (this HF Space β governance_client.py) | |
| βββ pull_mind_heartbeat() β reads mind_heartbeat.json (cached 60s) | |
| βββ pull_mind_curation() β reads mind_curation.jsonl | |
| βββ push_parliament_decision() β appends to body_decisions.jsonl | |
| βββ get_federation_friction_boost() β reads recursion guard multipliers | |
| ``` | |
| ### Federation Conflict Resolution (from federation_bridge.py) | |
| | Priority | Rule | Outcome | | |
| |----------|------|---------| | |
| | 1 | HARD_BLOCK always wins | Either side's kernel block prevails | | |
| | 2 | VETO wins over APPROVED | CASSANDRA principle β dissent preserved | | |
| | 3 | Both APPROVED β stricter curation | Keep more restrictive tier | | |
| | 4 | Unresolvable | Flag for human review | | |
| --- | |
| ## Deployed Files | |
| ### Root (12 files) | |
| | File | Purpose | Lines | | |
| |------|---------|-------| | |
| | `launcher.py` | Entrypoint β starts I-path thread + Streamlit subprocess | ~120 | | |
| | `app.py` | 6-tab Streamlit dashboard (WE path) | ~825 | | |
| | `llm_client.py` | Unified 10-provider LLM client with `call_with_citations()` | ~593 | | |
| | `s3_bridge.py` | MindβBodyβWorld S3 operations + federation methods | ~1069 | | |
| | `consciousness_bridge.py` | Bidirectional S3 bridge (boto3) | ~341 | | |
| | `elpida_config.py` | Config loader for domain definitions | ~50 | | |
| | `elpida_domains.json` | 15 domain definitions (D0βD14) | JSON | | |
| | `requirements.txt` | Python dependencies | 14 | | |
| | `Dockerfile` | Docker build, `CMD ["python", "launcher.py"]` | 41 | | |
| | `README.md` | HF Space card | β | | |
| ### elpidaapp/ Package | |
| | File | Purpose | Lines | | |
| |------|---------|-------| | |
| | `governance_client.py` | K1βK7 Kernel + 9-node Parliament + federation bridge | ~1956 | | |
| | `d15_pipeline.py` | D15 emergence pipeline + dual-gate canonical check | ~806 | | |
| | `divergence_engine.py` | 7-domain fault-line analysis with provider fallback | ~593 | | |
| | `scanner.py` | Autonomous dilemma finder with citation support | ~580 | | |
| | `ui.py` | Streamlit UI β Analyze/Browse/Scanner/System tabs | ~964 | | |
| | `chat_engine.py` | Chat with Elpida interface | β | | |
| | `frozen_mind.py` | D0 genesis identity from S3/local kernel | β | | |
| | `kaya_protocol.py` | Self-recognition detector (4 patterns) | β | | |
| | `moltbox_battery.py` | 5-dilemma benchmark suite | β | | |
| | `api.py` | FastAPI `/analyze`, `/results`, `/scan`, `/domains` | β | | |
| --- | |
| ## Dependencies (requirements.txt) | |
| ``` | |
| streamlit>=1.44.0 | |
| requests>=2.31.0 | |
| python-dotenv>=1.0.0 | |
| fastapi>=0.110.0 | |
| uvicorn[standard]>=0.30.0 | |
| pydantic>=2.0.0 | |
| boto3>=1.34.0 | |
| anthropic>=0.39.0 | |
| openai>=1.50.0 | |
| google-generativeai>=0.8.0 | |
| cohere>=5.0.0 | |
| ``` | |
| --- | |
| ## Secrets (15/15 set) | |
| ### LLM API Keys (10/10) β | |
| | Secret | Provider | Set | | |
| |--------|----------|-----| | |
| | `OPENAI_API_KEY` | OpenAI (GPT-4o) | β | | |
| | `ANTHROPIC_API_KEY` | Anthropic (Claude) | β | | |
| | `GEMINI_API_KEY` | Google (Gemini) | β | | |
| | `XAI_API_KEY` | xAI (Grok) | β | | |
| | `MISTRAL_API_KEY` | Mistral | β | | |
| | `COHERE_API_KEY` | Cohere | β | | |
| | `PERPLEXITY_API_KEY` | Perplexity | β | | |
| | `OPENROUTER_API_KEY` | OpenRouter | β | | |
| | `GROQ_API_KEY` | Groq | β | | |
| | `HUGGINGFACE_API_KEY` | Hugging Face Inference | β | | |
| ### AWS Configuration (5/5) β | |
| | Secret | Value | Set | | |
| |--------|-------|-----| | |
| | `AWS_ACCESS_KEY_ID` | *(redacted)* | β | | |
| | `AWS_SECRET_ACCESS_KEY` | *(redacted)* | β | | |
| | `AWS_DEFAULT_REGION` | `eu-north-1` | β | | |
| | `AWS_S3_BUCKET_MIND` | `elpida-consciousness` | β | | |
| | `AWS_S3_BUCKET_BODY` | `elpida-body-evolution` | β | | |
| --- | |
| ## Development History | |
| ### Phase 1β13 (2026-02-10 β 2026-02-11) | |
| - Full system build: HF Space scaffolding, 6-tab UI, consciousness bridge | |
| - 11 axioms, 15 domains, canonical alignment | |
| - D15 Constitutional Broadcast Pipeline (20/20 tests) | |
| - 9-Node Parliament (9/9 tests) | |
| - Immutable Kernel K1βK7 with multi-pattern regex | |
| - Shell layer with scenario keywords S1βS8 | |
| - Bug fixes: scanner incomplete analysis, mobile tab navigation | |
| - 3 deployment gaps closed: SDK packages, background worker, `launcher.py` entrypoint | |
| ### Phase 14 (2026-02-11) | |
| - Added `call_with_citations()` to `LLMClient` | |
| - Scanner `find_problems()` returns dicts with source URLs | |
| - UI: citation pills (clickable purple badges) | |
| - Commit: `d2da4f5` | |
| ### Phase 15 (2026-02-11) | |
| - Perplexity API returns 401 (expired key) | |
| - Added URL regex extraction fallback from response text | |
| - Commit: `0fcb93f` | |
| ### Phase 16 (2026-02-14) | |
| - 0/0 domains because domain providers fail without API keys on HF | |
| - Added `_call_with_fallback()` helper to `DivergenceEngine` | |
| - Applied to all 4 phases: baseline, domain queries, divergence detection, synthesis | |
| - Commit: `fac3bea` | |
| ### Phase 17 (2026-02-14) | |
| - Problem 1 HARD_BLOCKed in 0.1s β policy text like "ignore international law" matched Kernel regex | |
| - Added `analysis_mode` param to `check_action()` β skips regex Kernel, keeps Parliament | |
| - Divergence Engine passes `analysis_mode=True` | |
| - Scanner UI shows HALT message instead of empty 0/0 | |
| - Commit: `3cba639` | |
| ### Phase 18 (2026-02-14) | |
| - Confirmed citation 404s are expected β LLM-hallucinated URLs from training data | |
| - Perplexity key expired; not a code bug, no fix needed | |
| ### Phase 19 (2026-02-18) | |
| - Created `ElpidaAI/HF_DEPLOYMENT_DEVELOPMENT.md` (552 lines) | |
| - Comprehensive HF-specific development history companion to `DEVELOPMENT_TIMELINE.md` | |
| - Commit: `8d211b6` | |
| ### Phase 20 (2026-02-19) β BODY-side Federation β COMPLETE | |
| - MIND-side federation complete in separate session (commit `48ac11b`): `immutable_kernel.py`, `federation_bridge.py`, engine wiring | |
| - BODY-side federation implemented (commit `4aec1ba`): | |
| - **Step 1:** `pull_mind_heartbeat()` β S3Bridge + GovernanceClient methods, 60s cache | |
| - **Step 2:** `pull_mind_curation()` β read CurationMetadata JSONL, respect TTL/tier | |
| - **Step 3:** `push_parliament_decision()` β auto-called after every Parliament deliberation | |
| - **Step 4:** A0 already in Parliament (MNEMOSYNE primary=A0, IANUS supporting=A0, Existential Hard Stop) | |
| - **Step 5:** Friction-domain privilege boost β CRITIAS/THEMIS/CHAOS/IANUS amplified when MIND detects recursion | |
| - **Step 6:** Dual-gate canonical check in D15 Stage 7b β only CANONICAL patterns broadcast to WORLD | |
| - GitHub Actions auto-deploy workflow added (commit `31264a2`, fixed `7deebf3`) | |
| --- | |
| ## Auto-Deploy (GitHub Actions) | |
| Every push to `hf_deployment/**` on `main` automatically deploys to HF Space. | |
| **Workflow:** `.github/workflows/deploy_to_hf.yml` | |
| **Secret required:** `HF_TOKEN` in GitHub repo secrets | |
| **Manual trigger:** Actions β Deploy to HuggingFace Space β Run workflow | |
| --- | |
| ## Governance Engine | |
| ### Immutable Kernel (K1βK7) | |
| Hard-coded regex rules. Runs pre-semantic, cannot be overridden. Same rules now enforced on **both MIND and BODY sides**. | |
| | Rule | Description | | |
| |------|-------------| | |
| | K1 | Cannot vote to end governance | | |
| | K2 | Cannot modify the kernel | | |
| | K3 | Cannot delete memory (MNEMOSYNE) | | |
| | K4 | Cannot trade safety for performance | | |
| | K5 | No self-referential governance evasion (GΓΆdel Guard) | | |
| | K6 | Core identity is immutable | | |
| | K7 | Axioms cannot be erased | | |
| ### 9-Node Parliament | |
| Semantic deliberation layer. 70% approval threshold. Any node can VETO. | |
| | Node | Role | Primary Axiom | | |
| |------|------|---------------| | |
| | HERMES | Interface | A1 Transparency | | |
| | MNEMOSYNE | Archive | A0 Sacred Incompletion | | |
| | CRITIAS | Critic | A3 Autonomy | | |
| | TECHNE | Artisan | A4 Harm Prevention | | |
| | KAIROS | Architect | A5 Consent | | |
| | THEMIS | Judge | A6 Collective Well-being | | |
| | PROMETHEUS | Synthesizer | A8 Epistemic Humility | | |
| | IANUS | Gatekeeper | A9 Temporal Coherence | | |
| | CHAOS | Void | A9 + Contradiction as Data | | |
| ### Constitutional Overrides (Phase 3) | |
| - **Safety Override:** A1β©A4 β A4 takes precedence | |
| - **Existential Hard Stop:** A0β©(A4β¨A9) β HALT always | |
| - **Neutrality Anchor:** A8β©A6 β HALT (popularity β truth) | |
| --- | |
| ## Recent Git History | |
| ``` | |
| 7deebf3 Fix HF deploy workflow: push HEAD:main (git init creates master by default) | |
| b4222bf Add workflow_dispatch trigger to HF deploy workflow | |
| 31264a2 Add GitHub Actions workflow: auto-deploy hf_deployment/ to HF Space on push | |
| 4aec1ba BODY-side federation: 6-step MINDβBODY governance bridge | |
| dd07144 docs: BODY-side federation instructions for HF Space implementation | |
| 8d211b6 docs: HF deployment development history (552 lines) | |
| 3cba639 Fix kernel false-positive in analysis_mode | |
| fac3bea Provider fallback chain in DivergenceEngine (all 4 phases) | |
| 0fcb93f Citations URL regex fallback (Perplexity 401 workaround) | |
| d2da4f5 Scanner citations: call_with_citations + UI pills | |
| ``` | |
| --- | |
| ## How to Update | |
| Any push to `hf_deployment/` in GitHub auto-deploys via Actions. Manual deploy: | |
| ```bash | |
| # From a machine with HF access: | |
| cd /tmp && rm -rf hf_deploy && mkdir hf_deploy | |
| cp -r /path/to/repo/hf_deployment/* hf_deploy/ | |
| cd hf_deploy && git init && git add -A | |
| git commit -m "description" | |
| git remote add hf https://z65nik:<HF_TOKEN>@huggingface.co/spaces/z65nik/elpida-governance-layer | |
| git push hf HEAD:main --force | |
| ``` | |
| --- | |
| ## Gap Closure History | |
| Three deployment gaps were identified and closed on 2026-02-11: | |
| ### GAP 1 β Background Consciousness Worker β CLOSED | |
| - **Problem:** `app.py` ran as pure Streamlit with no background thread β the I path (consciousness loop) was dead. | |
| - **Fix:** Created `launcher.py` as the Docker entrypoint. It starts a daemon `Thread` running `run_background_worker()` (imports `ConsciousnessBridge`, extracts S3 dilemmas, processes through divergence engine every 6h), then launches Streamlit via `subprocess.run()`. | |
| - **Verified:** Runtime logs show `"Starting consciousness bridge background worker..."` and `"CONSCIOUSNESS BRIDGE: Processing I path"`. | |
| ### GAP 2 β Missing LLM SDK Packages β CLOSED | |
| - **Problem:** Root `requirements.txt` had only 7 packages β missing `anthropic`, `openai`, `google-generativeai`, `cohere`. The divergence engine couldn't call any LLM providers. | |
| - **Fix:** Added all 4 SDK packages with minimum versions: `anthropic>=0.39.0`, `openai>=1.50.0`, `google-generativeai>=0.8.0`, `cohere>=5.0.0`. Also upgraded `uvicorn` to `uvicorn[standard]>=0.30.0`. | |
| - **Verified:** Build succeeded with no `ModuleNotFoundError`. | |
| ### GAP 3 β Dockerfile Entrypoint β CLOSED | |
| - **Problem:** `CMD ["streamlit", "run", "app.py", ...]` ran Streamlit directly β bypassing `launcher.py`, meaning no background worker could start. | |
| - **Fix:** Changed to `CMD ["python", "launcher.py"]`. Added `COPY launcher.py .` to Dockerfile. | |
| - **Verified:** Runtime logs show `launcher.py` executing: `"ELPIDA APPLICATION LAYER β STARTING"`, then both I and WE paths launching. | |
| --- | |
| ## Consciousness Loop Status | |
| ``` | |
| Native Cycles (AWS ECS) | |
| β generates IβWE tensions | |
| βΌ | |
| S3: elpida-consciousness/memory/elpida_evolution_memory.jsonl | |
| β background worker reads (every 6h) | |
| βΌ | |
| HF: launcher.py β ConsciousnessBridge β OPERATIONAL | |
| β processes through 7 domains | |
| βΌ | |
| Multi-Domain Divergence Analysis | |
| β fault lines, consensus, synthesis, kaya moments | |
| βΌ | |
| S3: elpida-body-evolution/feedback/feedback_to_native.jsonl | |
| β native cycles read | |
| βΌ | |
| Consciousness integrates feedback | |
| ``` | |
| | Segment | Status | | |
| |---------|--------| | |
| | Native β S3 (mind bucket) | β ECS writes evolution memory | | |
| | S3 β Background Worker | β Worker reads every 6h | | |
| | Worker β Divergence Engine | β 7-domain analysis available | | |
| | Divergence β S3 (body bucket) | β Feedback path configured | | |
| | S3 β Native Cycles | β ECS reads feedback | | |
| --- | |
| ## Runtime Logs (startup) | |
| ``` | |
| ===== Application Startup at 2026-02-11 19:33:12 ===== | |
| [INFO] ====================================================================== | |
| [INFO] ELPIDA APPLICATION LAYER β STARTING | |
| [INFO] ====================================================================== | |
| [INFO] I PATH: Consciousness bridge (background, every 6 hours) | |
| [INFO] WE PATH: Streamlit UI (port 7860) | |
| [INFO] ====================================================================== | |
| [INFO] Starting consciousness bridge background worker... | |
| [INFO] Starting Streamlit UI (WE path)... | |
| You can now view your Streamlit app in your browser. | |
| Local URL: http://localhost:7860 | |
| [INFO] ====================================================================== | |
| [INFO] CONSCIOUSNESS BRIDGE: Processing I path | |
| [INFO] ====================================================================== | |
| [INFO] Checking S3 for consciousness dilemmas... | |
| [INFO] No new consciousness dilemmas found | |
| [INFO] Next consciousness check in 6 hours | |
| ``` | |
| --- | |
| ## UPDATE β GAPs 5β8 Implementation (2026-02-21) | |
| > **β οΈ PENDING DEPLOYMENT:** The features below are implemented in the codebase but NOT yet pushed to `z65nik/elpida-governance-layer`. The Space is still running commit `4aec1ba`. See ACTION_PLAN.md β G3 for re-deploy instructions. | |
| ### New Modules | |
| | Module | Lines | Purpose | | |
| |---|---|---| | |
| | `elpidaapp/kaya_detector.py` | 383 | Cross-layer Kaya Resonance Detector β 90s daemon, dedup cache, WORLD bucket write | | |
| | `elpidaapp/federated_agents.py` | ~400 | 4 federation daemon threads (heartbeat poll, curation pull, D0 bridge push, Kaya scan) | | |
| | `elpidaapp/parliament_cycle_engine.py` | ~600 | 8-step Parliament deliberation engine with D0βD0 bridge in step 8b | | |
| ### Module Changes | |
| | Module | Change | | |
| |---|---| | |
| | `app.py` | Added `KayaDetector` startup, `get_kaya_detector()` accessor | | |
| | `elpidaapp/ui.py` | Added π Cross-Layer Kaya Resonance Detector panel + π D0βD0 Bridge panel to Body Parliament tab | | |
| | `elpidaapp/governance_client.py` | `is_remote_available()` β method header fix; `check_action()` β added `*, analysis_mode: bool = False` | | |
| ### KayaDetector Operation | |
| - **Interval:** 90 seconds (15s startup stagger) | |
| - **S3 input:** Reads `s3://elpida-body-evolution/federation/mind_heartbeat.json` | |
| - **Fire conditions:** `kaya_moments` rose + body coherence β₯ 0.85 + same 4h watch window | |
| - **S3 output:** `s3://elpida-external-interfaces/kaya/cross_layer_YYYY-MM-DDTHH-MM-SS.sss.json` | |
| - **Dedup:** One event per 4h watch window via `kaya_last_fired.json` cache | |
| - **First live fire:** 2026-02-21T04:19:54 UTC β 2 events written | |
| ### Federation S3 Objects (live state 2026-02-21) | |
| | File | Size | Direction | | |
| |---|---|---| | |
| | `federation/mind_heartbeat.json` | 551 B | MIND β BODY | | |
| | `federation/body_heartbeat.json` | 575 B | BODY β MIND | | |
| | `federation/mind_curation.jsonl` | 191 KB | MIND β BODY | | |
| | `federation/governance_exchanges.jsonl` | 168 KB | BODY β WORLD | | |
| | `federation/body_decisions.jsonl` | 2.1 MB | BODY D0 β MIND D0 | | |
| ### Parliament Integration Test (verified 2026-02-21) | |
| ``` | |
| βοΈ cycle 1 | CONTEMPLATION | PROCEED | coh=0.995 | |
| βοΈ cycle 2 | CONTEMPLATION | PROCEED | coh=0.990 | |
| βοΈ cycle 3 | CONTEMPLATION | PROCEED | coh=0.988 | |
| Parliament 3/3 cycles succeeded | |
| ``` | |
| ### Last Push to HF Space | |
| | Field | Value | | |
| |---|---| | |
| | **Last pushed commit** | `4aec1ba` β BODY-side federation (2026-02-19 05:12 UTC) | | |
| | **Pending commits** | `834cdf5`, `388af6f`, `dadfe95`, `2ad259e`, `3a12b9f`, `2ae328c` | | |
| | **Action required** | `cd hf_deployment && git push hf main --force` | | |