Business Workflow DAG and Step Contract Design

    1

    Designs business workflow DAGs: step transitions, human checkpoints, retry timeouts, and compensation handlers.

    $5

    Secure checkout via Stripe

    30-day refund guarantee

    Converts to your local currency at checkout

    Security scanned

    Works with the AI tools you already use

    Claude CodeClaude CodeCursorCursorCodex CLICodex CLIMuseMuseOpenClawOpenClaw+21 more

    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

    CriterionWhy it matters hereWeightSource of the weight
    Zero-Skipped Regulatory StepsEnvironmental and Title checks are legal prerequisites for mortgage closing (INC-4945).0.40David O'Reilly (Lead Workflow Architect)
    Durable Human Checkpoints (14-Day SLA)Underwriting committees require up to two weeks to review commercial property packages.0.30Elena Rostova (Head of Mortgage Ops)
    Deterministic Join BarriersDownstream financial modeling must not execute until all parallel audits complete.0.15Commercial Underwriting SLA
    Automated Compensation on AbortAbandoned deals must cleanly release borrower deposit escrows and cancel title holds.0.15Regulatory Compliance Charter

    Comparison

    Workflow Coordination ApproachStep Integrity GuaranteeParallel Branch JoinHuman Timeout HandlingEvaluation
    Option A: Cron DB Polling (Legacy)Very Poor (Skipped step in INC-4945)Brittle (Flag synchronization)Cron sweep logicRejected: Caused INC-4945 $18M contaminated loan defect.
    Option B: Distributed Event SagasModerate (Kafka event hops)Complex (Correlation locks)Ad-hoc delayed topicsRejected: 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 signalsSelected: 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 IDStep NameExecution ModeTimeoutPreceding Dependency
    S01IntakeValidationSynchronous Task5 secondsNone (Workflow Ingress)
    S02TitleSearchParallel Branch A72 hoursS01
    S03PropertyAppraisalParallel Branch B120 hoursS01
    S04EnvironmentalAuditParallel Branch C (Mandatory)168 hoursS01
    S05LtvCovenantCalculationJoin Barrier Task30 secondsS02 AND S03 AND S04
    S06CreditCommitteeApprovalHuman Signal Checkpoint14 daysS05
    S07EscrowClosingIrreversible Pivot Task24 hoursS06 (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 (APPROVE or REJECT).

    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 CompensateRefinanceApplication executes:
        1. Releases temporary title liens placed during S02.
        2. Refunds unallocated borrower application fees.
        3. Emits MortgageApplicationArchivedEvent to compliance WORM storage.

    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

    ClaimClassificationSourceFreshness
    Commercial refinancing deals up to $25MprovidedBusiness scope intakeCurrent
    14 distinct workflow steps over 45 daysprovidedFunctional specificationCurrent
    Incident INC-4945 $18M environmental defectprovidedHistorical forensic audit reportHistorical
    Step dispatch latency budget p99 <= 15 msprovidedWorkflow Platform SLACurrent
    Code-governed DAG pattern selecteddecidedDavid O'Reilly & Elena Rostova2026-09-15
    Mandatory S04 Environmental Audit invariantdecidedArchitectural invariant INV-WF-012026-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

    1. Core Engineering encodes the 14-step DAG in the workflow definition repository.
    2. Platform team configures the Credit Committee portal to dispatch signed approval signals.
    3. Conduct staging simulation executing 50 concurrent deals with simulated human signal approvals.

    business-workflow-dag-and-step-contract-.pdf

    PDF · document

    Generated

    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

    Define valid state transitions and guard predicates for domain subjectsSpecify authoritative triggers and permissions for lifecycle movesIdentify and document forbidden transitions and terminal statesFormalize workflow contracts for underwriting and approval systems

    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

    1. Check local subject scope.
    2. Identify target subject and lifecycle boundaries.
    3. Map explicit state transitions and triggers.
    4. Define transition guards and authority.
    5. Establish terminal and invalid transition rules.
    6. 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.

    ~30 seconds
    1. 1

      Download the ZIP

      Free skills download straight away. Paid skills unlock right after purchase.

    2. 2

      Unzip into your skills folder

      Every agent reads skills from one folder on your machine. Drop the unzipped folder in there.

    3. 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

    Listed12 days ago

    What's inside

    Frequently Asked Questions