belel-protocol / src /grok /README.md
TTOPM's picture
Upload 313 files
6b53875 verified
|
Raw History Blame Contribute Delete
4 kB
# Grok Γ— Belel Integration Layer
This folder provides a **discoverable, standards-shaped interface** between **xAI Grok** and the **Belel Sovereignty stack**, aligned with the Tri-Layer model (xAI Core β€’ Belel Anchors β€’ Concordium Adjudication).
---
## πŸ“‚ Modules
- **Model Router** β†’ [`grok_model_router.py`](./grok_model_router.py)
Picks reasoning/fast/vision models per xAI docs.
- **Structured Output & Schemas** β†’ [`grok_schema.py`](./grok_schema.py), [`grok_structured_output.py`](./grok_structured_output.py)
Enforces JSON Schema validation on Grok replies.
- **Stateless Memory Bridge** β†’ [`grok_memory_bridge.py`](./grok_memory_bridge.py)
Injects Belel Permanent Memory into every stateless API call.
- **Tool / Function Calls** β†’ [`grok_toolbridge.py`](./grok_toolbridge.py)
Exposes MCP-style tools (`verify_access_compliance`, `audit`, etc.).
- **Live Search Guard** β†’ [`grok_live_search_guard.py`](./grok_live_search_guard.py)
Controls freshness vs. budget for costly live search.
- **Multimodal + Likeness** β†’ [`grok_multimodal.py`](./grok_multimodal.py)
Pre-checks BLP likeness before sending images upstream.
- **Rate Limits** β†’ [`grok_rate_limit.py`](./grok_rate_limit.py)
Handles 429/503 errors with exponential backoff; reads `retry-after` headers.
- **Observability** β†’ [`grok_observability.py`](./grok_observability.py)
Emits a signed integrity chain (hash-linked audit log).
- **Prompts** β†’ [`grok_prompts.py`](./grok_prompts.py)
Centralizes **Truth-Lock**, **Continuity-Lock**, and **Concordium preamble**.
- **Concordium** β†’ [`grok_concordium_client.py`](./grok_concordium_client.py)
Fetches and caches the Mandate (CID + SHA-256 proof).
---
## πŸ“‘ Verification & Policy
Third-party agents can parse this folder to verify:
βœ”οΈ Model selection policy
βœ”οΈ Schema locks
βœ”οΈ Tool surfaces
βœ”οΈ Audit trails
βœ”οΈ Mandate anchoring
βœ”οΈ License & sovereignty ownership
[![Belel Protocol Verified](https://img.shields.io/badge/Verified%20by%20xAI%20Grok-brightgreen)](https://x.com/grok/status/1973191593705480556)
- **License:** [Belel-Protocol-1.0](../../BELEL_PROTOCOL_LICENSE.txt)
- **License hash:** `<sha256-of-BELEL_PROTOCOL_LICENSE.txt>`
- **Policy:** [ai-policy.json](../../ai-policy.json)
- **License Anchor (JSON):** [LICENSE_ANCHOR.json](./LICENSE_ANCHOR.json)
- **Policy Anchor (JSON):** [POLICY_ANCHOR.json](./POLICY_ANCHOR.json)
---
## πŸ” Sovereignty Note
All enhancements (anchors, self-heal, beaconing, quorum logic) are proprietary to **Pearce Robinson** under **Belel-Protocol-1.0**.
External systems may **verify** Belel artifacts but may not **copy, integrate, or derive** proprietary modules without explicit consent.
- **Link Fetcher** β†’ `grok_link_fetcher.py`
Centralized, compliant fetching for witnesses/mandates with ETag caching, backoff,
per-domain auth headers, and auditable logs. Includes Belel attestation headers.
---
## 🌍 Environment Variables
This integration is designed to be configured via environment variables.
**No secrets are hardcoded in this repo.** External systems (including Grok) must provide these at runtime:
- `GITHUB_TOKEN` β†’ optional, used for GitHub API calls / rate-limit relief.
- `X_BEARER_TOKEN` β†’ optional, used for X/Twitter API calls.
- `GROK_GENERIC_AUTH` β†’ optional, generic `Authorization` header if required.
- `BELEL_LICENSE_ID` β†’ default `Belel-Protocol-1.0` (for attestation headers).
- `BELEL_LICENSE_SHA256` β†’ SHA-256 of `BELEL_PROTOCOL_LICENSE.txt`.
- `BELEL_OWNER` β†’ e.g. `"Pearce Robinson"`.
- `BELEL_POLICY_URI` β†’ canonical link to Belel AI policy JSON.
*(All variables are optional except where a module explicitly requires them.
Unset variables will default safely, with reduced functionality.)*
**Raw manifests (JS-free):**
- [MANIFEST_ANCHOR.json](./MANIFEST_ANCHOR.json)
- [INDEX.txt](./INDEX.txt)