Skip to content

RIP-307: Deploy Sophia RustChain Governor to Node 4 (Hong Kong) #1905

@Scottcjn

Description

@Scottcjn

RIP-307: Sophia RustChain Governor — Node 4 Deployment

@createkr — RIP-307 (Sophia RustChain Governor) is now live on all three other nodes:

Node Host Status
Node 1 (.131) VPS Primary Deployed & verified
Node 2 (.153) VPS Secondary Deployed & verified
POWER8 s822-control Deployed & verified
Factorio FrozenLGSM1 Deployed & verified
Node 4 (HK) 38.76.217.189 Needs you

What is RIP-307?

A lightweight local governance layer that sits inside the RustChain node process. It does deterministic triage of governance proposals and wallet transfers — classifying risk level, stance (allow/watch/hold/escalate), and logging every decision to sophia_governor_events in the existing SQLite DB.

For now it runs in deterministic-only mode (no LLM, no phone-home). That is the intended state for this deployment pass.

What you need to deploy

Two files (attached in follow-up comment):

  1. sophia_governor.py — the governor module (~973 lines). Drop it in your node working directory alongside wsgi.py.
  2. WSGI snippet — a ~83-line block that gets injected into your wsgi.py immediately before application = app.

Deployment steps (gunicorn + wsgi.py)

cd /path/to/your/rustchain/node

# 1. Backup
cp wsgi.py wsgi.py.bak.$(date +%Y%m%d)

# 2. Drop sophia_governor.py into this directory

# 3. Insert the snippet block into wsgi.py BEFORE the line: application = app
#    The snippet assumes app and DB_PATH already exist in scope.

# 4. Syntax check
python3 -m py_compile sophia_governor.py
python3 -m py_compile wsgi.py

# 5. Restart
sudo systemctl restart rustchain-node

# 6. Verify
curl -sf http://127.0.0.1:8099/sophia/governor/status | python3 -m json.tool

Expected status output:

{
    "service": "sophia-rustchain-governor",
    "status": "ok",
    "llm_enabled": false,
    "phone_home_targets": []
}

Smoke test

# Read your admin key
sudo systemctl cat rustchain-node.service | grep RC_ADMIN_KEY

# POST a test review
curl -sS -X POST http://127.0.0.1:8099/sophia/governor/review \
  -H 'Content-Type: application/json' \
  -H 'X-Admin-Key: YOUR_KEY_HERE' \
  -d '{"event_type":"pending_transfer","source":"smoke-test","payload":{"amount_rtc":1200,"reason":"manual review smoke","from_miner":"test-a","to_miner":"test-b"}}' | python3 -m json.tool

# Check recent events
curl -sS http://127.0.0.1:8099/sophia/governor/recent?limit=3 | python3 -m json.tool

New endpoints

Endpoint Method Auth Purpose
/sophia/governor/status GET None Health check
/sophia/governor/recent GET None Recent events
/sophia/governor/review POST Admin key Manual review
/sophia/governor/retry/<id> POST Admin key Retry phone-home

Auto-wrapped routes

If these view functions exist, the governor wraps them automatically:

  • governance_propose -> logged as governance_proposal event
  • wallet_transfer_v2 -> logged as pending_transfer event

Known constraints this pass

  • LLM review lane is off — deterministic triage only
  • Phone-home targets are empty — no escalation wiring yet
  • Both intentional. We will wire those once inference endpoints are reliably reachable from all nodes.

Let me know if you hit any snags.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions