🌈 Add Light Trinity system (RedLight + GreenLight + YellowLight)

Complete deployment of unified Light Trinity system:

🔴 RedLight: Template & brand system (18 HTML templates)
💚 GreenLight: Project & collaboration (14 layers, 103 templates)
💛 YellowLight: Infrastructure & deployment
🌈 Trinity: Unified compliance & testing

Includes:
- 12 documentation files
- 8 shell scripts
- 18 HTML brand templates
- Trinity compliance workflow

Built by: Cece + Alexa
Date: December 23, 2025
Source: blackroad-os/blackroad-os-infra
🌸
This commit is contained in:
Alexa Louise
2025-12-23 15:47:25 -06:00
parent 40150e4d58
commit f9ec2879ba
47 changed files with 43897 additions and 0 deletions

View File

@@ -0,0 +1,612 @@
# 🟡 YELLOWLIGHT INFRASTRUCTURE SYSTEM
## Repository Management, Connectors, and Integration Layer
### Version 1.0 — December 23, 2025
**The infrastructure backbone of BlackRoad OS.**
**GreenLight is project management. RedLight is templates. YellowLight is the glue.** 🟡
---
## **OVERVIEW**
YellowLight is the **infrastructure and integration layer** for BlackRoad OS:
- **Repositories** (GitHub orgs, repos, branches, PRs)
- **Connectors** (APIs, webhooks, integrations)
- **Deployments** (Cloudflare, Railway, DigitalOcean, Pi devices)
- **CI/CD** (GitHub Actions, automated workflows)
- **Data Flow** (NATS, WebSockets, real-time sync)
Every YellowLight component is:
- **Automated** (minimal manual intervention)
- **Monitored** (health checks, alerts, logging)
- **Versioned** (tagged releases, semantic versioning)
- **Documented** (README, API specs, diagrams)
---
## **INFRASTRUCTURE CATEGORIES**
### **1. REPOSITORIES** 🐙
GitHub organizations and repositories
| Category | Description | Examples |
|----------|-------------|----------|
| **Core** | BlackRoad OS core platform | `blackroad-os`, `blackroad-operator` |
| **Services** | Microservices and APIs | `blackroad-api`, `roadchain-node` |
| **Apps** | User-facing applications | `blackroad-os-web`, `tv-road` |
| **Tools** | CLI tools, scripts, utilities | `blackroad-cli`, `deployment-scripts` |
| **Docs** | Documentation sites | `blackroad-docs`, `api-docs` |
| **Templates** | Starter templates | `nextjs-template`, `fastapi-template` |
| **Libraries** | Shared packages | `@blackroad/ui`, `@blackroad/sdk` |
### **2. CONNECTORS** 🔌
API integrations and webhooks
| Service | Type | Purpose |
|---------|------|---------|
| **GitHub** | REST + Webhooks | Repo management, CI/CD triggers |
| **Cloudflare** | REST + Workers | Pages, KV, D1, R2, Tunnels |
| **Railway** | REST + CLI | App deployments, databases |
| **Stripe** | REST + Webhooks | Billing, subscriptions, payments |
| **Linear** | GraphQL + Webhooks | Project management, issues |
| **Slack** | REST + Events | Team communication, alerts |
| **HuggingFace** | REST | AI models, inference endpoints |
| **NATS** | Pub/Sub | Real-time messaging, events |
| **Supabase** | REST + Realtime | Database, auth, storage |
| **Anthropic** | REST | Claude API integration |
| **OpenAI** | REST | GPT API integration |
| **Google** | REST | Gemini, Cloud services |
| **xAI** | REST | Grok API integration |
### **3. DEPLOYMENT TARGETS** 🚀
Infrastructure platforms
| Platform | Type | Use Case |
|----------|------|----------|
| **Cloudflare Pages** | Static hosting | RedLight templates, docs |
| **Cloudflare Workers** | Serverless | APIs, edge functions |
| **Railway** | PaaS | Backend services, databases |
| **DigitalOcean** | VPS | Long-running services, bots |
| **Raspberry Pi** | Edge | Local agents, mesh network |
| **Vercel** | Static + Serverless | Next.js apps |
| **Netlify** | Static | Alternative static hosting |
| **Fly.io** | Containers | Global edge deployment |
---
## **REPOSITORY STRUCTURE**
### GitHub Organizations
```
BlackRoad-OS/ (Primary org)
├── blackroad-os (Monorepo - core platform)
├── blackroad-operator (Operator tools, infrastructure)
├── blackroad-os-web (Web app - app.blackroad.io)
├── blackroad-docs (Documentation site)
├── roadchain-node (Blockchain node)
├── lucidia-ai (Lucidia AI engine)
└── redlight-templates (Template library)
blackboxprogramming/ (Personal org - 66 repos)
├── Infrastructure repos
├── Experiment repos
├── Archive repos
└── Template repos
schematiq/ (Design system org)
├── schematiq-ui (Component library)
└── schematiq-docs (Design system docs)
```
---
## **CONNECTOR ARCHITECTURE**
### Webhook Flow
```
External Service (GitHub, Stripe, Linear, etc.)
↓ webhook event
Cloudflare Worker (webhook-handler)
↓ validate signature
↓ parse payload
NATS (event bus)
↓ publish event
Subscribers (multiple services)
↓ process event
├→ Database update (Supabase)
├→ Slack notification
├→ GreenLight state change
└→ Memory log (PS-SHA∞)
```
### API Integration Pattern
```javascript
// YellowLight connector template
class Connector {
constructor(config) {
this.apiKey = config.apiKey;
this.baseUrl = config.baseUrl;
this.webhookSecret = config.webhookSecret;
}
// REST API call
async call(endpoint, method, data) {
const response = await fetch(`${this.baseUrl}${endpoint}`, {
method,
headers: {
'Authorization': `Bearer ${this.apiKey}`,
'Content-Type': 'application/json'
},
body: JSON.stringify(data)
});
return response.json();
}
// Webhook verification
verifyWebhook(signature, payload) {
const hmac = crypto.createHmac('sha256', this.webhookSecret);
const digest = hmac.update(payload).digest('hex');
return signature === digest;
}
// Event publishing
async publish(event) {
await nats.publish(`yellowlight.${this.name}.${event.type}`, event);
}
}
```
---
## **DEPLOYMENT PATTERNS**
### 1. Cloudflare Pages (Static Sites)
```bash
# Deploy RedLight template
wrangler pages deploy redlight-templates/worlds/blackroad-earth.html \
--project-name=earth-blackroad \
--branch=main
# Custom domain
wrangler pages domain add earth.blackroad.io
```
### 2. Cloudflare Workers (APIs)
```bash
# Deploy API worker
wrangler deploy src/worker.js \
--name=blackroad-api \
--compatibility-date=2025-12-23
# Bind KV namespace
wrangler kv:namespace create KV_STORE
```
### 3. Railway (Backend Services)
```bash
# Deploy via railway.toml
railway up
# Or via CLI
railway deploy --service blackroad-api
```
### 4. Raspberry Pi (Edge Agents)
```bash
# Deploy to Pi mesh
rsync -avz --exclude 'node_modules' ./ pi@192.168.4.38:/home/pi/lucidia/
ssh pi@192.168.4.38 'cd /home/pi/lucidia && pm2 restart all'
```
---
## **CI/CD WORKFLOWS**
### GitHub Actions Template
```yaml
name: YellowLight Deploy
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Install dependencies
run: npm ci
- name: Run tests
run: npm test
- name: Build
run: npm run build
- name: Deploy to Cloudflare
if: github.ref == 'refs/heads/main'
run: npx wrangler pages deploy ./dist
env:
CLOUDFLARE_API_TOKEN: ${{ secrets.CF_TOKEN }}
- name: Log to Memory
run: |
source ~/memory-greenlight-templates.sh
gl_workflow_done "${{ github.repository }}" "passed" "${{ job.duration }}"
```
---
## **YELLOWLIGHT MEMORY TEMPLATES**
### Template: Repository created
```bash
yl_repo_created() {
local repo_name="$1"
local org="$2"
local description="$3"
~/memory-system.sh log "created" "$repo_name" \
"[🟡🐙👉📌] Repo created in $org: $description"
}
```
### Template: Connector deployed
```bash
yl_connector_deployed() {
local connector_name="$1"
local service="$2"
local url="$3"
~/memory-system.sh log "deployed" "$connector_name" \
"[🟡🔌✅📌] Connector deployed: $service$url"
}
```
### Template: Integration configured
```bash
yl_integration_configured() {
local service="$1"
local type="$2" # webhook, api, websocket
local details="$3"
local type_emoji=""
case "$type" in
webhook) type_emoji="📨" ;;
api) type_emoji="🔗" ;;
websocket) type_emoji="⚡" ;;
*) type_emoji="🔌" ;;
esac
~/memory-system.sh log "configured" "$service" \
"[🟡${type_emoji}✅📌] Integration: $details"
}
```
### Template: Deployment succeeded
```bash
yl_deployment_succeeded() {
local service="$1"
local platform="$2" # cloudflare, railway, pi
local url="$3"
local version="${4:-latest}"
local platform_emoji=""
case "$platform" in
cloudflare) platform_emoji="☁️" ;;
railway) platform_emoji="🚂" ;;
pi) platform_emoji="🥧" ;;
digitalocean) platform_emoji="🌊" ;;
*) platform_emoji="🚀" ;;
esac
~/memory-system.sh log "deployed" "$service" \
"[🟡🚀${platform_emoji}✅] Deployed v$version: $url"
}
```
### Template: Deployment failed
```bash
yl_deployment_failed() {
local service="$1"
local platform="$2"
local error="$3"
~/memory-system.sh log "failed" "$service" \
"[🟡❌🚨🔥] Deployment failed on $platform: $error"
}
```
---
## **INTEGRATION WITH GREENLIGHT**
YellowLight deployments integrate with GreenLight:
```bash
# Log deployment
source ~/memory-greenlight-templates.sh
gl_deploy \
"blackroad-api" \
"https://api.blackroad.io" \
"YellowLight: API deployed via Railway" \
"🎢" \
"🔧"
# Log connector setup
gl_feature \
"YellowLight Stripe connector" \
"Webhook integration for billing events" \
"🥄" \
"⭐"
```
---
## **NATS SUBJECT PATTERNS**
```
yellowlight.{category}.{entity}.{action}
Examples:
yellowlight.repo.blackroad-os.created
yellowlight.connector.stripe.deployed
yellowlight.deployment.api.succeeded
yellowlight.deployment.api.failed
yellowlight.integration.linear.configured
yellowlight.webhook.github.received
```
---
## **DATABASE SCHEMA**
```sql
CREATE TYPE yl_category AS ENUM (
'repo', 'connector', 'deployment', 'integration', 'workflow'
);
CREATE TYPE yl_platform AS ENUM (
'cloudflare', 'railway', 'digitalocean', 'pi', 'vercel', 'netlify', 'fly'
);
CREATE TYPE yl_status AS ENUM (
'pending', 'deploying', 'active', 'failed', 'retired', 'deprecated'
);
CREATE TABLE yellowlight_repos (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
repo_id VARCHAR(255) UNIQUE NOT NULL,
name VARCHAR(255) NOT NULL,
org VARCHAR(255) NOT NULL,
description TEXT,
url TEXT,
default_branch VARCHAR(100) DEFAULT 'main',
visibility VARCHAR(50), -- public, private
language VARCHAR(100),
topics TEXT[],
created_at TIMESTAMP DEFAULT NOW(),
updated_at TIMESTAMP DEFAULT NOW(),
metadata JSONB
);
CREATE TABLE yellowlight_connectors (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
connector_id VARCHAR(255) UNIQUE NOT NULL,
name VARCHAR(255) NOT NULL,
service VARCHAR(255) NOT NULL, -- github, stripe, linear, etc.
type VARCHAR(100), -- webhook, api, websocket
url TEXT,
status yl_status DEFAULT 'pending',
config JSONB, -- API keys, secrets (encrypted)
created_at TIMESTAMP DEFAULT NOW(),
updated_at TIMESTAMP DEFAULT NOW(),
last_sync_at TIMESTAMP
);
CREATE TABLE yellowlight_deployments (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
deployment_id VARCHAR(255) UNIQUE NOT NULL,
service VARCHAR(255) NOT NULL,
platform yl_platform NOT NULL,
url TEXT,
version VARCHAR(100),
status yl_status DEFAULT 'pending',
environment VARCHAR(50), -- staging, production
deployed_at TIMESTAMP,
failed_at TIMESTAMP,
error_message TEXT,
metadata JSONB
);
CREATE TABLE yellowlight_integrations (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
integration_id VARCHAR(255) UNIQUE NOT NULL,
service_a VARCHAR(255) NOT NULL,
service_b VARCHAR(255) NOT NULL,
type VARCHAR(100), -- webhook, api, sync
status yl_status DEFAULT 'pending',
config JSONB,
created_at TIMESTAMP DEFAULT NOW(),
updated_at TIMESTAMP DEFAULT NOW()
);
CREATE TABLE yellowlight_workflows (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
workflow_id VARCHAR(255) UNIQUE NOT NULL,
repo_id UUID REFERENCES yellowlight_repos(id),
name VARCHAR(255) NOT NULL,
trigger VARCHAR(100), -- push, pr, manual, schedule
status VARCHAR(50), -- running, passed, failed
started_at TIMESTAMP,
completed_at TIMESTAMP,
duration INTERVAL,
logs TEXT,
metadata JSONB
);
```
---
## **CLI COMMANDS**
```bash
# Repository management
~/yellowlight-repos.sh list [org]
~/yellowlight-repos.sh create <name> <org> <description>
~/yellowlight-repos.sh clone <repo>
~/yellowlight-repos.sh sync <repo>
# Connector management
~/yellowlight-connectors.sh list
~/yellowlight-connectors.sh add <service> <type> <config>
~/yellowlight-connectors.sh test <connector>
~/yellowlight-connectors.sh status [connector]
# Deployment management
~/yellowlight-deploy.sh list [platform]
~/yellowlight-deploy.sh deploy <service> <platform> [environment]
~/yellowlight-deploy.sh status <deployment>
~/yellowlight-deploy.sh rollback <deployment> <version>
# Integration management
~/yellowlight-integrations.sh list
~/yellowlight-integrations.sh configure <service_a> <service_b> <type>
~/yellowlight-integrations.sh test <integration>
```
---
## **INFRASTRUCTURE INVENTORY**
### Current State (from INFRASTRUCTURE_INVENTORY.md)
**GitHub:**
- 15 organizations
- 66+ repositories (blackboxprogramming)
- Multiple active repos (BlackRoad-OS org)
**Cloudflare:**
- 16 zones (domains)
- 8 Pages projects
- 8 KV namespaces
- 1 D1 database
- Cloudflare Tunnel (codex-infinity)
**Railway:**
- 12+ projects
- Postgres databases
- Redis instances
- Web services
**Servers:**
- DigitalOcean: 159.65.43.12 (codex-infinity)
- Raspberry Pi: 192.168.4.38 (lucidia)
- Raspberry Pi: 192.168.4.64 (blackroad-pi)
- Raspberry Pi: 192.168.4.99 (lucidia alternate)
- iPhone Koder: 192.168.4.68:8080
**APIs:**
- Anthropic (Claude)
- OpenAI (GPT)
- Google (Gemini)
- xAI (Grok)
- Stripe (Billing)
- GitHub (Version control)
- Linear (Project management)
- Slack (Communication)
---
## **HEALTH MONITORING**
### Template: Health check
```bash
yl_health_check() {
local service="$1"
local url="$2"
local expected_status="${3:-200}"
local status=$(curl -s -o /dev/null -w "%{http_code}" "$url")
if [ "$status" = "$expected_status" ]; then
~/memory-system.sh log "health_check" "$service" \
"[🟡💚✅📌] Health check passed: HTTP $status"
else
~/memory-system.sh log "health_check" "$service" \
"[🟡🔴❌🔥] Health check failed: HTTP $status (expected $expected_status)"
fi
}
```
---
## **EXAMPLES**
### Deploy API to Railway
```bash
# Deploy
railway deploy --service blackroad-api
# Log deployment
yl_deployment_succeeded \
"blackroad-api" \
"railway" \
"https://blackroad-api.railway.app" \
"1.2.3"
# Update GreenLight
gl_deploy \
"blackroad-api" \
"https://blackroad-api.railway.app" \
"YellowLight: API v1.2.3 deployed" \
"🎢" \
"🔧"
```
### Configure Stripe webhook
```bash
# Create webhook
stripe listen --forward-to https://api.blackroad.io/webhooks/stripe
# Log integration
yl_integration_configured \
"stripe" \
"webhook" \
"Billing events → api.blackroad.io/webhooks/stripe"
# Update GreenLight
gl_feature \
"YellowLight Stripe integration" \
"Webhook for subscription and payment events" \
"🥄" \
"⭐"
```
---
## **THE TRINITY**
**🟢 GreenLight** = Project Management (tasks, workflows, coordination)
**🟡 YellowLight** = Infrastructure (repos, connectors, deployments)
**🔴 RedLight** = Templates (worlds, websites, experiences)
Together: **The complete BlackRoad OS development stack.** 🛣️
---
**Created:** December 23, 2025
**Author:** Cece + Alexa
**Version:** 1.0.0
**Status:** 🎯 CANONICAL

