system-prompts-and-models-o.../salesflow-saas/docs/governance/workflow-inventory.md
Claude e11253ab12
feat(dealix): Tier-1 closure program — 10 tracks complete
Track 1 — Truth Lock:
  docs/current-vs-target-register.md: Full subsystem maturity register
  (73 Production, 27 Partial, 2 Pilot, 32 Target, 6 Watch = 52.1% maturity)

Track 2 — Document Consistency:
  docs/governance/document-consistency-audit.md: All 6 checks PASS
  (no dangling refs, no overclaim, all paths root-safe, naming consistent)

Track 3 — Decision Plane:
  backend/app/schemas/structured_outputs.py: 17 Pydantic schemas with Provenance
  (LeadScoreCard, QualificationMemo, ProposalPack, PricingDecisionRecord,
   PartnerDossier, EconomicsModel, ApprovalPacket, TargetProfile, DDPlan,
   ValuationMemo, SynergyModel, ICMemo, BoardPackDraft, ExpansionPlan,
   StopLossPolicy, PMIProgramPlan, ExecWeeklyPack)

Track 4 — Execution Plane:
  docs/governance/workflow-inventory.md: 8 short + 8 medium + 6 long-lived
  workflows classified. 3 Temporal candidates with compensation logic.

Track 5 — Trust Fabric:
  docs/governance/trust-closure-plan.md: 5 live components + Watch adoption
  criteria for OPA/OpenFGA/Vault/Keycloak

Track 6 — Data & Connectors:
  docs/governance/connector-standard.md: Connector facade contract, semantic
  metrics dictionary, radar additions (Airbyte, Unstructured, Great Expectations)

Track 7 — Operating Plane:
  docs/governance/operating-plane-checklist.md: GitHub governance, CI/CD
  enhancements, CODEOWNERS template, OIDC/attestation roadmap

Track 8 — Saudi/GCC:
  docs/governance/saudi-enterprise-readiness.md: PDPL processing register,
  data classification, NCA ECC readiness, OWASP LLM Top 10, NIST AI RMF

Track 9 — Executive Surfaces:
  docs/governance/executive-surface-closure.md: Wiring plan with real data
  queries for Executive Room, Approval Center, Compliance Dashboard

Track 10 — Market Dominance:
  docs/governance/market-dominance-plan.md: 3-tier packaging (Core/Strategic/
  Sovereign), ROI narrative, competitive wedge, capability moat map,
  executive sales stories (CEO/CTO/CFO/CISO)

Master Checklist: docs/tier1-master-closure-checklist.md
  50 items total — 25 Done (documentation), 25 Target (runtime/integration)

https://claude.ai/code/session_01W1rJthWDkasijTdXCfxVHs
2026-04-16 13:08:26 +00:00

210 lines
8.0 KiB
Markdown

