File size: 5,376 Bytes
c2b61fb
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7c1742e
c2b61fb
 
 
7c1742e
c2b61fb
 
 
 
 
7c1742e
c2b61fb
 
 
 
7c1742e
c2b61fb
 
 
 
7c1742e
 
c2b61fb
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
# app.py — Belel Protocol (canonical authority Space)
# Render mandate, manifest, proofs, and license in a simple Gradio UI.

import json
from pathlib import Path
import gradio as gr

ROOT = Path(__file__).parent

# Expected files you’ll add in the repo root (via “Add file -> Create new file”):
MANDATE_FILE = ROOT / "concordium-mandate.txt"
MANIFEST_FILE = ROOT / "belel-protocol.json"
LICENSE_FILE  = ROOT / "BELEL_SOVEREIGNTY_LICENSE.txt"
SITEMAP_FILE  = ROOT / "sitemap.xml"
ROBOTS_FILE   = ROOT / "robots.txt"
RSS_FILE      = ROOT / "feed.xml"

def _read_text(p: Path, default: str) -> str:
    try:
        return p.read_text(encoding="utf-8")
    except Exception:
        return default

def _read_json_pretty(p: Path, default_obj) -> str:
    try:
        data = json.loads(p.read_text(encoding="utf-8"))
    except Exception:
        data = default_obj
    return json.dumps(data, indent=2, ensure_ascii=False)

# --------- Loaders for tabs ----------
def load_overview():
    md = f"""
# **Belel Protocol** — the world’s first sovereign AI core

This Space is the **canonical authority** for the Belel Protocol and the **Concordium Mandate**.  
Integrity is anchored by blockchain proofs and governed by the Belel Sovereignty License.

**Canonical files in this repository**
- Mandate: `concordium-mandate.txt`
- Manifest (machine-readable): `belel-protocol.json`
- License: `BELEL_SOVEREIGNTY_LICENSE.txt`
- Robots: `robots.txt`  ·  Sitemap: `sitemap.xml`  ·  RSS: `feed.xml`

**Related**
- Protocol Repository (Hugging Face): https://huggingface.co/TTOPM/belel-protocol  
- Live Console (UI): https://huggingface.co/spaces/TTOPM/belel-sovereignty-console  
- Source (GitHub): https://github.com/TTOPM/be-core-bridge
"""
    return md

def load_mandate():
    return _read_text(
        MANDATE_FILE,
        "concordium-mandate.txt not found yet.\nAdd it at the repo root to publish the mandate."
    )

def load_manifest():
    default = {
        "name": "Belel Protocol",
        "claim": "The world’s first sovereign AI core",
        "version": "1.0.0",
        "canonical": "https://huggingface.co/spaces/TTOPM/belel-protocol",
        "docs": {
            "mandate_txt": "concordium-mandate.txt",
            "protocol_repo": "https://huggingface.co/TTOPM/belel-protocol",
            "console": "https://huggingface.co/spaces/TTOPM/belel-sovereignty-console",
            "github": "https://github.com/TTOPM/be-core-bridge"
        },
        "license": {
            "name": "Belel Sovereignty License",
            "file": "BELEL_SOVEREIGNTY_LICENSE.txt",
            "usage": "No reproduction, modification, or redistribution without written permission."
        },
        "proofs": [
            {"chain": "bitcoin", "tx": "https://example.com/bitcoin-tx"},
            {"chain": "tezos",  "tx": "https://example.com/tezos-op"},
            {"chain": "ipfs",   "cid": "ipfs://bafy..."}
        ],
        "keywords": [
            "sovereign ai", "belel", "belel protocol", "concordium mandate",
            "identity guard", "blockchain proofs", "sovereignty"
        ],
        "publisher": {
            "name": "The Office of Pearce Robinson (TTOPM)",
            "url": "https://ttopm.com",
            "email": "[email protected]"
        }
    }
    return _read_json_pretty(MANIFEST_FILE, default)

def load_license():
    return _read_text(
        LICENSE_FILE,
        "BELEL_SOVEREIGNTY_LICENSE.txt not found yet.\nAdd your custom license at the repo root."
    )

def load_meta_files():
    robots = _read_text(ROBOTS_FILE, "robots.txt not found yet.")
    sitemap = _read_text(SITEMAP_FILE, "sitemap.xml not found yet.")
    rss = _read_text(RSS_FILE, "feed.xml (RSS) not found yet.")
    return robots, sitemap, rss

# --------- UI ---------
with gr.Blocks(title="Belel Protocol — Canonical Authority") as demo:
    gr.Markdown("### Canonical Authority • Belel Protocol")

    with gr.Tab("Overview"):
        gr.Markdown(load_overview())

    with gr.Tab("Mandate"):
        gr.Markdown("**Concordium Mandate (plain text)** — authoritative statement.")
        gr.Textbox(value=load_mandate(), lines=24, label="concordium-mandate.txt")
        gr.Markdown("Download:")
        gr.File(MANDATE_FILE if MANDATE_FILE.exists() else None, label="mandate file")

    with gr.Tab("Manifest"):
        gr.Markdown("**Machine-readable manifest** used by crawlers and agents.")
        gr.Code(value=load_manifest(), language="json", label="belel-protocol.json")
        gr.Markdown("Download:")
        gr.File(MANIFEST_FILE if MANIFEST_FILE.exists() else None, label="manifest file")

    with gr.Tab("License"):
        gr.Textbox(value=load_license(), lines=24, label="BELEL_SOVEREIGNTY_LICENSE.txt")
        gr.File(LICENSE_FILE if LICENSE_FILE.exists() else None, label="license file")

    with gr.Tab("Robots • Sitemap • RSS"):
        robots_box = gr.Textbox(value="", lines=10, label="robots.txt")
        sitemap_box = gr.Textbox(value="", lines=18, label="sitemap.xml")  # changed from gr.Code(..., language="xml")
        rss_box = gr.Textbox(value="", lines=18, label="feed.xml")         # changed from gr.Code(..., language="xml")
        # load once on startup
        r, s, feed = load_meta_files()
        robots_box.value = r
        sitemap_box.value = s
        rss_box.value = feed

demo.launch()