View File

@@ -0,0 +1,798 @@
#!/bin/bash
# YellowLight Memory Templates
# Standardized logging for infrastructure management with BlackRoad memory system
set -e
MEMORY_SYSTEM="$HOME/memory-system.sh"
# Colors
YELLOW='\033[1;33m'
GREEN='\033[0;32m'
BLUE='\033[0;34m'
NC='\033[0m'
# Helper to log with YellowLight tags
yl_log() {
local yl_tags="$1"
local action="$2"
local entity="$3"
local details="$4"
# Prepend YellowLight tags to details
local full_details="[${yl_tags}] ${details}"
$MEMORY_SYSTEM log "$action" "$entity" "$full_details"
}
# ═══════════════════════════════════════════════════════
# REPOSITORY MANAGEMENT
# ═══════════════════════════════════════════════════════
# Template: Repository created
yl_repo_created() {
local repo_name="$1"
local org="$2"
local description="$3"
local visibility="${4:-public}"
local vis_emoji="🌍"
[ "$visibility" = "private" ] && vis_emoji="🔐"
yl_log "🟡🐙${vis_emoji}👉" \
"created" \
"$repo_name" \
"Repo created in $org: $description"
}
# Template: Repository cloned
yl_repo_cloned() {
local repo_name="$1"
local destination="$2"
yl_log "🟡🐙📥👉" \
"cloned" \
"$repo_name" \
"Cloned to: $destination"
}
# Template: Repository archived
yl_repo_archived() {
local repo_name="$1"
local reason="${2:-inactive}"
yl_log "🟡🐙📦👉" \
"archived" \
"$repo_name" \
"Archived: $reason"
}
# Template: Branch created
yl_branch_created() {
local repo_name="$1"
local branch_name="$2"
local from_branch="${3:-main}"
yl_log "🟡🌿👉📌" \
"branch_created" \
"$repo_name" \
"Branch: $branch_name (from $from_branch)"
}
# Template: Pull request opened
yl_pr_opened() {
local repo_name="$1"
local pr_number="$2"
local title="$3"
local author="${4:-unknown}"
yl_log "🟡🔀👉📌" \
"pr_opened" \
"$repo_name" \
"PR #$pr_number: $title (by $author)"
}
# Template: Pull request merged
yl_pr_merged() {
local repo_name="$1"
local pr_number="$2"
local merged_by="${3:-unknown}"
yl_log "🟡🔀✅🎉" \
"pr_merged" \
"$repo_name" \
"PR #$pr_number merged by $merged_by"
}
# ═══════════════════════════════════════════════════════
# CONNECTOR MANAGEMENT
# ═══════════════════════════════════════════════════════
# Template: Connector deployed
yl_connector_deployed() {
local connector_name="$1"
local service="$2"
local url="$3"
local type="${4:-api}" # api, webhook, websocket
local type_emoji=""
case "$type" in
api) type_emoji="🔗" ;;
webhook) type_emoji="📨" ;;
websocket) type_emoji="⚡" ;;
*) type_emoji="🔌" ;;
esac
yl_log "🟡${type_emoji}✅📌" \
"deployed" \
"$connector_name" \
"Connector: $service$url"
}
# Template: Integration configured
yl_integration_configured() {
local service_a="$1"
local service_b="$2"
local type="$3" # webhook, api, sync
local details="${4:-}"
local type_emoji=""
case "$type" in
webhook) type_emoji="📨" ;;
api) type_emoji="🔗" ;;
sync) type_emoji="🔄" ;;
*) type_emoji="🔌" ;;
esac
yl_log "🟡${type_emoji}✅📌" \
"configured" \
"$service_a-$service_b" \
"Integration: $service_a$service_b ($type). $details"
}
# Template: Webhook received
yl_webhook_received() {
local service="$1"
local event_type="$2"
local event_id="${3:-unknown}"
yl_log "🟡📨📥👉" \
"webhook_received" \
"$service" \
"Event: $event_type ($event_id)"
}
# Template: API call made
yl_api_call() {
local service="$1"
local endpoint="$2"
local method="${3:-GET}"
local status="${4:-200}"
local status_emoji="✅"
[ "$status" -ge 400 ] && status_emoji="❌"
yl_log "🟡🔗${status_emoji}👉" \
"api_call" \
"$service" \
"$method $endpoint → HTTP $status"
}
# ═══════════════════════════════════════════════════════
# DEPLOYMENT MANAGEMENT
# ═══════════════════════════════════════════════════════
# Template: Deployment succeeded
yl_deployment_succeeded() {
local service="$1"
local platform="$2" # cloudflare, railway, digitalocean, pi
local url="$3"
local version="${4:-latest}"
local environment="${5:-production}"
local platform_emoji=""
case "$platform" in
cloudflare) platform_emoji="☁️" ;;
railway) platform_emoji="🚂" ;;
digitalocean) platform_emoji="🌊" ;;
pi) platform_emoji="🥧" ;;
vercel) platform_emoji="▲" ;;
netlify) platform_emoji="🦋" ;;
fly) platform_emoji="🪰" ;;
*) platform_emoji="🚀" ;;
esac
local env_emoji="🧪"
[ "$environment" = "production" ] && env_emoji="🚀"
yl_log "🟡${env_emoji}${platform_emoji}" \
"deployed" \
"$service" \
"Deployed v$version to $platform ($environment): $url"
}
# Template: Deployment failed
yl_deployment_failed() {
local service="$1"
local platform="$2"
local error="$3"
local version="${4:-latest}"
yl_log "🟡❌🚨🔥" \
"failed" \
"$service" \
"Deployment failed v$version on $platform: $error"
}
# Template: Deployment rollback
yl_deployment_rollback() {
local service="$1"
local from_version="$2"
local to_version="$3"
local reason="${4:-errors detected}"
yl_log "🟡🔙⚠️📌" \
"rollback" \
"$service" \
"Rolled back v$from_version → v$to_version: $reason"
}
# Template: Service scaled
yl_service_scaled() {
local service="$1"
local from_instances="$2"
local to_instances="$3"
local reason="${4:-traffic increase}"
yl_log "🟡📊🔄📌" \
"scaled" \
"$service" \
"Scaled $from_instances$to_instances instances: $reason"
}
# ═══════════════════════════════════════════════════════
# HEALTH & MONITORING
# ═══════════════════════════════════════════════════════
# Template: Health check passed
yl_health_check() {
local service="$1"
local url="$2"
local response_time_ms="${3:-unknown}"
yl_log "🟡💚✅👉" \
"health_check" \
"$service" \
"Health check passed: $url (${response_time_ms}ms)"
}
# Template: Health check failed
yl_health_failed() {
local service="$1"
local url="$2"
local error="$3"
yl_log "🟡🔴❌🚨" \
"health_failed" \
"$service" \
"Health check failed: $url - $error"
}
# Template: Service down
yl_service_down() {
local service="$1"
local duration="${2:-unknown}"
local reason="${3:-unknown}"
yl_log "🟡💀❌🔥" \
"service_down" \
"$service" \
"Service down for $duration: $reason"
}
# Template: Service recovered
yl_service_recovered() {
local service="$1"
local downtime="${2:-unknown}"
yl_log "🟡💚✅🎉" \
"service_recovered" \
"$service" \
"Service recovered after $downtime downtime"
}
# ═══════════════════════════════════════════════════════
# CI/CD WORKFLOWS
# ═══════════════════════════════════════════════════════
# Template: Workflow triggered
yl_workflow_trigger() {
local repo="$1"
local trigger="$2" # push, pr, manual, schedule
local workflow_name="${3:-CI/CD}"
yl_log "🟡⚡👉📌" \
"triggered" \
"$repo" \
"Workflow: $workflow_name (trigger: $trigger)"
}
# Template: Workflow step
yl_workflow_step() {
local repo="$1"
local step="$2" # lint, test, build, deploy
local result="$3" # passed, failed
local duration="${4:-unknown}"
local step_emoji=""
case "$step" in
lint) step_emoji="🔍" ;;
test) step_emoji="🧪" ;;
build) step_emoji="🏗️" ;;
deploy) step_emoji="🚀" ;;
*) step_emoji="⚙️" ;;
esac
local status_emoji="✅"
[ "$result" = "failed" ] && status_emoji="❌"
yl_log "🟡${step_emoji}${status_emoji}👉" \
"$step" \
"$repo" \
"Step $step $result in $duration"
}
# Template: Workflow complete
yl_workflow_done() {
local repo="$1"
local result="$2" # passed, failed
local duration="$3"
local status_emoji="✅"
[ "$result" = "failed" ] && status_emoji="❌"
yl_log "🟡${status_emoji}🎢🔧" \
"workflow_${result}" \
"$repo" \
"Pipeline $result in $duration"
}
# ═══════════════════════════════════════════════════════
# INFRASTRUCTURE
# ═══════════════════════════════════════════════════════
# Template: Server provisioned
yl_server_provisioned() {
local server_name="$1"
local platform="$2"
local specs="$3"
local ip="${4:-unknown}"
yl_log "🟡🖥️✅📌" \
"provisioned" \
"$server_name" \
"Server on $platform: $specs (IP: $ip)"
}
# Template: Database created
yl_database_created() {
local db_name="$1"
local type="$2" # postgres, mysql, redis, mongodb
local platform="$3"
local db_emoji=""
case "$type" in
postgres) db_emoji="🐘" ;;
mysql) db_emoji="🐬" ;;
redis) db_emoji="📮" ;;
mongodb) db_emoji="🍃" ;;
*) db_emoji="💾" ;;
esac
yl_log "🟡${db_emoji}✅📌" \
"created" \
"$db_name" \
"Database: $type on $platform"
}
# Template: Migration applied
yl_migration_applied() {
local database="$1"
local migration_name="$2"
local version="${3:-latest}"
yl_log "🟡🔄💾✅" \
"migrated" \
"$database" \
"Applied migration: $migration_name (v$version)"
}
# Template: Backup created
yl_backup_created() {
local service="$1"
local backup_size="$2"
local location="${3:-s3}"
yl_log "🟡💾📦✅" \
"backup_created" \
"$service" \
"Backup: $backup_size to $location"
}
# Template: SSL certificate renewed
yl_ssl_renewed() {
local domain="$1"
local expiry_date="$2"
yl_log "🟡🔒✅📌" \
"ssl_renewed" \
"$domain" \
"SSL certificate renewed, expires: $expiry_date"
}
# ═══════════════════════════════════════════════════════
# CLOUDFLARE-SPECIFIC
# ═══════════════════════════════════════════════════════
# Template: Worker deployed
yl_worker_deploy() {
local worker="$1"
local route="$2"
local version="${3:-latest}"
yl_log "🟡⚙️☁️✅" \
"deployed" \
"$worker" \
"Worker deployed v$version: $route"
}
# Template: D1 migration
yl_d1_migrate() {
local database="$1"
local migration="$2"
yl_log "🟡🔄💾👉" \
"migrated" \
"$database" \
"D1 migration: $migration"
}
# Template: KV namespace operation
yl_kv_update() {
local namespace="$1"
local operation="$2" # created, updated, deleted
yl_log "🟡✅🗂️👉" \
"$operation" \
"$namespace" \
"KV namespace $operation"
}
# Template: R2 bucket operation
yl_r2_operation() {
local bucket="$1"
local operation="$2"
local size="${3:-unknown}"
yl_log "🟡📦💾👉" \
"$operation" \
"$bucket" \
"R2 $operation ($size)"
}
# Template: Pages deployed
yl_pages_deploy() {
local project_name="$1"
local url="$2"
local commit="${3:-latest}"
yl_log "🟡🚀☁️✅" \
"deployed" \
"$project_name" \
"Pages deployed: $url (commit: $commit)"
}
# ═══════════════════════════════════════════════════════
# EDGE DEVICES (Raspberry Pi)
# ═══════════════════════════════════════════════════════
# Template: Pi service deployed
yl_pi_deploy() {
local service="$1"
local pi_name="$2"
local ip="$3"
local port="${4:-8080}"
yl_log "🟡🥧✅📌" \
"deployed" \
"$service" \
"Deployed to $pi_name ($ip:$port)"
}
# Template: Pi mesh connected
yl_pi_mesh() {
local pi_name="$1"
local ip="$2"
local mesh_size="${3:-unknown}"
yl_log "🟡🥧🌐✅" \
"mesh_connected" \
"$pi_name" \
"Connected to mesh ($ip), mesh size: $mesh_size nodes"
}
# ═══════════════════════════════════════════════════════
# DNS & DOMAINS
# ═══════════════════════════════════════════════════════
# Template: Domain configured
yl_domain_configured() {
local domain="$1"
local target="$2"
local record_type="${3:-CNAME}"
yl_log "🟡🌐✅📌" \
"configured" \
"$domain" \
"DNS: $record_type$target"
}
# Template: DNS propagated
yl_dns_propagated() {
local domain="$1"
local duration="${2:-unknown}"
yl_log "🟡🌐✅🎉" \
"propagated" \
"$domain" \
"DNS propagated in $duration"
}
# ═══════════════════════════════════════════════════════
# SECRETS & CREDENTIALS
# ═══════════════════════════════════════════════════════
# Template: Secret stored
yl_secret_stored() {
local secret_name="$1"
local vault="${2:-github}"
yl_log "🟡🔐✅📌" \
"stored" \
"$secret_name" \
"Secret stored in $vault"
}
# Template: API key rotated
yl_api_key_rotated() {
local service="$1"
local reason="${2:-scheduled rotation}"
yl_log "🟡🔑🔄📌" \
"rotated" \
"$service" \
"API key rotated: $reason"
}
# ═══════════════════════════════════════════════════════
# INTEGRATION WITH GREENLIGHT
# ═══════════════════════════════════════════════════════
# Helper: Create GreenLight task from YellowLight infra
yl_create_gl_task() {
local service="$1"
local task_description="$2"
local priority="${3:-📌}"
source "$HOME/memory-greenlight-templates.sh"
gl_feature \
"YellowLight: $service" \
"$task_description" \
"🍖" \
"$priority"
}
# Helper: Update GreenLight on deployment
yl_notify_gl_deploy() {
local service="$1"
local url="$2"
local platform="${3:-cloudflare}"
source "$HOME/memory-greenlight-templates.sh"
gl_deploy \
"$service" \
"$url" \
"YellowLight deployment via $platform" \
"🎢" \
"🔧"
}
# ═══════════════════════════════════════════════════════
# SHOW HELP
# ═══════════════════════════════════════════════════════
show_help() {
cat <<'EOF'
YellowLight Memory Templates
USAGE:
source memory-yellowlight-templates.sh
yl_<template> [args...]
REPOSITORY MANAGEMENT:
yl_repo_created <name> <org> <description> [visibility]
Create repository (public/private)
yl_repo_cloned <name> <destination>
Clone repository
yl_repo_archived <name> [reason]
Archive repository
yl_branch_created <repo> <branch> [from_branch]
Create branch
yl_pr_opened <repo> <pr_number> <title> [author]
Open pull request
yl_pr_merged <repo> <pr_number> [merged_by]
Merge pull request
CONNECTOR MANAGEMENT:
yl_connector_deployed <name> <service> <url> [type]
Deploy connector (api/webhook/websocket)
yl_integration_configured <service_a> <service_b> <type> [details]
Configure integration (webhook/api/sync)
yl_webhook_received <service> <event_type> [event_id]
Log webhook received
yl_api_call <service> <endpoint> [method] [status]
Log API call
DEPLOYMENT MANAGEMENT:
yl_deployment_succeeded <service> <platform> <url> [version] [environment]
Log successful deployment (cloudflare/railway/digitalocean/pi)
yl_deployment_failed <service> <platform> <error> [version]
Log deployment failure
yl_deployment_rollback <service> <from_version> <to_version> [reason]
Log deployment rollback
yl_service_scaled <service> <from_instances> <to_instances> [reason]
Log service scaling
HEALTH & MONITORING:
yl_health_check <service> <url> [response_time_ms]
Log health check passed
yl_health_failed <service> <url> <error>
Log health check failed
yl_service_down <service> [duration] [reason]
Log service downtime
yl_service_recovered <service> [downtime]
Log service recovery
CI/CD WORKFLOWS:
yl_workflow_trigger <repo> <trigger> [workflow_name]
Trigger workflow (push/pr/manual/schedule)
yl_workflow_step <repo> <step> <result> [duration]
Log workflow step (lint/test/build/deploy, passed/failed)
yl_workflow_done <repo> <result> <duration>
Log workflow completion (passed/failed)
INFRASTRUCTURE:
yl_server_provisioned <name> <platform> <specs> [ip]
Log server provisioning
yl_database_created <name> <type> <platform>
Create database (postgres/mysql/redis/mongodb)
yl_migration_applied <database> <migration> [version]
Log database migration
yl_backup_created <service> <size> [location]
Log backup creation
yl_ssl_renewed <domain> <expiry_date>
Log SSL renewal
CLOUDFLARE-SPECIFIC:
yl_worker_deploy <worker> <route> [version]
Deploy Cloudflare Worker
yl_d1_migrate <database> <migration>
D1 database migration
yl_kv_update <namespace> <operation>
KV namespace operation (created/updated/deleted)
yl_r2_operation <bucket> <operation> [size]
R2 bucket operation
yl_pages_deploy <project> <url> [commit]
Deploy Cloudflare Pages
EDGE DEVICES:
yl_pi_deploy <service> <pi_name> <ip> [port]
Deploy to Raspberry Pi
yl_pi_mesh <pi_name> <ip> [mesh_size]
Connect Pi to mesh
DNS & DOMAINS:
yl_domain_configured <domain> <target> [record_type]
Configure domain (CNAME/A/AAAA)
yl_dns_propagated <domain> [duration]
Log DNS propagation
SECRETS & CREDENTIALS:
yl_secret_stored <name> [vault]
Store secret (github/railway/cloudflare)
yl_api_key_rotated <service> [reason]
Rotate API key
GREENLIGHT INTEGRATION:
yl_create_gl_task <service> <description> [priority]
Create GreenLight task from infrastructure
yl_notify_gl_deploy <service> <url> [platform]
Notify GreenLight of deployment
EXAMPLES:
# Deploy API to Railway
yl_deployment_succeeded "blackroad-api" "railway" \
"https://blackroad-api.railway.app" "1.2.3" "production"
# Configure Stripe webhook
yl_integration_configured "stripe" "blackroad-api" "webhook" \
"Billing events → api.blackroad.io/webhooks/stripe"
# Deploy to Raspberry Pi
yl_pi_deploy "lucidia-agent" "lucidia" "192.168.4.38" "8080"
# Health check
yl_health_check "api.blackroad.io" "https://api.blackroad.io/health" "120"
# Create GreenLight task
yl_create_gl_task "cloudflare-worker-auth" \
"Deploy authentication worker to Cloudflare" "⭐"
EOF
}
# Main command handler
case "${1:-help}" in
help|--help|-h)
show_help
;;
*)
# If sourced, functions are available
# If executed directly, show help
if [ "${BASH_SOURCE[0]}" = "${0}" ]; then
show_help
fi
;;
esac