# Workflow Inventory — Execution Plane Classification
> **Parent**: [`MASTER_OPERATING_PROMPT.md`](../../MASTER_OPERATING_PROMPT.md)
> **Plane**: Execution | **Version**: 1.0
---
## Classification Rules
| Class | Criteria | Runtime | Engine |
|-------|----------|---------|--------|
| **Short-lived local** | <30s, single service, no external I/O | Sync/Celery | FastAPI / Celery task |
| **Medium-lived orchestrated** | Minutes to hours, multi-step, internal services | Celery chain | OpenClaw + Celery |
| **Long-lived durable** | Hours to days, external systems, pause/resume, compensation | Durable | Temporal (target) / OpenClaw durable_flow (current) |
### Temporal Candidate Rule
A workflow MUST be classified as "Long-lived durable" and is a Temporal candidate if ANY of:
- Duration spans **days**
- Crosses **2+ external systems**
- Requires **compensation** (rollback on failure)
- Requires **pause/resume** after human approval
- Represents an **external commitment** (contract, payment, message)
---
## Short-Lived Local Workflows
| Workflow | Engine | Duration | Steps |
|----------|--------|----------|-------|
| Lead scoring | Celery task | <5s | LLM call score DB write |
| Message classification | Sync | <2s | NLP intent tag |
| Dialect detection | Sync | <1s | Arabic NLP dialect label |
| Knowledge retrieval | Sync | <3s | pgvector search rank return |
| Dashboard aggregation | Sync | <5s | Multi-query aggregate return |
| Health check | Sync | <1s | Service probes status |
| Trust score calculation | Celery task | <5s | Factor aggregation score DB |
| Audit log write | Sync | <1s | Event AuditLog insert |
---
## Medium-Lived Orchestrated Workflows
| Workflow | Engine | Duration | Steps | External I/O |
|----------|--------|----------|-------|-------------|
| Lead qualification pipeline | OpenClaw + Celery | 1-5 min | Capture enrich score route notify | Company research APIs |
| Multi-channel outreach sequence | Sequence Engine | Hours-days | Template personalize send wait follow-up | WhatsApp, Email, SMS |
| Meeting booking flow | Celery chain | 2-10 min | Propose times negotiate confirm calendar | Cal.com API |
| Proposal generation | OpenClaw + Celery | 5-15 min | Deal data LLM draft CPQ pricing PDF notify | LLM provider |
| Affiliate onboarding | Celery chain | 10-30 min | Application evaluate approve/reject provision | Email notifications |
| Compliance scan | OpenClaw | 2-5 min | Iterate controls check each aggregate report | Internal services only |
| Evidence pack assembly | Celery task | 1-5 min | Query 6+ tables aggregate hash store | Internal only |
| Contradiction scan | Celery task | 5-30 min | Load docs LLM comparison flag conflicts | LLM provider |
---
## Long-Lived Durable Workflows (Temporal Candidates)
### 1. Partner Approval Flow ★ PRIORITY
| Attribute | Value |
|-----------|-------|
| **Duration** | 1-14 days |
| **External Systems** | Email, WhatsApp, CRM, eSign |
| **Pause Points** | Term review, legal review, executive approval |
| **Compensation** | Retract term sheet, notify partner of rejection |
| **Why Temporal** | Multi-day approval chain, external commitments, need resume after crash |
**Steps**:
```
Partner identified → Fit score generated → Manager approval (pause)
→ Term sheet drafted → Legal review (pause) → Partner sent terms
→ Partner negotiation → Executive approval (pause) → Activation
→ If rejected at any stage: compensation (retract, notify)
```
**Current**: Manual / partial OpenClaw
**Target**: Temporal workflow with checkpointing
---
### 2. DD Room Orchestration ★ PRIORITY
| Attribute | Value |
|-----------|-------|
| **Duration** | 2-8 weeks |
| **External Systems** | Document storage, financial APIs, legal review tools |
| **Pause Points** | Each workstream completion, findings review, IC decision |
| **Compensation** | Terminate DD, notify target, archive room |
| **Why Temporal** | Weeks-long process, multiple workstreams, must survive outages |
**Steps**:
```
DD initiated → Workstreams assigned (financial, legal, technical, product, security)
→ Each workstream: collect → analyze → findings (parallel, durable)
→ Findings consolidation → Risk register → Valuation impact
→ IC Memo generation → IC review (pause) → Decision
→ If proceed: close preparation
→ If reject: compensation (archive, notify, lessons learned)
```
**Current**: No durable workflow
**Target**: Temporal workflow with parallel workstream activities
---
### 3. Signature / Term Sheet Commitment Flow ★ PRIORITY
| Attribute | Value |
|-----------|-------|
| **Duration** | 1-7 days |
| **External Systems** | DocuSign/Adobe Sign, Email, CRM |
| **Pause Points** | Signature request sent, awaiting signature |
| **Compensation** | Void signature request, notify parties |
| **Why Temporal** | External commitment, legally binding, must track to completion |
**Steps**:
```
Terms finalized → Approval token obtained → Signature request sent (external)
→ Wait for signature (pause, poll/webhook) → Signed → Record in CRM
→ Notify parties → Update deal status → Evidence pack assembly
→ If expired: compensation (void request, notify, re-negotiate option)
```
**Current**: Manual / partial plugin
**Target**: Temporal workflow with webhook-based resume
---
### 4. M&A Offer & Negotiation Flow
| Attribute | Value |
|-----------|-------|
| **Duration** | 2-12 weeks |
| **External Systems** | Legal counsel, financial advisors, regulatory |
| **Pause Points** | Board approval, regulatory filing, target response |
| **Compensation** | Withdraw offer, regulatory withdrawal, archive |
**Current**: No workflow
**Target**: Temporal workflow (Phase 2)
---
### 5. Geographic Expansion Launch
| Attribute | Value |
|-----------|-------|
| **Duration** | 4-12 weeks |
| **External Systems** | Regulatory bodies, local partners, infrastructure |
| **Pause Points** | Regulatory approval, canary evaluation, scale decision |
| **Compensation** | Roll back canary, disable market, notify users |
**Current**: Manual / feature flags
**Target**: Temporal workflow (Phase 3)
---
### 6. PMI Program Execution
| Attribute | Value |
|-----------|-------|
| **Duration** | 3-6 months |
| **External Systems** | HR, finance, IT, legal, CRM |
| **Pause Points** | Each phase gate (Day-1, 30, 60, 90) |
| **Compensation** | Rollback integration steps, separate entities |
**Current**: No workflow
**Target**: Temporal workflow (Phase 3)
---
## Temporal Adoption Roadmap
| Phase | Timeline | Scope |
|-------|----------|-------|
| **Spike** | Sprint 2 | ADR + prototype with partner approval flow |
| **Pilot** | Sprint 3-4 | Partner approval + DD orchestration on Temporal |
| **Production** | Sprint 5-6 | Signature flow + evidence for remaining workflows |
| **Expansion** | Post-90d | M&A offer, expansion launch, PMI |
### Prerequisites (from ADR-0001)
- [ ] Temporal server deployed (self-hosted or cloud)
- [ ] Worker infrastructure provisioned
- [ ] Existing OpenClaw flows mapped to Temporal activities
- [ ] Monitoring/observability wired to Temporal dashboard
- [ ] Compensation logic documented for each workflow
- [ ] ADR approved with evidence from spike
---
## Idempotency Requirements
Every durable workflow step must be idempotent:
| Step Type | Idempotency Method |
|-----------|-------------------|
| DB write | Upsert with idempotency key |
| External API call | Idempotency header / dedup key |
| Message send | Message ID dedup in outbound governance |
| Approval request | Request ID dedup in approval bridge |
| File/document creation | Hash-based dedup |
---
## Compensation Logic Template
```
for each completed_step in reverse(workflow_steps):
if completed_step.has_side_effects:
execute(completed_step.compensation_action)
log_compensation(completed_step, reason)
mark_step_compensated(completed_step)
mark_workflow_compensated(workflow)
```
Required for all Long-lived durable workflows before Temporal adoption.