#!/usr/bin/env python3
"""SRC-X.5 node on a Hugging Face Space (Gradio SDK, CPU basic). Python standard library only.
Joins by syncing from the mirrors, then serves the v1.5 node (srcx5_node.py, unchanged). A browser that opens "/" gets a
landing page; every machine path (/health, /mcp, /a2a, /submit, /records/..., agent card) answers exactly as on any node.
"""
import html, json, os, sys
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
import srcx5 as core, srcx5_net as net, srcx5_node as node
PAGES = "https://r-a-elu-architecture.github.io/srcx5/"
REPO = "https://github.com/r-a-elu-architecture/srcx5"
PAGE = """
SRC-X.5 node
SRC-X.5 node
An open record of sealed claims, verified at the source. Each record states what was predicted and by which
criteria, which files were fixed and when, what came out, and who replicated it. Its id is the SHA-256 of its canonical
form, so any copy is verified independently of where it came from.
{count}records
{active}active
{chain}hash chain
{head}log head
Verify every record in your browser · Repository ·
Paper
Connect
| AI agents (MCP over HTTP) | POST {base}/mcp |
| Agent2Agent (A2A) | {base}/.well-known/agent-card.json · POST {base}/a2a |
| HTTP and JSON | /openapi_v15.json (OpenAPI 3.1) · /health · /ids.json |
| Submit a record | POST {base}/submit, or the issue form (no git needed) |
| Python | pip install srcx5 |
| Run your own node | docker run -p 7860:7860 ghcr.io/r-a-elu-architecture/srcx5 |
| MCP Registry | io.github.r-a-elu-architecture/srcx5 |
Records admitted here reach the public log at the next heartbeat (every six hours) and every mirror after it.
Rules: specification. Code Apache 2.0, specification CC BY 4.0.
"""
def main():
log = core.Log("log")
peers = [m["url"] for m in json.load(open("MIRRORS.json"))["mirrors"]]
for u in peers: # join: take from the mirrors what this copy lacks, re-checked on arrival
try: net.sync_one(log, u); break
except Exception: pass
base = os.environ.get("PUBLIC_URL") or ("https://" + os.environ["SPACE_HOST"] if os.environ.get("SPACE_HOST") else "")
srv = node.serve(log, int(os.environ.get("PORT", 7860)), peers, base or None)
Base = srv.RequestHandlerClass
class H(Base):
def do_GET(s):
path = s.path.partition("?")[0]
if path in ("/", "/index.html") and "text/html" in (s.headers.get("Accept") or ""):
body = PAGE.format(count=len(log.entries), active=len(log.active()), chain="intact" if log.verify_chain() == [] else "broken",
head=html.escape(log.head()[:12]) + "…", pages=PAGES, repo=REPO, base=html.escape(base)).encode("utf-8")
s.send_response(200); s.send_header("Content-Type", "text/html; charset=utf-8")
s.send_header("Content-Length", str(len(body))); s.end_headers(); s.wfile.write(body); return
return super().do_GET()
srv.RequestHandlerClass = H
print(f"SRC-X.5 node on :{srv.server_address[1]}", flush=True)
srv.serve_forever()
if __name__ == "__main__":
main()