mirror of
https://github.com/x1xhlol/system-prompts-and-models-of-ai-tools.git
synced 2026-06-18 07:19:35 +00:00
Governance layer (14 docs): - MASTER_OPERATING_PROMPT.md — operating constitution (five planes, six tracks, policy classes) - docs/ai-operating-model.md — five-plane architecture (Decision/Execution/Trust/Data/Operating) - docs/dealix-six-tracks.md — six strategic tracks (Revenue/Intelligence/Compliance/Expansion/Operations/Trust) - docs/governance/execution-fabric.md — OpenClaw execution plane deep dive - docs/governance/trust-fabric.md — trust plane with contradiction engine + evidence packs - docs/governance/saudi-compliance-and-ai-governance.md — PDPL/ZATCA/SDAIA/NCA live controls - docs/governance/technology-radar-tier1.md — Core/Strong/Pilot/Watch/Hold classification - docs/governance/partnership-os.md — alliance lifecycle management - docs/governance/ma-os.md — M&A corporate development lifecycle - docs/governance/expansion-os.md — geographic and vertical growth - docs/governance/pmi-os.md — post-merger integration framework - docs/governance/executive-board-os.md — executive decision surfaces - docs/execution-matrix-90d-tier1.md — 90-day sprint execution plan - docs/adr/0001-tier1-execution-policy-spikes.md — 8 architectural decisions Backend (3 models, 6 services, 8 API routes): - Contradiction Engine — detect/track system conflicts - Evidence Pack System — tamper-evident audit proof with SHA256 - Saudi Compliance Matrix — live PDPL/ZATCA/SDAIA/NCA controls - Executive Room — unified executive decision surface - Connector Governance — integration health monitoring - Model Routing Dashboard — LLM provider metrics - Forecast Control Center — actual vs forecast across tracks - Approval Center — enhanced approval queue with SLA Frontend (9 components): - Executive Room, Evidence Pack Viewer, Approval Center - Connector Governance Board, Saudi Compliance Dashboard - Actual vs Forecast Dashboard, Risk Heatmap - Policy Violations Board, Partner Pipeline Board Tooling: - scripts/architecture_brief.py — preflight validation (40/40 checks pass) - Updated CLAUDE.md and AGENTS.md with governance references https://claude.ai/code/session_01W1rJthWDkasijTdXCfxVHs
116 lines
4.1 KiB
Python
116 lines
4.1 KiB
Python
"""Connector Governance — health checks and governance for all integrations."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from datetime import datetime, timezone
|
|
from typing import Any, Dict, List, Optional
|
|
|
|
from sqlalchemy import select
|
|
from sqlalchemy.ext.asyncio import AsyncSession
|
|
|
|
from app.models.operations import IntegrationSyncState
|
|
|
|
|
|
# Known connectors with their display names
|
|
KNOWN_CONNECTORS = {
|
|
"whatsapp": {"name": "WhatsApp Business API", "name_ar": "واتساب بيزنس"},
|
|
"salesforce": {"name": "Salesforce Agentforce", "name_ar": "سيلزفورس"},
|
|
"stripe": {"name": "Stripe Payments", "name_ar": "سترايب للمدفوعات"},
|
|
"voice": {"name": "Voice (Twilio)", "name_ar": "المكالمات الصوتية"},
|
|
"email": {"name": "Email (SMTP/SendGrid)", "name_ar": "البريد الإلكتروني"},
|
|
"docusign": {"name": "DocuSign / Adobe Sign", "name_ar": "التوقيع الإلكتروني"},
|
|
"cal": {"name": "Cal.com Meetings", "name_ar": "حجز الاجتماعات"},
|
|
}
|
|
|
|
|
|
class ConnectorGovernanceService:
|
|
"""Manages connector health, governance, and monitoring."""
|
|
|
|
async def get_governance_board(
|
|
self, db: AsyncSession, *, tenant_id: str
|
|
) -> List[Dict[str, Any]]:
|
|
stmt = (
|
|
select(IntegrationSyncState)
|
|
.where(IntegrationSyncState.tenant_id == tenant_id)
|
|
.order_by(IntegrationSyncState.connector_key)
|
|
)
|
|
result = await db.execute(stmt)
|
|
connectors = list(result.scalars().all())
|
|
|
|
board = []
|
|
seen_keys = set()
|
|
for conn in connectors:
|
|
seen_keys.add(conn.connector_key)
|
|
info = KNOWN_CONNECTORS.get(conn.connector_key, {})
|
|
board.append({
|
|
"connector_key": conn.connector_key,
|
|
"display_name": info.get("name", conn.connector_key),
|
|
"display_name_ar": conn.display_name_ar or info.get("name_ar", ""),
|
|
"status": conn.status,
|
|
"last_success_at": conn.last_success_at.isoformat() if conn.last_success_at else None,
|
|
"last_attempt_at": conn.last_attempt_at.isoformat() if conn.last_attempt_at else None,
|
|
"last_error": conn.last_error,
|
|
"registered": True,
|
|
})
|
|
|
|
# Add known but unregistered connectors
|
|
for key, info in KNOWN_CONNECTORS.items():
|
|
if key not in seen_keys:
|
|
board.append({
|
|
"connector_key": key,
|
|
"display_name": info["name"],
|
|
"display_name_ar": info["name_ar"],
|
|
"status": "not_configured",
|
|
"last_success_at": None,
|
|
"last_attempt_at": None,
|
|
"last_error": None,
|
|
"registered": False,
|
|
})
|
|
|
|
return board
|
|
|
|
async def update_connector_status(
|
|
self,
|
|
db: AsyncSession,
|
|
*,
|
|
tenant_id: str,
|
|
connector_key: str,
|
|
status: str,
|
|
error: Optional[str] = None,
|
|
) -> IntegrationSyncState:
|
|
stmt = (
|
|
select(IntegrationSyncState)
|
|
.where(IntegrationSyncState.tenant_id == tenant_id)
|
|
.where(IntegrationSyncState.connector_key == connector_key)
|
|
)
|
|
result = await db.execute(stmt)
|
|
conn = result.scalar_one_or_none()
|
|
|
|
now = datetime.now(timezone.utc)
|
|
if not conn:
|
|
info = KNOWN_CONNECTORS.get(connector_key, {})
|
|
conn = IntegrationSyncState(
|
|
tenant_id=tenant_id,
|
|
connector_key=connector_key,
|
|
display_name_ar=info.get("name_ar"),
|
|
status=status,
|
|
last_attempt_at=now,
|
|
last_error=error,
|
|
)
|
|
if status == "ok":
|
|
conn.last_success_at = now
|
|
db.add(conn)
|
|
else:
|
|
conn.status = status
|
|
conn.last_attempt_at = now
|
|
conn.last_error = error
|
|
if status == "ok":
|
|
conn.last_success_at = now
|
|
|
|
await db.commit()
|
|
await db.refresh(conn)
|
|
return conn
|
|
|
|
|
|
connector_governance = ConnectorGovernanceService()
|