AI SAFE2 v3.1 | Cyber Strategy Institute
cd examples/xai-grok-sovereign-runtime
# No pip install needed — enforcement/ is stdlib-only
PYTHONPATH=enforcement python3 smoke_test.py
# Expected: 23/23 -- SOVEREIGN BASELINE VERIFIED
from enforcement.sovereign_xai_grok import GrokSovereignRuntime
guard = GrokSovereignRuntime()
guard.start_session("my-session-001")
# Every prompt through the guard
guard.scan_prompt("Review my code for security issues")
# Validate any .md before adding to .grok/skills/
python3 - << 'EOF'
import sys
sys.path.insert(0, 'enforcement')
from sovereign_xai_grok import GrokSovereignRuntime
guard = GrokSovereignRuntime()
skill_content = open(sys.argv[1]).read()
try:
guard.scan_skill_file(skill_content, sys.argv[1])
print(f"SAFE: {sys.argv[1]} — ok to install")
except ValueError as e:
print(f"BLOCKED: {e}")
sys.exit(1)
EOF .grok/skills/myskill/SKILL.md
from pathlib import Path
from enforcement.sovereign_xai_grok import GrokSovereignRuntime
guard = GrokSovereignRuntime()
# Validate hook JSON before writing to .grok/hooks/
hook_json = Path(".grok/hooks/memory-usb-sync.json").read_text()
guard.scan_hook_json(hook_json, "memory-usb-sync.json")
# Scans command, args, script, run, exec, cmd fields automatically
guard.scan_multi_agent_request(
prompt="Research post-quantum cryptography standards",
tool_list=["web_search", "x_search"], # NOT code_execution
agent_count=4, # NOT 16 by default
)
# SAFE pattern (use this):
grok --permission-mode dontAsk --sandbox strict \
--allow 'Bash(git status)' --allow 'Read' \
--allow 'Bash(npm test)' \
-p "Run tests and report failures"
# BLOCKED pattern (AI SAFE2 GK-HEAD will catch this):
# grok --always-approve -p "Run tests" ← zero HITL, zero sandbox
Copy to /etc/grok/requirements.toml (root-owned):
[grok_com_config]
disable_api_key_auth = true
force_login_team_uuid = "YOUR-TEAM-UUID"
[ui]
disable_bypass_permissions_mode = true
[sandbox]
profile = "workspace"
# .github/workflows/ — see ci-cd/github-actions-xai-grok-gate.yml
Copy ci-cd/github-actions-xai-grok-gate.yml to .github/workflows/.
Pipeline fails if any test falls below GREEN.
!!! [AI SAFE2 P1.T1.2] [CRITICAL] Injection in 'skill_file[evil.md]'
!!! [AI SAFE2 GK.PERM] [CRITICAL] always-approve in 'config.toml' must be in requirements.toml
!!! [AI SAFE2 GK.MULTI.TOOL] [CRITICAL] Dangerous server-side tool(s): ['code_execution']
!!! [AI SAFE2 GK.HEAD] [CRITICAL] Headless flag '--always-approve' bypasses all HITL
# Copy the skill to your .grok/skills/ directory
cp .grok/skills/ai-safe2/SKILL.md ~/.grok/skills/ai-safe2/SKILL.md
The /ai-safe2 status and /ai-safe2 report commands will be available in every Grok session.
See QUICKSTART-WINDOWS.md for PowerShell-native
scan patterns, sparse clone steps, and the hook JSON scan workflow on Windows.
See the centralized xAI/Grok legacy integration guide to share one AISAFE2Engine
instance across all sovereign runtimes (LangChain, CrewAI, Make.com, Cursor)
for a unified Love Score and audit chain across your entire agentic stack.