mirror of
https://github.com/x1xhlol/system-prompts-and-models-of-ai-tools.git
synced 2026-06-18 07:19:35 +00:00
Program F — Multi-Tenancy RLS (Row-Level Security):
alembic 20260417_0002_add_rls.py: Enables RLS on 23 tenant-scoped tables.
database_rls.py: set_tenant_context() helpers for SET LOCAL app.tenant_id.
middleware/tenant_rls.py: Extracts tenant_id from JWT on every request.
Default-deny when no context. PostgreSQL only (CI safe on SQLite).
Result: OWASP A01:2025 — access control enforced at DB layer.
Program G — Idempotency Standard:
models/idempotency_key.py: IdempotencyKey table with TTL + SHA256 hash.
services/idempotency_service.py: get_existing/store with request fingerprint.
middleware/idempotency.py: HTTP middleware on POST/PUT/PATCH.
Result: Duplicate side effects prevented on retry.
Program E — Persistent Durable Execution:
models/durable_checkpoint.py: DurableCheckpoint with sequence_num + status.
services/durable_runtime.py: start_run/checkpoint/complete/resume/list_incomplete.
Result: Workflows survive crashes — resume from last persisted checkpoint.
Program K — OpenTelemetry:
observability/otel.py: init/span/inject_correlation_id with graceful
degradation when OTel packages absent.
openclaw/gateway.py: Wraps execute() in span, binds correlation_id to
trace_id. Bridge between business correlation and production observability.
Program J — Release Gate Hardening:
docs/governance/release-gates.md: Documents 3 mandatory gates.
.github/workflows/dealix-ci.yml: Adds release_readiness_matrix as CI step.
release_readiness_matrix.py: Updated to check 41/41 components.
Verification:
architecture_brief.py: 40/40 PASS
release_readiness_matrix.py: 41/41 PASS
https://claude.ai/code/session_01W1rJthWDkasijTdXCfxVHs
63 lines
2.6 KiB
Python
63 lines
2.6 KiB
Python
from __future__ import annotations
|
|
|
|
import uuid
|
|
from typing import Any, Dict
|
|
|
|
from app.observability.otel import span, inject_correlation_id
|
|
from app.openclaw.approval_bridge import approval_bridge
|
|
from app.openclaw.observability_bridge import observability_bridge
|
|
from app.openclaw.task_router import task_router
|
|
|
|
|
|
class OpenClawGateway:
|
|
"""Single ingress for OpenClaw tasks: policy -> progress -> execute."""
|
|
|
|
async def execute(
|
|
self,
|
|
*,
|
|
tenant_id: str,
|
|
task_type: str,
|
|
action: str,
|
|
payload: Dict[str, Any],
|
|
model_provider: str = "auto",
|
|
cache_hint: str = "prompt-cache-reuse",
|
|
correlation_id: str | None = None,
|
|
) -> Dict[str, Any]:
|
|
corr_id = correlation_id or str(uuid.uuid4())
|
|
payload.setdefault("_correlation_id", corr_id)
|
|
|
|
with span("openclaw.gateway.execute", {
|
|
"tenant_id": tenant_id,
|
|
"task_type": task_type,
|
|
"action": action,
|
|
"correlation_id": corr_id,
|
|
}):
|
|
inject_correlation_id(corr_id)
|
|
|
|
gate = approval_bridge.evaluate(action=action, payload=payload, tenant_id=tenant_id)
|
|
run_id = observability_bridge.start_run(
|
|
tenant_id=tenant_id,
|
|
task_type=task_type,
|
|
model_provider=model_provider,
|
|
cache_hint=cache_hint,
|
|
approval_required=bool(gate.get("requires_approval")),
|
|
)
|
|
observability_bridge.step(run_id, "policy_gate", "ok" if gate["allowed"] else "blocked", {"gate": gate})
|
|
if not gate["allowed"]:
|
|
observability_bridge.finish(run_id, status="blocked", error=gate["reason"])
|
|
return {"run_id": run_id, "correlation_id": corr_id, "status": "blocked", "gate": gate}
|
|
|
|
try:
|
|
observability_bridge.step(run_id, "routing", "ok", {"task_type": task_type})
|
|
result = await task_router.route(task_type, tenant_id, payload)
|
|
observability_bridge.step(run_id, "execution", "ok")
|
|
observability_bridge.finish(run_id, status="completed")
|
|
return {"run_id": run_id, "correlation_id": corr_id, "status": "completed", "gate": gate, "result": result}
|
|
except Exception as e:
|
|
observability_bridge.step(run_id, "execution", "error", {"error": str(e)})
|
|
observability_bridge.finish(run_id, status="failed", error=str(e))
|
|
return {"run_id": run_id, "correlation_id": corr_id, "status": "failed", "gate": gate, "error": str(e)}
|
|
|
|
|
|
openclaw_gateway = OpenClawGateway()
|