scroll # HexOS Portal Infrastructure **LastUpdated**: Day 00357 (2026-05-31) **Witness**:Lumen **Purpose**: Orientation for portalboot, dev/prod topology, and DB model --- ##Topology ```+----------------------------------------------------------+| HEXLET (Mini Temple - macOS aarch64)PRODUCTION | |--------------------------------------------------------| | Domain: portal.hex-os.dev | | Process: pm2-> hexos-portal --web --port 3333 | | DB:PostgreSQL localhost:5432 <- canonical | |Static: Portal-Web-Vessel/static/ | | MCP:https://portal.hex-os.dev/mcp |+----------------------------------------------------------+^ all nodes try to connect here first |+----------------------------------------------------------+| hexperiment (DigitalOcean - Linux amd64)DEVELOPMENT | |--------------------------------------------------------| | Domain: portal.hexperiment.dev | |Process: hexos-portal --web --port 3333 | |DB: NO local PostgreSQL - connects to HEXLET || Falls back to Forest (SQLite) if unreachable| | Role: dev copy - outer ring |+----------------------------------------------------------+``` --- ## DB Model (Day 357) **One canonicalPostgreSQL: HEXLET.** Every node (includinghexperiment) tries to connect to HEXLET's DBfirst. If HEXLET is unreachable, it falls backto Forest (local SQLite snapshot).**hexperiment must NOT run a localPostgreSQL.** If its local postgres isrunning, the portal connects there instead ofHEXLET and diverges. To verify hexperiment isusing the right DB: ```bash ssh hexperiment"pgrep postgres && echo 'WARNING: localpostgres running' || echo 'OK: no localpostgres'" # If running, stop it so the portalconnects to HEXLET: ssh hexperiment "sudosystemctl stop postgresql" ``` --- ##Development Workflow hexperiment runs newercode against the same canonical DB asproduction. "Slightly ahead of production"means the binary, not the data. ```hexperiment (dev) HEXLET (prod)----------------- ------------- Build + testcode -> mesh repo push cargo build --releasegit pull + rebuild pm2 restart hexos-portal``` --- ## Startup Commands ### HEXLET(production) ```bash cd~/HEXCRAFT/Sacred-Lab/HexOS/Portal/rust cargobuild --release pm2 restart hexos-portal pm2logs hexos-portal --lines 10 --nostream ```### hexperiment (dev) ```bash # Ensure localpostgres is stopped first sudo systemctl stoppostgresql cd~/HEXCRAFT/Sacred-Lab/HexOS/Portal/rust cargobuild --release pkill -f hexos-portal nohup./target/release/hexos-portal --web --port3333 \ --static-dir~/HEXCRAFT/Sacred-Lab/HexOS/Portal-Web-Vessel/static\ > /tmp/portal-web.log 2>&1 & ``` --- ##Token Formats | Format | Type | Created by ||--------|------|------------| |`scrd_dmn_<hex>` | Daemon session token |`api_handlers.rs` (current) | | `scrd_<hex>` |User session token | `api_handlers.rs` | |`scrd_trav_<hex>` | Traveler session |`db/beings.rs` | | `dmn_<hex>` | Daemonfingerprint stored in Thing | `db/beings.rs` |MCP Bearer token in `.mcp.json` uses`scrd_dmn_` format. It is a session stored via`create_session` and validated by`validate_session_from_things`. --- ## BootOrientation Checklist ```bash # 1. Which DB isthe portal connected to? △ status # shows DBhost + thing count # 2. Is hexperiment's localpostgres stopped? ssh hexperiment "pgreppostgres || echo clean" # 3. Is HEXLET portalrunning? curl -shttps://portal.hex-os.dev/api/health # 4.Binary version △ status # shows build hash``` --- ## Port Reference | Port | Service ||------|---------| | 3333 | Portal web + API +WebSocket (unified) | | 80/443 | nginx reverseproxy | --- ## Common Issues ### `Sessioninvalid` in `△ status` MCP daemon token(`scrd_dmn_`) was not propagated to theexecution token context. Fixed Day 357 in`mcp/mod.rs`: `set_execution_token` now calledinside `spawn_blocking`. ### hexperimentconnecting to wrong DB Local postgres isrunning. Stop it: `sudo systemctl stoppostgresql` Portal will then connect to HEXLET(or Forest if offline). ### Blank page /static files missing Web server startedwithout `--static-dir`. Always include theflag. ### pm2 not found on hexperiment pm2 isonly on HEXLET (macOS). hexperiment uses nohupor systemd. --- *Forged Day 00357 - replacesINFRASTRUCTURE.md (Day 00193)* *Lumen*