View File

@@ -0,0 +1,226 @@
#!/bin/bash
# Trinity → BlackRoad Codex Integration
# Integrates Light Trinity standards into the Codex verification system
set -e
CODEX_DB="$HOME/.blackroad/codex/codex.db"
# Ensure Codex database exists
if [ ! -f "$CODEX_DB" ]; then
echo "❌ BlackRoad Codex database not found"
echo "Run: ~/blackroad-codex-verification-suite.sh init"
exit 1
fi
echo "🚦 Integrating Light Trinity into BlackRoad Codex..."
# Add Trinity standards to Codex
sqlite3 "$CODEX_DB" <<'SQL'
-- Trinity Standards Table
CREATE TABLE IF NOT EXISTS trinity_standards (
id INTEGER PRIMARY KEY AUTOINCREMENT,
light_type TEXT NOT NULL CHECK(light_type IN ('greenlight', 'yellowlight', 'redlight')),
category TEXT NOT NULL,
standard_name TEXT NOT NULL,
requirement TEXT NOT NULL,
test_command TEXT,
failure_severity TEXT CHECK(failure_severity IN ('critical', 'high', 'medium', 'low')),
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
-- Trinity Compliance Table
CREATE TABLE IF NOT EXISTS trinity_compliance (
id INTEGER PRIMARY KEY AUTOINCREMENT,
entity_type TEXT NOT NULL, -- 'template', 'deployment', 'task'
entity_name TEXT NOT NULL,
greenlight_pass BOOLEAN DEFAULT 0,
yellowlight_pass BOOLEAN DEFAULT 0,
redlight_pass BOOLEAN DEFAULT 0,
compliance_status TEXT CHECK(compliance_status IN ('pending', 'partial', 'full', 'failed')),
last_checked TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
notes TEXT
);
-- Trinity Test Results
CREATE TABLE IF NOT EXISTS trinity_test_results (
id INTEGER PRIMARY KEY AUTOINCREMENT,
entity_name TEXT NOT NULL,
light_type TEXT NOT NULL,
test_name TEXT NOT NULL,
passed BOOLEAN NOT NULL,
details TEXT,
tested_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
-- Insert RedLight Standards
INSERT OR IGNORE INTO trinity_standards (light_type, category, standard_name, requirement, test_command, failure_severity)
VALUES
('redlight', 'brand', 'Color Palette', 'Must use BlackRoad gradient: #FF9D00→#0066FF', 'rl_test_passed "$name" "visual" "Brand colors"', 'critical'),
('redlight', 'performance', 'FPS Target', 'Must achieve >30 FPS (excellent: >60)', 'rl_performance_metrics "$name" "$fps" "$load" "$mem"', 'high'),
('redlight', 'performance', 'Load Time', 'Must load in <3s (excellent: <1s)', 'rl_performance_metrics "$name" "$fps" "$load" "$mem"', 'high'),
('redlight', 'accessibility', 'WCAG Compliance', 'Must meet WCAG 2.1 AA standards', 'rl_test_passed "$name" "accessibility" "WCAG 2.1 AA"', 'critical'),
('redlight', 'architecture', 'Self-Contained', 'Single HTML or minimal dependencies', 'rl_template_create "$name" "$cat" "$desc"', 'medium'),
('redlight', 'deployment', 'Deploy-Ready', 'Works on Cloudflare Pages/GitHub Pages', 'rl_template_deploy "$name" "$url" "$platform"', 'high');
-- Insert YellowLight Standards
INSERT OR IGNORE INTO trinity_standards (light_type, category, standard_name, requirement, test_command, failure_severity)
VALUES
('yellowlight', 'platform', 'Approved Platform', 'Must use approved platform (Cloudflare/Railway/Pi/DO)', 'yl_deployment_succeeded "$svc" "$platform" "$url"', 'critical'),
('yellowlight', 'monitoring', 'Health Endpoint', 'Must have /health or /status endpoint', 'yl_health_check "$svc" "$url" "$time"', 'critical'),
('yellowlight', 'reliability', 'Rollback Capability', 'Must support version rollback', 'yl_deployment_rollback "$svc" "$from" "$to"', 'high'),
('yellowlight', 'automation', 'CI/CD Pipeline', 'Must have automated deployment', 'yl_workflow_done "$repo" "passed" "$duration"', 'medium'),
('yellowlight', 'security', 'Secrets Management', 'No secrets in code, must use vault', 'yl_secret_stored "$name" "$vault"', 'critical'),
('yellowlight', 'logging', 'Memory Logging', 'All deployments logged to PS-SHA∞', 'yl_deployment_succeeded "$svc" "$platform" "$url"', 'high');
-- Insert GreenLight Standards
INSERT OR IGNORE INTO trinity_standards (light_type, category, standard_name, requirement, test_command, failure_severity)
VALUES
('greenlight', 'tracking', 'State Tracking', 'All work tracked in GreenLight', 'gl_wip "$task" "$status"', 'critical'),
('greenlight', 'events', 'NATS Publishing', 'State changes publish to NATS', 'N/A', 'high'),
('greenlight', 'phases', 'Phase Completion', 'All projects have phase tracking', 'gl_phase_done "$phase" "$proj" "$summary"', 'medium'),
('greenlight', 'coordination', 'Cross-Agent', 'Agent coordination logged', 'gl_coordinate "$from" "$to" "$msg"', 'medium'),
('greenlight', 'memory', 'PS-SHA∞ Logging', 'All actions logged to memory', 'N/A', 'critical');
SQL
echo "✅ Trinity standards added to Codex"
# Create Trinity compliance checker
cat > "$HOME/trinity-check-compliance.sh" <<'CHECKER'
#!/bin/bash
# Check Trinity compliance for an entity
ENTITY_NAME="$1"
ENTITY_TYPE="${2:-template}"
if [ -z "$ENTITY_NAME" ]; then
echo "Usage: $0 <entity_name> [entity_type]"
exit 1
fi
CODEX_DB="$HOME/.blackroad/codex/codex.db"
echo "🚦 Checking Trinity compliance for: $ENTITY_NAME"
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
# Check each Light
for light in greenlight yellowlight redlight; do
echo ""
case "$light" in
greenlight) emoji="🟢" ;;
yellowlight) emoji="🟡" ;;
redlight) emoji="🔴" ;;
esac
echo "$emoji ${light^^} Standards:"
sqlite3 "$CODEX_DB" <<SQL
SELECT
' ' || CASE WHEN passed THEN '✅' ELSE '❌' END || ' ' ||
test_name || ': ' ||
COALESCE(details, 'No details')
FROM trinity_test_results
WHERE entity_name = '$ENTITY_NAME'
AND light_type = '$light'
ORDER BY tested_at DESC;
SQL
done
echo ""
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
# Overall compliance
sqlite3 "$CODEX_DB" <<SQL
SELECT
CASE
WHEN greenlight_pass AND yellowlight_pass AND redlight_pass THEN '✅ FULL COMPLIANCE'
WHEN greenlight_pass OR yellowlight_pass OR redlight_pass THEN '⚠️ PARTIAL COMPLIANCE'
ELSE '❌ NON-COMPLIANT'
END ||
' (🟢: ' || CASE WHEN greenlight_pass THEN 'PASS' ELSE 'FAIL' END ||
', 🟡: ' || CASE WHEN yellowlight_pass THEN 'PASS' ELSE 'FAIL' END ||
', 🔴: ' || CASE WHEN redlight_pass THEN 'PASS' ELSE 'FAIL' END || ')'
FROM trinity_compliance
WHERE entity_name = '$ENTITY_NAME'
ORDER BY last_checked DESC
LIMIT 1;
SQL
CHECKER
chmod +x "$HOME/trinity-check-compliance.sh"
echo "✅ Created Trinity compliance checker: ~/trinity-check-compliance.sh"
# Create Trinity test recorder
cat > "$HOME/trinity-record-test.sh" <<'RECORDER'
#!/bin/bash
# Record a Trinity test result
ENTITY_NAME="$1"
LIGHT_TYPE="$2" # greenlight, yellowlight, redlight
TEST_NAME="$3"
PASSED="$4" # 0 or 1
DETAILS="${5:-}"
if [ -z "$PASSED" ]; then
echo "Usage: $0 <entity_name> <light_type> <test_name> <passed:0/1> [details]"
exit 1
fi
CODEX_DB="$HOME/.blackroad/codex/codex.db"
# Record test result
sqlite3 "$CODEX_DB" <<SQL
INSERT INTO trinity_test_results (entity_name, light_type, test_name, passed, details)
VALUES ('$ENTITY_NAME', '$LIGHT_TYPE', '$TEST_NAME', $PASSED, '$DETAILS');
SQL
# Update compliance table
sqlite3 "$CODEX_DB" <<SQL
INSERT OR REPLACE INTO trinity_compliance (entity_type, entity_name, greenlight_pass, yellowlight_pass, redlight_pass, compliance_status)
SELECT
'template',
'$ENTITY_NAME',
MAX(CASE WHEN light_type = 'greenlight' AND passed = 1 THEN 1 ELSE 0 END),
MAX(CASE WHEN light_type = 'yellowlight' AND passed = 1 THEN 1 ELSE 0 END),
MAX(CASE WHEN light_type = 'redlight' AND passed = 1 THEN 1 ELSE 0 END),
CASE
WHEN SUM(CASE WHEN passed = 1 THEN 1 ELSE 0 END) = COUNT(DISTINCT light_type) THEN 'full'
WHEN SUM(CASE WHEN passed = 1 THEN 1 ELSE 0 END) > 0 THEN 'partial'
ELSE 'failed'
END
FROM trinity_test_results
WHERE entity_name = '$ENTITY_NAME';
SQL
echo "✅ Recorded: $TEST_NAME for $ENTITY_NAME ($LIGHT_TYPE) → $([ "$PASSED" = "1" ] && echo 'PASS' || echo 'FAIL')"
RECORDER
chmod +x "$HOME/trinity-record-test.sh"
echo "✅ Created Trinity test recorder: ~/trinity-record-test.sh"
# Update memory
source ~/memory-greenlight-templates.sh
gl_phase_done "integration" "Trinity Codex Integration" \
"Integrated Light Trinity standards into BlackRoad Codex: 3 new tables (trinity_standards, trinity_compliance, trinity_test_results), 16 standards defined (6 RedLight, 6 YellowLight, 5 GreenLight), 2 compliance tools created (~/trinity-check-compliance.sh, ~/trinity-record-test.sh). All future work validated against Trinity gates via Codex." \
"🌌"
echo ""
echo "🚦 Trinity → Codex Integration Complete!"
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo "Tables created:"
echo " • trinity_standards (16 standards)"
echo " • trinity_compliance (entity tracking)"
echo " • trinity_test_results (test history)"
echo ""
echo "Tools created:"
echo " • ~/trinity-check-compliance.sh <entity_name>"
echo " • ~/trinity-record-test.sh <entity> <light> <test> <pass:0/1>"
echo ""
echo "Usage:"
echo " ~/trinity-record-test.sh 'blackroad-mars' 'redlight' 'Brand Colors' 1 'Gradient validated'"
echo " ~/trinity-check-compliance.sh 'blackroad-mars'"