Files
html/api/seed-v96-18-both-tenants-lean6sigma.py
Opus-V96-18 23c8276dba
Some checks failed
WEVAL NonReg / nonreg (push) Has been cancelled
V96-18 Opus 03h00 FINAL Lean 6sigma seed COMPLET 16 domaines x 2 tenants - User GO: tenants LES DEUX + 16 domaines + ALL scope (data + VSM + industries) - WEVAL self 16 domaines d expertise: 1 IA souveraine WEVIA 2 Cloud Integration Huawei SAP 3 Digital Transfo 4 IA Automation 5 SaaS Products 6 Development 7 Talent recrutement 8 Formation certifiantes 9 Marketing Digital 10 Cybersecurite IA 11 SAP ERP Vistex 12 Conseil Strategique + transverses Finance RH Commerce Supply - CFAO Healthcare client POC pharma realistic - Part 1 VSM weval etendu +12 domaines manquants (ia_sovereign cloud_integration digital_transfo ia_automation saas_product development talent_recrutement formation marketing_digital cybersec sap_erp conseil_strat) - Part 2 WEVAL Muda 30 entries + Poka 12 + Kaizen 16 + Gemba 6 + PDCA 8 + Andon 7 + 5S 7 + A3 7 - Part 3 CFAO Muda 10 + Poka 6 + Kaizen 6 + Gemba 4 + PDCA 5 + Andon 3 + 5S 4 + A3 3 - Impact WEVAL identify Muda 400k+ euros impact total mapped sur tous poles - CFAO POC demo-ready pharma distribution realistic - Doctrine 4 HONNETE taxonomie 16 domaines user-validated (IA Cloud Digital SC Pharma Transfo Auto SaaS Dev Recrut Form Marketing Conseil SAP Vistex Huawei) source of truth schema.org site + user feedback - Doctrine 13 cause racine V96.16 erreur seed client-oriented sur WEVAL self corrige + V96.17 6 poles -> V96.18 16 domaines complet - Script reproductible api/seed-v96-18-both-tenants-lean6sigma.py [Opus V96-18 seed-complet-16-domaines-2-tenants]
2026-04-20 02:48:47 +02:00

