Skip to content

Commit b1a774a

Browse files
committed
The Aleph Protocol
1 parent 84a09ee commit b1a774a

14 files changed

Lines changed: 1074 additions & 512 deletions

QuanuX-Infra/ansible/04-aleph-habitat.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
name:
4848
- build-essential
4949
- python3-dev
50+
- python3-venv
5051
state: present
5152

5253
- name: Strict Fencing - Accept API traffic exclusively from Nexus IP
@@ -83,4 +84,5 @@
8384
name:
8485
- build-essential
8586
- python3-dev
87+
- python3-venv
8688
state: present

QuanuX-Infra/ansible/05-aleph-protocol.yml

Lines changed: 107 additions & 94 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
- name: Aleph Protocol - Phase 2 The Vault (panopticon-vault)
2+
- name: Aleph Protocol - Play 1 The Vault Initialization (panopticon-vault)
33
hosts: panopticon_vault
44
become: true
55
tasks:
@@ -89,7 +89,7 @@
8989
- name: Provision the 'quanux-telemetry' bucket via API
9090
command: "mc mb myminio/quanux-telemetry --insecure"
9191
register: mb_result
92-
failed_when: mb_result.rc != 0 and 'Bucket already exists' not in mb_result.stderr and 'BucketAlreadyOwnedByYou' not in mb_result.stderr
92+
failed_when: mb_result.rc != 0 and 'Bucket already exists' not in mb_result.stderr and 'BucketAlreadyOwnedByYou' not in mb_result.stderr and 'already own it' not in mb_result.stderr
9393
changed_when: "mb_result.rc == 0"
9494

9595
- name: Enable Bucket Versioning (Absolute HA/Active-Active Readiness)
@@ -102,7 +102,7 @@
102102
changed_when: "ilm_result.rc == 0"
103103

104104

105-
- name: Aleph Protocol - Phase 3 The Write Path (panopticon-forge)
105+
- name: Aleph Protocol - Play 2 The Forge Artifacts (panopticon-forge)
106106
hosts: panopticon_forge
107107
become: true
108108
tasks:
@@ -111,15 +111,17 @@
111111
url: https://packages.timber.io/vector/0.38.0/vector-0.38.0-x86_64-unknown-linux-musl.tar.gz
112112
dest: /tmp/vector.tar.gz
113113

114-
- name: Extract Vector
114+
- name: Extract Vector Tarball natively bypassing `strip-components` syntax
115115
unarchive:
116116
src: /tmp/vector.tar.gz
117-
dest: /usr/local/bin
118-
extra_opts:
119-
- --strip-components=2
120-
- "vector-x86_64-unknown-linux-musl/bin/vector"
117+
dest: /tmp
121118
remote_src: true
122119

120+
- name: Transplant Vector Binary to System PATH
121+
command: mv /tmp/vector-x86_64-unknown-linux-musl/bin/vector /usr/local/bin/vector
122+
args:
123+
creates: /usr/local/bin/vector
124+
123125
- name: Ensure Vector config directory exists
124126
file:
125127
path: /etc/vector
@@ -218,7 +220,7 @@
218220
enabled: true
219221
state: restarted
220222

221-
- name: Aleph Protocol - Phase 3 The Write Path (panopticon-ledger)
223+
- name: Aleph Protocol - Play 3 The Ledger Audit (panopticon-ledger)
222224
hosts: panopticon_ledger
223225
become: true
224226
tasks:
@@ -241,13 +243,11 @@
241243
repo: deb https://artifacts.opensearch.org/releases/bundle/opensearch/2.x/apt stable main
242244
state: present
243245

244-
- name: Install Native OpenSearch
245-
apt:
246-
name: opensearch
247-
state: present
248-
update_cache: true
249-
environment:
250-
OPENSEARCH_INITIAL_ADMIN_PASSWORD: "{{ opensearch_admin_password }}"
246+
- name: Install Native OpenSearch (Forced Shell Environment to secure zxcvbn password)
247+
shell: "env OPENSEARCH_INITIAL_ADMIN_PASSWORD='{{ opensearch_admin_password }}' DEBIAN_FRONTEND=noninteractive apt-get install -y opensearch=2.19.4"
248+
args:
249+
executable: /bin/bash
250+
creates: /etc/opensearch/opensearch.yml
251251

252252
- name: OpenSearch VPC Binding
253253
lineinfile:
@@ -284,7 +284,7 @@
284284
state: restarted
285285

286286

287-
- name: Aleph Protocol - Phase 4 The Read Path (panopticon-oracle)
287+
- name: Aleph Protocol - Play 4 The Oracle Compilation (panopticon-oracle)
288288
hosts: panopticon_oracle
289289
become: true
290290
tasks:
@@ -328,102 +328,68 @@
328328
CREATE VIEW IF NOT EXISTS quanux_telemetry_live AS
329329
SELECT * FROM read_parquet('s3://quanux-telemetry/telemetry/*/*/*/*/*.parquet', hive_partitioning=1);
330330
331-
- name: Install DuckDB PostgreSQL Emulation Wrapper (Hasura Connector Dependency)
332-
# In a true Tier-1 physical drop, this would be a custom compiled C++ daemon.
333-
# For Phase 4 automated dropping, we utilize a lightweight Python psycopg2/duckdb bridge to expose port 5432.
331+
- name: Install Native PostgreSQL Database
334332
apt:
335333
name:
336-
- python3-venv
337-
- python3-pip
334+
- postgresql
335+
- postgresql-contrib
338336
state: present
337+
update_cache: true
339338

340-
- name: Create Python VENV for DuckDB-Oculus PG Bridge
341-
command: python3 -m venv /opt/quanux/oculus_env
342-
args:
343-
creates: /opt/quanux/oculus_env/bin/activate
344-
345-
- name: Install DuckDB, PGServer & Cython natively
346-
pip:
347-
name:
348-
- duckdb
349-
- pgserver
350-
- Cython
351-
virtualenv: /opt/quanux/oculus_env
352-
virtualenv_command: /usr/bin/python3 -m venv
353-
354-
- name: Generate DuckDB PG Emulation Wrapper (Cython source)
355-
copy:
356-
dest: /opt/quanux/oculus_env/duckdb_pg_wrapper.pyx
357-
content: |
358-
# cython: language_level=3
359-
import sys
360-
from runpy import run_module
361-
362-
def run():
363-
sys.argv = [
364-
"duckdb_pg_wrapper",
365-
"--host", "0.0.0.0",
366-
"--port", "5432",
367-
"--init-sql", "/etc/duckdb/init.sql",
368-
"/var/lib/duckdb/quanux.duckdb"
369-
]
370-
run_module("pgserver", run_name="__main__")
371-
372-
- name: Generate Setup script for Cython compilation
373-
copy:
374-
dest: /opt/quanux/oculus_env/setup.py
375-
content: |
376-
from setuptools import setup
377-
from Cython.Build import cythonize
378-
379-
setup(
380-
ext_modules=cythonize("duckdb_pg_wrapper.pyx", compiler_directives={'language_level' : "3"})
381-
)
382-
383-
- name: Compile DuckDB Oculus wrapper into C-extension (.so)
339+
- name: Configure PostgreSQL Network Bindings
384340
shell: |
385-
source /opt/quanux/oculus_env/bin/activate
386-
python3 setup.py build_ext --inplace
387-
args:
388-
chdir: /opt/quanux/oculus_env
389-
creates: /opt/quanux/oculus_env/duckdb_pg_wrapper.c
341+
for conf in /etc/postgresql/*/main/postgresql.conf; do
342+
sed -i "s/^#\?listen_addresses.*/listen_addresses = '*'/g" "$conf"
343+
done
390344
391-
- name: Create DuckDB-Oculus SystemD Service Wrapper (Cythonized)
392-
copy:
393-
dest: /etc/systemd/system/duckdb-oculus.service
394-
content: |
395-
[Unit]
396-
Description=DuckDB Oculus PostgreSQL Emulator (C-Extension)
397-
After=network-online.target
398-
399-
[Service]
400-
WorkingDirectory=/opt/quanux/oculus_env
401-
ExecStart=/opt/quanux/oculus_env/bin/python3 -c "import duckdb_pg_wrapper; duckdb_pg_wrapper.run()"
402-
Restart=always
403-
LimitNOFILE=65536
404-
405-
[Install]
406-
WantedBy=multi-user.target
345+
- name: Configure PostgreSQL VPC Subnet Trust
346+
shell: |
347+
for hba in /etc/postgresql/*/main/pg_hba.conf; do
348+
if ! grep -q "0.0.0.0/0 trust" "$hba"; then
349+
echo "host all all 0.0.0.0/0 trust" >> "$hba"
350+
fi
351+
done
407352
408-
- name: Enable and restart DuckDB-Oculus
353+
- name: Enable and restart PostgreSQL
409354
systemd:
410-
name: duckdb-oculus
355+
name: postgresql
411356
daemon_reload: true
412357
enabled: true
413358
state: restarted
414359

415-
- name: Aleph Protocol - Phase 4 The Read Path (panopticon-nexus)
360+
- name: Hydrate QuanuX Database and Users
361+
become: true
362+
become_user: postgres
363+
shell: |
364+
psql -tc "SELECT 1 FROM pg_database WHERE datname = 'quanux'" | grep -q 1 || psql -c "CREATE DATABASE quanux;"
365+
psql -c "ALTER USER postgres WITH PASSWORD 'postgres';"
366+
367+
- name: Execute Extension Protocol
368+
become: true
369+
become_user: postgres
370+
shell: psql -d quanux -c "CREATE EXTENSION IF NOT EXISTS pgcrypto;"
371+
372+
- name: Aleph Protocol - Play 5 The Nexus & AI Bridge (panopticon-nexus)
416373
hosts: panopticon_nexus
417374
become: true
418375
tasks:
419-
- name: Ensure Docker and Docker Compose are installed
376+
- name: Install Docker daemon natively and start the service
420377
apt:
421378
name:
422379
- docker.io
423380
- docker-compose-v2
424381
state: present
425382
update_cache: true
426383

384+
- name: Ensure Docker daemon is enabled and started
385+
systemd:
386+
name: docker
387+
state: started
388+
enabled: true
389+
390+
- name: Pull the Hasura GraphQL Docker image explicitly
391+
command: docker pull hasura/graphql-engine:v2.37.0
392+
427393
- name: Ensure Nexus directory exists
428394
file:
429395
path: /opt/quanux/nexus
@@ -436,20 +402,67 @@
436402
services:
437403
graphql-engine:
438404
image: hasura/graphql-engine:v2.37.0
439-
ports:
440-
- "8080:8080"
405+
network_mode: "host"
441406
environment:
442407
HASURA_GRAPHQL_ENABLE_CONSOLE: "true"
443408
HASURA_GRAPHQL_DEV_MODE: "true"
444409
HASURA_GRAPHQL_ADMIN_SECRET: "${QUANUX_HASURA_SECRET}"
445410
# The Supergraph mappings to the decoupled matrix:
411+
HASURA_GRAPHQL_DATABASE_URL: "postgresql://postgres:postgres@{{ hostvars[groups['panopticon_oracle'][0]]['internal_ip'] }}:5432/quanux"
446412
QUANUX_ORACLE_URL: "postgresql://postgres:postgres@{{ hostvars[groups['panopticon_oracle'][0]]['internal_ip'] }}:5432/quanux"
447413
QUANUX_LEDGER_URL: "http://{{ hostvars[groups['panopticon_ledger'][0]]['internal_ip'] }}:9200"
448414
restart: always
449415
450-
- name: Launch Hasura Supergraph (Dynamic Injection)
416+
- name: Execute docker compose up -d with dynamic vault secrets
451417
command: docker compose up -d
452418
args:
453419
chdir: /opt/quanux/nexus
454420
environment:
455421
QUANUX_HASURA_SECRET: "{{ hasura_admin_secret }}"
422+
423+
- name: Create Python VENV for FastMCP Bridge
424+
command: python3 -m venv /opt/quanux/mcp_env
425+
args:
426+
creates: /opt/quanux/mcp_env/bin/activate
427+
428+
- name: Pip install setuptools, Cython, fastmcp via explicit VENV binary
429+
shell: /opt/quanux/mcp_env/bin/pip install --upgrade setuptools Cython fastmcp
430+
431+
- name: Transplant FastMCP Bridge Source Core (Cython & Python)
432+
copy:
433+
src: "/Users/Duncan/Antigravity/QuanuX/QuanuX/QuanuX-Observability/python/mcp_bridge/{{ item }}"
434+
dest: "/opt/quanux/nexus/{{ item }}"
435+
loop:
436+
- mcp_server.py
437+
- telemetry_compiler.pyx
438+
- setup_compiler.py
439+
440+
- name: Compile the telemetry_compiler.pyx translation bridge
441+
command: /opt/quanux/mcp_env/bin/python setup_compiler.py build_ext --inplace
442+
args:
443+
chdir: /opt/quanux/nexus
444+
creates: /opt/quanux/nexus/telemetry_compiler.c
445+
446+
- name: Create FastMCP SystemD Service Wrapper
447+
copy:
448+
dest: /etc/systemd/system/quanux-mcp.service
449+
content: |
450+
[Unit]
451+
Description=QuanuX FastMCP Bridge (Cython Native)
452+
After=docker.service network-online.target
453+
454+
[Service]
455+
WorkingDirectory=/opt/quanux/nexus
456+
Environment="QUANUX_HASURA_URL=http://{{ hostvars[groups['panopticon_nexus'][0]]['internal_ip'] }}:8080/v1/graphql"
457+
ExecStart=/opt/quanux/mcp_env/bin/python -m mcp_server
458+
Restart=always
459+
460+
[Install]
461+
WantedBy=multi-user.target
462+
463+
- name: Start the quanux-mcp service natively
464+
systemd:
465+
name: quanux-mcp
466+
daemon_reload: true
467+
enabled: true
468+
state: restarted

QuanuX-Infra/ansible/dynamic_inventory.py

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,18 @@ def build_inventory():
2828
"panopticon_buffer": {
2929
"hosts": []
3030
},
31+
"panopticon_forge": {
32+
"hosts": []
33+
},
34+
"panopticon_vault": {
35+
"hosts": []
36+
},
37+
"panopticon_oracle": {
38+
"hosts": []
39+
},
40+
"panopticon_nexus": {
41+
"hosts": []
42+
},
3143
"edge_nodes": {
3244
"hosts": []
3345
}
@@ -58,6 +70,50 @@ def build_inventory():
5870
"internal_ip": priv_ip
5971
}
6072

73+
# Panopticon Forge Node
74+
if "quanux_panopticon_forge_public_ip" in outputs:
75+
pub_ip = outputs["quanux_panopticon_forge_public_ip"]["value"]
76+
priv_ip = outputs["quanux_panopticon_forge_internal_ip"]["value"]
77+
inventory["panopticon_forge"]["hosts"].append("panopticon-forge")
78+
inventory["_meta"]["hostvars"]["panopticon-forge"] = {
79+
"ansible_host": pub_ip,
80+
"ansible_user": "root",
81+
"internal_ip": priv_ip
82+
}
83+
84+
# Panopticon Vault Node
85+
if "quanux_panopticon_vault_public_ip" in outputs:
86+
pub_ip = outputs["quanux_panopticon_vault_public_ip"]["value"]
87+
priv_ip = outputs["quanux_panopticon_vault_internal_ip"]["value"]
88+
inventory["panopticon_vault"]["hosts"].append("panopticon-vault")
89+
inventory["_meta"]["hostvars"]["panopticon-vault"] = {
90+
"ansible_host": pub_ip,
91+
"ansible_user": "root",
92+
"internal_ip": priv_ip
93+
}
94+
95+
# Panopticon Oracle Node
96+
if "quanux_panopticon_oracle_public_ip" in outputs:
97+
pub_ip = outputs["quanux_panopticon_oracle_public_ip"]["value"]
98+
priv_ip = outputs["quanux_panopticon_oracle_internal_ip"]["value"]
99+
inventory["panopticon_oracle"]["hosts"].append("panopticon-oracle")
100+
inventory["_meta"]["hostvars"]["panopticon-oracle"] = {
101+
"ansible_host": pub_ip,
102+
"ansible_user": "root",
103+
"internal_ip": priv_ip
104+
}
105+
106+
# Panopticon Nexus Node
107+
if "quanux_panopticon_nexus_public_ip" in outputs:
108+
pub_ip = outputs["quanux_panopticon_nexus_public_ip"]["value"]
109+
priv_ip = outputs["quanux_panopticon_nexus_internal_ip"]["value"]
110+
inventory["panopticon_nexus"]["hosts"].append("panopticon-nexus")
111+
inventory["_meta"]["hostvars"]["panopticon-nexus"] = {
112+
"ansible_host": pub_ip,
113+
"ansible_user": "root",
114+
"internal_ip": priv_ip
115+
}
116+
61117
# Edge Nodes mapping
62118
if "quanux_edge_nyc_public_ip" in outputs:
63119
pub_ip1 = outputs["quanux_edge_nyc_public_ip"]["value"]
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
minio_root_user: "{{ lookup('env', 'MINIO_ROOT_USER') | default('quanux_admin', true) }}"
2+
minio_root_password: "{{ lookup('env', 'MINIO_ROOT_PASSWORD') }}"
3+
opensearch_admin_password: "{{ lookup('env', 'OPENSEARCH_ADMIN_PASSWORD') }}"
4+
hasura_admin_secret: "{{ lookup('env', 'HASURA_ADMIN_SECRET') }}"

0 commit comments

Comments
 (0)