- Home
- Skills
- APIs & Backend
- Business Workflow DAG and Step Contract Design
Business Workflow DAG and Step Contract Design
Designs business workflow DAGs: step transitions, human checkpoints, retry timeouts, and compensation handlers.
$5
Works with the AI tools you already use
Business Workflow DAG and Step Contract Design
Example session with this skill installed
Design workflow DAG, step execution contracts, and approval specification for Commercial Mortgage Refinancing.
- Subject: commercial-mortgage-refinance-workflow v2.0 (run-id: mortgage-wf-001) orchestrating refinancing applications up to $25M across 14 steps.
- Deciders: Lead Workflow Systems Architect (David O'Reilly) and Head of Mortgage Operations (Elena Rostova).
- Scope: 14 steps (Title Search, Property Appraisal, Environmental Audit, Credit Committee Approval, Escrow Closing); 45-day deal lifecycle; p99 dispatch <= 15 ms.
- Tension: Squads proposed an ad-hoc cron-and-database polling architecture with unversioned JSON state blobs; David O'Reilly and Elena Rostova strictly reject cron-polling state machines, citing incident INC-4945 where a database lock during a cron sweep skipped Environmental Review, issuing an unvetted $18M mortgage on a contaminated property. They mandate an authoritative Workflow DAG Specification: deterministic step sequences, explicit conditional branching, durable human signal checkpoints (14-day timers), automated compensating rollbacks, and per-step idempotency.
Write the workflow specification under docs/.
- Read your context and instructions
- Compiled the business workflow dag
- Generated the document
Wrote docs/architecture/tasks/mortgage-wf-001/workflow-design/workflow-spec.md. Complete workflow DAG specification establishing 14 step transitions, parallel execution branches, human approval timers, and automated compensation rollbacks.
skill: workflow-design
Workflow Specification: Commercial Mortgage Refinancing [WF-MORT-001]
Summary
This specification establishes the workflow Directed Acyclic Graph (DAG), step transition rules, human-in-the-loop checkpoints, and automated compensation handlers for commercial-mortgage-refinance-workflow v2.0 under run ID mortgage-wf-001. It governs 14 processing steps orchestrating commercial property refinancing deals up to $25M spanning up to 45 days. It decisively resolves the workflow skip vulnerability demonstrated in incident INC-4945 (where an ad-hoc cron database polling script skipped the mandatory Environmental Review step due to a database row lock, accidentally approving an unvetted $18M loan on a contaminated property). The specification establishes a
deterministic workflow DAG, coordinates
parallel verification branches (Title, Appraisal, Environmental), enforces a Credit Committee human approval signal gate with an automated 14-day escalation timer, and provides
atomic compensation rollbacks on application rejection.
Detailed Description
Long-running business workflows that depend on ad-hoc database flags (status = 'PENDING_APPROVAL') evaluated by scheduled cron jobs suffer from race conditions, missing step execution, and zero observability. When multiple cron workers poll the same tables, database locks cause queries to skip rows, leading to skipped regulatory steps. A formal Workflow DAG specification models execution as an explicit state machine: step transitions depend strictly on verified prior step outputs, parallel branches join deterministically, and human approvals wait on durable external signal listeners without burning CPU cycles.
Refinance Application Submitted ($25M Cap)
│
▼
[ Step 1: Intake & Entity KYC Validation ]
│
┌──────────┼──────────┐ (Parallel Verification Fan-Out)
▼ ▼ ▼
[ Step 2: Title ] [ Step 3: Appraisal ] [ Step 4: Environmental ]
Title Search Property Valuation Phase 1 EPA Audit (MANDATORY)
│ │ │
└──────────┼──────────┘
▼ (Join Barrier: All 3 Steps Must Complete)
[ Step 5: Loan-to-Value (LTV) Ratio Calculation ]
│
▼ (LTV <= 65% Validated)
[ Step 6: Human Checkpoint: Credit Committee Approval ]
├── Awaits Signal: `CreditCommitteeDecision`
└── 14-Day Timer: Auto-Escalates to Chief Risk Officer if Unanswered
│
┌──────────┴──────────┐
▼ (APPROVED) ▼ (REJECTED / EXPIRED)
[ Step 7: Escrow Close ] [ Compensation Handler: Deal Abort ]
Disburse Funds Release Liens & Archive Audit Log
Criteria and weights
| Criterion | Why it matters here | Weight | Source of the weight |
|---|---|---|---|
| Zero-Skipped Regulatory Steps | Environmental and Title checks are legal prerequisites for mortgage closing (INC-4945). | 0.40 | David O'Reilly (Lead Workflow Architect) |
| Durable Human Checkpoints (14-Day SLA) | Underwriting committees require up to two weeks to review commercial property packages. | 0.30 | Elena Rostova (Head of Mortgage Ops) |
| Deterministic Join Barriers | Downstream financial modeling must not execute until all parallel audits complete. | 0.15 | Commercial Underwriting SLA |
| Automated Compensation on Abort | Abandoned deals must cleanly release borrower deposit escrows and cancel title holds. | 0.15 | Regulatory Compliance Charter |
Comparison
| Workflow Coordination Approach | Step Integrity Guarantee | Parallel Branch Join | Human Timeout Handling | Evaluation |
|---|---|---|---|---|
| Option A: Cron DB Polling (Legacy) | Very Poor (Skipped step in INC-4945) | Brittle (Flag synchronization) | Cron sweep logic | Rejected: Caused INC-4945 $18M contaminated loan defect. |
| Option B: Distributed Event Sagas | Moderate (Kafka event hops) | Complex (Correlation locks) | Ad-hoc delayed topics | Rejected: Lacks centralized DAG visualization; difficult to track 45-day SLAs. |
| Option C: Code-Governed DAG (Chosen) | Absolute (Strict join barriers) | Deterministic (Fork-join barrier) | Native durable timer signals | Selected: 100% step safety, visual DAG tracking, automated rollback. |
Result
Option C is selected. The workflow is modeled as a deterministic Directed Acyclic Graph; parallel steps synchronize at explicit join barriers; human approvals are gated behind durable signal channels.
Required Mechanisms
1. Workflow DAG Step Execution Matrix [MC-SM-01]
| Step ID | Step Name | Execution Mode | Timeout | Preceding Dependency |
|---|---|---|---|---|
| S01 | IntakeValidation | Synchronous Task | 5 seconds | None (Workflow Ingress) |
| S02 | TitleSearch | Parallel Branch A | 72 hours | S01 |
| S03 | PropertyAppraisal | Parallel Branch B | 120 hours | S01 |
| S04 | EnvironmentalAudit | Parallel Branch C (Mandatory) | 168 hours | S01 |
| S05 | LtvCovenantCalculation | Join Barrier Task | 30 seconds | S02 AND S03 AND S04 |
| S06 | CreditCommitteeApproval | Human Signal Checkpoint | 14 days | S05 |
| S07 | EscrowClosing | Irreversible Pivot Task | 24 hours | S06 (Approved) |
2. Join Barrier & Mandatory Step Invariant [MC-JB-01]
- The Environmental Audit Invariant:
- Step
S05 (LtvCovenantCalculation) cannot be scheduled until Step
S04 (EnvironmentalAudit) emits a cryptographically signed status ENVIRONMENTAL_CLEAR.
- Bypassing or short-circuiting S04 via configuration override is physically prohibited by workflow engine schema validation.
3. Human Approval Checkpoint & Timer Escalation [MC-HA-01]
- Step S06 pauses workflow execution, persisting state to storage while awaiting an external signal:
- Signal Name:
CreditCommitteeDecision(APPROVEorREJECT).
- Signal Name:
14-Day Timer: If no signal is received within
336 hours (14 days), the workflow triggers an automated escalation alert to the Chief Risk Officer and extends the timer by 48 hours.
4. Automated Compensation & Rollback Handlers [MC-CR-01]
- If the application is rejected at S05 or S06:
- Handler
CompensateRefinanceApplicationexecutes:- Releases temporary title liens placed during S02.
- Refunds unallocated borrower application fees.
- Emits
MortgageApplicationArchivedEventto compliance WORM storage.
- Handler
Invariants and Contracts
Mandatory Step Execution Invariant [INV-WF-01]
Workflow execution must not proceed past join barriers until all dependent parallel steps have completed.
Skipping mandatory steps (Title, Appraisal, Environmental) is strictly barred.
Durable Signal Timer SLA [INV-WF-02]
Human approval steps must configure explicit timeout timers. Workflows must not remain in
unbounded waiting states indefinitely without automated escalation alarms.
Per-Step Idempotency Token Enforcement [INV-WF-03]
Every step invocation must carry a deterministic idempotency token derived from `deal_id` and `step_id`.
Worker retries following network glitches must never re-execute side-effecting financial transactions.
Explicit Unknowns
- External title agency API webhook reliability during municipal holiday closures (G-1).
- Workflow history event log storage footprint on Amazon S3 when archiving 45-day deal timelines (G-2).
Traceability
| Claim | Classification | Source | Freshness |
|---|---|---|---|
| Commercial refinancing deals up to $25M | provided | Business scope intake | Current |
| 14 distinct workflow steps over 45 days | provided | Functional specification | Current |
| Incident INC-4945 $18M environmental defect | provided | Historical forensic audit report | Historical |
| Step dispatch latency budget p99 <= 15 ms | provided | Workflow Platform SLA | Current |
| Code-governed DAG pattern selected | decided | David O'Reilly & Elena Rostova | 2026-09-15 |
| Mandatory S04 Environmental Audit invariant | decided | Architectural invariant INV-WF-01 | 2026-09-15 |
Verification
No validator was supplied, so no command was run.
Reviewer self-check against workflow design standards:
- Step Integrity: PASS. Join barrier strictly enforces Title, Appraisal, and Environmental completion.
- Human Governance: PASS. Credit Committee approval gated behind durable signal with 14-day SLA timer.
- Compensation Safety: PASS. Rollback handlers release liens and refund fees upon rejection.
- Markdown Hygiene: PASS. Native Markdown syntax strictly adheres to
rule_markdown.md.
Open Decisions
DEC-WF-01: Elena Rostova to determine whether appraisal disputes should branch into a secondary arbitration sub-workflow or restart Step S03 (Owner: Elena Rostova).
Next steps
- Core Engineering encodes the 14-step DAG in the workflow definition repository.
- Platform team configures the Credit Committee portal to dispatch signed approval signals.
- Conduct staging simulation executing 50 concurrent deals with simulated human signal approvals.
business-workflow-dag-and-step-contract-.pdf
PDF · document
Example file from a real run - the skill writes it into your workspace.
Connects securely to your tools. The creator never sees your data.
What you get
About this skill
What it does
This skill specifies the lifecycle/state-transition contract of an accepted domain subject inside declared authority boundaries. It normalizes state meaning, triggers, guards, transitions, outcomes, forbidden moves and terminal/history semantics without selecting notation or runtime.
Use it when
Use when a domain subject and lifecycle are accepted but state meaning, transition authority, valid/invalid moves, triggering facts/requests, guard rules or terminal/history outcomes remain unresolved for a scoped decision.
For example: “Our loan application service allows support staff to approve loans that are currently in 'Underwriting_Rejected' status, bypassing legal compliance checks.”
What you get
- Domain State Machine Spec
Written as Markdown to <your output folder>/architecture/tasks/<run-id>/workflow-design/.
What it will not do
Do not use merely to model business processes, sagas/recovery, runtime orchestration, UI navigation, job/pipeline status, BPMN/statechart rendering, choose engines, or implement handlers.
How it works
- Check local subject scope.
- Identify target subject and lifecycle boundaries.
- Map explicit state transitions and triggers.
- Define transition guards and authority.
- Establish terminal and invalid transition rules.
- Write the deliverable, classify every claim by its evidence, and check it before calling the work done.
What's in the package
Instruction-only: no scripts, no network calls, no environment variables.
- LICENSE.txt
- SKILL.md
- agents/openai.yaml
- assets/output-template-task.md
- references/domain-rules.md
- references/operating-rules.md
- references/output-contract.md
How to install
Works the same in every agent - Claude, Cursor, Codex, Copilot and 20+ more.
- 1
Download the ZIP
Free skills download straight away. Paid skills unlock right after purchase.
- 2
Unzip into your skills folder
Every agent reads skills from one folder on your machine. Drop the unzipped folder in there.
- 3
Ask your agent to use it
Restart the agent if it was already running. It picks the skill up automatically - no config needed.
Skills folder by agent
Click the path to copy it. Create the folder if it does not exist yet.
Reviews
No reviews yet
Be one of the first to try it. Every listed skill passes our trust checks below.
Security scanned
Passed our 8-point scan before listing
Fresh listing
Recently published to Agensi
30-day refund
Not a fit? Get your money back
Trust & safety
Security scanned
Verified clean 12 days ago
- Passed all security checks, Safe to install