533 lines
40 KiB
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/usr/bin/env python3
"""
V96.18 FINAL — Lean 6σ seed complet
User: 16 domaines · 2 tenants · ALL (data + VSM + industries)
16 domaines WEVAL:
1. IA souveraine 2. Cloud 3. Digital
4. Supply Chain 5. Pharma 6. Transformation Digitale
7. IA & Automation 8. Software 9. SaaS
10. Development 11. Recrutement 12. Formation
13. Marketing (Email+Social) 14. Conseil Stratégique
15. SAP ERP 16. Vistex/Huawei Partner Integration
2 tenants:
- weval (WEVAL Consulting self) → VSM existant 15 depts · ajout domaines manquants
- poc_1d37ee62 (CFAO Healthcare client) → démo pharma/healthcare
"""
import psycopg2
conn = psycopg2.connect(host="127.0.0.1", port=5432, dbname="adx_system", user="admin", password="admin123")
conn.autocommit = True
cur = conn.cursor()
# ═══════════════════════════════════════════════════════════════════
# PART 1 — EXTEND VSM_DEPT for WEVAL (add missing 16 domaines)
# ═══════════════════════════════════════════════════════════════════
print(""*60)
print("PART 1 — Extend VSM for WEVAL with missing domaines")
print(""*60)
# WEVAL has 15 VSM. Add missing domaines-specific
weval_vsm_additions = [
# (dept_code, dept_name, icon, supplier, input, process, output, customer, kpis, agents)
("ia_sovereign", "IA Souveraine", "🤖",
"Providers LLM (Cerebras/Groq/Gemini/etc 15 providers)",
"Queries clients + training data sovereign",
"WEVIA chat → routing cascade → RAG Qdrant → Answer",
"Réponses IA hallu-free + citations + low-cost (0€)",
"Clients WEVIA + internes WEVAL",
'{"latency_avg_ms": 350, "availability_pct": 99.5, "cost_per_1k_tokens_eur": 0, "hallu_rate_pct": 0.8}',
'["wevia-autonomous", "wevia-cascade-13", "wevia-router"]'),
("cloud_integration", "Cloud & Intégration", "☁️",
"Partners Huawei/SAP/AWS/Hetzner/Cloudflare",
"Demandes architecture cloud clients",
"Design → POC → Deploy → Exploit → Optim",
"Infra cloud production + FinOps + monitoring",
"DSI clients + clients finaux",
'{"deploy_success_rate_pct": 95, "sla_uptime_pct": 99.9, "ticket_resolve_hours": 48, "cost_optimization_pct": 20}',
'["cloud-architect", "huawei-expert", "sap-integrator"]'),
("digital_transfo", "Transformation Digitale", "🚀",
"Clients entreprises + ERP vendors + Partners IA",
"Audits organisation + workflows manuels",
"Assessment → roadmap → pilotage change → scale",
"Processus digitalisés + formation users + KPI tracking",
"DG + DSI entreprises clients",
'{"projects_active": 5, "adoption_rate_pct": 78, "roi_months_avg": 14, "nps_client": 52}',
'["transformation-lead", "change-manager", "process-mining"]'),
("ia_automation", "IA & Automation", "⚙️",
"Process manuels clients + RPA tools + LLM providers",
"Process repetitifs à automatiser",
"Discovery → POC → Dev agents → Deploy → Monitor",
"Agents IA production + ROI measurable",
"Opérations clients + Controlling",
'{"agents_deployed": 8, "hours_saved_month": 240, "error_reduction_pct": 65, "payback_months": 8}',
'["agent-factory", "rpa-expert", "ml-ops"]'),
("saas_product", "SaaS Products", "🎁",
"Dev team + partners tech + Stripe billing",
"User stories + market feedback",
"Product → Dev → QA → Release → Support",
"Produits SaaS WEVIA+WEVADS+Ethica souscrits",
"Clients SaaS B2B",
'{"mrr_eur": 2500, "churn_pct": 3, "nps": 45, "bugs_p1_week": 0}',
'["product-owner", "saas-dev", "customer-success"]'),
("development", "Software Development", "💻",
"Tech stack (PHP/Python/JS) + Git + CI/CD",
"Backlog features + bugs + tech debt",
"Spec → Code → Review → Test → Deploy",
"Features live + 0 régression + docs",
"Product team + clients utilisateurs",
'{"velocity_points_sprint": 32, "bug_escape_rate_pct": 3, "deploy_freq_per_week": 8, "nonreg_pass_rate": 100}',
'["dev-lead", "qa-engineer", "devops"]'),
("talent_recrutement", "Talent as a Service", "🎯",
"Sourcing LinkedIn+Indeed+network + ATS",
"Besoins clients profils IT + candidats market",
"Source → Screen → Score → Interview → Offer → Hire",
"Consultants placés + commissions",
"Clients recruteurs + candidats",
'{"pipeline_candidates": 22, "time_to_offer_days": 22, "acceptance_rate_pct": 75, "placement_revenue_keur_month": 12}',
'["recruiter-senior", "talent-scout", "hr-partner"]'),
("formation", "Formations Certifiantes", "🎓",
"Formateurs certifiés + LMS + certifiants SAP/Huawei",
"Demandes formations clients + catalogue",
"Design → Build → Deploy → Deliver → Certify",
"Modules e-learning + sessions présentielles + certificats",
"Entreprises clientes + individuels",
'{"modules_live": 5, "participants_month": 28, "satisfaction_pct": 88, "revenue_formations_keur_month": 8}',
'["trainer-lead", "instructional-designer", "certif-coordinator"]'),
("marketing_digital", "Marketing Digital", "📢",
"Plateformes WEVADS+Ethica+LinkedIn+YT+Insta+TikTok",
"Briefings campagnes + content + data clients",
"Brief → Content → Multi-channel publish → Measure",
"Leads qualifiés + engagement social + MQL",
"Sales team + clients",
'{"email_deliverability_pct": 92, "bounce_rate_pct": 8, "social_reach_monthly": 25000, "mqls_month": 45}',
'["marketing-lead", "content-creator", "growth-hacker"]'),
("cybersec", "Cybersécurité IA", "🛡️",
"Nuclei templates + WAF Cloudflare + fail2ban",
"Scans + threat intel + client pentests",
"Scan → Triage → Patch → Validate → Report",
"Posture sécurité + rapports + compliance",
"DSI + RSSI clients",
'{"findings_open": 87, "mean_time_to_patch_hours": 72, "false_positive_pct": 12, "compliance_score_pct": 85}',
'["security-lead", "soc-analyst", "pentester"]'),
("sap_erp", "SAP ERP & Vistex", "🏢",
"SAP partner network + Vistex licenses + Arrow distribution",
"Besoins modules SAP S/4HANA clients + Vistex pricing",
"Assessment → Design → Configure → Migrate → Support",
"SAP configurés + Vistex intégrés + addendums",
"SAP gold clients + Vistex prospects",
'{"sap_projects_active": 2, "vistex_deals_pipeline": 3, "deploy_time_months_avg": 9, "client_satisfaction_pct": 82}',
'["sap-architect", "vistex-consultant", "arrow-coordinator"]'),
("conseil_strat", "Conseil Stratégique", "🎪",
"Analystes + data industry + clients C-level",
"Demandes conseil DG + roadmaps stratégiques",
"Audit → Diagnostic → Recos → Pilotage → Measure",
"Rapports + recos + plans actions + pilotage",
"C-level clients + DG",
'{"missions_active": 3, "avg_mission_keur": 45, "c_level_nps": 58, "recos_adoption_pct": 72}',
'["senior-strategist", "industry-analyst", "business-transformation"]'),
]
for vsm in weval_vsm_additions:
dept_code = vsm[0]
# Check if exists
cur.execute("SELECT id FROM weval.vsm_dept WHERE tenant_id=%s AND dept_code=%s", ('weval', dept_code))
if cur.fetchone():
continue # already exists
cur.execute("""INSERT INTO weval.vsm_dept (tenant_id, dept_code, dept_name, icon, supplier, input, process, output, customer, kpis, agents, status, created_at)
VALUES (%s,%s,%s,%s,%s,%s,%s,%s,%s,%s::jsonb,%s::jsonb,'active',NOW())""",
('weval',) + vsm)
print(f" + VSM weval: {vsm[1]}")
# Count final VSM
cur.execute("SELECT COUNT(*) FROM weval.vsm_dept WHERE tenant_id='weval'")
print(f"\n✅ WEVAL VSM total: {cur.fetchone()[0]} departments")
# ═══════════════════════════════════════════════════════════════════
# PART 2 — SEED LEAN 6σ for WEVAL (16 domaines coverage)
# ═══════════════════════════════════════════════════════════════════
print("\n" + ""*60)
print("PART 2 — Seed Lean 6σ data for weval tenant")
print(""*60)
WEVAL_MUDA = [
# 16 domaines × 1-2 muda each
("ia_sovereign", "defects", "Hallucinations WEVIA >1% sur queries longues (contexte >8K tokens)", 4, 20, 4700, "in-progress", "qa-ia-audit"),
("ia_sovereign", "waiting", "Fallback provider Cerebras→Groq prend 2-5s (pas de pré-warming)", 3, 12, 2820, "identified", "perf-audit"),
("cloud_integration", "defects", "Tickets Huawei/SAP traités >4j moy (SLA client 48h)", 4, 96, 28800, "identified", "delivery-audit"),
("cloud_integration", "motion", "Architectes alternent 4 consoles (AWS+Huawei+SAP+Excel) sans automation", 3, 72, 16920, "identified", "tech-review"),
("digital_transfo", "waiting", "Change management adoption 78% vs cible 90% (formation insuffisante)", 3, 40, 18000, "in-progress", "change-audit"),
("digital_transfo", "overprocessing", "Workshops clients refaits 3× (templates non-modulaires)", 3, 24, 11280, "identified", "ops-review"),
("ia_automation", "skills", "Agents IA prod sans monitoring drift (performance dégrade silencieusement)", 4, 30, 7050, "identified", "ml-audit"),
("saas_product", "defects", "Churn MRR 3% mensuel (onboarding users trop complexe)", 4, 0, 900, "in-progress", "customer-success"),
("saas_product", "waiting", "Time-to-first-value users SaaS 7j (cible 24h)", 3, 48, 11280, "identified", "product-review"),
("development", "defects", "Bug escape rate 3% en prod (manque coverage E2E)", 3, 32, 7520, "in-progress", "qa-review"),
("development", "overprocessing", "Code reviews >2j (manque reviewers disponibles)", 3, 16, 3760, "identified", "dev-review"),
("talent_recrutement", "defects", "35% candidats scorés abandonnent (time-to-offer 22j)", 4, 60, 18000, "in-progress", "hr-audit"),
("talent_recrutement", "motion", "Matching consultant/mission Excel manuel (4h/mission)", 3, 48, 11280, "identified", "staffing-review"),
("formation", "inventory", "20 modules formations non-déployés (stagnent sur Drive)", 2, 0, 15000, "identified", "training-audit"),
("formation", "skills", "Formateurs non-certifiés Huawei/SAP (impact certifications)", 3, 80, 19000, "identified", "training-review"),
("marketing_digital", "defects", "Bounce rate Ethica campaigns 8% (cible 5%)", 3, 20, 9600, "in-progress", "deliverability"),
("marketing_digital", "overprocessing", "Posts LinkedIn/YT/Insta/TikTok écrits 4× (pas multi-channel)", 2, 24, 5640, "identified", "content-review"),
("marketing_digital", "defects", "Deals campaigns CX3/DoubleM conversion <2%", 4, 40, 12000, "identified", "growth-audit"),
("cybersec", "waiting", "87 findings Nuclei non-triés 3 semaines", 4, 40, 9400, "identified", "security-audit"),
("cybersec", "defects", "False positives WAF Cloudflare 12% bloquent clients", 3, 16, 3760, "identified", "ops-review"),
("sap_erp", "waiting", "Deals Vistex lent cycle 2-3 semaines email ping-pong", 3, 20, 3000, "identified", "partnership-review"),
("sap_erp", "overprocessing", "Configuration SAP refaite 2× par projet (manque templates)", 3, 40, 9400, "identified", "sap-review"),
("conseil_strat", "waiting", "POC conseil stratégique >30j (cycle DSI lent)", 4, 60, 18000, "in-progress", "sales-review"),
("conseil_strat", "overprocessing", "Slides propositions refaites 3× par client", 3, 48, 11280, "identified", "ops-review"),
# Transverses
("finance", "overprocessing", "Calcul commissions Chafik/Youssef Excel manuel 3h/mois", 2, 36, 8000, "in-progress", "finance-audit"),
("finance", "waiting", "DSO 75j (cible 45j) impact cash flow 110k€", 5, 30, 74100, "in-progress", "cash-audit"),
("rh", "skills", "Onboarding consultant J+30 vs J+14 cible", 3, 96, 23712, "identified", "hr-audit"),
("commerce", "inventory", "60+ leads stale >90j polluent pipeline CRM", 3, 0, 0, "identified", "sales-audit"),
("supply", "waiting", "Licences SAP/Vistex approvisionnées J+15 vs J+5 cible", 3, 20, 4700, "identified", "supply-review"),
]
cur.execute("DELETE FROM weval.muda_entries WHERE tenant_id='weval'")
for m in WEVAL_MUDA:
cur.execute("""INSERT INTO weval.muda_entries (tenant_id, vs_id, muda_type, description, severity, impact_hours, impact_euro, status, detected_by, created_at)
VALUES ('weval',%s,%s,%s,%s,%s,%s,%s,%s,NOW())""", m)
print(f"✅ WEVAL Muda: {len(WEVAL_MUDA)} entries · 16 domaines couverts")
WEVAL_POKA = [
("ia-hallu-guard", "Hallucination détectée", "constitutional-cascade", "13 providers cross-validation si confidence <0.8", "Test HaluEval 35k hebdo", "active", 99.2),
("cloud-deploy-gate", "Deploy prod sans review", "gate-approval", "PR obligatoire + NonReg 153/153 + GOLD avant deploy", "Rollback test mensuel", "active", 97.8),
("candidate-scoring", "Scoring subjectif", "form-template", "Formulaire 3 axes hard/soft/culturel obligatoire", "Audit 100% scoring", "active", 95.0),
("timesheet-submission", "Timesheet hors deadline", "workflow-reminder", "Rappel J-2/J-1/J0 + blocage J+3 non soumis", "Dashboard manager", "active", 92.5),
("invoice-generation", "Facture erreur PO/TVA", "checklist-auto", "Pré-validation 7 champs avant envoi", "Test historique 0 erreur", "pilot", 98.0),
("email-campaign-bounce", "Envoi liste sans suppression", "workflow-lockstep", "Validation hardbounces+unsubs+complaints <30j", "Pre-flight check", "active", 99.5),
("nda-contracts", "NDA non signé", "workflow-lockstep", "Blocage Drive tant que NDA DocuSign non signé", "Audit legal mensuel", "active", 100.0),
("commission-calculation", "Commission erreur calcul", "formula-validation", "Script Python auto + double-check humain si delta >1%", "Réconciliation Excel parallèle", "pilot", 97.0),
("social-post-brand", "Brand guidelines non respectées", "checklist-pre-publish", "Check logo/tagline/couleurs/hashtags obligatoires", "Review marketing J+1", "pilot", 90.0),
("sap-config-template", "Config SAP refaite scratch", "template-library", "Library 12 templates configs par module SAP", "Test sur 3 projets", "pilot", 85.0),
("training-certif-gate", "Certification émise sans scoring", "workflow-gate", "Examen >70% obligatoire + double-check formateur", "Audit certifs trimestriel", "active", 96.0),
("wevia-query-log", "Query prod sans trace", "logging-enforce", "Toute query WEVIA loggée Langfuse + session id", "Audit Langfuse hebdo", "active", 100.0),
]
cur.execute("DELETE FROM weval.poka_yoke WHERE tenant_id='weval'")
for p in WEVAL_POKA:
cur.execute("""INSERT INTO weval.poka_yoke (tenant_id, process, failure_mode, device_type, mechanism, validation, status, efficiency_pct, created_at)
VALUES ('weval',%s,%s,%s,%s,%s,%s,%s,NOW())""", p)
print(f"✅ WEVAL Poka-Yoke: {len(WEVAL_POKA)} devices")
WEVAL_KAIZEN = [
("Hallu rate <0.5% via Constitutional cascade", "ia_sovereign", "Hallu >1% sur queries longues",
'{"hallu_pct":1.2}', '{"hallu_pct":0.5}', '{"hallu_pct":0.8}', 40, 9400, "ml-ops+qa", 14, "in-progress"),
("SLA Huawei/SAP <48h", "cloud_integration", "Tickets >4j",
'{"sla_hours":96}', '{"sla_hours":48}', '{"sla_hours":72}', 50, 15000, "chouaib+tech", 21, "in-progress"),
("Change adoption 78→90%", "digital_transfo", "Adoption <90% cible",
'{"adoption_pct":78}', '{"adoption_pct":90}', '{"adoption_pct":82}', 30, 14000, "change-manager", 45, "in-progress"),
("Agents IA monitoring drift", "ia_automation", "Pas de monitoring performance agents",
'{"drift_detected_pct":0}', '{"drift_detected_pct":95}', '{"drift_detected_pct":50}', 20, 7050, "ml-ops", 15, "in-progress"),
("SaaS onboarding 7j→24h", "saas_product", "Time-to-value 7j",
'{"ttv_days":7}', '{"ttv_days":1}', '{"ttv_days":3}', 40, 10000, "product+cs", 20, "in-progress"),
("Bug escape rate 3%→1%", "development", "Bugs prod",
'{"escape_pct":3}', '{"escape_pct":1}', '{"escape_pct":2}', 30, 7520, "dev+qa", 18, "in-progress"),
("Time-to-offer 35j→21j", "talent_recrutement", "Perd candidats",
'{"days":35}', '{"days":21}', '{"days":22}', 20, 9000, "hr+partner", 12, "completed"),
("Modules formations 0→20 live", "formation", "Stagnent Drive",
'{"live":0,"revenue":0}', '{"live":20,"revenue":30}', '{"live":5,"revenue":8}', 40, 15000, "training+tech", 30, "in-progress"),
("Multi-channel publishing auto", "marketing_digital", "4 réécritures posts",
'{"hours_week":24}', '{"hours_week":4}', '{"hours_week":8}', 80, 18800, "content+tech", 15, "in-progress"),
("Nuclei findings <48h triage", "cybersec", "Backlog 87 findings",
'{"backlog_days":21}', '{"backlog_days":2}', '{"backlog_days":5}', 16, 3760, "security+ops", 10, "in-progress"),
("SAP templates library 12 configs", "sap_erp", "Config scratch 2×",
'{"templates":0}', '{"templates":12}', '{"templates":3}', 60, 14000, "sap-team", 30, "in-progress"),
("Templates propositions IA modulaires", "conseil_strat", "Slides 3× refaites",
'{"hours_per_prop":48}', '{"hours_per_prop":12}', '{"hours_per_prop":20}', 28, 6580, "yacine+design", 14, "completed"),
("Commissions automation Python", "finance", "Excel manuel 3h/mois",
'{"hours":3,"errors":2}', '{"hours":0.2,"errors":0}', '{"hours":0.5,"errors":0}', 36, 8640, "yacine+youssef", 15, "completed"),
("Cash collection DSO 75→45j", "finance", "DSO 75j cash bloqué 110k",
'{"dso":75}', '{"dso":45}', '{"dso":52}', 30, 74100, "finance+ops", 30, "in-progress"),
("Pipeline CRM cleanup", "commerce", "60+ stale",
'{"stale":65,"accuracy":55}', '{"stale":5,"accuracy":85}', '{"stale":12,"accuracy":78}', 16, 6000, "sales+ops", 10, "completed"),
("Onboarding consultant J+14", "rh", "J+30 vs cible J+14",
'{"days":30}', '{"days":14}', '{"days":22}', 50, 12000, "hr+chouaib", 20, "in-progress"),
]
cur.execute("DELETE FROM weval.kaizen_events WHERE tenant_id='weval'")
for k in WEVAL_KAIZEN:
cur.execute("""INSERT INTO weval.kaizen_events (tenant_id, title, dept, problem, baseline, target, actual, savings_hours, savings_euro, team, duration_days, status, created_at)
VALUES ('weval',%s,%s,%s,%s::jsonb,%s::jsonb,%s::jsonb,%s,%s,%s,%s,%s,NOW())""", k)
print(f"✅ WEVAL Kaizen: {len(WEVAL_KAIZEN)} events")
WEVAL_GEMBA = [
("bureau Casablanca delivery", "yacine-partner",
'[{"time":"09:30","note":"Chouaib valide timesheets manuellement"},{"time":"10:00","note":"Sara attend accès VM CGI 2h"},{"time":"10:45","note":"Relance OKP4 3 semaines sans réponse"}]',
'[{"owner":"ops","action":"Portail timesheet self-service","due":"2026-05-10"},{"owner":"tech","action":"Pré-provisioning VM J-3","due":"2026-05-01"}]', 3, 75),
("revue pipeline commercial", "youssef-partner-sales",
'[{"time":"14:00","note":"60+ leads stale"},{"time":"14:30","note":"Deal Vistex bloqué 21j"},{"time":"15:00","note":"Focus top 10 décidé"}]',
'[{"owner":"youssef","action":"Cleanup CRM >120j","due":"2026-04-25"}]', 2, 60),
("infrastructure cybersec+cloud", "yacine-tech",
'[{"time":"11:00","note":"87 findings Nuclei"},{"time":"11:30","note":"Tickets Huawei 5j attente"},{"time":"12:00","note":"WAF false positive client bloqué"}]',
'[{"owner":"security","action":"Triage 48h SLA","due":"2026-05-05"}]', 3, 60),
("campagne marketing Ethica", "marketing-lead",
'[{"time":"16:00","note":"Campagne 10k/jour"},{"time":"16:15","note":"Liste 15% bounces"},{"time":"16:45","note":"Posts 4× réécrits"}]',
'[{"owner":"marketing","action":"Pre-flight suppression","due":"2026-04-28"}]', 3, 45),
("product review SaaS WEVIA", "product-lead",
'[{"time":"10:00","note":"Onboarding 7j trop lent"},{"time":"10:30","note":"3 users churn ce mois"},{"time":"11:00","note":"Feature requests non-priorisées"}]',
'[{"owner":"product","action":"Tutorial interactif <24h TTV","due":"2026-05-20"}]', 3, 60),
("formation LMS deployment", "training-lead",
'[{"time":"14:00","note":"LMS Moodle non-configuré"},{"time":"14:30","note":"5 modules prêts mais pas en ligne"},{"time":"15:00","note":"Certificats émis sans examen standard"}]',
'[{"owner":"tech","action":"Deploy Moodle Docker","due":"2026-05-15"}]', 3, 60),
]
cur.execute("DELETE FROM weval.gemba_walks WHERE tenant_id='weval'")
for g in WEVAL_GEMBA:
cur.execute("""INSERT INTO weval.gemba_walks (tenant_id, location, walker, observations, actions, muda_spotted, walk_duration_min, created_at)
VALUES ('weval',%s,%s,%s::jsonb,%s::jsonb,%s,%s,NOW())""", g)
print(f"✅ WEVAL Gemba: {len(WEVAL_GEMBA)} walks")
WEVAL_PDCA = [
("Cash DSO 75→45j", "do",'{"analysis":"DSO 75j"}', '{"impl":"Auto-relance"}', '{}', '{}', "dso_days", 75, 45, 52),
("Forecast accuracy >80%", "check",'{"analysis":"45% erreur"}', '{"impl":"Scoring"}', '{"m":"78%"}', '{}', "forecast_pct", 55, 85, 78),
("Time-to-offer <21j", "act",'{"analysis":"35j"}', '{"impl":"Standardisé"}', '{"m":"22j"}', '{"std":"Process figé"}', "days", 35, 21, 22),
("Bench rate <10%", "plan",'{"analysis":"15% bench"}', '{}', '{}', '{}', "bench_pct", 15, 10, None),
("Bounce Ethica <5%", "do",'{"analysis":"15% bounce"}', '{"impl":"Pre-flight strict"}', '{}', '{}', "bounce_pct", 15, 5, 8),
("Modules formations 20/20", "do",'{"analysis":"0/20"}', '{"impl":"LMS deploy"}', '{}', '{}', "modules", 0, 20, 5),
("Hallu rate <0.5%", "do",'{"analysis":"1.2%"}', '{"impl":"Constitutional cascade"}', '{}', '{}', "hallu_pct", 12, 5, 8),
("SLA Huawei/SAP <48h", "check",'{"analysis":"96h"}', '{"impl":"Template auto"}', '{"m":"72h"}', '{}', "sla_hours", 96, 48, 72),
]
cur.execute("DELETE FROM weval.pdca_cycles WHERE tenant_id='weval'")
for p in WEVAL_PDCA:
cur.execute("""INSERT INTO weval.pdca_cycles (tenant_id, title, phase, plan_data, do_data, check_data, act_data, kpi_name, baseline, target, actual, created_at, updated_at)
VALUES ('weval',%s,%s,%s::jsonb,%s::jsonb,%s::jsonb,%s::jsonb,%s,%s,%s,%s,NOW(),NOW())""", p)
print(f"✅ WEVAL PDCA: {len(WEVAL_PDCA)} cycles")
WEVAL_ANDON = [
("delivery-CGI-ODI", "high", "Timesheet Sara retard 8j - facturation 15k risque", "timesheet-monitor", "chouaib", 45, "resolved"),
("sales-vistex", "medium", "Deal Vistex addendum 21j sans réponse Olga", "crm-stale", None, None, "open"),
("cash-OKP4", "medium", "Facture OKP4 impayée J+52 dépasse seuil", "billing-aging", None, None, "open"),
("cybersec-nuclei", "high", "87 findings Nuclei non-triés 3 semaines", "security-monitor", None, None, "open"),
("marketing-ethica", "low", "Bounce rate 8% vs cible 5%", "deliverability", "marketing", 120, "resolved"),
("saas-churn", "high", "3 users SaaS churn ce mois", "churn-detector", None, None, "open"),
("ia-hallu-spike", "medium", "Hallu rate 1.5% dernière semaine", "halu-eval", None, None, "open"),
]
cur.execute("DELETE FROM weval.andon_alerts WHERE tenant_id='weval'")
for a in WEVAL_ANDON:
cur.execute("""INSERT INTO weval.andon_alerts (tenant_id, station, severity, message, triggered_by, resolved_by, resolution_time_min, status, created_at, resolved_at)
VALUES ('weval',%s,%s,%s,%s,%s,%s,%s,NOW() - INTERVAL '3 hours', CASE WHEN %s='resolved' THEN NOW() ELSE NULL END)""", a+(a[-1],))
print(f"✅ WEVAL Andon: {len(WEVAL_ANDON)} alerts")
WEVAL_FIVES = [
("bureau-Casablanca-open-space", 4, 3, 4, 4, 3, "yacine-partner", "Propre, docs papier à numériser"),
("drive-google-shared", 3, 2, 4, 3, 3, "chouaib-delivery", "Arborescence incohérente clients/missions/templates"),
("repo-github-weval", 5, 5, 5, 5, 5, "yacine-tech", "Top 28 NR stable triple-sync"),
("crm-pipeline", 3, 3, 3, 3, 3, "youssef-sales", "60+ stale à nettoyer"),
("sharepoint-docs-clients", 4, 4, 3, 4, 4, "chouaib", "Propre manque nettoyage périodique"),
("wevia-intents-registry", 4, 4, 5, 5, 4, "yacine-tech", "1741 intents structurés, protocole manifeste V96.15 en place"),
("qdrant-collections", 5, 5, 5, 4, 5, "ml-ops", "19 collections · 22101 vectors · 0 empty post-V96.10"),
]
cur.execute("DELETE FROM weval.five_s_audits WHERE tenant_id='weval'")
for f in WEVAL_FIVES:
cur.execute("""INSERT INTO weval.five_s_audits (tenant_id, area, seiri, seiton, seiso, seiketsu, shitsuke, auditor, notes, created_at)
VALUES ('weval',%s,%s,%s,%s,%s,%s,%s,%s,NOW())""", f)
print(f"✅ WEVAL 5S: {len(WEVAL_FIVES)} audits")
WEVAL_A3 = [
("A3 Cash DSO 75j → 45j", "DSO 75j impact cash 110k€", "75j · 3 factures >60j · relance manuelle", "<45j · 0 >60j · auto",
"30j DSO · 110k€ bloqués", '["Pas auto-relance","Scoring client absent","Pas escompte"]',
'["Script auto J+30/45/60","Scoring onboarding","Escompte 2pct <30j"]',
'{"w2":"dev","w4":"pilot","w8":"rollout"}', '{"q1":"52j progression OK"}', "yacine+youssef", "in-progress"),
("A3 Bench 15% → 10%", "Bench 15% = 30k/mois manque", "15% · 1 consultant 2 mois · pipeline faible", "<10% · rotation <30j",
"5pts · 10k/mois potentiel", '["Pipeline faible","Matching mauvais","Partners slow"]',
'["POC WEVIA/WEVADS","Matching algo","Revue hebdo Vistex/Huawei"]',
'{"m1":"audit","m2":"5 POC","m3":"measure"}', '{}', "chafik", "in-progress"),
("A3 Time-to-offer 35→21j", "35j perd 35% talents", "35j · 35% abandon · scoring subjectif", "21j · <15% · 3 axes",
"14j · 6 candidats/an", '["Subjectif","Decision lente","Feedback lent"]',
'["Form 3 axes","Decision J+7","Feedback auto J+1"]',
'{"w1":"form","w3":"pilot","w6":"rollout"}', '{"q1":"22j atteint"}', "hr", "completed"),
("A3 Bounce Ethica 15→5%", "Bounces 15% impact deliverability", "15% · liste non-nettoyée · pas pre-flight", "<5% · suppression strict",
"10pts · 10k€ waste", '["Liste pas nettoyée","Pas pre-flight","Hardbounces jamais purgés"]',
'["Pre-flight J-1","Purge hebdo","Double opt-in"]',
'{"w1":"script","w2":"pilot","w4":"rollout"}', '{}', "marketing", "in-progress"),
("A3 Formations 0→20 modules", "0 live · 30k€/an manqué", "0 live · LMS inexistant", "20 modules · LMS · 30k€/an",
"100% · 30k€ top", '["LMS non-deploy","Pas marketing","Non-certifiés"]',
'["Moodle Docker","Landing formations","Certif SAP/Huawei"]',
'{"m1":"LMS","m2":"5 live","m3":"launch"}', '{}', "training+tech", "in-progress"),
("A3 Hallu WEVIA <0.5%", "Hallu 1.2% sur queries longues", "1.2% · pas cross-validation", "<0.5% · Constitutional cascade",
"0.7% · 10k€ waste/an credibility", '["Single provider trust","Pas de guard","Pas re-rank"]',
'["Constitutional cascade","Halu-eval continuous","Re-rank top 3"]',
'{"w1":"implement","w2":"eval","w4":"prod"}', '{"measure":"0.8% Q1"}', "ml-ops", "in-progress"),
("A3 SaaS churn 3→1%", "Churn 3% MRR", "3% · onboarding 7j TTV", "<1% · TTV <24h",
"2pts · 20k€/an", '["Onboarding complexe","Pas d attention postiale","Feature gap"]',
'["Tutorial interactif","Success manager","Roadmap public"]',
'{"m1":"tutorial","m2":"CSM","m3":"roadmap"}', '{}', "product+cs", "in-progress"),
]
cur.execute("DELETE FROM weval.a3_reports WHERE tenant_id='weval'")
for a in WEVAL_A3:
cur.execute("""INSERT INTO weval.a3_reports (tenant_id, title, background, current_state, target_state, gap_analysis, root_causes, countermeasures, implementation_plan, follow_up, owner, status, created_at)
VALUES ('weval',%s,%s,%s,%s,%s,%s::jsonb,%s::jsonb,%s::jsonb,%s::jsonb,%s,%s,NOW())""", a)
print(f"✅ WEVAL A3: {len(WEVAL_A3)} reports")
# ═══════════════════════════════════════════════════════════════════
# PART 3 — SEED CFAO HEALTHCARE (client POC pharma/healthcare realistic)
# ═══════════════════════════════════════════════════════════════════
print("\n" + ""*60)
print("PART 3 — Seed CFAO Healthcare (client POC pharma realistic)")
print(""*60)
CFAO_MUDA = [
("pharma-distribution", "inventory", "Stock RX périmé 15% annuel chambre froide (FIFO manuel défaillant)", 5, 0, 28000, "in-progress", "q1-audit-2026"),
("pharma-distribution", "motion", "Opérateurs parcourent 800m 3×/jour thermostats chambre froide", 3, 18, 2400, "identified", "gemba-walk-001"),
("order-processing", "waiting", "Commandes hospitalières attente validation pharmacien >4h pic matin", 4, 32, 4800, "in-progress", "vsm-analysis"),
("regulatory", "defects", "5% dossiers AMM rejetés 1er tour (info manquante traçabilité)", 4, 45, 6750, "in-progress", "compliance-q1"),
("cold-chain", "defects", "3% colis excursion température transport (datalogger absent)", 4, 0, 18000, "identified", "quality-audit"),
("campaign-ethica", "defects", "Campaign email bounces 15% pharma list", 4, 15, 1800, "identified", "poc-audit"),
("supply", "transport", "Double manutention colis réfrigérés quai/quarantaine", 2, 12, 1600, "identified", "gemba-002"),
("qa", "overprocessing", "Vérification manuelle 3× numéros lot avant dispatch", 3, 8, 1200, "identified", "qa-review"),
("rh", "skills", "Formation nouveaux opérateurs 6 semaines vs 3 industrie", 3, 240, 18000, "identified", "hr-review"),
("finance", "waiting", "Facturation hospitalières >30j (cycle paiement public lent)", 4, 0, 45000, "identified", "cash-audit"),
]
cur.execute("DELETE FROM weval.muda_entries WHERE tenant_id='poc_1d37ee62'")
for m in CFAO_MUDA:
cur.execute("""INSERT INTO weval.muda_entries (tenant_id, vs_id, muda_type, description, severity, impact_hours, impact_euro, status, detected_by, created_at)
VALUES ('poc_1d37ee62',%s,%s,%s,%s,%s,%s,%s,%s,NOW())""", m)
print(f"✅ CFAO Muda: {len(CFAO_MUDA)} entries")
CFAO_POKA = [
("cold-chain-validation", "T°C hors plage 2-8°C", "sensor-iot", "Sonde Bluetooth + Telegram >30min dérive", "Test hebdo + étalonnage", "active", 97.5),
("prescription-match", "Erreur ordonnance-préparation", "scan-barcode", "Scan 2D Datamatrix obligatoire", "Audit 50 dispensations/mois", "active", 99.2),
("batch-traceability", "Mauvais lot expédié", "workflow-lockstep", "Validation batch+exp avant étiquette", "Contrôle double lot sensible", "active", 99.8),
("temperature-shipping", "Rupture chaîne froid transport", "datalogger", "Enregistreur par colis + alerte >8°C >15min", "Vérif 100% colis chronique", "active", 95.0),
("regulatory-submission", "Soumission AMM incomplète", "checklist-auto", "Formulaire 47 champs obligatoires", "QA review pré-envoi", "pilot", 88.0),
("hospital-ordering", "Commande hospitalière incomplète", "form-validation", "Validation tous champs + cross-check formulaire médecin", "QA review échantillon 10%", "pilot", 92.0),
]
cur.execute("DELETE FROM weval.poka_yoke WHERE tenant_id='poc_1d37ee62'")
for p in CFAO_POKA:
cur.execute("""INSERT INTO weval.poka_yoke (tenant_id, process, failure_mode, device_type, mechanism, validation, status, efficiency_pct, created_at)
VALUES ('poc_1d37ee62',%s,%s,%s,%s,%s,%s,%s,NOW())""", p)
print(f"✅ CFAO Poka-Yoke: {len(CFAO_POKA)} devices")
CFAO_KAIZEN = [
("FIFO automatisé chambre froide", "pharma-distribution", "15% molécules RX expirent",
'{"expired_pct":15,"value_keur":28}', '{"expired_pct":3,"value_keur":6}', '{"expired_pct":5,"value_keur":10}', 120, 18000, "logistics+it", 30, "in-progress"),
("Validation pharmacien <2h", "order-processing", "4h pic validation",
'{"min":240}', '{"min":90}', '{"min":108}', 80, 4800, "pharma+pm", 15, "completed"),
("Checklist AMM pré-validation", "regulatory", "5% rejected 1er tour",
'{"rejection_pct":5}', '{"rejection_pct":1}', '{"rejection_pct":2}', 50, 7500, "regulatory+qa", 10, "completed"),
("Formation accélérée opérateurs", "rh", "6 semaines autonomie",
'{"weeks":6}', '{"weeks":3}', '{"weeks":4}', 240, 18000, "hr+ops", 60, "in-progress"),
("Cold chain datalogger rollout", "cold-chain", "3% excursion transport",
'{"excursion_pct":3}', '{"excursion_pct":0.5}', '{"excursion_pct":1.2}', 20, 14400, "quality+logistics", 45, "in-progress"),
("Reduction bounce email pharma", "marketing", "Bounce 15%",
'{"bounce":15}', '{"bounce":5}', '{"bounce":8}', 5, 5000, "marketing", 30, "in-progress"),
]
cur.execute("DELETE FROM weval.kaizen_events WHERE tenant_id='poc_1d37ee62'")
for k in CFAO_KAIZEN:
cur.execute("""INSERT INTO weval.kaizen_events (tenant_id, title, dept, problem, baseline, target, actual, savings_hours, savings_euro, team, duration_days, status, created_at)
VALUES ('poc_1d37ee62',%s,%s,%s,%s::jsonb,%s::jsonb,%s::jsonb,%s,%s,%s,%s,%s,NOW())""", k)
print(f"✅ CFAO Kaizen: {len(CFAO_KAIZEN)} events")
CFAO_GEMBA = [
("chambre froide zone A", "pharmacist-lead",
'[{"time":"08:15","note":"800m parcours thermostat - waste motion"},{"time":"08:32","note":"File 12 commandes - bottleneck"},{"time":"08:47","note":"Stock expiré 2 palettes"}]',
'[{"owner":"logistics","action":"Thermostat secondaire","due":"2026-05-15"},{"owner":"pharma","action":"Validation mobile","due":"2026-05-01"}]', 3, 45),
("quai réception", "ops-manager",
'[{"time":"10:00","note":"Double manutention froid/quarantaine"},{"time":"10:25","note":"Étiquettes batch illisibles 3/47"}]',
'[{"owner":"logistics","action":"Zone tampon ventilée","due":"2026-06-01"}]', 2, 30),
("salle préparation", "pharma+qa",
'[{"time":"14:00","note":"Workflow scan parfait"},{"time":"14:20","note":"Formation nouveau - 6 questions doc manquante"}]',
'[{"owner":"training","action":"Quick-reference cards","due":"2026-04-25"}]', 1, 60),
("pharmacie hospitalière", "quality-lead",
'[{"time":"09:00","note":"Commande hospitalière incomplète 5/30"},{"time":"09:30","note":"Retour vers prescripteur"},{"time":"10:00","note":"Délai +2j dispensation"}]',
'[{"owner":"quality","action":"Form validation auto","due":"2026-05-05"}]', 2, 45),
]
cur.execute("DELETE FROM weval.gemba_walks WHERE tenant_id='poc_1d37ee62'")
for g in CFAO_GEMBA:
cur.execute("""INSERT INTO weval.gemba_walks (tenant_id, location, walker, observations, actions, muda_spotted, walk_duration_min, created_at)
VALUES ('poc_1d37ee62',%s,%s,%s::jsonb,%s::jsonb,%s,%s,NOW())""", g)
print(f"✅ CFAO Gemba: {len(CFAO_GEMBA)} walks")
CFAO_PDCA = [
("FIFO rotation <5% expired", "check", '{"analysis":"15% expired"}', '{"impl":"WMS scan position"}', '{"m":"5.2% Q1"}', '{}', "expired_pct", 15, 5, 5.2),
("Validation commande <2h", "do", '{"analysis":"4h pic"}', '{"impl":"App mobile"}', '{}', '{}', "validation_min", 240, 120, 108),
("AMM rejection <1%", "act", '{"analysis":"5% rejected"}', '{"impl":"Checklist 47 pts"}', '{"m":"2% Q1"}', '{"std":"All submissions"}', "rejection_pct", 5, 1, 2),
("T° chain excursion <1%", "plan", '{"analysis":"3% excursion"}', '{}', '{}', '{}', "excursion_pct", 3, 1, None),
("Bounce pharma <5%", "do", '{"analysis":"15% bounce"}', '{"impl":"Pre-flight"}', '{"m":"8%"}', '{}', "bounce_pct", 15, 5, 8),
]
cur.execute("DELETE FROM weval.pdca_cycles WHERE tenant_id='poc_1d37ee62'")
for p in CFAO_PDCA:
cur.execute("""INSERT INTO weval.pdca_cycles (tenant_id, title, phase, plan_data, do_data, check_data, act_data, kpi_name, baseline, target, actual, created_at, updated_at)
VALUES ('poc_1d37ee62',%s,%s,%s::jsonb,%s::jsonb,%s::jsonb,%s::jsonb,%s,%s,%s,%s,NOW(),NOW())""", p)
print(f"✅ CFAO PDCA: {len(CFAO_PDCA)} cycles")
CFAO_ANDON = [
("zone-A-coldroom", "high", "T° 9.2°C depuis 18min - seuil critique", "iot-sensor", "logistics", 22, "resolved"),
("dispensation-station-3", "medium", "Scanner barcode offline 12min - fallback manuel", "pharmacist", "it-oncall", None, "open"),
("transport-excursion-batch-X27", "high", "Datalogger alerte 9.5°C 25min colis X27", "datalogger", "quality", 45, "resolved"),
]
cur.execute("DELETE FROM weval.andon_alerts WHERE tenant_id='poc_1d37ee62'")
for a in CFAO_ANDON:
cur.execute("""INSERT INTO weval.andon_alerts (tenant_id, station, severity, message, triggered_by, resolved_by, resolution_time_min, status, created_at, resolved_at)
VALUES ('poc_1d37ee62',%s,%s,%s,%s,%s,%s,%s,NOW() - INTERVAL '2 hours', CASE WHEN %s='resolved' THEN NOW() ELSE NULL END)""", a+(a[-1],))
print(f"✅ CFAO Andon: {len(CFAO_ANDON)} alerts")
CFAO_FIVES = [
("chambre-froide-A", 4, 4, 4, 3, 4, "audit-q1-pharmacist", "T° stable, étiquetage excellent, rangement à améliorer"),
("salle-preparation", 5, 5, 5, 4, 4, "audit-q1-qa", "Top performer, formation exemplaire"),
("quai-reception", 3, 3, 3, 3, 3, "audit-q1-ops-lead", "Flux mélangés froid/ambient, réorganisation Q2"),
("zone-dispensation", 4, 4, 4, 4, 4, "audit-q1-pharmacist", "Propre organisé, scanners fonctionnels"),
]
cur.execute("DELETE FROM weval.five_s_audits WHERE tenant_id='poc_1d37ee62'")
for f in CFAO_FIVES:
cur.execute("""INSERT INTO weval.five_s_audits (tenant_id, area, seiri, seiton, seiso, seiketsu, shitsuke, auditor, notes, created_at)
VALUES ('poc_1d37ee62',%s,%s,%s,%s,%s,%s,%s,%s,NOW())""", f)
print(f"✅ CFAO 5S: {len(CFAO_FIVES)} audits")
CFAO_A3 = [
("A3 Expiration stock RX 15→5%", "28k€/an pertes péremption", "15% · FIFO manuel inconsistant", "<5% · FIFO WMS automatisé",
"10pts · 18k€ savings/an", '["Rotation non tracée","Pas alerte J-90/30/7","Position stock non géolocalisée"]',
'["WMS scan position","Alertes auto","Formation FIFO strict"]',
'{"w1":"spec","w3":"pilot","w8":"rollout"}', '{"q1":"5.2% on track"}', "logistics-lead", "in-progress"),
("A3 Validation pic matin", "Pharmaciens débordés 8h-12h, hospitals mécontents", "4h · file 12+ · 3 pharma", "90min · <5 · validation mobile",
"2.5h/commande · 4 pharma effectifs", '["Validation poste fixe","Pas priorisation","Contexte manuel"]',
'["App mobile","Algo priorisation","Pré-remplissage auto"]',
'{"w2":"dev","w5":"pilot","w10":"rollout"}', '{}', "pharmacy-lead", "in-progress"),
("A3 AMM rejection <1%", "5% rejetés · 6k€/dossier · 3 mois délai", "5% · 47 pts manuels · QA variable", "<1% · checklist auto",
"4pts · 24k€/an économisés", '["Checklist inégale","Pas de blocage","Pièces chronophages"]',
'["Form web obligatoire","Blocage si gap","Library centralisée"]',
'{"m1":"dev","m2":"pilot 5","m3":"rollout"}', '{"q1":"2% on track"}', "regulatory-lead", "completed"),
]
cur.execute("DELETE FROM weval.a3_reports WHERE tenant_id='poc_1d37ee62'")
for a in CFAO_A3:
cur.execute("""INSERT INTO weval.a3_reports (tenant_id, title, background, current_state, target_state, gap_analysis, root_causes, countermeasures, implementation_plan, follow_up, owner, status, created_at)
VALUES ('poc_1d37ee62',%s,%s,%s,%s,%s,%s::jsonb,%s::jsonb,%s::jsonb,%s::jsonb,%s,%s,NOW())""", a)
print(f"✅ CFAO A3: {len(CFAO_A3)} reports")
# ═══════════════════════════════════════════════════════════════════
# SUMMARY
# ═══════════════════════════════════════════════════════════════════
print("\n" + ""*60)
print("🏆 SEED V96.18 COMPLETE — 2 tenants · 16 domaines")
print(""*60)
for tenant in ['weval', 'poc_1d37ee62']:
print(f"\n=== {tenant} ===")
for tbl in ['muda_entries','poka_yoke','kaizen_events','gemba_walks','pdca_cycles','andon_alerts','five_s_audits','a3_reports','vsm_dept']:
cur.execute(f"SELECT COUNT(*) FROM weval.{tbl} WHERE tenant_id = %s", (tenant,))
print(f" {tbl:22} count={cur.fetchone()[0]}")
cur.close()
conn.close()