mirror of
https://github.com/x1xhlol/system-prompts-and-models-of-ai-tools.git
synced 2026-06-17 23:09:35 +00:00
Security Curator (4 modules) — جدار الحماية الأول
- secret_redactor: 11 patterns (GitHub PAT, OpenAI/Anthropic/Supabase/WhatsApp/Moyasar/Sentry/Google/AWS/private keys); never returns raw secret
- patch_firewall: blocks .env / credentials.json / RSA keys; scans added lines for secret patterns
- trace_redactor: masks phones (+966...) and emails for PII safety
- tool_output_sanitizer: cleans tool outputs before they hit ledger/Proof Pack/UI/observability
Growth Curator (5 modules) — التحسين الذاتي
- message_curator: grades Arabic messages (0..100), detects 8 risky phrases, suggests Saudi-tone skeleton
- playbook_curator: scores playbooks by outcome (accept/reply/meeting/deal); winner/promising/needs_work/archive
- mission_curator: scores completed missions; ship_it_widely/iterate/rework_or_retire
- skill_inventory: deterministic 23-skill catalog across 5 layers
- curator_report: weekly Arabic summary "ماذا تعلمنا هذا الأسبوع"
Meeting Intelligence (5 modules) — ذكاء الاجتماعات
- transcript_parser: accepts Google Meet entries OR plain "Speaker: text" format
- meeting_brief: 6-section pre-meeting brief in Arabic (objective/questions/objections/offer/next-step)
- objection_extractor: 8 categories (price/timing/authority/trust/integration/competitor/results/complexity)
- followup_builder: email + WhatsApp drafts; live_send_allowed=False always
- deal_risk: 0..100 score from objections + missing next-step + decision-maker absence + days-since-touch
Model Router (5 modules) — موجّه النماذج
- provider_registry: 7 providers (Claude Sonnet/Haiku, GPT-4-class, GPT-4o-mini, Gemini Pro, Azure OAI KSA-region, Local Qwen Arabic-tuned)
- task_router: 10 task types × routing decisions with reasons_ar
- cost_policy: bulk → low; output > 1500 tokens → high
- fallback_policy: high-sensitivity workloads prefer KSA-region/self-hosted FIRST
- usage_dashboard: deterministic demo of all task routes
Connector Catalog (3 modules) — كتالوج التكاملات
- 14 connectors (WhatsApp Cloud, Gmail, Calendar, Google Meet, Moyasar, LinkedIn Lead Forms, Google Business Profile, X API, Instagram, Sheets, CRM, Website Forms, Composio, MCP Gateway)
- Each has launch_phase (1-4), risk_level, allowed_actions, blocked_actions, Arabic risk dossier
- WhatsApp blocks cold_send_without_consent; Moyasar blocks store_card_number; MCP requires allowlist
Agent Observability (5 modules) — مراقبة الوكلاء + التقييمات
- trace_events: SHA256-hashes user/company IDs; sanitizes payload/output before logging
- safety_eval: 7 rules (guarantee, scarcity_fake, medical_claim, financial, regulatory, personal_data, urgency); 0..100 → safe/needs_review/blocked
- saudi_tone_eval: positive markers (هلا, لاحظت, يناسبك) vs negative (تحية طيبة وبعد, synergy, leverage); arabic_ratio bonus
- eval_pack: 5 curated cases with expected verdicts
- cost_tracker: per workflow/provider/task_type aggregation
Routers (6 new) — 30 endpoints
- /api/v1/security-curator/{demo, redact, inspect-diff, sanitize-output}
- /api/v1/growth-curator/{skills/inventory, messages/grade, messages/improve, messages/duplicates, missions/next, report/weekly, report/demo}
- /api/v1/meeting-intelligence/{brief, brief/demo, transcript/summarize, followup/draft, deal-risk}
- /api/v1/model-router/{providers, tasks, route, cost-class, usage/demo}
- /api/v1/connector-catalog/{catalog, summary, status, risks, {key}}
- /api/v1/agent-observability/{trace/build, safety/eval, tone/eval, evals/run}
Tests (6 new files, 76 tests)
- test_security_curator: 16 tests (PAT detect, key redact, env diff block, payload scan, trace mask)
- test_growth_curator: 16 tests (Arabic grade, risky phrases, dup detect, playbook scoring, mission recommend, weekly report)
- test_meeting_intelligence: 13 tests (transcript parse, brief sections, objection extract, followup drafts, deal risk)
- test_dealix_model_router: 11 tests (every task → ≥1 provider, KSA-region for high sensitivity, cost class, primary override)
- test_agent_observability: 12 tests (trace hashing, safety verdicts, tone scoring, eval pack)
- test_connector_catalog: 11 tests (≥12 connectors, every has risk/blocked actions, WA cold-send blocked, Moyasar card-storage blocked)
Docs (8 new + 1 updated)
- AGENT_SECURITY_CURATOR.md (Arabic)
- GROWTH_CURATOR_STRATEGY.md (Arabic)
- MEETING_INTELLIGENCE.md (Arabic)
- MODEL_PROVIDER_ROUTER.md (Arabic)
- CONNECTOR_CATALOG.md (Arabic)
- AGENT_OBSERVABILITY_EVALS.md (Arabic)
- PRIVATE_BETA_LAUNCH_TODAY.md (Arabic) — go-checklist + offer + risks
- DEMO_SCRIPT_12_MINUTES.md (Arabic) — minute-by-minute demo flow
- FIRST_20_OUTREACH_MESSAGES.md (Arabic) — 7 personas + 3 follow-ups, all under safety/tone evals
- DEALIX_100_PERCENT_LAUNCH_PLAN.md — added §34 Self-Improving Agent Platform + §35 Private Beta Launch
Landing
- landing/private-beta.html — Arabic RTL, dark theme, pricing, 11 demo endpoints, safety banner
Test results
- 76/76 new tests pass
- Full suite: 663 passed, 2 skipped (missing API keys, unrelated)
- 0 existing tests broken
Safety
- All 6 layers honor approval-first, draft-only, no-live-send
- Hash user/company IDs before any trace
- No secrets in logs/embeddings/traces (3-layer defense: redactor + sanitizer + firewall)
- Saudi tone eval rejects "تحية طيبة وبعد" + "synergy" auto-corporate language
- Safety eval blocks "ضمان 100%" + medical claims + fake urgency
- Connector Catalog: WhatsApp blocks cold-send, Moyasar blocks card storage, MCP requires allowlist
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
133 lines
4.2 KiB
Python
133 lines
4.2 KiB
Python
"""Unit tests for the Security Curator."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from auto_client_acquisition.security_curator import (
|
|
detect_secret_patterns,
|
|
inspect_diff,
|
|
is_safe_diff,
|
|
redact_secrets,
|
|
redact_trace,
|
|
sanitize_tool_output,
|
|
sanitize_trace_event,
|
|
scan_payload,
|
|
)
|
|
|
|
|
|
# ── Secret Redactor ──────────────────────────────────────────
|
|
def test_detects_github_pat():
|
|
text = "my token is ghp_AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA1234"
|
|
findings = detect_secret_patterns(text)
|
|
assert any(f.label == "github_pat" for f in findings)
|
|
assert all("ghp_AAAA" not in f.sample_redacted for f in findings) # never raw
|
|
|
|
|
|
def test_redacts_openai_key():
|
|
text = "key=sk-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA1234 done"
|
|
out = redact_secrets(text)
|
|
assert "sk-AAAA" not in out
|
|
assert "sk-***" in out
|
|
|
|
|
|
def test_redacts_anthropic_key():
|
|
text = "ANTHROPIC=sk-ant-aBcDeFgHiJkLmNoPqRsTuVwXyZ1234"
|
|
out = redact_secrets(text)
|
|
assert "sk-ant-aBcD" not in out
|
|
|
|
|
|
def test_scan_payload_dict_redacts_sensitive_keys():
|
|
payload = {"api_key": "ghp_AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA1234",
|
|
"name": "ali"}
|
|
result = scan_payload(payload)
|
|
assert result["has_secrets"] is True
|
|
assert result["redacted"]["api_key"] == "***"
|
|
assert result["redacted"]["name"] == "ali"
|
|
|
|
|
|
def test_scan_payload_handles_nested():
|
|
payload = {"outer": {"token": "EAA" + "x" * 40, "ok": "yes"}}
|
|
result = scan_payload(payload)
|
|
assert result["has_secrets"] is True
|
|
assert result["redacted"]["outer"]["token"] == "***"
|
|
|
|
|
|
def test_scan_empty_returns_no_findings():
|
|
out = scan_payload({})
|
|
assert out["has_secrets"] is False
|
|
assert out["findings"] == []
|
|
|
|
|
|
# ── Patch Firewall ───────────────────────────────────────────
|
|
def test_blocks_env_file_diff():
|
|
diff = """diff --git a/.env b/.env
|
|
new file mode 100644
|
|
+++ b/.env
|
|
+API_KEY=ghp_AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA1234
|
|
"""
|
|
r = inspect_diff(diff)
|
|
assert r.safe is False
|
|
assert any(".env" in f for f in r.blocked_files)
|
|
|
|
|
|
def test_blocks_secret_in_added_line():
|
|
diff = """+++ b/src/foo.py
|
|
+OPENAI_KEY = "sk-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA1234"
|
|
"""
|
|
r = inspect_diff(diff)
|
|
assert r.safe is False
|
|
assert r.secret_findings
|
|
|
|
|
|
def test_allows_safe_diff():
|
|
diff = """+++ b/src/foo.py
|
|
+def hello():
|
|
+ return "world"
|
|
"""
|
|
assert is_safe_diff(diff) is True
|
|
|
|
|
|
def test_empty_diff_is_safe():
|
|
assert is_safe_diff("") is True
|
|
|
|
|
|
# ── Trace Redactor ───────────────────────────────────────────
|
|
def test_trace_masks_phone_and_email():
|
|
payload = {"note": "call +966500000123 or email ali@example.com"}
|
|
out = redact_trace(payload, mask_pii=True)
|
|
assert out["had_pii"] is True
|
|
masked = out["redacted"]["note"]
|
|
assert "+966500000123" not in masked
|
|
assert "ali@example.com" not in masked
|
|
assert "@example.com" in masked # domain preserved
|
|
|
|
|
|
def test_trace_redacts_secrets_and_pii_together():
|
|
payload = {"token": "ghp_AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA1234",
|
|
"phone": "+966500000999"}
|
|
out = redact_trace(payload)
|
|
assert out["had_secrets"] is True
|
|
assert out["redacted"]["token"] == "***"
|
|
|
|
|
|
# ── Tool Output Sanitizer ────────────────────────────────────
|
|
def test_sanitize_output_strips_secret():
|
|
output = {"raw": "ghp_AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA1234 inside"}
|
|
out = sanitize_tool_output(output)
|
|
assert out["safe"] is False
|
|
assert "ghp_AAAA" not in str(out["redacted"])
|
|
assert any("حساسة" in n for n in out["notes_ar"])
|
|
|
|
|
|
def test_sanitize_trace_event_keeps_safe_keys():
|
|
event = {
|
|
"event_type": "tool_call", "agent_name": "scout",
|
|
"status": "ok", "latency_ms": 120,
|
|
"payload": {"phone": "+966500000123"},
|
|
}
|
|
out = sanitize_trace_event(event)
|
|
assert out["event_type"] == "tool_call"
|
|
assert out["agent_name"] == "scout"
|
|
assert out["latency_ms"] == 120
|
|
# payload was sanitized
|
|
assert "+966500000123" not in str(out["payload"])
|